@name mouseaimedturret
@inputs E:entity Driver:entity ACTIVE
@outputs
@persist Vec:vector Ang:angle
@trigger

runOnTick(1)

#Made by TheMrFailz.

#TOSETUP: place e2+baseplate+turretpiece+ent.marker
#Ballsocket turret to base, mark turret piece with marker
#attach wire accordingly.


#E = entity():isWeldedTo()
if(ACTIVE){
Vec = (Driver:pos() - entity():pos() + vec(0,0,100))
E:applyForce((Vec + $Vec*5)*entity():mass())

Pitch = E:elevation(Driver:aimPos())
Yaw = E:bearing(Driver:aimPos())
Roll = E:angles():roll()/15

Ang = -ang(Pitch,Yaw,Roll)
E:applyAngForce((Ang + $Ang*5)*E:mass()*15)
}
