convoy_assaulter object

This commit is contained in:
spencershepard 2024-02-10 19:03:17 -08:00 committed by Spencer Shepard
parent 1d99f0f032
commit 2ab00504dc
2 changed files with 467 additions and 444 deletions

View File

@ -1,5 +1,5 @@
RotorOps = {}
RotorOps.version = "1.4.1"
RotorOps.version = "1.4.2"
local debug = false
@ -115,6 +115,7 @@ local zone_defenders_flags = {
local clear_text_index = 0
RotorOps.farp_names = {}
RotorOps.convoy_suppressor = nil
RotorOps.convoy_assaulter = nil
RotorOps.convoy_status = "none"
@ -343,6 +344,11 @@ function RotorOps.eventHandler:onEvent(event)
if event.initiator:hasAttribute("Tanks") then
env.info("ROTOROPS: convoy unit killed by armor. Should suppress convoy")
RotorOps.convoy_suppressor = event.initiator
else
env.info("ROTOROPS: convoy unit killed by non-armor.")
RotorOps.convoy_assaulter = event.initiator
--set a timer to nullify the convoy assaulter; in case it was a passing attack
timer.scheduleFunction(function() RotorOps.convoy_assaulter = nil end, nil, timer.getTime() + 300)
end
end
end
@ -1127,23 +1133,31 @@ function RotorOps.assessUnitsInZone(var)
RotorOps.ai_attacking_vehicle_groups = RotorOps.groupsFromUnits(attacking_vehicles)
local halt_convoy = false
RotorOps.convoy_status = "enroute"
local convoy_status = "enroute"
if #attacking_ground_units > 0 and not RotorOps.defending and RotorOps.halt_convoy_without_airsupport then
if RotorOps.convoy_suppressor then
if RotorOps.convoy_suppressor:isExist() then
halt_convoy = true
RotorOps.convoy_status = "suppressed"
convoy_status = "suppressed"
else
RotorOps.convoy_suppressor = nil
end
elseif not RotorOps.predAirSupportNearActive() then
RotorOps.convoy_status = "waiting_for_escort"
convoy_status = "waiting_for_escort"
halt_convoy = true
end
end
if RotorOps.convoy_assaulter then
if RotorOps.convoy_assaulter:isExist() then
convoy_status = "under_attack"
else
RotorOps.convoy_assaulter = nil
end
end
for index, group in pairs(RotorOps.ai_defending_infantry_groups) do
if group and not isStaticGroup(group) then
RotorOps.aiTask(group, "patrol")
@ -1156,7 +1170,7 @@ function RotorOps.assessUnitsInZone(var)
RotorOps.aiTask(group, "guard")
else
RotorOps.aiTask(group, "clear_zone", RotorOps.active_zone)
RotorOps.convoy_status = "clearing_zone"
convoy_status = "clearing_zone"
end
end
end
@ -1167,7 +1181,7 @@ function RotorOps.assessUnitsInZone(var)
RotorOps.aiTask(group, "guard")
else
RotorOps.aiTask(group, "clear_zone", RotorOps.active_zone)
RotorOps.convoy_status = "clearing_zone"
convoy_status = "clearing_zone"
end
end
end
@ -1269,6 +1283,10 @@ function RotorOps.assessUnitsInZone(var)
trigger.action.setUserFlag(RotorOps.staged_units_flag, percent_staged_remain)
trigger.action.setUserFlag('ROPS_ATTACKERS', percent_staged_remain)
if #staged_units_remaining == 0 then
convoy_status = "destroyed"
end
--is the game finished?
if all_zones_clear then
@ -1379,6 +1397,8 @@ function RotorOps.assessUnitsInZone(var)
end
end
--Update the convoy status
RotorOps.convoy_status = convoy_status
--zone status display
@ -1402,9 +1422,12 @@ function RotorOps.assessUnitsInZone(var)
body = "Convoy enroute to " .. RotorOps.active_zone
elseif RotorOps.convoy_status == "suppressed" then
local supressor_type = RotorOps.convoy_suppressor:getTypeName() or "enemy units"
body = "Convoy pinned down by "..supressor_type.."!"
local grid = mist.tostringMGRS(coord.LLtoMGRS(coord.LOtoLL(RotorOps.convoy_suppressor:getPosition().p)), 4) or "unknown location"
body = "Convoy pinned down by "..supressor_type.." at "..grid
elseif RotorOps.convoy_status == "under_attack" then
body = "Convoy under attack!"
end
if #staged_units_remaining == 0 then
if RotorOps.convoy_status == "destroyed" then
body = "Convoy has been destroyed."
end
end

View File

@ -15,7 +15,7 @@
RotorOpsPerks = {}
RotorOpsPerks.version = "1.5.3"
RotorOpsPerks.version = "1.5.4"
env.warning('ROTOROPS PERKS STARTED: '..RotorOpsPerks.version)
trigger.action.outText('ROTOROPS PERKS STARTED: '..RotorOpsPerks.version, 10)
RotorOpsPerks.perks = {}
@ -1124,7 +1124,7 @@ function handle:onEvent(e)
env.warning('KILL: initiator is not a unit')
return
end
if e.initiator:getCoalition() and e.initiator:getCoalition() ~= e.target:getCoalition() then
if e.initiator:getCoalition() and e.target:getCoalition() and e.initiator:getCoalition() ~= e.target:getCoalition() then
debugMsg('KILL: initiator groupname: ' .. e.initiator:getGroup():getName())
local initiator_group_name = e.initiator:getGroup():getName()