@name TF2 Bot Ammut
@inputs W A S D Space Seat:entity Active Turret:entity M1 M2
@outputs CamPos:vector CamAng:angle Holo:entity Pos:vector Jump J
@persist Sheild:entity View UBER MoveVel Fall String:array
@trigger 
if(first()){
 #entity():setColor(0,0,0,0)
 runOnTick(1)
 runOnChat(1)
 holoCreate(1)
 holoModel(1,"models/bots/demo/bot_sentry_buster.mdl")
 holoAnim(1,"STAND_PRIMARY") 
 holoSetPose(1,"move_scale",0)
 holoSkin(1,1)
holoAng(1,ang(holoEntity(1):angles():yaw() * 180))
 holoCreate(2)
 holoModel(2,"models/weapons/w_models/w_scattergun.mdl")
holoAlpha(2,0)
 holoCreate(5)
 holoAlpha(5,0)
 timer("Startup",750)
 MoveVel = 6
String[1,string]="/mvm/sentrybuster/mvm_sentrybuster_step_01.wav"
String[2,string]="/mvm/sentrybuster/mvm_sentrybuster_step_02.wav"
String[3,string]="/mvm/sentrybuster/mvm_sentrybuster_step_03.wav"
String[4,string]="/mvm/sentrybuster/mvm_sentrybuster_step_04.wav"
holoEntity(1):soundPlay(100,100,"/mvm/sentrybuster/mvm_sentrybuster_intro.wav")
timer("tick",500)
}

Random = 4000

if(clk("tick")){
 holoEntity(1):soundPlay(4000,4000,"/mvm/sentrybuster/mvm_sentrybuster_loop.wav") 
}


if(W){
 holoEntity(1):soundPlay(10,10,String[randint(1,4),string])   
}
if(A){
 holoEntity(1):soundPlay(10,10,String[randint(1,4),string])   
}

if(S){
 holoEntity(1):soundPlay(10,10,String[randint(1,4),string])   
}

if(D){
 holoEntity(1):soundPlay(10,10,String[randint(1,4),string])   
}


if(clk("Startup")){
stoptimer("Startup")
holoPos(2,holoEntity(1):attachmentPos("weapon_bone"))
holoAng(2,holoEntity(1):attachmentAng("weapon_bone")-ang(0,90,90))
holoParentAttachment(2,holoEntity(1),"weapon_bone")
}

Ranger = rangerOffset(100000,holoEntity(1):pos()+vec(0,0,5000),-holoEntity(1):up())

if(~W & W){
 holoAnim(1,"RUN_SECONDARY")
 holoSetPose(1,"move_scale",1)
 holoSetPose(1,"move_x",1)
 holoSetPose(1,"move_yaw",0)

}

if(~W & !W){
 holoAnim(1,"STAND_PRIMARY") 
 holoSetPose(1,"move_scale",0)
 holoSetPose(1,"move_x",0)
 holoSetPose(1,"move_yaw",0)
}

if(~A & A){
 holoAnim(1,"RUN_PRIMARY")
 holoSetPose(1,"move_scale",1)
 holoSetPose(1,"move_yaw",90)

}

if(~A & !A){
 holoAnim(1,"STAND_PRIMARY") 
 holoSetPose(1,"move_scale",0)
 holoSetPose(1,"move_yaw",0)
}

if(~S & S){
 holoAnim(1,"RUN_PRIMARY")
 holoSetPose(1,"move_scale",1)
 holoSetPose(1,"move_yaw",-180)

}

if(~S & !S){
 holoAnim(1,"STAND_PRIMARY") 
 holoSetPose(1,"move_scale",0)
 holoSetPose(1,"move_yaw",0)
}

if(~D & D){
 holoAnim(1,"RUN_PRIMARY")
 holoSetPose(1,"move_scale",1)
 holoSetPose(1,"move_yaw",-90)

}

if(~D & !D){
 holoAnim(1,"STAND_PRIMARY") 
 holoSetPose(1,"move_scale",0)
 holoSetPose(1,"move_y",0)
}

if(W){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):forward()*MoveVel)
}

if(A){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):right()*-MoveVel)
}

if(S){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):forward()*-MoveVel)
}

if(D){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):right()*MoveVel)
}

CamPos = holoEntity(5):toWorld(vec(-75,0,0))
CamAng = holoEntity(5):angles()

Holo = holoEntity(1)
Ang = Seat:driver():eyeAngles() 

holoAng(1,ang(0,Ang:yaw(),0))

holoAng(5,Ang)
holoPos(5,holoEntity(1):attachmentPos("head"))

if(~Active & Active){
    Sheild = propSpawn("models/hunter/blocks/cube6x6x6.mdl",Seat:pos(),ang(),1)
    Seat:hintDriver("W and S to go forward and back, Mouse 2 to change to your front view, Mouse 1 to toggle UBER.",10)
}
if(~Active & !Active){
 Sheild:propDelete()   
}

if(dupefinished()){
 reset()   
}

if(~M1 & M1){
 UBER = !UBER   
}

if(changed(UBER)&UBER){
    soundStop(4000)
holoAnim(1,"sentry_buster_preExplode") 
holoCreate(3,holoEntity(1):pos())
holoParent(3,holoEntity(1))
holoAlpha(3,0)
holoEntity(3):soundPlay(300,300,"/mvm/sentrybuster/mvm_sentrybuster_spin.wav")
timer("boom",2000)
}
if(clk("boom")){
    soundStop(300)
    Ent = propSpawn("models/props_phx/ball.mdl",holoEntity(1):pos(),1)
Ent:propBreak()
holoDelete(1)
selfDestructAll()}

if(chatClk(owner())){
    if(owner():lastSaid()=="/kill"){
        Seat:killPod()
        hideChat(1)
    }    
}

if(~M2 & M2){
 View = !View
}

if(View){
    holoAng(5,Ang-ang(0,180,0))
    holoSetPose(1,"body_pitch",Ang:pitch())
} else {
holoAng(5,Ang)
holoSetPose(1,"body_pitch",-Ang:pitch())
}

Turret:setColor(0,0,0,0)
Turret:setPos(holoEntity(2):pos())
Turret:setAng(holoEntity(2):angles())


Ranger = rangerOffset(500000000,holoEntity(1):pos()+vec(0,0,15),-holoEntity(1):up())
G = rangerOffsetHull(holoEntity(1):toWorld(vec(0,0,50)),holoEntity(1):toWorld(vec(0,0,-3)),vec(-10,-10,1),vec(10,10,1))

if(!G:hit()){
    if(!Fall){Fall = 1}
    if (Jump==0){
    Fall+=0.15
    Fall = clamp(Fall,-25,25)
    holoPos(1,holoEntity(1):pos()-vec(0,0,Fall))
}
}
if(G:hit()){Fall = 0 holoPos(1,G:position())}

if(Ranger:pos():z()>holoEntity(1):pos():z()){
    holoPos(1,Ranger:pos())
}

if(!holoEntity(1):pos():isInWorld()){
 holoPos(1,holoEntity(1):toWorld(vec(-50,0,0)))
}

if (changed(Space)&Space==1&Fall==0){Jump=1
    J=4}
if (Jump==1){J-=0.1
    holoPos(1,holoEntity(1):pos()+vec(0,0,J))
}
if (J<=-1){Jump=0}

