@name Kill Dragon Turret
@inputs Gun:wirelink
@outputs Ang:angle I CanDo [Ranger F]:entity
@persist [G E O F]:entity Ro:ranger
@model models/props_junk/PopCan01a.mdl
#by [ME]OmicroN
if(first()){
    runOnTick(1)
    O = owner()
    E = entity()
    G = Gun:entity()
    G:setMass(50000)
    rangerFilter(G)
    rangerPersist(1)
}

if(findCanQuery()){
    
    F = players()[2,entity]
}
## Pos is the global position of where the Grabber will hover at ##
Pos = E:toWorld(vec(0,0,40))
G:applyForce(((Pos-G:pos())*15-G:vel()/2)*G:mass())

## F:pos() is the global position that the grabber will aim at ##
Dir = G:pos()-(F:pos()+F:vel()/10)

Q = quat(Dir:toAngle())*qRotation(vec(0,0,1),180)
G:applyTorque((150*G:toLocal(rotationVector(Q/quat(G))+G:pos()) - 12*G:angVelVector())*G:inertia())


Object = G:pos() + G:forward()
Aim = G:forward()
Ranger = rangerOffset(500000,Object,Aim):entity()
if(Ranger==F){Gun["Fire",number]=1}else{Gun["Fire",number]=0}
