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

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)
function Distance(a,b)
   return math.sqrt((a.x - b.x)^2 + (a.y - b.y)^2 + (a.z - b.z)^2)

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

          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)

               missileData.throttle = 0



you may have better luck getting hold of one of the LUA gurus on the discord channel.  changing missile throttle is a thing (though i'm not sure why you would want to cut all thrust) what i'm not sure of is if the APN will work or if the LUA module interferes with it.

On a separate note i would advise against further developing this weapon.  i've seen the idea floated a number of times as a way of getting past LAMs defenses, but in reality the shear difficulty of attacking even a gently maneuvering target makes the concept unworkable.  You end up losing almost as much, and often more, missiles to simple misses as you would to enemy defenses.
-Do not bring forth an argument as fact that can be disproven with a 10 minute Google search.

I didn't test the script but this part looks off to me

x,y would be 2d like a flat map coordinate. If your going for altitude then you should be playing with the z dimension

Forum Jump:

Users browsing this thread:
1 Guest(s)