API ReferenceGE Extensionsscenario
Damage Goal
A scenario goal that monitors vehicle damage and triggers win or fail when damage exceeds a configurable limit. Supports threshold-based progress notifications.
A scenario goal that monitors vehicle damage and triggers win or fail when damage exceeds a configurable limit. Supports threshold-based progress notifications.
Internal State
| Field | Type | Description |
|---|---|---|
M.instances | varies | Assigned as {} |
Public API
| Function | Signature | Description |
|---|---|---|
M.init | (scenario) | Parses and validates damage goals from scenario JSON |
M.processState | (scenario, state, stateData) | Checks damage each tick; triggers win/fail at limit |
M.updateFinalStatus | (scenario, instance) | Reports final goal status to statistics system |
Goal JSON Schema
{
"goal": {
"damage": {
"damageLimit": 1000,
"damageThreshold": 100,
"purpose": "fail",
"msg": "scenarios.myScenario.damageFail"
}
}
}| Field | Type | Default | Description |
|---|---|---|---|
damageLimit | number | required | Damage value that triggers the goal |
damageThreshold | number | optional | Increment for progress flash messages |
purpose | string | "fail" | "fail" or "win" - what happens at limit |
msg | localizedString | auto | Custom message on trigger |
How It Works
initfilters scenario goals forid == "damage", validates types, defaultspurposeto"fail"- Each
onRaceTick, readsfobjData.damagefrom the map object tracker - If damage exceeds
damageLimit, callsshowMsgwhich:- Sets result to
"failed"or"passed"based onpurpose - Calls
scenario_scenarios.finish()with appropriate message
- Sets result to
- If
damageThresholdis set, shows progress flash messages at each threshold increment - Tracks
lastProgressto avoid duplicate notifications
Usage Examples
-- In scenario JSON: fail if damage exceeds 500
{
"vehicles": {
"scenario_player0": {
"goal": {
"damage": {
"damageLimit": 500,
"purpose": "fail"
}
}
}
}
}
-- With progress notifications every 20% of limit
{
"damage": {
"damageLimit": 1000,
"damageThreshold": 200,
"purpose": "fail"
}
}Key Notes
- Uses
map.objects[map.objectNames[vehicleName]]for damage tracking - If the map object is missing, re-tracks the vehicle via
helper.trackVehicle - The
damageThresholdshows flash messages like "50% damaged" at each increment purpose: "win"is useful for demolition-style scenarios where taking damage is the objective
See Also
- Scenario Bus Driver - Bus Route Scenario Logic - Related reference
- Scenario Demolition Derby - Last Vehicle Moving Wins - Related reference
- Scenario Distance Goal - Distance-Based Win/Fail Condition - Related reference
- Scenario System Guide - Guide