@inputs Pod:wirelink TURR:wirelink Cam:wirelink
@outputs X Y Z Pitch CAM:entity CamPos:vector CamAng:angle Turret:entity Start GT:array 
@persist W A S D M2 Shift Space Act Y2 R P E:entity GL:array  Boom:entity Des:entity
@model models/hunter/plates/plate025x075.mdl 
runOnTick(1)

E = entity():isWeldedTo()

Ang = Pod["Entity",entity]:driver():eyeAngles()

Cam["Angle",angle] = E:angles()

Cam["Position",vector] = E:pos()+vec(-100,0,15):rotate(E:angles())

Cam["Activated",number] = Pod["Active",number]

E:applyForce(E:forward()*(W-S)*E:mass()*150)

E:applyForce(E:right()*(D-A)*E:mass()*100)

E:applyForce(E:up()*(Space-Shift)*E:mass()*100)

E:applyForce(-E:vel()*E:mass()/7.5)

E:setMass(50000)

V = E:toLocal(rotationVector(quat(Ang)/quat(E))+E:pos())
E:applyTorque((200*V - 25*E:angVelVector())*E:inertia())





if (first()|dupefinished()){
    Start=0
    entity():setAlpha(0)
    holoCreate(1)
    holoCreate(2)
    holoCreate(3)
    holoCreate(4)
    
    holoCreate(5)
    holoCreate(6)
    
    holoCreate(7)
    holoCreate(8)
    holoCreate(9)
    holoCreate(10)
    
    holoCreate(11)
    holoCreate(12)
    holoCreate(13)
    holoCreate(14)
    
    holoCreate(15)
    holoCreate(16)
    holoCreate(17)
    holoCreate(18)
    holoCreate(19)
    holoCreate(20)
    holoCreate(21)
    holoCreate(22)
    holoCreate(23)
    
    holoModel(2,"models/hunter/triangles/05x05x05.mdl")
    holoModel(3,"models/hunter/triangles/05x05x05.mdl")
    holoModel(4,"models/hunter/triangles/05x05x05.mdl")
    holoModel(11,"models/hunter/tubes/tube2x2x025.mdl")
    holoModel(12,"models/hunter/tubes/tube2x2x025.mdl")
    holoModel(13,"models/hunter/tubes/tube2x2x025.mdl")
    holoModel(14,"models/hunter/tubes/tube2x2x025.mdl")
    
    holoModel(15,"models/mechanics/wheels/wheel_smooth_48.mdl")
    holoModel(16,"models/mechanics/wheels/wheel_smooth_48.mdl")
    holoModel(17,"models/mechanics/wheels/wheel_smooth_48.mdl")
    holoModel(18,"models/mechanics/wheels/wheel_smooth_48.mdl")
    holoModel(21,"models/airboatgun.mdl")
    holoModel(22,"models/Items/combine_rifle_ammo01.mdl")
    holoModel(23,"models/Items/BoxFlares.mdl")
    
    holoScale(1,vec(3,0.6,0.6))
    holoScale(2,vec(0.3,0.6,0.1))
    holoScale(3,vec(0.3,0.6,0.2))
    holoScale(4,vec(0.3,0.4,0.3))
    holoScale(5,vec(2,0.4,0.05))
    holoScale(6,vec(2,0.4,0.05))
    
    holoScale(7,vec(1,0.15,0.05))
    holoScale(8,vec(1,0.15,0.05))
    holoScale(9,vec(1,0.15,0.05))
    holoScale(10,vec(1,0.15,0.05))
    
    holoScale(11,vec(0.2,0.2,0.1))
    holoScale(12,vec(0.2,0.2,0.1))
    holoScale(13,vec(0.2,0.2,0.1))
    holoScale(14,vec(0.2,0.2,0.1))
    
    holoScale(15,vec(0.38,0.38,0.05))
    holoScale(16,vec(0.38,0.38,0.05))
    holoScale(17,vec(0.38,0.38,0.05))
    holoScale(18,vec(0.38,0.38,0.05))
    holoScale(19,vec(0.1,0.8,0.2))
    holoScale(21,vec(0.4,0.5,0.7))
    holoScale(22,vec(0.75,1.5,0.75))
    holoScale(23,vec(0.5,0.5,1))
    
    holoPos(2,entity():toWorld(vec(0,25,2.5)))
    holoPos(3,entity():toWorld(vec(0,25,-1.1)))
    holoPos(4,entity():toWorld(vec(0,-22.5,0)))
    holoPos(5,entity():toWorld(vec(5,0,3)))
    holoPos(6,entity():toWorld(vec(-5,0,3)))
    
    holoPos(7,entity():toWorld(vec(10,8,2)))
    holoPos(8,entity():toWorld(vec(10,-8,2)))
    holoPos(9,entity():toWorld(vec(-10,8,2)))
    holoPos(10,entity():toWorld(vec(-10,-8,2)))
    
    holoPos(11,entity():toWorld(vec(21,18,2)))
    holoPos(12,entity():toWorld(vec(21,-18,2)))
    holoPos(13,entity():toWorld(vec(-21,18,2)))
    holoPos(14,entity():toWorld(vec(-21,-18,2)))
    holoPos(15,entity():toWorld(vec(21,18,2)))
    holoPos(16,entity():toWorld(vec(21,-18,2)))
    holoPos(17,entity():toWorld(vec(-21,18,2)))
    holoPos(18,entity():toWorld(vec(-21,-18,2)))
    holoPos(19,entity():toWorld(vec(-4,5,-10)))
    holoPos(21,entity():toWorld(vec(0,-5,-6.5)))
    holoPos(22,entity():toWorld(vec(3.5,-15,-6.5)))
    holoPos(23,entity():toWorld(vec(7,-2,-6)))
    
    holoAng(3,entity():toWorld(ang(180,0,0)))
    holoAng(4,entity():toWorld(ang(180,180,0)))
    
    holoAng(7,entity():toWorld(ang(0,-45,0)))
    holoAng(8,entity():toWorld(ang(0,45,0)))
    holoAng(9,entity():toWorld(ang(0,45,0)))
    holoAng(10,entity():toWorld(ang(0,-45,0)))
    holoAng(19,entity():toWorld(ang(0,+90,0)))
    holoAng(21,entity():toWorld(ang(0,90,180)))
    holoAng(22,entity():toWorld(ang(0,0,-90)))
    holoAng(23,entity():toWorld(ang(0,0,90)))
    
    holoParent(1,entity())
    holoParent(2,entity())
    holoParent(3,entity())
    holoParent(4,entity())
    holoParent(5,entity())
    holoParent(6,entity())
    
    holoParent(7,entity())
    holoParent(8,entity())
    holoParent(9,entity())
    holoParent(10,entity())
    
    holoParent(11,entity())
    holoParent(12,entity())
    holoParent(13,entity())
    holoParent(14,entity())
    holoParent(15,entity())
    holoParent(16,entity())
    holoParent(17,entity())
    holoParent(18,entity())
    
    holoParent(21,entity())
    holoParent(19,21)
    holoParent(22,21)
    holoParent(23,21)
    holoAlpha(20,0)
    holoAlpha(19,0)
    CamPos=holoEntity(19):pos()
    
    function entity:turnTo(Tarang:angle){
V = This:toLocal(rotationVector(quat(Tarang)/quat(This))+This:pos())
This:applyTorque((100*V - 30*This:angVelVector())*This:inertia()/3)
}
function entity:goto(Vector:vector){
 This:applyForce(((Vector-This:pos())*10-entity():vel())*entity():mass())   
}   
}
W=Pod["W",number]
A=Pod["A",number]
S=Pod["S",number]
D=Pod["D",number]
Space=Pod["Space",number]
Shift=Pod["Shift",number]
Act=Pod["Active",number]
M2=Pod["Mouse2",number]
E=Pod["Entity",entity]
Turret=TURR:entity()
TURR["Fire",number]=Pod["Mouse1",number]
if (Act==1)
{
    Y2+=10
    holoAng(15,entity():toWorld(ang(0,Y2,0)))
    holoAng(16,entity():toWorld(ang(0,Y2,0)))
    holoAng(17,entity():toWorld(ang(0,Y2,0)))
    holoAng(18,entity():toWorld(ang(0,Y2,0)))
    
    entity():goto(holoEntity(20):toWorld(vec(X,Y,Z)))
    entity():turnTo(ang(P,E:driver():eyeAngles():yaw()-90,R))
    if (W==1&S==0){Y+=0.5
        R=-20
        Pitch+=0.5}
    if (S==1&W==0){Y-=0.5
        R=20
        Pitch+=0.5}
    if (A==1&D==0){X-=0.5
        P=-20
        Pitch+=0.5}
    if (D==1&A==0){X+=0.5
        P=20
        Pitch+=0.5}
    if (Space==1&Shift==0){Z+=0.25
        Pitch+=0.25}
    if (Shift==1&Space==0){Z-=0.25
        Pitch-=0.25}
    if (W==0&S==0&A==0&D==0&Space==0&Shift==0){Pitch-=1}
    
    if (W==0&S==0){
        R=0
        if (Y<0){Y+=1}
        if (Y>0){Y-=1}
    }
    if (A==0&D==0){
        P=0
        if (X<0){X+=1}
        if (X>0){X-=1}
    }
    if (Space==0&Shift==0){
        if (Z<0.75){Z+=0.25}
        if (Z>0.75){Z-=0.25}
    }
    
    if (Y>=100){Y=100}
    if (Y<=-100){Y=-100}
    if (Z>=10){Z=10}
    if (Z<=-10){Z=-10}
    if (X>=100){X=100}
    if (X<=-100){X=-100}
    if (Pitch<=0){Pitch=0}
    if (Pitch>=100){Pitch=100}
}
if (changed(Act)&Act==1){
    soundPlay(1,0,"/npc/combine_gunship/dropship_onground_loop1.wav")
}
if (changed(Act)&Act==0){soundStop(1)}
   soundPitch(1,Pitch+150)
holoPos(20,entity():pos())
holoAng(20,ang(0,entity():angles():yaw(),0)) 
holoAng(21,entity():toWorld(ang(E:driver():eyeAngles():pitch(),90,E:driver():eyeAngles():roll()-180))) 
CAM=holoEntity(19)
CamAng=holoEntity(19):angles()-ang(0,0,0)
Turret:setPos(holoEntity(21):toWorld(vec(20,0,2)))
Turret:setAlpha(0)
Turret:setAng(holoEntity(19):angles())
Turret:propFreeze(1)
Turret:propNotSolid(1)
if (changed(Pod["Mouse1",number])&Pod["Mouse1",number]==1){
    soundPlay(2,0,"/npc/combine_gunship/gunship_fire_loop1.wav")
    soundPitch(2,250)
}
if (changed(Pod["Mouse1",number])&Pod["Mouse1",number]==0){
    soundStop(2)
}
#GL fire sound= /weapons/boxing_gloves_hit3.wav
if (M2==1&GL:count()<5){timer("boom",100)
}
if (clk("boom")){
    soundPlay(3,0.9,"/weapons/boxing_gloves_hit3.wav")
    Boom=propSpawn("models/Items/AR2_Grenade.mdl",holoEntity(22):pos(),holoEntity(19):angles(),0)
    Boom:setTrails(15,0,2,"trails/smoke",vec(255,255,255),255)
    Boom:applyForce((Boom:forward())*10000)
    GL:pushEntity(Boom)
    GT:pushNumber(Start)
}

for(I=1,GL:count()){
GT[I,number]=GT[I,number]+1
if (GT[I,number]>200){GT:remove(I)
    Des=propSpawn("models/props_phx/amraam.mdl",GL[I,entity]:pos(),1)
    Des:propBreak()
    GL[I,entity]:propDelete()
    GL:remove(I)
}
}
