@name FailCake Fake Rocket
@outputs [O E Ply Missile]:entity Go Prepare Kill P Dist Deads Bum Rdy Hold
@persist 
@trigger all
runOnTick(1)


if(first()){
E = entity()
O = owner()
Go = 0
propSpawnEffect(0)
}



if(O:keyAttack2() & Go == 0 & Kill == 0){
if(O:aimEntity():isPlayer() & O:aimEntity() != noentity()){
Go = 1
Ply = O:aimEntity()
hint("Target to Scare Selected!",7)
hint("Target "+Ply:name(),7)   
}
}

if(Go){
    
if(Prepare == 0){
Prepare = 1
Missile = propSpawn("models/weapons/W_missile_closed.mdl",E:toWorld(vec(0,0,16)),ang(-90,0,0),1)    
E:soundPlay(100,100,"vo/k_lab/kl_initializing02.wav")
Missile:setTrails(10,10,2,"trails/smoke",vec(1,1,1),255)
}

if(Prepare == 1){
timer("wait",5000)
if(clk("wait")){
Kill = 1 
Prepare = 0
Go = 0
E:soundPlay(100,100,"buttons/button9.wav")
stoptimer("wait")  
}    
}

}



if(Kill){
    
if(P <= 50){
P+=10
Missile:setPos(E:pos()+vec(0,0,16+P))
}else{

if(Rdy != 1){
Missile:setAng((vec(0,0,-40)+Missile:pos()-Ply:pos()):toAngle()+ang(180,0,0)) 
Missile:setPos(Missile:pos()+Missile:forward()*10)
}
Dist = Missile:pos():distance(Ply:pos())
if(Dist <= 70 ){
Rdy = 1 
Hold = 1   
}

}
}

Dist = Missile:pos():distance(Ply:pos())

if(Rdy){
timer("holds",1000)
Kill = 0

if(Hold == 1){
Missile:setPos(Missile:pos()+vec(0,0,0))
}

if(clk("holds")){
Kill = 0
Hold = 0
Rdy = 0
Bum = 1
Missile:soundPlay(100,100,"")
Missile:removeTrails()
Missile:propFreeze(0)
}
}   

if(Bum){
timer("Bum",3000)

if(clk("Bum")){
Missile:propDelete()
reset()  
}

}

# This code is not even done right im just bored and making it longer..
