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

  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Chaos Flares

#1
Here's a small countermeasure script I made for missiles to semi orbit around your craft.

[Image: bmmTFrG.jpg]


Note: For now you must use acbs to fire these in the same fashion as you would regular flares

Code:
--Chaos Flares by SLK18
--Settings
--Halo radius
halor = 200
--Height of halo (Real y value)
y = 90
--Radius of interception sphere
IS = 70
--Raises height every time a WP is hit
usetornado = true
--Must be larger than y (after this is hit reset back to y)
tornadocap = 170
--Default initialization
--Don't touch anything beyond this point
wp = {}
yy = y
j=1
k=2
l=3
--Distance Function
function D3(x1,y1,z1,x2,y2,z2)
   return math.sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)
end
--4 Waypoints based on quadrant math
function Update(I)
  I:ClearLogs()
  I:Log(y)
  I:Log("Y: ")
  
  for t=0,I:GetLuaTransceiverCount() do
    for m=0,I:GetLuaControlledMissileCount(t) do
      cI = I:GetConstructPosition()
      --Quadrant Grid Waypoint Positions
      --x=0, y=1, z=2, so forth
      
      wp[1] = cI.x + halor
      wp[2] = y
      wp[3] = cI.z + halor
      
      wp[4] = cI.x - halor
      wp[5] = y
      wp[6] = cI.z + halor
      
      wp[7] = cI.x - halor
      wp[8] = y
      wp[9] = cI.z - halor
  
      wp[10] = cI.x + halor
      wp[11] = y
      wp[12] = cI.z - halor
      --Handling the offset missiles
      wp[13] = cI.x + halor
      wp[14] = y
      wp[15] = cI.z + halor
      
      wp[16] = cI.x - halor
      wp[17] = y
      wp[18] = cI.z + halor
      
      
      mI = I:GetLuaControlledMissileInfo(t,m)
      mx = mI.Position.x
      my = mI.Position.y
      mz = mI.Position.z

      D = D3(wp[j],wp[k],wp[l],mx,my,mz)
      
      if D < IS then
        j = j + 3
        k = k + 3
        l = l + 3
        if usetornado then
          y = y + 10
          if y > tornadocap then
            y = yy
          end
        end
        if j > 10 then
          j = 1
          k = 2
          l = 3
        end
      end
      
      if math.fmod(m,2) == 0 then
      I:SetLuaControlledMissileAimPoint(t,m,wp[j],wp[k],wp[l])
      else
      I:SetLuaControlledMissileAimPoint(t,m,wp[j+3],wp[k+3],wp[l+3])
      end
    end
  end
end
Reply



Messages In This Thread
Chaos Flares - by SLK18 - 2017-02-16, 07:14 AM
RE: Chaos Flares - by jcacoustik - 2017-02-17, 03:31 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)