@name FailCake LigthSaber V1 
@outputs Ply:entity On
@persist Player:entity A:array Tim Active
@trigger all
interval(100)
E=entity()

if(first()){
    findByClass("player")
    A=findToArray() 
    Active = 0
    On = 0
    soundPlay(100,100,"weapons/fx/nearmiss/bulletLtoR13.wav")
    soundPitch(100,80)
    ## BASE ##
    
    holoCreate(1)
    holoModel(1,"hqcylinder")
    holoScaleUnits(1,vec(2,2,6))
    holoPos(1,E:toWorld(vec(2.1,0,10)))
    holoAng(1,ang(90,0,0))
    holoMaterial(1,"phoenix_storms/car_tire")
    
    ## LAST ##
    
    holoCreate(2)
    holoModel(2,"hqcylinder")
    holoScaleUnits(2,vec(2.5,2.5,1.5))
    holoPos(2,E:toWorld(vec(5.5,0,10)))
    holoAng(2,ang(90,0,0))
    holoColor(2,vec(90,90,90))
    holoMaterial(2,"models/shiny")
    
    ## Second Tube ##
    
    holoCreate(3)
    holoModel(3,"hqcylinder")
    holoScaleUnits(3,vec(2.5,2.5,2))
    holoPos(3,E:toWorld(vec(2.5,0,10)))
    holoAng(3,ang(90,0,0))
    holoColor(3,vec(90,90,90))
    holoMaterial(3,"models/shiny")
    
    ## Second Tube Cube##
    
    holoCreate(4)
    holoModel(4,"cube")
    holoScaleUnits(4,vec(0.5,0.5,2))
    holoPos(4,E:toWorld(vec(2.5,0,11.2)))
    holoAng(4,ang(90,0,0))
    holoColor(4,vec(90,90,90))
    holoMaterial(4,"models/shiny")
    
    ## Third Tube ##
    
    holoCreate(5)
    holoModel(5,"hqcylinder")
    holoScaleUnits(5,vec(1.8,1.8,1.7))
    holoPos(5,E:toWorld(vec(-1.4,0,10)))
    holoAng(5,ang(90,0,0))
    holoColor(5,vec(255,200,0))
    holoMaterial(5,"models/shiny")
    
    ## Third Tube Thingy ##
    
    holoCreate(6)
    holoModel(6,"hqcylinder")
    holoScaleUnits(6,vec(2,2,0.4))
    holoPos(6,E:toWorld(vec(-1.7,0,10)))
    holoAng(6,ang(90,0,0))
    holoColor(6,vec(255,200,0))
    holoMaterial(6,"models/shiny")
    
    ## END Cyli ##
    
    holoCreate(7)
    holoModel(7,"hqcylinder")
    holoScaleUnits(7,vec(1,1,0.4))
    holoPos(7,E:toWorld(vec(-2.2,0,10)))
    holoAng(7,ang(90,0,0))
    holoColor(7,vec(255,90,0))
    holoMaterial(7,"models/shiny")
    
    ## END Cone ##
    
    holoCreate(8)
    holoModel(8,"hqcylinder")
    holoScaleUnits(8,vec(2,2,1))
    holoPos(8,E:toWorld(vec(-2.6,0,10)))
    holoAng(8,ang(90,0,0))
    holoColor(8,vec(90,90,90))
    holoMaterial(8,"models/shiny")
    
    ## Button Cyl ##
    
    holoCreate(9)
    holoModel(9,"cylinder")
    holoScaleUnits(9,vec(0.5,0.5,0.4))
    holoPos(9,E:toWorld(vec(3,-1.1,10)))
    holoAng(9,ang(90,90,0))
    holoColor(9,vec(70,70,70))
    holoMaterial(9,"models/shiny")
    
    ## Button Sphere ##
    
    holoCreate(10)
    holoModel(10,"icosphere3")
    holoScaleUnits(10,vec(0.5,0.5,0.5))
    holoPos(10,E:toWorld(vec(1.9,-1.1,10)))
    holoAng(10,ang(90,90,0))
    holoColor(10,vec(90,0,0))
    holoMaterial(10,"models/shiny")
    
    ## Saber ##
    
    holoCreate(11)
    holoModel(11,"hqcylinder")
    holoScaleUnits(11,vec(2,2,30))
    holoPos(11,E:toWorld(vec(-17,0,10)))
    holoAng(11,ang(90,0,0))
    holoColor(11,vec(0,0,200))
    holoAlpha(11,0)
    holoMaterial(11,"cable/xbeam")
    
    ## Saber End ##
    
    holoCreate(12)
    holoModel(12,"dome")
    holoScaleUnits(12,vec(2,2,2))
    holoPos(12,E:toWorld(vec(-31.25,0,10)))
    holoAng(12,ang(-90,0,0))
    holoColor(12,vec(0,0,200))
    holoAlpha(12,0)
    holoMaterial(12,"cable/xbeam")
    
    
    
}

