Wingmen now generated on takeoff and destroyed on landing

This commit is contained in:
Ambroise Garel 2025-07-23 21:08:07 +02:00
parent 1f5993c87f
commit 17596987d0

View File

@ -8,22 +8,22 @@ TUM.supportWingmen = {}
do
local wingmenGroupID = nil
function TUM.supportWingmen.create()
if TUM.settings.getValue(TUM.settings.id.MULTIPLAYER) then return end -- No wingmen in multiplayer
local function createWingmen()
TUM.supportWingmen.removeAll() -- Destroy all pre-existing wingmen
TUM.log("Creating wingmen...")
local player = world:getPlayer()
if not player then return end
local count = 1 -- TODO
local playerTypeName = player:getTypeName()
local groupInfo = DCSEx.unitGroupMaker.create(
TUM.settings.getPlayerCoalition(),
Group.Category.AIRPLANE, -- TODO: or helicopter!
DCSEx.math.randomPointInCircle(DCSEx.math.vec3ToVec2(player:getPoint()), 500, 250),
{ player:getTypeName() },
{ playerTypeName, playerTypeName },
{
callsign = DCSEx.unitCallsignMaker.getNextGroupCallSign(player:getCallsign()),
silenced = true,
taskFollow = DCSEx.dcs.getObjectIDAsNumber(player:getGroup()),
unlimitedFuel = true
@ -46,4 +46,22 @@ do
wingmenGroupID = nil
end
-------------------------------------
-- Called when an event is raised
-- @param event The DCS World event
-------------------------------------
function TUM.supportWingmen.onEvent(event)
if TUM.settings.getValue(TUM.settings.id.MULTIPLAYER) then return end -- No wingmen in multiplayer
if TUM.mission.getStatus() == TUM.mission.status.NONE then return end
if not event.initiator then return end
if Object.getCategory(event.initiator) ~= Object.Category.UNIT then return end
if not event.initiator:getPlayerName() then return end
if event.id == world.event.S_EVENT_TAKEOFF then -- Create wingmen on takeoff
createWingmen()
elseif event.id == world.event.S_EVENT_LAND then
TUM.supportWingmen.removeAll() -- Remove wingmen on landing
end
end
end