@name FailCake Slime V2
@inputs Damage Attacker:entity
@outputs On Angry Dead Once
@persist Vec:vector T Bullet:entity Timer
@persist AngDir:vector Ang:angle TPos:vector Target:entity
@trigger all
@model models/hunter/blocks/cube05x05x05.mdl
runOnTick(1)

E=entity()
if(first()){
On = 0
hint("Made by Failcake",100)
Angry = 0
E:setColor(0,90,0,250)    
E:setMaterial("models/debug/debugwhite")

holoCreate(1)
holoModel(1,"cube")
holoColor(1,vec(0,0,0))
holoScaleUnits(1,vec(1,6,6))
holoPos(1,E:toWorld(vec(-12,6,3)))
holoParent(1,E)
holoAlpha(1,255)
holoMaterial(1,"models/debug/debugwhite")

holoCreate(2)
holoModel(2,"cube")
holoColor(2,vec(0,0,0))
holoScaleUnits(2,vec(1,6,6))
holoPos(2,E:toWorld(vec(-12,-6,3)))
holoParent(2,E)
holoAlpha(2,255)
holoMaterial(2,"models/debug/debugwhite")

holoCreate(3)
holoModel(3,"cube")
holoColor(3,vec(0,0,0))
holoScaleUnits(3,vec(1,3,3))
holoPos(3,E:toWorld(vec(-12,-1,-4)))
holoParent(3,E)
holoAlpha(3,255)
holoMaterial(3,"models/debug/debugwhite")
}

if(Damage > 1){
On = 1    
}
if(On){
findByClass("player")
Target = findClosest(entity():pos())    

rangerHitWater(1)
rangerFilter(entity())
Range = rangerOffset(6,entity():pos(),vec(0,0,-2))   
Range2=rangerOffset(8,entity():pos(),vec(sinr(curtime()*1000),cosr(curtime()*1000),0))

Vec = Vec-vec(0,0,0.1)

if(Damage > 10){
T++   
}

if(Range:hit()){Vec = vec(-1,0,3) E:soundPlay(100,100,"ambient/levels/canals/toxic_slime_gurgle5.wav")}
if(Range2:hit())
{
Vec=Vec*vec(-1.5,-1.5,1)
}
TPos = Target:pos()
Ang = (entity():pos()-TPos):toAngle():setPitch(0)

if(T >= 3){
Angry = 1   
}
if(Dead == 0){
E:setPos(E:toWorld(Vec))
E:setAng(Ang)
}
}

if(Angry == 1){
timer("coolDown",15000)

if(clk("coolDown")){
Angry = 0    
}

E:setColor(255,0,0,250)

if(Target:pos():distance(entity():pos())<500 & Angry == 1)
{
timer("shoot",1000)
if(clk("shoot"))
{
Once = 0
Bullet:propDelete()
Bullet = propSpawn("models/hunter/misc/sphere025x025.mdl",0)   
Bullet:setPos(E:pos())
Bullet:setColor(vec(0,0,0))
Bullet:setMaterial("models/debug/debugwhite")
Bullet:setMass(100)
Bullet:setColor(0,255,0,200)
Bullet:applyForce((Target:shootPos()-Bullet:pos())*Bullet:mass()*10000)
}  

}
}


if(Angry == 0 & Once ==0){
Bullet:propDelete()
stoptimer("shoot")     
stoptimer("coolDown")  
E:setColor(0,255,0,250) 
T = 0
Once= 1
}

if(T > 20){
E:soundPlay(100,1000,"ambient/levels/canals/toxic_slime_sizzle4.wav")
selfDestructAll()    
}

if(duped()){selfDestructAll()}

####################################################################
## Do not rename the E2 or remove the hint("Made by Failcake",100)##
####################################################################
