Advertisement
Guest User

FTD Stagger Fire For Turrets

a guest
Feb 26th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. -- Stagger Fire Turret Controller
  2. -- Use Local Weapon Controllers as usual for targeting, but set their Max_Firerate to 0
  3.  
  4. -- SET THESE FOR USE
  5. turret_ID = 1       -- 1 for first turret placed, 2 for second, etc...
  6. interval = 0.250    -- in seconds; use multiples of 0.025s since 1 physics frame = 0.025s
  7. mainframe_index = 0 -- 0 for first mainframe placed, 1 for second, etc...
  8.  
  9. -- DON'T CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
  10. -- initialize global variables
  11. next_weapon = 0
  12. weapon_count = 0
  13. last_fired_time = 0
  14.  
  15. function Update(I)
  16.   if (I:GetAIFiringMode(mainframe_index) == 'On') then
  17.     weapon_count = I:GetWeaponCountOnSubConstruct(turret_ID)
  18.     if (I:GetNumberOfTargets(mainframe_index) > 0) then
  19.       if (I:GetGameTime() - last_fired_time >= interval) then
  20.         if (I:FireWeaponOnSubConstruct(turret_ID,next_weapon,0)) then
  21.           last_fired_time = I:GetGameTime()
  22.           next_weapon = (next_weapon + 1) % weapon_count
  23.         end
  24.       end
  25.     end
  26.   end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement