@name FailCake InsideEverything
@outputs [E O]:entity Dist Active Fase MaxDis OP I
@persist [Props Included Ang Pos]:array OrPos:vector
@trigger all
@model models/props_c17/TrapPropeller_Lever.mdl

runOnTick(1)

if(first()){
setName("FailCake InsideEverything [Ready]") 
O = owner() 
E = entity()  
MaxDis = 300
Active = 0
Fase = 1
OP = 0
I = 0
}

Dist = O:pos():distance(E:pos())

if(O:keyUse() & Dist <= 100 & O:aimEntity() == E & Active == 0){
Active = 1 
Fase = 1 
setName("FailCake InsideEverything [Activated]")    
}


if(Active){
    
if(Fase == 1){
findIncludePlayerProps(O)
findByClass("*")
Props = findToArray()

timer("add",100)
if(clk("add")){
I+=1
if(Props[I,entity]:pos():distance(E:pos()) <= MaxDis){
OP+=1
Included[OP,entity] = Props[I,entity]
Pos[OP,vector] = Props[I,entity]:pos()
Ang[OP,angle] = Props[I,entity]:angles()

Included[OP,entity]:setAlpha(150)
}
   
}

if(I >= Props:count()){
Fase = 2
OrPos = E:pos()
setName("FailCake InsideEverything [Running]")     
}
}


if(Fase == 2){
timer("Update",10)  
if(clk("Update")){
for(I2=0,Included:count()){
Included[I2,entity]:propFreeze(1)
Included[I2,entity]:setPos(Included[I2,entity]:pos() - OrPos:distance(E:pos()))
}
}
    
}


  
}
