@name Turret @inputs On FriendObj:entity FoundObj:entity Moter:entity Button:entity HitOBJ:entity HitZ Eye:entity Gun:entity None:entity Data:array @outputs Fire Spin Spread Rot Pulserate Bulets AimY NoShoot:array ThoughtsOut:array Timing Range @persist Oldheatlh Count Rot TimeLastHit Spread AimY SoundOut:string OldSound:string Thoughts:array FriendObj:entity Range MoterStep @trigger all runOnLast(1) Mode=1 #1=normal #2=kill all life #3=kill all npcs MoterStep+=0.1 Timing=TimeLastHit if(Data){if(Data:number(1)==1){exit()}} if(!Thoughts){Range=0 MoterStep=0 Thoughts=array("Screen init")} if(MoterStep>1.7){MoterStep=-0.25} if(!FriendObj){ if(Button){FriendObj=Button:owner()}elseif(Moter){FriendObj=Moter:owner()}} if(Mode==2){FriendObj=None} function logtext(Text:string){ if(Thoughts:exists(10)==1){Thoughts:shift()} Thoughts:pushString(Text) } if(removing()==1&!(On==0&Button)){ Fire=1 Spread=10 Bulets=10 Spin=0 if(Gun){} SoundOut="npc/turret_floor/die.wav" logtext("ded") if(Moter){Moter:applyTorque(vec(0,0,5000))} if(Gun){Gun:applyTorque(vec(100,1000,100))} } ThoughtsOut=array(Thoughts:concat("\n"),Timing) if((On==0&Button)|(!(Gun|FoundObj|HitOBJ|Eye)&On==0)){ if(TimeLastHit!=9.123){ SoundOut="npc/turret_floor/turret_disabled_3.wav" logtext("Shutdown") } if(Range>1){Range=min(Range-max(floor(Range/500)*100,2),Range-1) Range=Range-1 }else{runOnTick(0)} TimeLastHit=9.123 Spin=0 Fire=0 if(AimY<1){AimY+=0.05*(20000-Range)/20000} if(AimY>1){AimY-=0.05*(20000-Range)/20000} if(AimY<1){AimY+=0.01*(20000-Range)/20000} if(AimY>1){AimY-=0.01*(20000-Range)/20000} soundStop(1) MoterStep=0 if(Range<100){Moter:applyTorque(vec(0,0,0)) exit()} }else{runOnTick(1)} if(Range<20000&(On==1|!Button)){Range=Range+5*(1+On)} if (HitOBJ==FriendObj&TimeLastHit<3&FriendObj){ logtext("Hit freind"+FriendObj:name()) SoundOut="npc/turret_floor/turret_disabled_2.wav" Fire=0 Spin=0 FoundObj=None Spread=0} if(!Button){ On=1 } Pulserate=0.05 if(FoundObj){logtext("Found something") if( On == 1 & FoundObj:isAlive() & !FoundObj:isWorld() & FoundObj!=FriendObj|(FoundObj:isVehicle()&FoundObj:driver()!=FriendObj&FoundObj:driver()!=None&Mode!=3)&((Mode==3&FoundObj:isNPC())|Mode!=3)) { if(Spread==0&(max(AimY,-AimY)>0.1/HitZ/FoundObj:height())|HitZ/FoundObj:height()>FoundObj:height()){ Spread=min(max(AimY,-AimY)/2,max(AimY,-AimY)/((HitZ*FoundObj:height())-TimeLastHit))} if(Fire==0){ SoundOut="npc/turret_floor/turret_deploy_4.wav" logtext("target is found") if(FoundObj:inGodMode()){SoundOut="npc/turret_defective/defect_goodbye05.wav" logtext("target is cheating") } } Spin=1 if(Moter){logtext("Stopping moter") Moter:applyTorque(vec(0,0,0))} Fire=1 logtext("Fire") Health=FoundObj:health() Spread=Spread+0.00001/floor((HitZ+FoundObj:height())/10) TimeLastHit=1 if ( Health == Oldheatlh|Health > Oldheatlh|HitOBJ!=FoundObj){ Spread=Spread+0.05 logtext("Missed") }elseif(HitOBJ==FoundObj){ Spread=Spread-0.01 } Oldheatlh=Health logtext("Hit") }else{ if(TimeLastHit>1.3|FoundObj==FriendObj|(!FoundObj:isAlive()|!FoundObj:isVehicle())){Fire=0}}}else{if(TimeLastHit>1.2){Fire=0}} if ((!FoundObj|!FoundObj:isAlive()&TimeLastHit>1.1&Eye)){ TimeLastHit=TimeLastHit+0.005 Spread=Spread-max(10-HitZ/100,0.5) if(Spread<0){Spread=0} Spin=0 }elseif(!Eye&(HitOBJ==None|Spin==0)){TimeLastHit=TimeLastHit+0.005} Count=Count+0.2 if ( Count > TimeLastHit ){ Count=0 if(Moter){Moter:applyTorque(vec(0,0,0))} }elseif(TimeLastHit>1.1){ if(Moter){Moter:applyTorque(vec(0,0,((max(14-TimeLastHit,TimeLastHit))*35*3*round(MoterStep)))) }} if(TimeLastHit>9){TimeLastHit=9} if(Eye){Bulets=4+Spread/3} if(!Eye){ Spread=0.2} if(Spin!=1&TimeLastHit>1.1){ if(TimeLastHit>2&TimeLastHit<5){AimY=AimY/1.01} if(TimeLastHit>5){ AimY=AimY+0.01 if(AimY>0.2){AimY=-0.5 }}} if(TimeLastHit>3&TimeLastHit<4){SoundOut="npc/turret_floor/turret_autosearch_2.wav" } if(!Eye&(!HitOBJ|(HitOBJ&(!HitOBJ:isAlive())))){Fire=max(0,randint(-25,1)) Bulets=2} if(HitOBJ&HitOBJ:isAlive()&(HitOBJ==FriendObj)){Fire=0 Spin=0 Bulets=0 if(TimeLastHit>8){TimeLastHit=5} if(TimeLastHit>6){Fire=1} if(Moter){Moter:applyTorque(vec(0,0,min(9-TimeLastHit,0)*8*2*round(MoterStep)))} } if(!Eye&HitOBJ&HitOBJ:isAlive()&HitOBJ!=FriendObj){Fire=1 if(Moter){Moter:applyTorque(vec(0,0,0))} Spin=1 TimeLastHit=0 Bulets=10 } if(((Moter&Moter:isFrozen())|(Eye&Eye:isFrozen())|(Gun&Gun:isFrozen()))&TimeLastHit>2){ TimeLastHit=9 Spin=max(random(10)-9,0) SoundOut="npc/turret_floor/turret_disabled_3.wav" logtext("Hey dont freeze me")} NoShoot=array(Gun,Eye,Moter,FriendObj) if(Fire==1&FoundObj&Eye&!Gun){Eye:shootTo(FoundObj:pos()-Eye:pos()+vec(0,0,FoundObj:height()/2),Spread,100,10,Bulets,0) logtext("No gun found")} if(Fire==1&FoundObj&Eye&Gun){Eye:shootTo(FoundObj:pos()-Eye:pos()+vec(0,0,FoundObj:height()/2),0,50,5,Bulets,0)} if(Spin==1&TimeLastHit>7){Spin=0} if(TimeLastHit>8){HitOBJ=None} if(removing()==1){ Fire=1 Spread=10 Bulets=10 Spin=0 if(Gun){} SoundOut="npc/turret_floor/die.wav" logtext("ded") if(Moter){Moter:applyTorque(vec(0,0,10000))} if(Gun){Gun:applyTorque(vec(100,1000,100))} } if(OldSound!=SoundOut){soundStop(1) soundPlay(1,99,SoundOut) OldSound=SoundOut logtext("Play "+SoundOut) }