@name FailCake Harmless Cube E2 V1
@outputs A:array Go OnceS OnceSS Update Happy Attack LOL NORMAL
@persist Player:entity Timer Pos:vector Track Move Move2 Wait T R_D SongHap Jump
@trigger all
@model models/props/metal_box.mdl
#@model models/hunter/blocks/cube075x075x075.mdl
if(first()){
T = 255
Happy = 1
hint("Made By FailCake",100)
}
runOnTick(1)
runOnChat(1)

Ee = entity()

Ee:setMaterial("")
entity():setSkin(1)
Ee:setMass(200)
findByClass("player")
Player = findClosest(Ee:pos())
Go = (Player:aimEntity()==Ee? 0 : 1)
NoNoclip = Player:inNoclip()
if(NoNoclip == 1){
NoNoclipp = 0
}else{
NoNoclipp = 1
}

if(Go & NoNoclipp & Happy == 0 ){
holoMaterial(11,"models/debug/debugwhite")
holoMaterial(12,"models/debug/debugwhite")
holoMaterial(13,"models/debug/debugwhite")
holoMaterial(14,"models/debug/debugwhite")
holoMaterial(15,"models/debug/debugwhite")
holoMaterial(17,"models/debug/debugwhite")
holoMaterial(18,"models/debug/debugwhite")
entity():setMass(200) 
holoCreate(11)
holoModel(11,"cube")
holoPos(11,Ee:toWorld(vec(19,5,5)))
holoAng(11,Ee:toWorld(ang(0,0,0)))
holoScale(11,vec(0.1,0.2,0.7))
holoColor(11,vec(255,0,0))
holoParent(11,Ee)

holoCreate(12)
holoModel(12,"cube")
holoPos(12,Ee:toWorld(vec(19,-5,5)))
holoAng(12,Ee:toWorld(ang(0,0,0)))
holoScale(12,vec(0.1,0.2,0.7))
holoColor(12,vec(255,0,0))
holoParent(12,Ee)
    
 
holoCreate(13)
holoModel(13,"cube")
holoPos(13,Ee:toWorld(vec(19,-7,-4)))
holoAng(13,Ee:toWorld(ang(0,0,-60)))
holoScale(13,vec(0.1,0.2,0.7))
holoColor(13,vec(255,0,0))
holoParent(13,Ee)

holoCreate(14)
holoModel(14,"cube")
holoPos(14,Ee:toWorld(vec(19,0,-2)))
holoAng(14,Ee:toWorld(ang(0,0,90)))
holoScale(14,vec(0.1,0.2,0.7))
holoColor(14,vec(255,0,0))
holoParent(14,Ee)

holoCreate(15)
holoModel(15,"cube")
holoPos(15,Ee:toWorld(vec(19,7,-4)))
holoAng(15,Ee:toWorld(ang(0,0,60)))
holoScale(15,vec(0.1,0.2,0.7))
holoColor(15,vec(255,0,0))
holoParent(15,Ee)   

holoCreate(16)
holoModel(16,"cube")
holoPos(16,Ee:toWorld(vec(19,7,12)))
holoAng(16,Ee:toWorld(ang(0,0,-60)))
holoScale(16,vec(0.1,0.2,0.6))
holoColor(16,vec(255,0,0))
holoParent(16,Ee)   

holoCreate(17)
holoModel(17,"cube")
holoPos(17,Ee:toWorld(vec(19,-7,12)))
holoAng(17,Ee:toWorld(ang(0,0,60)))
holoScale(17,vec(0.1,0.2,0.6))
holoColor(17,vec(255,0,0))
holoParent(17,Ee)   
   
Songs=array()
Songs:setString(1,"d3_citadel/stalker_breathing.wav")
Songs:setString(2,"npc/stalker/breathing3.wav")
Songs:setString(3,"vo/ravenholm/madlaugh03.wav")
Songs:setString(4,"vo/ravenholm/madlaugh04.wav")
Songs:setString(5,"vo/npc/male01/behindyou01.wav")
Songs:setString(6,"vo/npc/male01/behindyou02.wav")

Songs:setString(7,"vo/npc/male01/excuseme02.wav")
Songs:setString(8,"vo/gman_misc/gman_riseshine.wav")
Songs:setString(9,"music/stingers/industrial_suspense1.wav")
Songs:setString(10,"ambient/levels/prison/radio_random1.wav")
Songs:setString(11,"ambient/voices/playground_memory.wav")
Songs:setString(12,"vo/k_lab/kl_fiddlesticks.wav")
Songs:setString(13,"vo/k_lab/kl_ohdear.wav")

Timer+= 1

if(Timer == 10){
R = randint(1,13)
Ee:soundPlay(7331,0,Songs:string(R))
soundVolume(7331,999999)
soundPitch(7331,100)
}
if(Timer >= 150){
Timer = 0 
}
    

if(Go&$Go){Track = 1 hint("Kill = "+ Player:name() +".",100) }
if(Player:health()<=0&Track==1){Track=0 }

if(Track & NoNoclipp & Happy == 0){
Distance = Player:pos():distance(Ee:pos())
Pos = (Player:pos() - Ee:pos())

if(Distance >= 90){
Move += 1
Move2 = 0
if(Move >= 0 & Move <= 10){
Ee:applyForce(Pos*30 + $Pos*30)    
}
if(Move == 80){
Move = 0
}
}
if(Distance <= 60){
Move2 += 1
Move = 1
if(Move2 >= 0 & Move2 <= 10){
Ee:applyForce(Pos*29 + $Pos*29)    
}
if(Move2 == 80){
Move2 = 0
}
}

if(Distance <= 60){
Wait += 1
Ee:setMass(50)
if(Wait == 10){
Ee:applyForce(Pos*40 + $Pos*40) 
}    
if(Wait == 80){
Wait = 0
}


}    
if(Distance >= 90){
Ee:setMass(200)
OnceS = 0
OnceSS = 0
}

if(Distance <= 80){
if(OnceS==0){
OnceS = 1
soundPlay(1000,1000,"weapons/knife/knife_deploy1.wav")
}
}

if(Distance <= 50){ 
Ee:applyForce(Pos*1000 + $Pos*1000)
if(OnceSS == 0){
OnceSS = 1
soundPlay(1000,1000,"weapons/knife/knife_stab.wav")
}
}
}


}else{
Ee:applyForce(vec(0,0,0))
OnceS = 0
OnceSS = 0
soundStop(7331)
Timer = 0
Go = 0
Wait = 0
Move = 0
Move2 = 0
}

