Author Topic: [DONE][Suggestion] Access to object counters within Arc/Mission/Event scripts  (Read 257 times)

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 7154
  • OXCE developer
    • View Profile
    • My Wiki
All 3 script types now have access to 3 different kinds of counters:

1. mission script `varName` counter... you can find it under `alienStrategy:` in the save file

2. global object counter... you can find it under `ids:` in the save file
- this contains the number of various generated game objects, most notably mission markers

3. custom global object counter... this is also under the same `ids:` in the save file
- this contains modder-defined counters, that can increase or decrease after mission success/failure/despawn

The `varName` can be accessed via `missionVarName`.
Global counters (both default and custom) can be accessed via `missionMarkerName`.

The counter is then compared against the limits defined via `counterMin` and `counterMax`.

IMPORTANT: please note that `ids:` in the save file hold a value of the counter plus 1. For example if the game generated 2 terror site, the save will contain `STR_TERROR_SITE: 3`.

Example for an event script (same syntax is valid for mission scripts and arc scripts):

Code: [Select]
eventScripts:
  - type: STR_TEST
...
    missionVarName: shippingLanes           # varName from mission scripts
    missionMarkerName: STR_TERROR_SITE      # marker name from alien deployment
    missionMarkerName: CUST_TERROR_SUCCESS  # custom counter name from alien deployment
    counterMin: 3
    counterMax: 3                           # -1 = infinity/unlimited
...

Please only use one of the `missionVarName` and `missionMarkerName` at a time; they share the `counterMin` and `counterMax` values.
Default for `counterMin` is 0 (zero).
Default for `counterMax` is -1 (unlimited).
« Last Edit: January 17, 2022, 01:46:59 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 7154
  • OXCE developer
    • View Profile
    • My Wiki
Custom mission counters are defined via 8 new alienDeployment attributes:
1. `counterSuccess` - increases on mission success
2. `counterFailure` - increases on mission failure and on mission site despawn (which is also a failure, duh)
3. `counterDespawn` - increases on mission site despawn
4. `counterAll` - increases on mission success, failure and despawn

5. `decreaseCounterSuccess` - decreases on mission success
6. `decreaseCounterFailure` - decreases on mission failure and on mission site despawn (which is also a failure, duh)
7. `decreaseCounterDespawn` - decreases on mission site despawn
8. `decreaseCounterAll` - decreases on mission success, failure and despawn

Example:

Code: [Select]
alienDeployments:
  - type: STR_TERROR_MISSION
...
    counterSuccess: CUSTOM_TERROR_SUCCESS
    counterFailure: CUSTOM_TERROR_FAILURE
    counterDespawn: CUSTOM_TERROR_DESPAWN
    counterAll: CUSTOM_TERROR_ALL
...

PS: note that just like the default game object counters, also these custom counters have a value in the save file increased by one... keep that in mind when testing/investigating

PS2: counters cannot decrease below zero

PS3: don't decrease non-custom counters, you'll break/crash the game
« Last Edit: January 17, 2022, 01:52:02 pm by Meridian »