@name FailCake EP2 Mag
@persist [E O Bomb]:entity With T Spawn In NextSpawn
@persist [Ply Bombs]:array MaxBomb Pos:vector
@trigger all
@model models/magnusson_teleporter_off.mdl

#weapons\strider_buster\ol12_stickybombcreator.wav
#weapons\strider_buster\strider_buster_detonate.wav
#weapons\strider_buster\strider_buster_stick1.wav
interval(100)
#models/magnusson_teleporter_off.mdl
#models/magnusson_teleporter.mdl
if(first() | duped()){

E = entity()
O = owner()
E:setAlpha(0)

holoCreate(1)
holoModel(1,"models/magnusson_teleporter.mdl") 
holoPos(1,E:toWorld(vec(0,0,0)))   
holoParent(1,E)
holoAng(1,ang(0,0,0))
holoAnim(1,0)
MaxBomb = 10
With = 0
NextSpawn = 2000
}


if(With == 0){
if(Bombs:count() < MaxBomb){
timer("spawn",NextSpawn)
With = 1   
NextSpawn = 10000
} 
}

if(clk("spawn")){
holoAnim(1,1)    
#weapons/strider_buster/ol12_stickybombcreator.wav
holoEntity(1):soundPlay(1,0,"weapons/strider_buster/ol12_stickybombcreator.wav") 
Spawn = 1
}

if(Spawn){
T+=1

if(T >= 60){
Spawn = 0
In = 1
holoAnim(1,0) 
Bomb = propSpawn("models/magnusson_device.mdl",E:toWorld(vec(0,4,47)),ang(0,90,0),1)  
Bombs:pushEntity(Bomb)
Bomb:setTrails(30,30,1,"trails/laser",vec(244,138,0),255)
T = 0
}   
}

if(In){
findByClass("player")
Ply = findToArray()    

for(I=1,Ply:count()){    
if(changed(Ply[I,entity]:keyAttack2()) & Ply[I,entity]:keyAttack2() & Ply[I,entity]:aimEntity() == Bomb & Ply[I,entity]:weapon():type() == "weapon_physcannon" & Ply[I,entity]:pos():distance(Bomb:pos()) < 100){
soundStop(1)
Bomb:propFreeze(0) 
With = 0    
In = 0  
}    
}
}
