Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Mirador Lamp
- @persist [Me HoverTarget BaseProp]:entity TargetPos:vector HeightOffset AngularDeltaSmoother AngularDeltaMultiplier DeltaSmoother DeltaMultiplier
- if (first()) {
- runOnTick(1)
- Follow = 1 # 0=Mode statique, 1=Mode Dynamique au dessus de la tete
- HeightOffset = 100 # Hauteur au dessus de votre tete
- Mass = 100 # Masse de la lampe
- Alpha = 255 # Transparence de la lampe 0-255 0=invisible
- TargetPos = vec(0,0,0) # Initialisation de la variable a 0
- # NE PAS MODIFIER #
- AngularDeltaSmoother = 10
- AngularDeltaMultiplier = 90
- DeltaSmoother = 5
- DeltaMultiplier = 50
- #-----------------#
- Me = owner() # Raccourci, parceque les codeurs, c'est des feignants
- BaseProp = entity():isWeldedTo() # Trouve la lampe sur laquelle l'Expression 2 est colle
- BaseProp:setMass(Mass) # Fixe la masse de la lampe
- BaseProp:setAlpha(Alpha) # Fixe la transparence de la lampe
- if(Follow == 1) { # Quelque variable pour le mode de la lampe
- HoverTarget = Me
- }
- else {
- TargetPos = BaseProp:pos()
- }
- }
- if(Me:team() != 4) { # Les vrais comprendrons
- print(_HUD_PRINTCENTER, "Vous n'avez pas le bon metier.")
- selfDestructAll()
- }
- #----------------------------------#
- # Calcul et application de l'angle #
- #----------------------------------#
- VectorToTarget = Me:aimPos() - BaseProp:pos()
- AngleToTarget = VectorToTarget:toAngle()
- BaseAngles = BaseProp:angles()
- TargetYaw = AngleToTarget:yaw()
- BaseYaw = BaseProp:angles():yaw()
- if (TargetYaw - BaseYaw > 180) {
- TargetYaw -= 360
- }
- TargetPitch = AngleToTarget:pitch()
- BasePitch = BaseProp:angles():pitch()
- if (TargetPitch - BasePitch > 180) {
- TargetPitch -= 360
- }
- AngularForce = ang(TargetPitch, TargetYaw, AngleToTarget:roll()) - BaseProp:angles()
- AngularDelta = BaseProp:angVel() / AngularDeltaSmoother
- AngularForce = (AngularForce - AngularDelta) * AngularDeltaMultiplier
- BaseProp:applyAngForce(AngularForce)
- #----------#
- # Hovering #
- #----------#
- if(TargetPos == vec(0,0,0)) { # Mode dynamique au dessus de la tete
- Thrust = (HoverTarget:pos() - BaseProp:pos()) + BaseProp:massCenterL() + vec(0, 0, HeightOffset)
- Delta = BaseProp:vel() / DeltaSmoother
- Thrust = (Thrust - Delta) * DeltaMultiplier
- Multiplier = BaseProp:mass()/10
- if (Multiplier < 1) {
- Multiplier = 1
- }
- Thrust = Thrust * Multiplier
- BaseProp:applyForce(Thrust)
- }
- else { # Mode statique
- Force = (TargetPos - BaseProp:pos()) * 5 - BaseProp:vel()
- Force *= BaseProp:mass()
- BaseProp:applyForce(Force)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement