Enemy CAP respawn rate now decreases the more enemy planes are shot

This commit is contained in:
Ambroise Garel 2025-09-11 12:28:10 +02:00
parent a9edd4a819
commit 64bde651c3
3 changed files with 40 additions and 3 deletions

View File

@ -80,7 +80,7 @@ Please also note that PvP is not supported at the moment and that the mission wi
- AI improvements
- [ ] AI wingmen should engage tracking radars first when told to engage SAM sites, in order to disable the site ASAP
- Balance improvements
- [ ] Lowered enemy CAP respawn rate
- [x] Enemy CAP respawn rate now decreases the more enemy planes are shot
- [ ] Tweaked XP requirements for medals/promotions
- Bug fixes
- [ ] AWACS datalinked contacts not showing on SA pages

View File

@ -116,6 +116,8 @@ function TUM.initialize()
if not event then return end -- No event
TUM.ambientRadio.onEvent(event) -- Must be first so other (more important) radio messages will interrupt the "ambient" ones
TUM.airForce.onEvent(event)
TUM.ambientWorld.onEvent(event)
TUM.ambientWorld.onEvent(event)
TUM.objectives.onEvent(event)
TUM.playerScore.onEvent(event)

View File

@ -6,9 +6,13 @@
TUM.airForce = {}
do
local SUPPRESSION_INCREASE_ON_KILL = 0.35 -- Value added to enemyCAPSuppression each time an enemy aircraft is shot down
local desiredUnitCount = { 4, 4 } -- Desired max number of aircraft in the air at any single time
local fighterGroups = { {}, {} }
local enemyCAPSuppression = 1
local enemyCAPSuppressionTimer = 1
local playerCenter = nil
local function getSkillLevel(side)
@ -65,7 +69,7 @@ do
local function launchNewAircraftGroup(side, airbases)
local groupSize = DCSEx.table.getRandom({ 1, 2, 2, 2, 2, 3, 3, 4 })
groupSize = math.min(groupSize, desiredUnitCount[side] - getAirborneUnitCount(side))
if groupSize <= 0 then return false end
if groupSize <= 0 then return false end -- No aircraft slots left
local faction = TUM.settings.getEnemyFaction()
if side == TUM.settings.getPlayerCoalition() then faction = TUM.settings.getPlayerFaction() end
@ -73,6 +77,17 @@ do
local units = Library.factions.getUnits(faction, DCSEx.enums.unitFamily.PLANE_FIGHTER, groupSize, true)
if not units or #units == 0 then return false end -- No aircraft found
-- If enemy CAP suppression timer > 0, decrement it by 1 but don't spawn any aircraft
if side == TUM.settings.getEnemyCoalition() then
enemyCAPSuppressionTimer = enemyCAPSuppressionTimer - 1
if enemyCAPSuppressionTimer > 0 then
TUM.log("Enemy CAP is still suppressed (suppression="..tostring(enemyCAPSuppressionTimer).."), no enemy CAP spawned.")
return false
end
enemyCAPSuppressionTimer = enemyCAPSuppression
end
local launchAirbase = airbases[DCSEx.math.clamp(math.random(1, math.ceil(math.sqrt(#airbases))), 1, #airbases)]
local originPt = DCSEx.math.vec3ToVec2(launchAirbase:getPoint())
@ -150,7 +165,6 @@ do
randomizeDesiredAircraftCount(side)
end
-- return launchNewAircraftGroup(side, airbases)
return launchNewAircraftGroup(side, validAirbases)
end
end
@ -170,6 +184,23 @@ do
return updateAirForce(side)
end
-------------------------------------
-- Called when an event is raised
-- @param event The DCS World event
-------------------------------------
function TUM.airForce.onEvent(event)
if not event.initiator then return end
if Object.getCategory(event.initiator) ~= Object.Category.UNIT then return end
if event.id ~= world.event.S_EVENT_UNIT_LOST then return end
local groupID = DCSEx.dcs.getGroupIDAsNumber(event.initiator:getGroup())
if DCSEx.table.contains(fighterGroups[TUM.settings.getEnemyCoalition()], groupID) then
enemyCAPSuppression = enemyCAPSuppression + SUPPRESSION_INCREASE_ON_KILL
TUM.log("Enemy CAP suppression increased to "..tostring(enemyCAPSuppression))
end
end
function TUM.airForce.create()
TUM.airForce.removeAll()
TUM.log("Creating friendly and enemy air forces...")
@ -190,6 +221,10 @@ do
end
end
-- Reset enemy CAP suppression
enemyCAPSuppression = 1
enemyCAPSuppressionTimer = 1
fighterGroups = { {}, {} }
end