@name Blah2
@inputs 
@outputs 
@persist State Spin 
@trigger 
interval(60)

O = findPlayerByName("Divalent")

if (first()) {
    holoCreate(1)
    holoModel(1,"models/weapons/world/rifles/sks.mdl")
    holoPos(1,entity():toWorld(vec(0,0,50)))
    
    function number checkLPI(H) {
        local Holo = holoEntity(H)
        local Vec = (O:shootPos()+(Holo:up():dot(Holo:pos()-O:shootPos()))/(Holo:up():dot((O:shootPos()+O:eye())-O:shootPos()))*((O:shootPos()+O:eye())-O:shootPos()))
        
        local Min = Holo:pos()-(holoScaleUnits(holoIndex(Holo))/1.01)
        local Max = Holo:pos()+(holoScaleUnits(holoIndex(Holo))/1.01)
        
        return inrange(Vec, Min, Max)
    }
}

Holo = holoEntity(1)

if (changed(O:keyUse()) & O:keyUse() & checkLPI(1)) {
    Spin = 1
    State = 1
}

if (Spin == 1) {
    holoPos(1,entity():toWorld(vec(0,0,50 + sin(curtime() * 100) * 3)))
    holoAng(1,entity():toWorld(ang(0,curtime() * 100, 0)))
}

if (State == 1 & changed(O:keyWalk()) & O:keyWalk()) {
    Prop = propSpawn("models/weapons/world/pistols/ots33.mdl",0)
    Prop:setPos(holoEntity(1):pos())
    Spin = 0
    State = 0
    holoPos(1,entity():toWorld(vec(0,0,50)))
    holoAng(1,entity():toWorld(ang(0,0,0)))
}


#[ models

models/weapons/w_m24.mdl
models/weapons/world/rifles/sks.mdl
models/weapons/w_dv2.mdl
models/weapons/world/pistols/w_deserteagle.mdl
