@name Old Remote Me Code
@inputs 
@outputs 
@persist 
@trigger 

#    #Quanternian Turret This is added
#    if (tickClk()) {
#    
#    Aim1Dir =(Self:forward()) #this is the direction you want the turret to aim from. 
#    Aim1DirF = (Enemy:massCenter() - Self:pos())
#    
#    if(C<=3){
#        Aim2Dir=Self:forward()
#        Aim2DirF=vec(1,0,0)
#    }else{
#        Aim2Dir = (Self:up()) #use this to control the turret's aim vector
#        Aim2DirF = vec(0,0,1)#entity(154):pos()-Self:pos()#:normalized()
#    }    
#    
#    Qinitial = quat(Aim1Dir,Aim2Dir)
#    Qfinal = quat(Aim1DirF,Aim2DirF)
#    Qrot= qMod(Qfinal*inv(Qinitial)) #need to modulo it to stop angle glich
#    RotationNeeded = vec(2*log(Qrot))
#    #RotationNeeded = vec(2*log(Qfinal*inv(Qinitial)))
#    #rotation vector = 2*ln(Qfinal-inv(Qinitial)))
#    
#    SelfAngVel = Self:angVelVector()*pi()/180
#    ActualInertia = Self:inertia()*InertiaConstantRad
#    LocalRot = Self:toLocalAxis(RotationNeeded)
#    Self:applyTorque((LocalRot/TickTime - SelfAngVel)*ActualInertia)
#    } elseif (first()) {
#        Enemy = entity(153)
#        Self = entity(155)
#        #the inertia constant Rad is the base inertia constant
#        InertiaConstantRad = 1550.0030838848
#        TickTime =0.015
#        runOnTick(1)
#    }
#}
    
#   Old Frog Code 
##if (tickClk()) {
##    if (Enemy:isPlayer()|Enemy:isNPC()) {
##        EnemyPosition = Enemy:pos()
##        EnemyPosition += vec(0,0,Enemy:height()/2)
##    } else {
##        EnemyPosition = Enemy:massCenter()
##}    
#    
#    
#    #######################################
#    #rotates to local for points
#    Point=1 #toggles this behavior 1=vector aimed 0=target entity aimed
#    if(Point){
#        #AimPos=owner():aimPos()
#        rangerFilter(Tools[6,entity])
#        rangerFilter(Tools[6,entity]:isConstrainedTo())
#        AimPos=rangerOffset(50000,Position,Direction):position()
#        AttackPosition=AimPos #aim here
#        RelativePosition = Self:toLocal(AttackPosition-
#        (Self:massCenter() - Self:pos())) #this line adjusts for center of mass
#    }else{
##        #rotates to local for entities
##        RelativePosition = Self:toLocal(EnemyPosition-
##        (Self:massCenter() - Self:pos())+ #this line adjusts for center of mass
##        EnemyVelocity*Time-Self:vel()*Time+#this line adjusts for player and self velocity
##        Enemy:isPlayer()*EnemyVelocity*Time)#lead for players only
#    }
#    if(C!=3){
#        #inertia needs to be recalculated incase weight change
#        Inertia = ang(Self:inertia():y(),Self:inertia():z(),Self:inertia():x())
#        
#        #Takes a vector representing distance from target relative to turret 
#        #(this rotates the turret rightside up and prevents the 179 to -179 jitters
#        RelativeAngles = angnorm(RelativePosition:toAngle():setRoll( -Self:angles():roll()+Roll))
#        #finds the correct impulse and applies it
#        AngularImpulse = Inertia*InertiaConstant*(RelativeAngles*RS-Self:angVel())
#        Self:applyAngForce(AngularImpulse)#this function applies impulse, not force
#        #######################################
#    }else{
# 
#        Dir = RelativePosition #Self:pos()-AimPos
#        Q = quat(Dir:toAngle())*qRotation(vec(0,1,0),-90)
#        Self:applyTorque((150*Self:toLocal(rotationVector(Q/quat(Self))+Self:pos()) - 12*Self:angVelVector())*Self:inertia())
#    }
#
##    } elseif (first()) {
#    if(first()){
#        if(!isSinglePlayer()){
#            Time = 0.015 #time for a game tick
#        }else{Time=0.020}
#        InertiaConstant = 27.053079273838 #Universal inertia constant
#        
#        RS = 1/Time #Rotational speed #Theoritically optimal speed (1 tick to aim)
#        
#        timer("startup1",300)
#        Enemy = entity(147)
#        
#    } elseif (clk("startup1")) {
#    
#        if (findCanQuery()) {
#            #findByClass("gmod_turret")
#            #findByClass("gmod_wire_turret")
#            #findByClass("gmod_wire_grabber")
#            #Self = find()
#            runOnTick(1)
#        } else {
#            timer("startup1",300)
#        }
#    }
#}
##G is turret F is target T is time
#

