Kills / RTB Points Script

Version: 1.2

Overview

Kills_RTB_points.lua is a DCS World mission-end efficiency scoring script for the 4YA Project Overlord WWII campaign.

Instead of raw kill counts, it awards bonus victory points based on the kill-to-sortie ratio. A side that scores kills while safely recovering most of its pilots will earn a higher ratio than a side that loses pilots in the process.

The script runs once, a configurable number of seconds before mission end, compares Axis vs Allies ratios, and writes bonus points back to two DCS trigger flags.


How It Works

1. Event Tracking (entire mission)

A world.addEventHandler listens for these events:

Event ID DCS Event What is tracked
28 Kill Player (human) kills an airborne unit.
3 Takeoff Player (human) takes off.
4 Land Player (human) lands at an airfield.

Only human players are counted — the script guards on getPlayerName() ~= nil.

Counters maintained:

KillsAxis      -- total airborne kills by Axis players
KillsAllies    -- total airborne kills by Allied players
TakeoffAxis    -- Axis player takeoffs
TakeoffAllies  -- Allied player takeoffs
LandedAxis     -- Axis player landings
LandedAllies   -- Allied player landings

2. Scoring Formula (single evaluation)

At timer.getTime() + Countingtime the script evaluates once:

local axis_sorties   = TakeoffAxis   / math.max(LandedAxis, 1)
local allies_sorties = TakeoffAllies / math.max(LandedAllies, 1)
AxisKillPoints   = KillsAxis   / axis_sorties
AlliesKillPoints = KillsAllies / allies_sorties

-- prevent divide-by-zero when neither side has points
if AxisKillPoints == 0 and AlliesKillPoints == 0 then
  KillPointsRatio = 1
else
  KillPointsRatio = AxisKillPoints / AlliesKillPoints
end

A higher ratio means Axis performed better per sortie; lower means Allies performed better.

3. Point Awards

Axis Ratio Axis Bonus Allied Bonus
>= 2.0 +15
>= 1.5 +7
<= 0.667 … > 0.5 +7
<= 0.5 +15

These points are added to the current trigger flag values and written back: - AxisPointsFlag = 21 - AlliesPointsFlag = 11

4. Configuration Tunables

Edit the top of the script before embedding in a mission:

local Countingtime = 16030  -- seconds after mission start to evaluate
local AxisPointsFlag = 21   -- DCS trigger flag for Axis total points
local AlliesPointsFlag = 11 -- DCS trigger flag for Allied total points

Logic Flow Diagrams

Event Capture (Kill / Takeoff / Land)

DCS Event Firesid = 3, 4, or 28Is initiator a player?getPlayerName() ~= nilIgnore eventEvent type?Is target airborne?TargetCategory == 1LandedAxis += 1Ignore landingLandedAllies += 1Ignore landing NoYesKill 28YesNoYesNo

Event Capture (Kill / Takeoff / Land)

End-of-Mission Scoring Evaluation

Timer expiresCountingtime reachedRead current points from trigger flagsaxis_sorties = TakeoffAxis / max(LandedAxis,1)allies_sorties = TakeoffAllies / max(LandedAllies,1)AxisKillPoints = KillsAxis / axis_sortiesAlliesKillPoints = KillsAllies / allies_sortiesBoth efficiencies are zero?KillPointsRatio = 1KillPointsRatio = AxisKillPoints / AlliesKillPointsBroadcast kills, efficiency, and ratioEvaluate ratio tiersAxisPoints += 15AxisPoints += 7AlliesPoints += 7AlliesPoints += 15No bonus — inert gapWrite updated points back to trigger flags YesNo= 2.0= 1.5= 0.667 0.5= 0.50.667 ratio 1.5

End-of-Mission Scoring Evaluation


Known Limitations

Issue Description Status
Landing at enemy airfields counted ~~The script verified event.place ~= nil but did not check the base coalition.~~ Fixed in v1.2 — now calls event.place:getCoalition() and only counts safe RTB when landing on a friendly or neutral airfield. Fixed v1.2
Division-by-zero edge case ~~If LandedAxis or LandedAllies remained at its init value of 1 while takeoffs happened, the ratio calculation could divide by zero.~~ Fixed in v1.2 — uses math.max(Landed, 1) to guard the denominator, plus explicit dual-zero handling for the final ratio. Fixed v1.2
Inert period gap (design intent) If the ratio falls between 0.667 and 1.5 (e.g. 1.0, 1.2), no bonus points are awarded to either side. This is intentional — neither side demonstrated decisive efficiency superiority. The script now explicitly sets both point totals unchanged in this range. By design

Changelog

Version Change
1.0 Initial release
1.1 Fixed string.format calls missing %s placeholder in error handlers (lines 88, 121)
1.2 Fixed landing at enemy airfields counting as safe RTB; added event.place:getCoalition() check. Fixed division-by-zero in scoring formula using math.max(Landed, 1) and added explicit else branch for inert gap (ratio 0.667–1.5). Added sortie efficiency and ratio to broadcast text.
1.3 Added event.target nil guard in kill handler to prevent crashes when target is destroyed before event fires.

Dependencies


Part of the 4YA Project Overlord DCS WWII mission set.