@name Pyro GX
#@inputs E:entity 
@inputs [Pod Num Cam]:wirelink Pitch Yaw Roll
#@inputs [W A D S Space Shift Mouse1 Mouse2]:number
@outputs Pos:vector Angle:angle Spd Strafe HSpd RTotal Guns Hit:array
@persist [O E]:entity  YTotal PTotal [Hitbox Len]:array
@model
Float=2.135 #655 for PyroGX and 0.6 for a single prop

if( duped() ){reset()}
interval(50)
if( first()|dupefinished() ){
    E=entity():isConstrainedTo()
    E:setMass(5000) 
    #runOnTick(1)
    #runOnChat(1)
    #runOnLast(1)
    Len=array()
    Len:pushNumber(0)
    Len:pushNumber(70)
    Len:pushNumber(100)
    Len:pushNumber(140)
    Len:pushNumber(140)
    Len:pushNumber(100)
    O = owner()
    #E = entity():isWeldedTo() ?: entity()
    
    Pos = E:pos()
    
        
}

if(Pod["Active",number]){
  Guns=Pod["R",number]
  Roll = Roll
  Pitch = Pitch
  Yaw = -Yaw
  Cam["Position",vector]=Pod["Entity",entity]:pos()+(Pod["Entity",entity]:up()*40)
  Cam["Angle",angle]=Pod["Entity",entity]:angles()
  
  Cam["Activated",number]=1
  Pod["Crosshairs",number]=1
}else{
  Guns=0
  Roll=Yaw=Pitch=0
  Cam["Activated",number]=0
  Pod["Crosshairs",number]=0
}

For=E:forward()*220
#[
holoCreate(1,E:pos()+E:up()*70+For)
holoCreate(2,E:pos()-E:up()*100+For)
holoCreate(3,E:pos()+E:right()*140+For)
holoCreate(4,E:pos()-E:right()*140+For)
holoCreate(5,E:pos()-E:forward()*100)
]#

Hitbox=array()
P=E:pos()
Hitbox:pushVector(P+For)
Hitbox:pushVector(P+E:up()*70+For)
Hitbox:pushVector(P-E:up()*100+For)
Hitbox:pushVector(P+E:right()*140+For)
Hitbox:pushVector(P-E:right()*140+For)
#Hitbox:pushVector(P-E:forward()*100)

Hit=array()
for(C=2,Hitbox:count()){
    rangerHitEntities(1)
    Hit:pushNumber(rangerOffset(Len[C,number],Hitbox[1,vector],Hitbox[C,vector]):hit())
}

#rangerOffset(100,-E:up()
#Aim=(E:pos()-Pod["AimPos",vector])/Pod["AimPos",vector]:length()
Movement = Pod["W",number] - Pod["S",number]
SMove = Pod["A",number] - Pod["D",number]
VMove = Pod["Space",number] - Pod["Shift",number]
#Roll = Pod["Mouse1",number] - Pod["Mouse2",number]
#Pitch=Aim:x()
#Yaw=Aim:y() 

#Pitch = Num["8",number] - Num["2",number]
#Yaw =  Num["4",number] - Num["6",number]

Spd = clamp( Spd + Movement, -100, 100 ) - !Movement*Spd/10 #50
Strafe = clamp( Strafe + SMove, -100, 100 ) - !SMove*Strafe/10 #50
HSpd = clamp( HSpd + VMove, -25, 25 ) - !VMove*HSpd/10 #50
RTotal+=Roll*3
YTotal+=Yaw*3
PTotal+=Pitch*3

Pos = E:pos() + E:toWorldAxis(vec(Spd,Strafe,HSpd)) + vec(0,0,Float)
#Angle = ang(PTotal,YTotal,RTotal)
Angle = ang(PTotal,YTotal,RTotal)

E:applyForce(((Pos-E:pos())*15-E:vel()/2)*E:mass())
E:applyTorque((150*E:toLocalAxis(rotationVector(quat(Angle)/quat(E)))-12*E:angVelVector())*E:inertia())
