Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Stagger Fire Turret Controller
- -- Use Local Weapon Controllers as usual for targeting, but set their Max_Firerate to 0
- -- SET THESE FOR USE
- turret_ID = {1, 2, 3} -- 1 for first turret placed, 2 for second, etc...
- interval = 0.250 -- in seconds; use multiples of 0.025s since 1 physics frame = 0.025s
- mainframe_index = 0 -- 0 for first mainframe placed, 1 for second, etc...
- -- DON'T CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
- -- initialize global variables
- next_weapon = 0
- weapon_count = 0
- last_fired_time = 0
- initialize = true
- weapon_ID = {}
- function Update(I)
- if (initialize == true) then
- for i= 1,#turret_ID do
- local_weapon_count = I:GetWeaponCountOnSubConstruct(turret_ID[i])
- for w = 0,local_weapon_count do
- if (I:GetWeaponInfoOnSubConstruct(turret_ID[i], w)['Valid'] == true) then
- if (I:GetWeaponInfoOnSubConstruct(turret_ID[i], w)['WeaponType'] == 0) then
- weapon_ID[weapon_count] = {turret_ID[i], w}
- weapon_count = weapon_count + 1
- end
- end
- end
- end
- initialize = false
- end
- if (I:GetAIFiringMode(mainframe_index) == 'On') then
- if (I:GetNumberOfTargets(mainframe_index) > 0) then
- if (I:GetGameTime() - last_fired_time >= interval) then
- if (I:FireWeaponOnSubConstruct(weapon_ID[next_weapon][1],weapon_ID[next_weapon][2],0)) then
- last_fired_time = I:GetGameTime()
- next_weapon = (next_weapon + 1) % weapon_count
- else
- for i=0,#weapon_ID do
- if (I:FireWeaponOnSubConstruct(weapon_ID[i][1],weapon_ID[i][2],0)) then
- last_fired_time = I:GetGameTime()
- break
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement