added event handler for into game messages

This commit is contained in:
spencer-ki 2022-01-16 19:13:26 -08:00
parent 080734f5bf
commit 48f2d855a5
6 changed files with 27 additions and 3 deletions

View File

@ -47,6 +47,7 @@ trigger.action.outText("ROTOR OPS STARTED: "..RotorOps.version, 5)
env.info("ROTOR OPS STARTED: "..RotorOps.version) env.info("ROTOR OPS STARTED: "..RotorOps.version)
RotorOps.staged_units = {} --table of ground units that started in the staging zone RotorOps.staged_units = {} --table of ground units that started in the staging zone
RotorOps.eventHandler = {}
local commandDB = {} local commandDB = {}
local game_message_buffer = {} local game_message_buffer = {}
local active_zone_initial_defenders local active_zone_initial_defenders
@ -54,6 +55,7 @@ local apcs = {} --table to keep track of infantry vehicles
local low_units_message_fired = false local low_units_message_fired = false
RotorOps.gameMsgs = { RotorOps.gameMsgs = {
push = { push = {
{'ALL GROUND UNITS, PUSH TO THE ACTIVE ZONE!', 'push_next_zone.ogg'}, {'ALL GROUND UNITS, PUSH TO THE ACTIVE ZONE!', 'push_next_zone.ogg'},
@ -137,6 +139,17 @@ local sound_effects = {
["troop_dropoff"] = {'troops_unload_thanks.ogg', 'troops_unload_everybody_off.ogg', 'troops_unload_get_off.ogg', 'troops_unload_here_we_go.ogg', 'troops_unload_moving_out.ogg',}, ["troop_dropoff"] = {'troops_unload_thanks.ogg', 'troops_unload_everybody_off.ogg', 'troops_unload_get_off.ogg', 'troops_unload_here_we_go.ogg', 'troops_unload_moving_out.ogg',},
} }
function RotorOps.eventHandler:onEvent(event)
if (world.event.S_EVENT_ENGINE_STARTUP == event.id) then --play some sound files when a player starts engines
local initaitor = event.initiator:getGroup():getID()
if RotorOps.defending then
trigger.action.outSoundForGroup(initaitor , RotorOps.gameMsgs.enemy_pushing[RotorOps.active_zone_index + 1][2])
else
trigger.action.outSoundForGroup(initaitor , RotorOps.gameMsgs.push[RotorOps.active_zone_index + 1][2])
end
end
end
function RotorOps.registerCtldCallbacks(var) function RotorOps.registerCtldCallbacks(var)
@ -661,6 +674,7 @@ function RotorOps.assessUnitsInZone(var)
--debugMsg("taking stock of the active zone") --debugMsg("taking stock of the active zone")
active_zone_initial_defenders = defending_ground_units active_zone_initial_defenders = defending_ground_units
low_units_message_fired = false low_units_message_fired = false
env.info("ROTOR OPS: zone activated: "..RotorOps.active_zone)
end end
@ -751,10 +765,12 @@ function RotorOps.assessUnitsInZone(var)
if should_deploy then if should_deploy then
local function timedDeploy() local function timedDeploy()
if vehicle:isExist() then
RotorOps.deployTroops(4, vehicle:getGroup(), false) RotorOps.deployTroops(4, vehicle:getGroup(), false)
end end
end
local id = timer.scheduleFunction(timedDeploy, nil, timer.getTime() + math.random(850, 860)) local id = timer.scheduleFunction(timedDeploy, nil, timer.getTime() + math.random(90, 180))
end end
end end
@ -770,6 +786,7 @@ function RotorOps.assessUnitsInZone(var)
if not low_units_message_fired then if not low_units_message_fired then
if defenders_remaining_percent <= 40 then if defenders_remaining_percent <= 40 then
low_units_message_fired = true low_units_message_fired = true
env.info("ROTOR OPS: low units remaining in zone")
if RotorOps.defending then if RotorOps.defending then
RotorOps.gameMsg(RotorOps.gameMsgs.enemy_almost_cleared, math.random(1, #RotorOps.gameMsgs.enemy_almost_cleared)) RotorOps.gameMsg(RotorOps.gameMsgs.enemy_almost_cleared, math.random(1, #RotorOps.gameMsgs.enemy_almost_cleared))
else else
@ -873,14 +890,18 @@ function RotorOps.setActiveZone(new_index)
RotorOps.active_zone = RotorOps.zones[new_index].name RotorOps.active_zone = RotorOps.zones[new_index].name
if new_index ~= old_index then --the active zone is changing if new_index ~= old_index then --the active zone is changing
if not RotorOps.defending then if not RotorOps.defending then
if old_index > 0 then if old_index > 0 then
ctld.activatePickupZone(RotorOps.zones[old_index].name) --make the captured zone a pickup zone ctld.activatePickupZone(RotorOps.zones[old_index].name) --make the captured zone a pickup zone
end end
ctld.deactivatePickupZone(RotorOps.zones[new_index].name) ctld.deactivatePickupZone(RotorOps.zones[new_index].name)
end end
RotorOps.game_state = new_index RotorOps.game_state = new_index
trigger.action.setUserFlag(RotorOps.game_state_flag, new_index) trigger.action.setUserFlag(RotorOps.game_state_flag, new_index)
if new_index > old_index then if new_index > old_index then
if RotorOps.defending == true then if RotorOps.defending == true then
RotorOps.gameMsg(RotorOps.gameMsgs.enemy_pushing, new_index) RotorOps.gameMsg(RotorOps.gameMsgs.enemy_pushing, new_index)
@ -1014,7 +1035,6 @@ function RotorOps.startConflict()
if RotorOps.staged_units[1]:getCoalition() == 1 then --check the coalition in the staging zone to see if we're defending if RotorOps.staged_units[1]:getCoalition() == 1 then --check the coalition in the staging zone to see if we're defending
RotorOps.defending = true RotorOps.defending = true
RotorOps.gameMsg(RotorOps.gameMsgs.start_defense) RotorOps.gameMsg(RotorOps.gameMsgs.start_defense)
debugMsg(RotorOps.zones[#RotorOps.zones].name)
ctld.activatePickupZone(RotorOps.zones[#RotorOps.zones].name) --make the last zone a pickup zone for defenders ctld.activatePickupZone(RotorOps.zones[#RotorOps.zones].name) --make the last zone a pickup zone for defenders
ctld.deactivatePickupZone(RotorOps.staging_zone) ctld.deactivatePickupZone(RotorOps.staging_zone)
else else
@ -1025,7 +1045,11 @@ function RotorOps.startConflict()
RotorOps.setActiveZone(1) RotorOps.setActiveZone(1)
local id = timer.scheduleFunction(RotorOps.assessUnitsInZone, 1, timer.getTime() + 5) local id = timer.scheduleFunction(RotorOps.assessUnitsInZone, 1, timer.getTime() + 5)
world.addEventHandler(RotorOps.eventHandler)
end end

Binary file not shown.

BIN
sound/friendly_cap.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
sound/friendly_convoy.ogg Normal file

Binary file not shown.

BIN
sound/friendly_sead.ogg Normal file

Binary file not shown.