Version: 1.2
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.
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
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.
| 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
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
Countingtime should be set to mission duration - 170 seconds (evaluate ~ 2 minutes before mission end).Event Capture (Kill / Takeoff / Land)
End-of-Mission Scoring Evaluation
| 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 |
| 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. |
mist.scheduleFunction) for deferred evaluationPart of the 4YA Project Overlord DCS WWII mission set.