################
# > Spear'd: Fire harpoons everywhere.
# > How to use: Left click to fire it where you look. Right click to make it penetrate where you look.
################

@name Spear'd
@persist Spear:entity I Sound

interval(10)

Throw1=owner():keyAttack1()
Throw2=owner():keyAttack2()

if (changed(Throw1)&Throw1) {
    Spear = propSpawn("models/props_junk/harpoon002a.mdl",0)
    Spear:setPos(owner():toWorld(vec(100,0,48)))
    Spear:setAng((owner():aimPos()-(owner():pos()+vec(0,0,48))):toAngle())
    Spear:setMass(50000)
    Spear:applyForce((owner():aimPos()-(owner():toWorld(vec(100,0,48))))*Spear:mass()*1000000000)
}

if (changed(Throw2)&Throw2) {
    Spear = propSpawn("models/props_junk/harpoon002a.mdl",1)
    Spear:setPos(owner():aimPos())
    Spear:setAng((owner():aimPos()-(owner():pos()+vec(0,0,48))):toAngle())
    Sound = randint(2)
    if (Sound==1) {
        Spear:soundPlay(I,0,"weapons/crowbar/crowbar_impact1.wav")
    }
    elseif (Sound==2) {
        Spear:soundPlay(I,0,"weapons/crowbar/crowbar_impact2.wav")
    }
    I+=1
}
