Skip to content

Scenarios: skip destroyed or missing entities in 03, 06, 07, 08, 31, 44, 50, 55, 57 - #2913

Open
dj803 wants to merge 1 commit into
daid:masterfrom
dj803:pr/scenario-destroyed-entity-guards-2
Open

dj803 wants to merge 1 commit into
daid:masterfrom
dj803:pr/scenario-destroyed-entity-guards-2

Conversation

@dj803

@dj803 dj803 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Same kind of fix as #2908. A destroyed entity loses all its methods (only isValid() still works), so a script that holds a reference and calls a method on it later raises a Lua error. GameGlobalInfo::update stops calling update() after 5 errors in a row, so the mission can freeze with no win or loss. Each hunk guards one call; nothing changes while the entity is alive.

Scenario Site Error
03_waves spawnWave friendlyList[1]:addReputationPoints after that station died; now rewards the first one still alive
06_edgeofspace ~441 kraylor_e1..4:orderRoaming() on destroyed ships
07_gftp ~262 update() kept using stakhanov after victory("Ghosts"); now returns
08_atlantis phase1 dummies setShields / setShieldsMax / isScannedBy on a destroyed dummy; a destroyed dummy counts as scanned
31_payload CheckWinCondition, DeterminePayloadTarget, HandlePayloadMovement, SafeAttackRandom method on a destroyed PayloadShip; irandom(1, 0) on an empty list
44_outpost enemyComms table.insert(enemy_reverts, ...) before the table exists
50_gaps nearStations, waves, freighter comms empty list indexed; areEnemiesInRange on a destroyed homeStation; comms_target.target:getCallSign() when the target is gone
55, 57 freighter comms same "Where are you headed?" guard (one new string, "I no longer have a destination."); 55 endStatistics checks station:isValid(); 57 friendlyFreighterComms defines the shipType local its branches use

Testing: every added line (apart from 4 comment lines) is identical to code that ran in automated headless runs of all 16 stock scenarios on a fork, with 0 Lua errors from these sites. Some guards (03, 06, 07, 50 homeStation) were never reached by a run, so those are review-by-reading only.

🤖 Generated with Claude Code

…44, 50, 55, 57

Destroyed entities lose all their methods (only isValid() works), so a
script that keeps a reference and calls a method on it later raises a Lua
error. GameGlobalInfo::update stops calling update() after 5 errors in a
row, so a mission can freeze with no win or loss. Each hunk guards one such
call; no behaviour changes while the entity is alive.

- 03_waves: reward the first friendly station still alive, not friendlyList[1]
- 06_edgeofspace: orderRoaming only on Kraylor ships that still exist
- 07_gftp: return after victory("Ghosts"); the rest of update() uses stakhanov
- 08_atlantis: target dummies may be destroyed before the scan phase ends; a
  destroyed dummy counts as scanned
- 31_payload: PayloadShip checked in CheckWinCondition, DeterminePayloadTarget,
  HandlePayloadMovement; SafeAttackRandom returns false for an empty list
  (irandom(1, 0))
- 44_outpost: enemy_reverts created before the first table.insert
- 50_gaps: nearStations with an empty list, areEnemiesInRange on a destroyed
  homeStation, "Where are you headed?" when the freighter's target is gone
- 55_defenderHunter, 57_shoreline: same "Where are you headed?" guard;
  55 endStatistics checks station:isValid(); 57 friendlyFreighterComms
  defines the local shipType its branches use

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant