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

#2
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.
Reply

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

"I:SetLuaControlledMissileAimPoint(t,m,TPos.x,400,TPos.z)"
x,y,z
x,y would be 2d like a flat map coordinate. If your going for altitude then you should be playing with the z dimension
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)