Advertisement
SaucyPanda

Chaos Flares

Feb 16th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. --Chaos Flares by SLK18
  2. --Settings
  3. --Halo radius
  4. halor = 200
  5. --Height of halo (Real y value)
  6. y = 90
  7. --Radius of interception sphere
  8. IS = 70
  9. --Raises height every time a WP is hit
  10. usetornado = true
  11. --Must be larger than y (after this is hit reset back to y)
  12. tornadocap = 170
  13. --Default initialization
  14. --Don't touch anything beyond this point
  15. wp = {}
  16. yy = y
  17. j=1
  18. k=2
  19. l=3
  20. --Distance Function
  21. function D3(x1,y1,z1,x2,y2,z2)
  22.    return math.sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)
  23. end
  24. --4 Waypoints based on quadrant math
  25. function Update(I)
  26.   I:ClearLogs()
  27.   I:Log(y)
  28.   I:Log("Y: ")
  29.  
  30.   for t=0,I:GetLuaTransceiverCount() do
  31.     for m=0,I:GetLuaControlledMissileCount(t) do
  32.       cI = I:GetConstructPosition()
  33.       --Quadrant Grid Waypoint Positions
  34.       --x=0, y=1, z=2, so forth
  35.      
  36.       wp[1] = cI.x + halor
  37.       wp[2] = y
  38.       wp[3] = cI.z + halor
  39.      
  40.       wp[4] = cI.x - halor
  41.       wp[5] = y
  42.       wp[6] = cI.z + halor
  43.      
  44.       wp[7] = cI.x - halor
  45.       wp[8] = y
  46.       wp[9] = cI.z - halor
  47.  
  48.       wp[10] = cI.x + halor
  49.       wp[11] = y
  50.       wp[12] = cI.z - halor
  51.       --Handling the offset missiles
  52.       wp[13] = cI.x + halor
  53.       wp[14] = y
  54.       wp[15] = cI.z + halor
  55.      
  56.       wp[16] = cI.x - halor
  57.       wp[17] = y
  58.       wp[18] = cI.z + halor
  59.      
  60.      
  61.       mI = I:GetLuaControlledMissileInfo(t,m)
  62.       mx = mI.Position.x
  63.       my = mI.Position.y
  64.       mz = mI.Position.z
  65.  
  66.       D = D3(wp[j],wp[k],wp[l],mx,my,mz)
  67.      
  68.       if D < IS then
  69.         j = j + 3
  70.         k = k + 3
  71.         l = l + 3
  72.         if usetornado then
  73.           y = y + 10
  74.           if y > tornadocap then
  75.             y = yy
  76.           end
  77.         end
  78.         if j > 10 then
  79.           j = 1
  80.           k = 2
  81.           l = 3
  82.         end
  83.       end
  84.      
  85.       if math.fmod(m,2) == 0 then
  86.       I:SetLuaControlledMissileAimPoint(t,m,wp[j],wp[k],wp[l])
  87.       else
  88.       I:SetLuaControlledMissileAimPoint(t,m,wp[j+3],wp[k+3],wp[l+3])
  89.       end
  90.     end
  91.   end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement