@name 1#Ban Hammer
@inputs 
@outputs Code:string M1 Throwing M2 Thrown TPos:vector Eye:vector
@persist Bar:entity Grip:entity Head:entity Arg1:string Arg2:string Spike1:entity Spike2:entity LC:string
@trigger 

interval(10)
runOnChat(1)
E = owner()
Material = "models/props_pipes/pipeset_metal"
Material2 = "models/effects/vol_light001"
Material3 = "models/props_canal/metalwall005b"
Material4 = "models/props_combine/metal_combinebridge001"
Model1 = "hqcone"
Model2 = "hqcylinder"
RH = "anim_attachment_RH"

Command = owner():lastSaid()
if((Command:explode(" "):string(1) == "-mode")&(LC!=Command)){
    Code = owner():lastSaid():explode(" "):string(2)
    Arg1 = owner():lastSaid():explode(" "):string(3)
    Arg2 = owner():lastSaid():explode(" "):string(4)

if(Arg1 == ""){
    hint("Mode set to: "+Code+" With no arguments",5)
}else{
    hint("Mode set to: "+Code+" With arguments:"+Arg1+", "+Arg2,5)
}
}
LC = owner():lastSaid()
if (first() | duped())
{
    print("Gaben 50% Off Steam Sales HL3")
    print("You must aqquire a crowbar to use the Ban Hammer.")
    print("If you wish to use another weapon, edit line 78 with a n ew weapon name.")
    
    Bar = holoCreate(1,E:attachmentPos(RH),vec(0.2,0.2,4),E:attachmentAng(RH))
    holoPos(1,Bar:toWorld(vec(0,0,20)))
    holoParentAttachment(1,E,RH)
    holoMaterial(1,Material)
    holoModel(1,Model2)
    
    Head = holoCreate(2,E:attachmentPos(RH),vec(4,2,2),E:attachmentAng(RH))
    holoPos(2,Bar:toWorld(vec(0,0,20)))
    holoAng(2,E:attachmentAng(RH))
    holoParent(2,1)
    holoMaterial(2,Material)
    
    Spike1 = holoCreate(3,E:attachmentPos(RH),vec(1,1,1),E:attachmentAng(RH))
    holoPos(3,Bar:toWorld(vec(30,0,20)))
    holoAng(3,E:attachmentAng(RH)+ang(90,0,0))
    holoParent(3,2)
    holoMaterial(3,Material3)
    holoModel(3,Model1)
    
    Spike2 = holoCreate(4,E:attachmentPos(RH),vec(1,1,1),E:attachmentAng(RH))
    holoPos(4,Bar:toWorld(vec(-30,0,20)))
    holoAng(4,E:attachmentAng(RH)+ang(-90,0,0))
    holoParent(4,2)
    holoMaterial(4,Material3)
    holoModel(4,Model1)
    
    Grip = holoCreate(5,E:attachmentPos(RH),vec(0.23,0.23,1),E:attachmentAng(RH))
    holoPos(5,Grip:toWorld(vec(0,0,2)))
    holoParent(5,1)
    holoMaterial(5,Material4)
    holoModel(5,Model2)

    #HOLO FOR SOUND
    holoCreate(6)
    holoAlpha(6,0)



}

# Color the crowbar if its out
if ((E:weapon():type() == "weapon_crowbar")&!Thrown)
{
    E:weapon():setMaterial(Material2)
    Bar:setAlpha(255)
    Grip:setAlpha(255)
    Head:setAlpha(255)
    Spike1:setAlpha(255)
    Spike2:setAlpha(255)

M1 = E:keyAttack1()
M2 = E:keyAttack2()

if(M1&$M1&!Throwing)
{
    owner():soundPlay(1,0,"npc/strider/fire.wav")
    OP = E:aimEntity()
    if($M1 & OP:isPlayer() & E:pos():distance(OP:pos()) <= 300)
    {
        concmd("ulx "+Code+" \""+OP:name()+"\" "+Arg1+" "+Arg2)
    }
}


if(M2&$M2){
Throwing=!Throwing
hint("Throwing: "+Throwing,5)
}


if(M1&$M1&Throwing)
{
    holoEntity(1):soundPlay(2,0,"weapons/tripwire/ropeshoot.wav")
    soundPitch(2,25)
    Thrown=1
    TPos=owner():shootPos()
    Eye=owner():eye()
    holoAng(1,Eye:toAngle())
    holoUnparent(1)
    JT=1
}





}

elseif(!Thrown)
{
    Bar:setAlpha(0)
    Grip:setAlpha(0)
    Head:setAlpha(0)
    Spike1:setAlpha(0)
    Spike2:setAlpha(0)
}
if(Thrown){
TPos+=Eye*15
holoPos(1,TPos)
holoAng(1,holoEntity(1):toWorld(ang(20,0,0)))
RD=rangerOffset(30,TPos,Eye)
if(RD:hit()){
    holoPos(6,RD:position())
    holoEntity(6):soundPlay(1,0,"npc/strider/fire.wav")
    OP = RD:entity()
    if(OP:isPlayer())
    {
        concmd("ulx "+Code+" \""+OP:name()+"\" "+Arg1+" "+Arg2)
    }


    Thrown=0
    holoCreate(1,E:attachmentPos(RH),vec(0.2,0.2,4),E:attachmentAng(RH))
    holoModel(1,Model2)
    holoPos(1,Bar:toWorld(vec(0,0,20)))
    holoParentAttachment(1,E,RH)
    soundStop(2)
}
}
M1 = owner():keyAttack1()
if (clk("timeout")|(M1&$M1)){
     Thrown=0
    holoCreate(1,E:attachmentPos(RH),vec(0.2,0.2,4),E:attachmentAng(RH))
    holoModel(1,Model2)
    holoPos(1,Bar:toWorld(vec(0,0,20)))
    holoParentAttachment(1,E,RH) 
    soundStop(2)
}
