@name TF2 Bot
@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/scout/bot_scout.mdl")
 holoAnim(1,"STAND_PRIMARY") 
 holoSetPose(1,"move_scale",0)
 holoSkin(1,1)
 holoCreate(2)
 holoModel(2,"models/weapons/w_models/w_scattergun.mdl")
 holoCreate(5)
 holoAlpha(5,0)
 timer("Startup",750)
 MoveVel = 6
String[1,string]="/vo/mvm/norm/scout_mvm_domination01.mp3"
#[String[2,string]="/vo/mvm/norm/scout_mvm_domination02.mp3"
String[3,string]="/vo/mvm/norm/scout_mvm_domination03.mp3"
String[4,string]="/vo/mvm/norm/scout_mvm_domination04.mp3"
String[5,string]="/vo/mvm/norm/scout_mvm_domination05.mp3"
String[6,string]="/vo/mvm/norm/scout_mvm_domination06.mp3"
String[7,string]="/vo/mvm/norm/scout_mvm_domination07.mp3"
String[8,string]="/vo/mvm/norm/scout_mvm_domination08.mp3"
String[9,string]="/vo/mvm/norm/scout_mvm_domination09.mp3"
String[10,string]="/vo/mvm/norm/scout_mvm_domination10.mp3"
String[11,string]="/vo/mvm/norm/scout_mvm_domination11.mp3"
String[12,string]="/vo/mvm/norm/scout_mvm_domination12.mp3"
String[13,string]="/vo/mvm/norm/scout_mvm_domination13.mp3"
String[14,string]="/vo/mvm/norm/scout_mvm_domination14.mp3"
String[15,string]="/vo/mvm/norm/scout_mvm_domination15.mp3"
String[16,string]="/vo/mvm/norm/scout_mvm_domination16.mp3"
String[17,string]="/vo/mvm/norm/scout_mvm_domination17.mp3"
String[18,string]="/vo/mvm/norm/scout_mvm_domination18.mp3"
String[19,string]="/vo/mvm/norm/scout_mvm_domination19.mp3"
String[20,string]="/vo/mvm/norm/scout_mvm_domination20.mp3"
String[21,string]="/vo/mvm/norm/scout_mvm_domination21.mp3"
String[22,string]="/vo/mvm/norm/taunts/scout_mvm_taunts01.mp3"
String[23,string]="/vo/mvm/norm/taunts/scout_mvm_taunts02.mp3"
String[24,string]="/vo/mvm/norm/taunts/scout_mvm_taunts03.mp3"
String[25,string]="/vo/mvm/norm/taunts/scout_mvm_taunts04.mp3"
String[26,string]="/vo/mvm/norm/taunts/scout_mvm_taunts05.mp3"
String[27,string]="/vo/mvm/norm/taunts/scout_mvm_taunts06.mp3"
String[28,string]="/vo/mvm/norm/taunts/scout_mvm_taunts07.mp3"
String[29,string]="/vo/mvm/norm/taunts/scout_mvm_taunts08.mp3"
String[30,string]="/vo/mvm/norm/taunts/scout_mvm_taunts09.mp3"
String[31,string]="/vo/mvm/norm/taunts/scout_mvm_taunts10.mp3"
String[32,string]="/vo/mvm/norm/taunts/scout_mvm_taunts11.mp3"
String[33,string]="/vo/mvm/norm/taunts/scout_mvm_taunts12.mp3"
String[34,string]="/vo/mvm/norm/taunts/scout_mvm_taunts13.mp3"
String[35,string]="/vo/mvm/norm/taunts/scout_mvm_taunts14.mp3"
String[36,string]="/vo/mvm/norm/taunts/scout_mvm_taunts15.mp3"
String[37,string]="/vo/mvm/norm/taunts/scout_mvm_taunts16.mp3"
String[38,string]="/vo/mvm/norm/taunts/scout_mvm_taunts17.mp3"
String[39,string]="/vo/mvm/norm/taunts/scout_mvm_taunts18.mp3"]#
timer("S",random(7000,10000))
}

Random = random(7000,15000)

if(clk("S")){
 stoptimer("S")
 timer("S",Random)
 holoEntity(1):soundPlay(0,0,String[random(1,String:count()),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_PRIMARY")
 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){
 holoSkin(1,3)   
}

if(changed(UBER)&!UBER){
 holoSkin(1,1)   
}

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}