Command = owner():lastSaid():lower()
if((Command:explode(" "):string(1) == "-update")&Update != 1){
hint("Updated! New Kill = "+ Player:name() +".",100)
Update = 1
}
if((Command:explode(" "):string(1) == "-happy")&Happy != 1){
hint("Companion Cubes Happy!",100)
Update = 0
Happy = 1
Attack = 0
}
if((Command:explode(" "):string(1) == "-angry")&Attack != 1){
hint("Companion Cubes Attacking >:(",100)
Update = 1
soundStop(1000)
Happy = 0
Attack = 1
}

if((Command:explode(" "):string(1) == "-lolface")&LOL != 1){
hint("Companion Cubes LOL",100)
Update = 0
soundStop(1000)
Happy = 0
LOL = 1
Attack = 0
}

if((Command:explode(" "):string(1) == "-normal")&NORMAL != 1){
hint("Companion Cubes Normal Face",100)
Update = 0
soundStop(1000)
Happy = 0
LOL = 0
NORMAL = 1
Attack = 0
}
## Kill Cubie :D ##


Kill_D = Ee:isOnFire()

if(Kill_D){
soundStop(7331)
T -= 1
Ee:setColor(T,T,T)
R_D += 1
if(R_D==1){
    #vo/aperture_ai/escape_02_spheredestroy1-01.wav
soundPlay(1000,1000,"vo/aperture_ai/escape_02_ballhitpain-01.wav")
}
if(R_D==30){
soundPlay(1000,1000,"vo/aperture_ai/escape_02_ballhitpain-02.wav")
}

if(T==-80){
 soundPlay(10000,10000,"vo/aperture_ai/file_deleted.wav")   
}
if(T<=-120){
T-= 0
T = 0   

selfDestruct()
}
}

