@name Croco's Tf2 Life Of a sentry
@inputs 
@outputs T TT
@persist 
@trigger 
Me = owner()
runOnTick(1)
if(first()){
holoCreate(1)
holoModel(1,"models/player/engineer.mdl")
holoAng(1,ang(0,0,0))
T = 0
KK = 0
J = 0
Upgrade = 0
Test = 0
HH = 0
CHECK = 0
TT = 0
LEVEL2 = 0
timer("spy",38000)
timer("demo",44000)
timer("dispen",26000)
timer("soldier",20000)
timer("soldier2",21000)
gSetStr(1,"turn")
holoCreate(2)
holoAnim(1,2)
holoModel(2,"models/buildables/sentry1_heavy.mdl")
holoEntity(1):soundPlay(50,50,"vo/engineer_autobuildingsentry01.wav")
holoAnim(2,2)
holoPos(2,entity():toWorld(vec(60,0,5)))
    holoCreate(3)
    holoModel(3,"models/player/soldier.mdl")
    holoSkin(3,1)
    holoAnim(3,2)
    holoAng(3,ang(0,180,0))
    holoPos(3,vec(99999,99999,99999))
    holoCreate(5)
    holoAlpha(5,0)
    holoPos(5,vec(99999,99999,99999))   
    holoCreate(6)
    holoAlpha(6,0)
    holoPos(6,entity():pos())
    holoCreate(7)
    holoModel(7,"models/player/spy.mdl")
    holoSkin(7,21)
    holoPos(7,vec(9999,9999,9999))
    holoAng(7,ang(0,240,0))
if(gGetStr(1)=="2"){gSetStr(1,"3434")}
}

timer("5",5500)
if(KK == 0){
timer("hit",1500)}
if(clk("hit")){
holoAnim(1,73)
holoAng(1,ang(0,90,90))
T++
holoEntity(6):soundPlay(10,1,"weapons/wrench_hit_build_success1.wav")}

if(T > 10){
Phase = "Upgrade"
 KK = 1
JJ = 1
holoAnim(1,2)
holoModel(2,"models/buildables/sentry2.mdl")
holoDelete(6)

}
if(clk("5")){
    if(Upgrade == 0){

    holoModel(2,"models/buildables/sentry1.mdl")
    holoAnim(2,0)
}}



if(JJ == 1){
 Pos = holoEntity(2):toWorld(vec(0,0,30))
   Ang = (Pos + vec(0,0,25) - Me:aimPos()):toAngle() + ang(0,90,0)

 holoSetPose(2,"aim_pitch", clamp(Ang:pitch(), 0, 0)) 
    holoSetPose(2,"aim_yaw", sin(curtime()*20)*90) 
  
}

if(clk("soldier")){
JJ == 1000
    holoPos(3,entity():toWorld(vec(200,0,5)))
holoPos(5,entity():toWorld(vec(60,0,5)))
holoSetPose(2,"aim_yaw", sin(curtime()*0)*0)
holoEntity(5):soundPlay(10,10,"weapons/sentry_shoot2.wav")
holoPos(5,vec(99999,99999,99999))}
if(clk("soldier2")){
holoDelete(5)
holoEntity(3):soundPlay(10,1,"vo/soldier_paincrticialdeath01.wav")
holoAnim(3,288)
timer("kill",300)
}





if(clk("kill")){
holoDelete(3)}



    

if(clk("spy")){
    holoPos(7,entity():toWorld(vec(60,40,5)))
    holoCreate(10)
    holoModel(10,"models/weapons/w_models/w_sapper.mdl")
   holoPos(10,entity():toWorld(vec(45,27,53)))
    holoAng(10,ang(90,90,0))
    entity():soundPlay(10,10,"vo/spy_laughevil02.wav")
    holoAnim(7,3)
timer("sap",2000)
}

        Y = round(holoEntity(2):angles():yaw())


if(clk("sap")){
    holoCreate(8)
    holoDelete(10)
    holoModel(8,"models/buildables/sapper_sentry2.mdl")
    entity():soundPlay(3,3,"weapons/sapper_timer.wav")
    holoPos(8,entity():toWorld(vec(55,0,57)))
    holoAng(8,ang(0,Y,0))
    timer("sap2",3000)
    
}
if(clk("sap2")){
    entity():soundPlay(10,10,"vo/engineer_autodestroyedsentry01.wav")
    holoDelete(2)
    propSpawn("models/buildables/Gibs/sentry2_Gib1.mdl",entity():toWorld(vec(55,0,10)),0)
    propSpawn("models/buildables/Gibs/sentry2_Gib2.mdl",entity():toWorld(vec(55,0,10)),0)
    propSpawn("models/buildables/Gibs/sentry2_Gib3.mdl",entity():toWorld(vec(55,0,10)),0)
    holoDelete(8)
    holoDelete(7)
}


if(first()){
    Head="exhaust"
    
    for(I=1,1){
        holoCreate(9)
        holoPos(9,holoEntity(1):attachmentPos(Head))
        holoAng(9,holoEntity(1):attachmentAng(Head))
        holoPos(9,holoEntity(9):toWorld(vec(-5,-5,0)))
        holoAng(9,holoEntity(9):toWorld(ang(0,240,180)))
        holoParentAttachment(9,holoEntity(1),Head)
        holoModel(9,"models/weapons/w_models/w_wrench.mdl")
        holoMaterial(9,"models/weapons/w_models/w_wrench.mdl")
        holoScale(9,vec(1,1,1))
    }
}

if(clk("dispen")){
    holoAng(1,ang(0,180,0))
    holoCreate(11)
    holoModel(11,"models/buildables/dispenser.mdl")
    holoAnim(11,1)
    holoPos(11,entity():toWorld(vec(-50,0,3)))
    timer("switch",5500)
}

if(clk("switch")){
    holoModel(11,"models/buildables/dispenser_light.mdl")
}

if(clk("demo"))
{
    holoCreate(12)
    holoModel(12,"models/player/demo.mdl")
    holoSkin(12,1)
    holoPos(12,entity():toWorld(vec(-100,0,3)))
    holoEntity(12):soundPlay(100,100,"vo/demoman_specialcompleted09.wav")
    timer("bewm",3000)
}

if(clk("bewm")){
    holoAnim(12,166)
    holoEntity(12):soundPlay(100,100,"vo/demoman_specialcompleted11.wav")
    timer("end",600)
}

if(clk("end")){
    U = propSpawn("models/props_c17/oildrum001_explosive.mdl",entity():toWorld(vec(-100,0,3)),1)
U:propBreak()
holoDelete(1)
holoDelete(11)
holoDelete(12)
U = propSpawn("models/buildables/Gibs/dispenser_gib4.mdl",entity():toWorld(vec(-50,0,3)),0)
U = propSpawn("models/buildables/Gibs/dispenser_gib2.mdl",entity():toWorld(vec(-50,0,3)),0)
U = propSpawn("models/buildables/Gibs/dispenser_gib3.mdl",entity():toWorld(vec(-50,0,3)),0)
U = propSpawn("models/buildables/Gibs/dispenser_gib1.mdl",entity():toWorld(vec(-50,0,3)),0)
U = propSpawn("models/player/gibs/engineergib002.mdl",entity():toWorld(vec(0,0,3)),0)
U = propSpawn("models/player/gibs/engineergib004.mdl",entity():toWorld(vec(0,0,3)),0)
selfDestruct()
}
