Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name KrazziPro's SpaceHeli NoHolo
- @inputs Pod:wirelink Active_p [Cam Pod MainRotor TailRotor]:wirelink
- @outputs Light:vector W A S D PilotLink:array Hurt Mass Constraints:array
- @persist E:entity R1_dist W_i START Active Active_i E_speed H_i R_E:array Warning_bip W_active M1 P1 P2 Mod Yaw MRB TRB Mass Hurt EyeX1 EyeY1 Speed Timer Hover Invert Damage Toggle NewYaw AimingM TRLinked MRLinked Injured InTimer Throttle Interval StrafeAlter LiftAlter AimingMethod HoloStartUp StartUpSpeed YawPlus Health RotorDeath RotorProblem AirFriction SoundPitchMult CollisionSpeed TrueSensitivity CameraRotation Manuevarebility HoloRotorEnabled WaterLevel EngineDeath MainRotorBlades TailRotorBlades [RotorSound RotorSound2 RotorMaterial]:string [Array HintDriver AimingModes EyeSensitivity]:array AimingData:table [EyePod MainRotorAng TailRotorAng TargetAngles DeathAng]:angle [E Prop Model]:entity [Place Clamp RotorColor MainRotorPos TailRotorPos CameraPosition MainRotorSize TailRotorSize]:vector
- @trigger
- @model models/props_phx/construct/metal_plate1x2.mdl
- interval(20)
- if(first()| dupefinished())
- {
- timer("bip",500)
- soundPlay(0,0,"ambient/tones/garage.wav")
- soundPlay(1,0,"ambient/machines/big_truck.wav")
- soundPlay(2,0,"weapons/airboat/airboat_gun_loop2.wav")
- E=entity()
- E:setMass(300)
- #E:setAlpha(0)
- R_E=E:getConstraints()
- rangerPersist(1)
- rangerHitWater(1)
- rangerPersist(1)
- rangerHitWater(1)
- }
- W=Pod["W",number]
- A=Pod["A",number]
- S=Pod["S",number]
- D=Pod["D",number]
- BEA=Pod["Bearing",number]
- ELE=Pod["Elevation",number]
- M1=Pod["Mouse1",number]
- START=Pod["R",number]
- DRIVER=Pod["Entity",entity]
- if(START & $START)
- {
- Active=Active==0
- if(Active)
- {
- soundPlay(6,0,"ambient/machines/thumper_startup1.wav")
- soundStop(5)
- soundPlay(7,2,"hl1/fvox/activated.wav")
- }
- else
- {
- soundPlay(5,0,"ambient/machines/thumper_shutdown1.wav")
- soundStop(6)
- soundPlay(8,2,"hl1/fvox/deactivated.wav")
- }
- }
- Active_i+=-0.012+(Active>Active_i)*0.02
- W_i=W
- if($W)
- {
- if(W)
- {
- holoAlpha(9,255)
- holoSkin(8,0)
- soundPlay(4,0,"ambient/machines/diesel_engine_idle1.wav")
- }
- else
- {
- holoAlpha(9,0)
- holoSkin(8,1)
- soundStop(4)
- }
- }
- SHIFT=Pod["Shift",number]
- Light=vec(100,100,255)*Active
- E_vel=E:vel()
- E_speed=E_vel:length()
- R1_dist_set=30-min(E_vel:z()/2,0)
- if($E_speed<-(50+Active*250) )
- {
- if(Active)
- {
- #fx("explosion",E:pos(),1)
- soundPlay(9,0,"vehicles/v8/vehicle_impact_heavy.wav")
- }
- #Active=0
- #Active_i=0
- #Pod["Damage Health",number]=E_speed/20
- #soundPlay(6,0.8,"vehicles/v8/vehicle_impact_heavy"+randint(1,4):toString()+".wav")
- }
- rangerFilter(R_E)
- R1=rangerOffset(R1_dist_set,E:toWorld(vec(0,35,-10)),-vec(0,0,1))
- rangerFilter(R_E)
- R1_2=rangerOffset(R1_dist_set,E:toWorld(vec(0,-35,-10)),-vec(0,0,1))
- rangerFilter(R_E)
- R2=rangerOffset(E:pos(),E:pos()+E:vel()*3)
- R1_dist=R1:distance()
- R2_dist=R1_2:distance()
- E_velL=E:velL()
- Force=(8+(R1_dist_set-(R1_dist+R2_dist)/2)/3-$R1_dist*3*R1:hit()-E_velL:z()/300 +E_velL:y()/1200)
- #Force=(10+SHIFT*6+(80-R1_dist)/3-$R1_dist*3*R1:hit())
- S_i=abs(E_velL:y())/5
- H_i+=(S_i/10+6)*Active_i
- holoAng(0,E:toWorld(ang(H_i,0,90)))
- holoAng(1,E:toWorld(ang(-H_i,0,90)))
- soundPitch(0,(Force*3 +S_i/2)*Active_i)
- soundPitch(1,(40+S_i/2)*Active_i)
- soundPitch(2,Active*10+(20+S_i/4)*Active_i)
- soundPitch(4,(200+S_i/10)*Active_i)
- E:applyForce((-E:forward()*E_velL:x()*vec(1,1,-0.7)*10+E:up()*Force*400 -E:right()*(W-S)*10000 +E_vel)*Active_i)
- #E:applyAngForce((-ang(E_velL:x()*2 -(D-A)*100,(-A+D)*500,+min(max(-E_velL:y()+(W-S)*100000,-400),400+E_velL:y()/2))/20-E:angles()*ang(1,0,1)-E:angVel()/2)*500)
- E:applyAngForce(((-ang(+min(max(E_velL:x()*2 -(D-A)*100,-70000000000000),70000000),(-A+D)*900,(R1_dist-R2_dist)*120+(W-S)*500 +0- E_velL:y()*((Active_p==0)*10-0.5+SHIFT*1.6) )/20-E:angles()*ang(1,0,1)-E:angVel()*ang(0.5,0.5,1))*500)*Active_i)
- holoAng(2,ang(-ELE,BEA,0)+ang(180,0,0))
- if(M1 & $M1)
- {
- #Missile=spawnEntity("rpg_missile",E:pos()-E:up()*35,ang(-ELE,BEA,0),0)
- }
- if(clk("bip"))
- {
- timer("bip",500)
- if(R2:hit() & Active)
- {
- Dist_i=(E:pos()-R2:position()):length()
- if(((E_vel:length()*3)/Dist_i)>3)
- {
- #soundPlay(8,0,"hl1/fvox/warning.wav")
- soundPitch(8,100)
- timer("bip",1000)
- }
- else
- {
- #soundPlay(8,0,"buttons/button17.wav")
- soundPitch(8,50+8000/Dist_i)
- timer("bip",300)
- }
- }
- }
- if(abs(E:angles():pitch())>70 & E_speed<3)
- {
- E:applyAngForce(-E:angles()*ang(1,0,1)*8000)
- E:soundPlay(12,0,"ambient/machines/diesel_engine_idle1.wav")
- }
- #holoAlpha(5,(0.4+random(1))*Active_i)
- #holoAlpha(6,(0.4+random(1))*Active_i)
- #holoAlpha(7,(0.4+random(1))*Active_i)
- #holoAlpha(4,(0.4+random(1))*Active_i)
- ———————————————
- ———————————————
- ———————————————
- #@name Badger's helicopter chip
- #@inputs [Cam Pod MainRotor TailRotor]:wirelink
- #@outputs PilotLink:array Hurt Mass Constraints:array
- #@persist P1 P2 Mod Yaw MRB TRB Mass Hurt EyeX1 EyeY1 Speed Timer Hover Invert Damage Toggle NewYaw AimingM TRLinked MRLinked
- #@persist Injured InTimer Throttle Interval StrafeAlter LiftAlter AimingMethod HoloStartUp StartUpSpeed YawPlus Health RotorDeath RotorProblem
- #@persist AirFriction SoundPitchMult CollisionSpeed TrueSensitivity CameraRotation Manuevarebility HoloRotorEnabled WaterLevel EngineDeath
- #@persist MainRotorBlades TailRotorBlades [RotorSound RotorSound2 RotorMaterial]:string
- #@persist [Array HintDriver AimingModes EyeSensitivity]:array AimingData:table [EyePod MainRotorAng TailRotorAng TargetAngles DeathAng]:angle [E Prop Model]:entity
- #@persist [Place Clamp RotorColor MainRotorPos TailRotorPos CameraPosition MainRotorSize TailRotorSize]:vector
- #@model models/hunter/blocks/cube1x2x025.mdl
- # Badger130 made this
- # Please do not claim as your own
- # distribute freely
- # version - V1.2.4
- #Digit 1 Represents a major functionality change
- #Digit 2 Represents a new feature
- #Digit 3 Represents a bug fix
- ###### this is Badger130's Helicopter Chip ######
- if(first()){
- ###### setup #######
- #New Info to read on V1.2.2
- #The wirelinks MainRotor and TailRotor are for rotor survivability
- #This is for more realistic heli battles in acf or gdc
- #If you dont want that, just leave those 2 variables alone and DONT link them
- #They way they work if you do want them, is you link them to a prop,
- #and it will destroy the rotor If that prop is killed
- #@model changes the model of the base prop
- Interval = 20 #Increasing this will decrease ops, but you will need to increase the lift and other options
- #Performance may also drop if it is too high
- #Flight Settings
- Manuevarebility = 10 #this is how agile the helicopter is
- LiftAlter = 20 #This is how much pressing W or S affects the heli
- StrafeAlter = 1.4 #This is how much the helicopter will strafe
- AirFriction = 100 #This is how much friction there is for the heli
- StartUpSpeed = 0.15 #This is how fast it takes the heli to reach full throttle
- #Phyiscal damage settings
- Damage = 1 #Determines weather the heli will acount for physical damage or not
- CollisionSpeed = 250 #This is how fast the heli has to be flying prior to a collision to hurt the motor
- #Camera settings
- CameraPosition = vec(0,0,160) #This is the position of the camera relative to the helicopter
- CameraRotation = 270 #This is the position of the camera relative to the player's eye
- AimingModes = array(1,2,3,4) #This controls the order of the aiming modes by the alt button
- #Simply remove a number if you dont want that aiming mode
- #1 is 3rd person look-around, 2 is 1st person look-around
- #3 is bf3 1st person, 4 is bf3 3rd person
- MainRotorBlades = 5 #This is the number of blades on the main rotor
- MainRotorSize = vec(26,1,0.2) #This is the scale of the main rotor being length,width,height repsectively
- MainRotorPos = vec(0,0,80) #This is the position of the main rotor reliative to the e2
- MainRotorAng = ang(0,0,0) #This is the angle the main rotor will rotate on
- TailRotorBlades = 3 #This is the number of blades on the tail rotor
- TailRotorSize = vec(8,0.5,0.2) #This is the scale of the tail rotor being length,width,height repsectively
- TailRotorPos = vec(0,-170,60) #This is the position of the tail rotor reliative to the e2
- TailRotorAng = ang(-90,0,0) #This is the angle the tail rotor will rotate on
- RotorColor = vec(140,140,140) #This is the color of the rotors in Red,Green,Blue format
- RotorMaterial = "phoenix_storms/concrete1" #This is the material of the rotors
- RotorSound = "NPC_AttackHelicopter.Rotors" #This is the Sound of the rotors
- SoundPitchMult = 2.9 #This is how much the soundpitch is multiplied
- ###### setup #######
- #####Update Info#####
- #[
- ---
- Version Update V1.2.4
- Optimized lift calculation so that heli can now perform heavy lifting-
- -and you will no longer need to manual calculate lift
- ---
- Version Update V1.2.3
- Fixed no warning sounds being played when your heli is damaged
- ---
- Version Update V1.2.2
- Added Rotor survivability to improve accuracy to real life helis
- Fixed Death animations to be properly implented
- ---
- Version update V1.1.2
- Optimized and cleaned coding
- Transfered the aiming system from a large conditional to split dual-conditionals and an array
- Fixed the rotor blur clipping and looking lopsided
- Modifed the hover mode slightly
- ---
- Version update V1.1.1
- Added Support for the holoPilot via array "PilotLink"
- Added a feature called "AimingModes" to control the order and content of the 4 aiming modes
- Added Version update details to keep track of progress and inform users of new content
- Fixed Transitioning between look-around and bf3 aiming methods
- Fixed Startup on bf3 mode, so the heli doesnt flip around
- Fixed Yaw on bf3 mode, so the heli wont default to 0 yaw
- Fixed AutoHover on bf3 mode
- ---
- ]#
- # Codeing below
- # Do not alter unless you know what you are doing
- interval(20)
- E = entity()
- Array = array()
- EyeSensitivity = array()
- WaterLevel = -70000
- AimingM = 0
- MainRotorDeath = 0
- TailRotorDeath = 0
- TRLinked = ->TailRotor
- MRLinked = ->MainRotor
- Clamp = vec(Manuevarebility,Manuevarebility,Manuevarebility)
- Constraints = E:getConstraints()
- for(A = 1,E:hasConstraints())
- {
- if(Constraints[A,entity]:parent():isValid())
- {
- Mass += 0
- }
- else
- {
- Mass += Constraints[A,entity]:mass()
- }
- }
- #Data goes in order as follows - array(AimingMode,HoloPos during parenting,CamPos during parenting,AimingModeHint
- AimingData = table(
- array(1,vec(-CameraRotation,0,0),vec(),"Third person 'point-style' aiming engaged")
- ,array(2,vec(),vec(),"First person 'Look-Around' aiming engaged")
- ,array(3,vec(),vec(),"First person 'BF3' aiming engaged")
- ,array(4,vec(),vec(),"Third person 'BF3' aiming engaged")
- )
- HintDriver = array(
- "This is Badger130's Helicopter Chip",3
- ,"Turn on your light to Start the engine",4
- ,"Press W to go up, and S to go down",4.7
- ,"Hold ALT to switch aiming methods",5.4
- ,"Use the mouse to aim the helicopter",6.1
- ,"Speed is dependent on your pitch and roll",7
- )
- W = Pod["W",number]
- A = Pod["A",number]
- S = Pod["S",number]
- D = Pod["D",number]
- Alt = Pod["Alt",number]
- Light = Pod["Light",number]
- Space = Pod["Space",number]
- Active = Pod["Active",number]
- Seat = Pod["Entity",entity]
- EAng = E:angles()
- EPos = E:pos()
- EVel = E:vel()
- MR = MainRotor:entity()
- TR = TailRotor:entity()
- Cam["Activated",number] = Active
- if(changed(Active) & Active)
- {
- for(H = 1,HintDriver:count()/2)
- {
- Seat:hintDriver(HintDriver[H * 2 - 1,string]
- ,HintDriver[H * 2,number])
- timer("Purge",250)
- }
- Pod["Hide Player",number] = ->PilotLink
- }
- if(changed(AimingMethod) | changed(Active) | clk("Purge"))
- {
- CurData = AimingData[AimingMethod,array]
- Cam["Position",vector] = CurData[2,vector]
- Cam["Angle",angle] = ang()
- Cam["Parent",entity] = holoEntity(2)
- Seat:hintDriver(CurData[4,string],5)
- Yaw = EAng:yaw() + 90
- EyeY1 = AimingMethod <= 2 ? E:angles():yaw() + 90 : -EAng:pitch()
- }
- elseif(!changed(Active))
- {
- if(Alt)
- {InTimer = clamp(InTimer + 1,0,18)}
- elseif(!Alt)
- {InTimer = 0}
- AimingM = mod(AimingM + (changed(InTimer)
- & (InTimer == 18)),AimingModes:count())
- AimingMethod = AimingModes[AimingM + 1,number]
- if(changed(Space) & Space)
- {Hover = !Hover
- HoverHeight = EPos:z()}
- CamPos = E:toWorld(CameraPosition:setZ(0))
- + vec(0,0,CameraPosition:z())
- EyeAngles = Seat:toLocal(Seat:driver():eyeAngles())
- EyeSensitivity:insertAngle(1,EyeAngles)
- if(EyeSensitivity:count() > 2)
- {EyeSensitivity:pop()}
- EyePod1 = EyeAngles - EyeSensitivity[2,angle]
- EyePodYaw = EyePod1:yaw()
- YawPlus = (EyePodYaw > 180) ? -360 * (EyePodYaw > 180) : 360 * (EyePodYaw < -180)
- EyePod = EyePod1 + ang(0,YawPlus,0)
- EyeX1 = mod(EyeX1 + EyePod:pitch(),360)
- EyeY1 = mod(EyeY1 + EyePod:yaw(),360)
- Eye = ang(EyeX1,EyeY1,EyeAngles:roll())
- if(changed(Alt) & !Alt & (InTimer < 18))
- {Invert = !Invert
- Seat:hintDriver("Pitch Inverted",5)}
- if(!Hover & !RotorDeath)
- {#Condition 3.2.2.1 Start
- NewYaw = EAng:yaw()
- if(!changed(AimingMethod) & AimingMethod <= 2)
- {
- Strafe = (D - A) * StrafeAlter
- TargetAngles = Eye:setRoll( -E:angVel():yaw() / 2 + Strafe * 15)
- }
- elseif(!changed(AimingMethod) & (AimingMethod >= 3))
- {
- Yaw = mod(Yaw + (A - D)*StrafeAlter - E:velL():x()*0.0016,360)
- TargetAngles = ang(Eye:pitch() * (Invert - !Invert),Yaw,-Eye:yaw())
- }
- }#Condition 3.2.2.1 End
- elseif(Hover & !RotorDeath)
- {#Condition 3.2.2.2 Start
- VelL = E:velL()
- TargetAngles = ang(
- clamp(-(VelL:y() * abs(VelL:y())) / 2000, -75, 75),
- NewYaw + 90,
- clamp(-(VelL:x() * abs(VelL:x())) / 2000, -75, 75))
- }#Condition 3.2.2.2 End
- elseif(RotorDeath)
- {
- TargetAngles = EAng - ang(0,20,0)
- Clamp = vec(Manuevarebility,Manuevarebility,50)
- }
- (AimingMethod == 1 ? CamPos : (->PilotLink ? Seat:toWorld(vec(0,7,39)) + vec(4,0,0):rotate(Eye) : Seat:toWorld(vec(0,1,35)))) :
- (AimingMethod == 3 ? Seat:toWorld(vec(0,6,45)) : CamPos + vec(0,-CameraRotation,0):rotate(E:angles()))
- }#Condition 3.2.2 End
- #ApplyForce Code#
- Constraints = E:getConstraints()
- if(changed(Constraints:count()))
- {
- Mass = 0
- for(G = 1,Constraints:count())
- {
- if(Constraints[G,entity]:parent():isValid())
- {
- Mass += 0
- }
- else
- {
- Mass += Constraints[G,entity]:mass()
- }
- }
- }
- if(!MainRotorDeath)
- {
- Affect = Throttle*(Mass / E:mass() / 2 + 0.57) +
- (clamp((-EVel:z())*Hover / 10 + W - S - RotorDeath,-1,1))*LiftAlter
- Alter = (vec(0,0,1):rotate(E:toWorld(ang())*ang(1.7,1,1.5))
- - EVel*AirFriction*0.000002)
- E:applyForce(Alter * Affect * E:mass())
- }
- #ApplyForce Code#
- #Quaternion Aiming code#
- TarQ2 = quat(TargetAngles)
- CurQ2 = quat(E:toWorld(ang(0,90,0)))
- Q2 = TarQ2/CurQ2
- V2 = clamp(E:toLocal(rotationVector(Q2) + EPos)*Active,-Clamp,Clamp)
- E:applyTorque((200*V2 - 40*E:angVelVector())
- *E:inertia()*(Throttle/33))
- #Quaternion Aiming Code#
- #Engine Control#
- Water = E:isUnderWater()
- if(changed(Water) & Water)
- {WaterLevel = EPos:z()}
- UnderWater = (E:toWorld(MainRotorPos - vec(0,0,50)):z() < WaterLevel)
- if(changed(Light) & Light)
- {
- Toggle = !Toggle
- Speed = StartUpSpeed
- }
- elseif(changed(UnderWater) & UnderWater & Water)
- {
- Toggle = 0
- Speed = 0.6
- }
- elseif(changed(Active) & !Active)
- {Toggle = 0}
- Timer = clamp(Timer + (Toggle-!Toggle - RotorProblem) * Speed,0,33)
- Throttle = (Timer ^ 2) / 33
- P1 = clamp(P1+(W-!W)*(Throttle>=30)/4,0,4)
- P2 = clamp(P2+(S-!S)*(Throttle>=30)/4,0,2)
- Go = (Timer+P1-P2)
- Mod = mod(Mod+Timer,360)
- #Engine Control#
- #Rotor Survivability#
- if(Damage > 0)
- {
- Array:insertNumber(1,EVel:length())
- if(Array:count()>7)
- {Array:pop()}
- ChangedSpeed = EVel:length() - Array[7,number]
- Physgun = owner():weapon():type()
- == "weapon_physgun" & owner():keyAttack1()
- LPrev = (ChangedSpeed< -(CollisionSpeed)) & !Physgun
- HPrev = (ChangedSpeed< -(CollisionSpeed*2)) & !Physgun
- if(changed(LPrev) & LPrev)
- {E:soundPlay(2,1,"ATV_impact_medium")}
- if(changed(HPrev) & HPrev)
- {
- E:soundPlay(5,0,"/vehicles/digger_stopengine1.wav")
- E:soundPlay(6,0,"ATV_impact_heavy")
- RotorProblem = 3
- Seat:soundPlay(8,0,"/npc/attack_helicopter/aheli_crash_alert2.wav")
- }
- if(MRLinked & changed(->MainRotor) & !->MainRotor)
- {
- Seat:soundPlay(8,0,"/npc/attack_helicopter/aheli_crash_alert2.wav")
- RotorDeath = 1
- RotorProblem = 6
- }
- }
- if(TRLinked & changed(->TailRotor) & !->TailRotor)
- {
- RotorDeath = 1
- Seat:soundPlay(8,0,"/npc/attack_helicopter/aheli_crash_alert2.wav")
- for(G = 1,TailRotorBlades)
- {
- holoVisible(4,players(),0)
- holoVisible(5,players(),0)
- holoVisible(G + 6 + MainRotorBlades,players(),0)
- }
- }
- }
- #Rotor Survivability#
- PilotLink = array(Active,Seat,Timer / 1.735 + P1 - P2,Eye,EAng - Eye + ang(0,90,0),AimingMethod)
- soundPitch(1,Go*SoundPitchMult/1)
- soundPitch(4,Go*SoundPitchMult/1)
- }#Condition 3 End
- Valid = ->MainRotor
- if(dupefinished())
- {reset()}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement