@name Hunter Chopper Gun
@inputs Fire LinkTurret:wirelink
@outputs Rot R Fev
@persist 
@trigger 

#Toxic Teady's Hunter Chopper Gun                  
#Q%A: Q: The gun is not shooting when I wire the fire button! 
#A: You need to link a turret to the gun.
#Q: Is it safe to dupe it?
#A: Yes. If you want it to blow up when you dupe it,
#Heres a link to my Super Simple E2 Protection: http://www.wiremod.com/forum/finished-contraptions/32846-e2-super-simple-e2-dupe-protection.html
runOnTick(1)
if(first()){
    holoCreate(1,entity():toWorld(vec(-0.5,-1,-3)))
    
    holoScale(1,vec(1,1,1))
    
    holoModel(1,"models/airboatgun.mdl")
    
    holoParent(1,entity())

}
holoAng(2,holoEntity(1):toWorld(ang(R,90,90)))
if(Fire==1){Rot+=0.75}
if(Fire==0){Rot-=0.75}
if(Rot>=50){Rot=50}
if(Rot<=0){Rot=0}
R+=Rot


#The Sounds used, unrecommended to change this.
if(changed(Fire)&Fire==1){
    soundPlay(0,1.05,"npc/attack_helicopter/aheli_charge_up.wav")
}

if(changed(Fire)&Fire==0){
    soundPurge()
    soundPlay(0,0,"npc/attack_helicopter/aheli_charge_up.wav")
}
if(clk("wind")){soundPlay(1,9999,"npc/attack_helicopter/aheli_charge_up.wav")}

if(Rot>49){Fev=1}
if(Rot<49){Fev=0}

if(changed(Fev)&Fev==1){
    soundStop(1)
    soundPlay(1,9999,"npc/attack_helicopter/aheli_weapon_fire_loop3.wav")
}

#Turret Stuff; Dont change this unless you know what your doing.
if(changed(LinkTurret:entity())&LinkTurret:entity()!=noentity()){LinkTurret:entity():propFreeze(1)
    LinkTurret:entity():setPos(entity():toWorld(vec(26,-1,-5)))
    LinkTurret:entity():setAng(entity():angles())
    timer("parent",100)
}
    
    if(clk("parent")){LinkTurret:entity():parentTo(entity())}
    LinkTurret["Fire",number]=Fev
