Not a member yet? Why not Sign up today
Create an account  

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Missile LUA Help

#1
i was trying to write a code to get missiles to cruise at 400m until within 100m horizontally from the target, then cut engines and glide down to impact (using APN), but i can't seem to get it to work. any help would be greatly appreciated, i'm still fairly new to LUA. i'm also not sure if "missileData.throttle" is a real thing or not, if not could you please let me know what i actually need to do to change thrust in a variable missile?


function Speed(vel)
   return math.sqrt(vel.x^2 + vel.y^2 + vel.z^2)
end
 
function Distance(a,b)
   return math.sqrt((a.x - b.x)^2 + (a.y - b.y)^2 + (a.z - b.z)^2)
end



function Update(I)
     for t=0,I:GetLuaTransceiverCount() do
        for m=0,I:GetLuaControlledMissileCount(t) do
 
         missileInfo = I:GetLuaControlledMissileInfo(t, m)
         targetInfo = I:GetTargetInfo(0, 0)
     

          if(targetInfo.Valid == false or targetInfo.Protected == false) then
               break
          end

          Pos = missileInfo.Position
          TSpeed = Speed(targetInfo.Velocity)
          TPos = targetInfo.AimPointPosition
          V = targetInfo.Velocity
          D = Distance(Pos, TPos)
          S = Speed(TSpeed-missileInfo.Velocity)
          PDis = math.sqrt((Pos.x-TPos.x)^2 + (Pos.y-TPos.y)^2)
          Time =  D/S

          if (PDis >100)
               
               I:SetLuaControlledMissileAimPoint(t,m,TPos.x,400,TPos.z)
          end

          else 
               missileData.throttle = 0

               I:SetLuaControlledMissileAimPoint(t,m,TPos.x,TPos.y,TPos.z)
          end
               

end
Reply



Messages In This Thread
Missile LUA Help - by Alexedra - 2018-08-27, 12:55 AM
RE: Missile LUA Help - by Lincrono - 2018-09-15, 07:45 AM
RE: Missile LUA Help - by evilebob - 2018-10-16, 10:52 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)