for(I=1,A:count()){
if(A[I,entity]:keyUse() & A[I,entity]:aimEntity()==entity() & On == 0 & A[I,entity]:pos():distance(entity():pos())<= 70)
{
On = 1
Player = A[I,entity]
}
}

if(On){
Player:weapon():setMaterial("models/effects/vol_light001") 
   
if(Player:weapon():type()=="weapon_crowbar"){
    
    
    holoCreate(1)
    holoAng(1,Player:attachmentAng("anim_attachment_RH"))
    holoPos(1,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(1,Player,"anim_attachment_RH")
    holoModel(1,"hqcylinder")
    holoScaleUnits(1,vec(2,2,6))
    holoPos(1,holoEntity(1):toWorld(vec(0,0,0)))
    holoAng(1,holoEntity(1):toWorld(ang(0,0,0)))
    holoMaterial(1,"phoenix_storms/car_tire")
    
    holoCreate(2)
    holoAng(2,Player:attachmentAng("anim_attachment_RH"))
    holoPos(2,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(2,Player,"anim_attachment_RH")
    holoModel(2,"hqcylinder")
    holoScaleUnits(2,vec(2.5,2.5,1.5))
    holoPos(2,holoEntity(2):toWorld(vec(0,0,-3)))
    holoAng(2,holoEntity(2):toWorld(ang(0,0,0)))
    holoColor(2,vec(90,90,90))
    holoMaterial(2,"models/shiny")
    
    holoCreate(3)
    holoAng(3,Player:attachmentAng("anim_attachment_RH"))
    holoPos(3,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(3,Player,"anim_attachment_RH")
    holoModel(3,"hqcylinder")
    holoScaleUnits(3,vec(2.5,2.5,2))
    holoPos(3,holoEntity(3):toWorld(vec(0,0,0)))
    holoAng(3,holoEntity(3):toWorld(ang(0,0,0)))
    holoColor(3,vec(90,90,90))
    holoMaterial(3,"models/shiny")
    
    holoCreate(4)
    holoAng(4,Player:attachmentAng("anim_attachment_RH"))
    holoPos(4,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(4,Player,"anim_attachment_RH")
    holoModel(4,"cube")
    holoScaleUnits(4,vec(0.5,0.5,2))
    holoPos(4,holoEntity(4):toWorld(vec(-1.3,0,0)))
    holoAng(4,holoEntity(4):toWorld(ang(0,0,0)))
    holoColor(4,vec(90,90,90))
    holoMaterial(4,"models/shiny")
    
    holoCreate(5)
    holoAng(5,Player:attachmentAng("anim_attachment_RH"))
    holoPos(5,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(5,Player,"anim_attachment_RH")
    holoModel(5,"hqcylinder")
    holoScaleUnits(5,vec(1.8,1.8,1.7))
    holoPos(5,holoEntity(5):toWorld(vec(0,0,3)))
    holoAng(5,holoEntity(5):toWorld(ang(0,0,0)))
    holoColor(5,vec(255,200,0))
    holoMaterial(5,"models/shiny")
    
    holoCreate(6)
    holoAng(6,Player:attachmentAng("anim_attachment_RH"))
    holoPos(6,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(6,Player,"anim_attachment_RH")
    holoModel(6,"hqcylinder")
    holoScaleUnits(6,vec(2,2,0.4))
    holoPos(6,holoEntity(6):toWorld(vec(0,0,3.2)))
    holoAng(6,holoEntity(6):toWorld(ang(0,0,0)))
    holoColor(6,vec(255,200,0))
    holoMaterial(6,"models/shiny")
    
    holoCreate(7)
    holoAng(7,Player:attachmentAng("anim_attachment_RH"))
    holoPos(7,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(7,Player,"anim_attachment_RH")
    holoModel(7,"hqcylinder")
    holoScaleUnits(7,vec(1,1,0.4))
    holoPos(7,holoEntity(7):toWorld(vec(0,0,3.7)))
    holoAng(7,holoEntity(7):toWorld(ang(0,0,0)))
    holoColor(7,vec(255,90,0))
    holoMaterial(7,"models/shiny")
    
    holoCreate(8)
    holoAng(8,Player:attachmentAng("anim_attachment_RH"))
    holoPos(8,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(8,Player,"anim_attachment_RH")
    holoModel(8,"hqcylinder")
    holoScaleUnits(8,vec(2,2,1))
    holoPos(8,holoEntity(8):toWorld(vec(0,0,4)))
    holoAng(8,holoEntity(8):toWorld(ang(0,0,0)))
    holoColor(8,vec(90,90,90))
    holoMaterial(8,"models/shiny")
    
    holoCreate(9)
    holoAng(9,Player:attachmentAng("anim_attachment_RH"))
    holoPos(9,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(9,Player,"anim_attachment_RH")
    holoModel(9,"cylinder")
    holoScaleUnits(9,vec(0.5,0.5,0.4))
    holoPos(9,holoEntity(9):toWorld(vec(0,1,-0.5)))
    holoAng(9,holoEntity(9):toWorld(ang(0,0,90)))
    holoColor(9,vec(70,70,70))
    holoMaterial(9,"models/shiny")
    
    holoCreate(10)
    holoAng(10,Player:attachmentAng("anim_attachment_RH"))
    holoPos(10,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(10,Player,"anim_attachment_RH")
    holoModel(10,"icosphere3")
    holoScaleUnits(10,vec(0.5,0.5,0.5))
    holoPos(10,holoEntity(10):toWorld(vec(0,1,0.5)))
    holoAng(10,holoEntity(10):toWorld(ang(0,0,0)))
    holoColor(10,vec(90,0,0))
    holoMaterial(10,"models/shiny")
    
    holoCreate(11)
    holoAng(11,Player:attachmentAng("anim_attachment_RH"))
    holoPos(11,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(11,Player,"anim_attachment_RH")
    holoModel(11,"hqcylinder")
    holoScaleUnits(11,vec(2,2,30))
    holoPos(11,holoEntity(11):toWorld(vec(0,0,18.6)))
    holoAng(11,holoEntity(11):toWorld(ang(0,0,0)))
    holoColor(11,vec(0,0,200))
    holoMaterial(11,"cable/xbeam")
    
    holoCreate(12)
    holoAng(12,Player:attachmentAng("anim_attachment_RH"))
    holoPos(12,Player:attachmentPos("anim_attachment_RH"))
    holoParentAttachment(12,Player,"anim_attachment_RH")
    holoModel(12,"dome")
    holoScaleUnits(12,vec(2,2,2))
    holoPos(12,holoEntity(12):toWorld(vec(0,0,30)))
    holoAng(12,holoEntity(12):toWorld(ang(0,0,0)))
    holoColor(12,vec(0,0,200))
    holoMaterial(12,"cable/xbeam")
}

if(Player:keyAttack2()& Active == 0){
Tim += 1
if(Tim == 1){
            holoEntity(11):soundPlay(0,0,"weapons/physgun_off.wav")
            soundPitch(0,160)
            holoEntity(11):soundPlay(1,0,"ambient/atmosphere/city_beacon_loop1.wav")
            soundPitch(1,90)
            holoAlpha(11,200)
            holoAlpha(12,200)
 
}
if(Tim >= 4){
Active = 1
}  
}
}
