@name Gun Aimer by Dangle
@inputs Gun:entity 
@outputs Gyro:angle Vec:vector
@persist Gyro:angle Vec:vector Owner:entity
@trigger 

runOnTick(1)
runOnChat(1)

if(chatClk(owner())){
    Chat = owner():lastSaid():explode(" ")
    if(Chat:string(1)=="/o"){
        hideChat(1)
        Owner = findPlayerByName(owner():lastSaid():sub(4))
        }
    }


P = Gun:elevation(Owner:aimPos())
Y = Gun:bearing(Owner:aimPos())
R = Gun:angles():roll()


Gyro = -ang(P,Y,R)*500

Gun:applyAngForce(Gyro + $Gyro*5)

#Vec = (Gun:pos() - entity():pos()+vec(0,0,40))*500

#Gun:applyForce(Vec + $Vec*5)