if(Happy){
entity():setSkin(2) 
entity():setMass(300)  

## HOLO XD ##
holoDelete(11)
holoDelete(12)
holoDelete(13)
holoDelete(14)
holoDelete(15)
holoDelete(16)
holoDelete(17)

holoDelete(6)
holoDelete(7)
holoDelete(8)
holoDelete(9)
holoDelete(10)
Normal = 1

holoMaterial(1,"models/debug/debugwhite")
holoMaterial(2,"models/debug/debugwhite")
holoMaterial(3,"models/debug/debugwhite")
holoMaterial(4,"models/debug/debugwhite")
holoMaterial(5,"models/debug/debugwhite")

holoCreate(1)
holoModel(1,"cube")
holoPos(1,Ee:toWorld(vec(19,5,5)))
holoAng(1,Ee:toWorld(ang(0,0,0)))
holoScale(1,vec(0.1,0.2,0.7))
holoColor(1,vec(0,255,0))
holoParent(1,Ee)

holoCreate(2)
holoModel(2,"cube")
holoPos(2,Ee:toWorld(vec(19,-5,5)))
holoAng(2,Ee:toWorld(ang(0,0,0)))
holoScale(2,vec(0.1,0.2,0.7))
holoColor(2,vec(0,255,0))
holoParent(2,Ee)

holoCreate(3)
holoModel(3,"cube")
holoPos(3,Ee:toWorld(vec(19,-7,-3)))
holoAng(3,Ee:toWorld(ang(0,0,60)))
holoScale(3,vec(0.1,0.2,0.7))
holoColor(3,vec(0,255,0))
holoParent(3,Ee)

holoCreate(4)
holoModel(4,"cube")
holoPos(4,Ee:toWorld(vec(19,0,-5)))
holoAng(4,Ee:toWorld(ang(0,0,90)))
holoScale(4,vec(0.1,0.2,0.7))
holoColor(4,vec(0,255,0))
holoParent(4,Ee)

holoCreate(5)
holoModel(5,"cube")
holoPos(5,Ee:toWorld(vec(19,7,-3)))
holoAng(5,Ee:toWorld(ang(0,0,-60)))
holoScale(5,vec(0.1,0.2,0.7))
holoColor(5,vec(0,255,0))
holoParent(5,Ee)

SongHap += 1
Jump += 1
if(SongHap == 2){
entity():soundPlay(1000,1000,"music/portal_still_alive.mp3")
}
if(Jump == 2){
Ee:applyForce(vec(0,0,100000))    
}
if(Jump == 100){
Jump = 0
Ee:applyForce(vec(0,0,0))
}
if(SongHap/10 >= soundDuration("music/portal_still_alive.mp3")){
SongHap = 0
}
}else{
Jump = 0
SongHap = 0
holoDelete(1)
holoDelete(2)
holoDelete(3)
holoDelete(4)
holoDelete(5)
}

if(LOL){
holoMaterial(6,"models/debug/debugwhite")
holoMaterial(7,"models/debug/debugwhite")
holoMaterial(8,"models/debug/debugwhite")
holoMaterial(9,"models/debug/debugwhite")
holoMaterial(10,"models/debug/debugwhite")

holoDelete(11)
holoDelete(12)
holoDelete(13)
holoDelete(14)
holoDelete(15)
holoDelete(16)
holoDelete(17)

holoCreate(6)
holoModel(6,"cube")
holoPos(6,Ee:toWorld(vec(19,5,5)))
holoAng(6,Ee:toWorld(ang(0,0,0)))
holoScale(6,vec(0.1,0.2,0.7))
holoColor(6,vec(255,0,0))
holoParent(6,Ee)

holoCreate(7)
holoModel(7,"cube")
holoPos(7,Ee:toWorld(vec(19,-5,5)))
holoAng(7,Ee:toWorld(ang(0,0,0)))
holoScale(7,vec(0.1,0.2,0.7))
holoColor(7,vec(255,0,0))
holoParent(7,Ee)
    
 
holoCreate(8)
holoModel(8,"cube")
holoPos(8,Ee:toWorld(vec(19,-7,-3)))
holoAng(8,Ee:toWorld(ang(0,0,-60)))
holoScale(8,vec(0.1,0.2,0.7))
holoColor(8,vec(0,255,0))
holoParent(8,Ee)

holoCreate(9)
holoModel(9,"cube")
holoPos(9,Ee:toWorld(vec(19,0,-5)))
holoAng(9,Ee:toWorld(ang(0,0,90)))
holoScale(9,vec(0.1,0.2,0.7))
holoColor(9,vec(0,255,0))
holoParent(9,Ee)

holoCreate(10)
holoModel(10,"cube")
holoPos(10,Ee:toWorld(vec(19,7,-3)))
holoAng(10,Ee:toWorld(ang(0,0,60)))
holoScale(10,vec(0.1,0.2,0.7))
holoColor(10,vec(0,255,0))
holoParent(10,Ee)    
}else{
holoDelete(6)
holoDelete(7)
holoDelete(8)
holoDelete(9)
holoDelete(10)
}

if(duped()){selfDestructAll()}

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