@name FailCake Combine Mine 
@persist E:entity Ply:array Hold MaxH InGround Del
@trigger all
@model models/props_combine/combine_mine01.mdl

#npc/roller/mine/combine_mine_active_loop1.wav
#npc/roller/mine/combine_mine_deploy1.wav
#npc/roller/mine/combine_mine_deactivate1.wav
#npc/roller/mine/rmine_blip3.wav
#npc/roller/blade_cut.wav

if(first() | duped()){
runOnTick(1)
E = entity()

## SETTINGS ##
MaxH = 20
## SETTINGS ##

holoCreate(1)
holoModel(1,"hqcylinder")
holoParent(1,E)
holoScaleUnits(1,vec(10,10,0.7))
holoColor(1,vec(255,0,0))
holoMaterial(1,"models/debug/debugwhite")
holoPos(1,E:toWorld(vec(0,0,9.6)))

E:soundPlay(1,0,"npc/roller/blade_cut.wav")
E:setPos(E:toWorld(vec(0,0,-8)))
E:propFreeze(1)

MaxDis = 300
InGround = 0
Hold = 0

findByClass("player")
Ply = findToArray()
print(Ply:count())
}




if(tickClk()){
if(InGround == 0){
    
for(I=1,Ply:count()){

if(Ply[I,entity]:aimEntity() == E & Ply[I,entity]:keyAttack2() & Ply[I,entity]:weapon():type() == "weapon_physcannon" & Ply[I,entity]:pos():distance(E:pos()) <= 200){
Hold++
Del = 0  
}elseif(Hold > 0 & Del == 0){
timer("delay",300)
Del = 1
}
   

if(Ply[I,entity]:pos():distance(E:pos()) <= 200){
holoColor(1,vec(255,0,0))    
}else{
holoColor(1,vec(0,255,0)) 
}

}
}

if(Hold >= MaxH){
InGround = 1
Hold = 0
Del = 0
holoColor(1,vec(255,170,0)) 
E:soundPlay(1,0,"npc/roller/mine/combine_mine_deactivate1.wav")   
}

if(clk("delay")){
Hold = 0  
stoptimer("delay")  
}
 
if(InGround){
E:propFreeze(0)
}

}

