aliens

Author Topic: [Suggestion] When game fails to create alien mission, it should be logged in geoscapeDebugLog  (Read 780 times)

Offline zRrr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Currently, GeoscapeState::processCommand can silently fail to create alien mission, usually because all possible regions already have mission of this type running. This can be a bit surprising, and low number of missions may be blamed on rng instead of mission configuration, so I propose to add a log entry to geoscapeDebugLog when this happens, to make issue more visible.

Alternatively such events can be observed with new script rng logging feature, but it is harder to search for. For example:

Code: (example from Piratez) [Select]
  - "month: 2 script: milconvoysEarly odds: 50 rng: 1"
  - "month: 2 script: milconvoysEarly id: 24 type: STR_MISSION_MILCONVOY race: STR_RAIDER region: REGION_WORLD_MILCONVOY targetZone: -1 targetArea: -1"
  - "month: 2 script: rogueCourierVeryEarly odds: 100 rng: 1"
  - "month: 2 script: rogueCourierVeryEarly id: 25 type: STR_MISSION_ROGUE_COURIER race: STR_BANDIT_ROBBERS region: STR_NORTH_AFRICA targetZone: -1 targetArea: -1"
  - "month: 2 script: rogueCourierEarly odds: 50 rng: 1"
# script has targetBaseOdds: 100, and player has only one base, so another STR_MISSION_ROGUE_COURIER is not created
# error log entry here would be nice
  - "month: 2 script: giftsOfBlood odds: 100 rng: 1"


Code: (from X-com Files) [Select]
  - "month: 1 script: CultApprehensionDagon odds: 20 rng: 0"
  - "month: 1 script: CultApprehensionEXALT odds: 20 rng: 1"
  - "month: 1 script: CultApprehensionEXALT id: 5 type: STR_CULT_APPREHENSION_EXALT race: STR_EXALT region: STR_SOUTH_AMERICA targetZone: 3 targetArea: 22"
...
  - "month: 1 script: CultApprehensionEXALT1 odds: 20 rng: 0"
...
  - "month: 1 script: CultApprehensionEXALT5 odds: 20 rng: 1"
  - "month: 1 script: CultApprehensionEXALT5 id: 12 type: STR_CULT_APPREHENSION_EXALT race: STR_EXALT region: STR_NORTH_AMERICA targetZone: 3 targetArea: 31"
...
  - "month: 1 script: CultApprehensionEXALT7 odds: 20 rng: 1"
# This could be 3rd STR_CULT_APPREHENSION_EXALT mission for new month, but both NA and SA already have one, so processCommand fails silently
# again, some log message could be useful
  - "month: 1 script: CultApprehensionZSRR7 odds: 20 rng: 0"
...

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8679
    • View Profile
Sorry, no, it is not my intention to bloat the save file with every imaginable log entry anyone can come up with.

Also, in your example, what you call "silent fail" and "issue" is for me "intended behavior" and "feature".

Offline Juku121

  • Commander
  • *****
  • Posts: 1660
  • We're all mad here.
    • View Profile
Where is this feature documented? Are major modders aware of this?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8679
    • View Profile
Where is this feature documented?

I don't know if basic OG features are documented anywhere, try Ufopedia.
If not, there's always OXC source code.

Are major modders aware of this?

I don't know if all major modders are aware of how OG/OXC works.

Offline Juku121

  • Commander
  • *****
  • Posts: 1660
  • We're all mad here.
    • View Profile
Okay, it's kinda described here.

The problem with that is that this is the old, table-based mission generation and e.g. these CultApprehensionEXALT missions have 'useTable: false', which would lead one to guess that this limitation would no longer apply. But apparently it does.

So, this is very poorly documented at best, and expecting modders to code dive for something that can have a major impact on script-based mission generation is... not a terribly productive idea.

Am I understanding this right that since e.g. CultApprehensionLotus has four regions defined, any time the game tries to generate the mission, it tries to pick one of the four that hasn't been used yet, everything beyond that gets ignored, and thus you'll ever get a maximum of four such missions per month, spread across all four regions? And the actual region distribution pretty much only determines the region-vs-time order of those missions if there are four of them?

If so, that's a major facet of script-based (as opposed to table-based) mission generation and very much needs at least a mention in the ruleset reference.
« Last Edit: November 26, 2023, 06:23:42 pm by Juku121 »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8679
    • View Profile
I cannot confirm or disprove what you said, I don't know all the details.
I would have to test, just like everyone else.

What I can confirm is that missions are skipped for several different reasons during mission generation and all of them are intentional.
Xcom doesn't inform anybody of skipped missions, be it for whatever reason, period.

If you think the documentation is poor, you're welcome to improve it.
And no, I don't expect modders, or anybody else, to code-dive, or save the world, or do anything.
I'm not anybody's babysitter, not anybody's slave, and not anybody's whipping-boy... so stop throwing this shit into my face.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8679
    • View Profile
Am I understanding this right that since e.g. CultApprehensionLotus has four regions defined, any time the game tries to generate the mission, it tries to pick one of the four that hasn't been used yet, everything beyond that gets ignored, and thus you'll ever get a maximum of four such missions per month, spread across all four regions? And the actual region distribution pretty much only determines the region-vs-time order of those missions if there are four of them?

I have done a small test, and can happily disprove this.
The game is able to generate two missions in the same region defined by the script without a problem.

For example:

Code: [Select]
missionScripts:
  - type: gameStart
    missionWeights:
      0:
        STR_ALIEN_RESEARCH: 100
    regionWeights:
      0:
        STR_EUROPE: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false

  - type: gameStart2
    missionWeights:
      0:
        STR_ALIEN_RESEARCH: 100
    regionWeights:
      0:
        STR_EUROPE: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false

Result:

Code: [Select]
alienMissions:
  - type: STR_ALIEN_RESEARCH
    region: STR_EUROPE
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 9390
    liveUfos: 0
    uniqueID: 1
    missionSiteZone: -1
  - type: STR_ALIEN_RESEARCH
    region: STR_EUROPE
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 5940
    liveUfos: 0
    uniqueID: 2
    missionSiteZone: -1
« Last Edit: November 26, 2023, 07:08:23 pm by Meridian »

Offline Juku121

  • Commander
  • *****
  • Posts: 1660
  • We're all mad here.
    • View Profile
I am not saying this is your fault, or you owe anybody anything. Sorry if I came across like that. :-[


I'm happy to hear that my understanding was wrong! But what might have prevented the original CultApprehensionEXALT7 script from running, then, if it was not "SA and NA are both full", as zRrr said?



Edit: I mean, if it's some occasional confluence of circumstances that's not really relevant for a modder, I don't really need to know, but if I can accidentally prevent missions from popping because of something easily overlooked, I'd rather be aware.
« Last Edit: November 26, 2023, 07:47:52 pm by Juku121 »

Offline zRrr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
But what might have prevented the original CultApprehensionEXALT7 script from running, then, if it was not "SA and NA are both full", as zRrr said?

This is because STR_CULT_APPREHENSION_EXALT is objective: 3 (mission site) type mission. Feature is in the game to prevent multiple terror missions or retaliations from hitting region or base that already has this kind of mission going. Works fine in basic game, since it has only one terror mission per month and whole globe to play with. I guess it can also be used to limit number of missions or to make mission that appears every other month, idk if anyone does that.

It's not a big deal in XCF either. Worst case, Arrest the suspects (Exalt), has 8 scripts with 20% chance and 2 available regions, and will hit the ceiling 20% of times, which is comparable to 17% chance it wont spawn at all in this month. For next stage (safehouses, 8 scripts with 8% chance), chance to roll 3 or more missions drops to 2% compared to 51% of not spawning anything.

Offline Juku121

  • Commander
  • *****
  • Posts: 1660
  • We're all mad here.
    • View Profile
Okay, so it is as I feared, but only for (fake or not) terror missions and base retaliations? Are the other special mission objectives (1,2,5,6) 'safe'?


While XCF and its multitude of low-chance missions does not really suffer too much (might even be an improvement, given the mission slog in there), it still very much flies in the face of mission scripts supposedly being free from table-based limits or similar effects. It definitely sabotages CultActivityEXALT8 a bit. And if someone were to try to script in a "the world explodes with cultist activity until they're killed off" or something like that, well, sadly not possible due to this (without somehow finding out that you need to add a bunch more regions).

In this case, the ruleset reference needs at least a Guidelines/Tips addition, something like "Missions with objective: 3 (mission site/terror) or objective: 4 (retaliation) can only happen once per month for each assigned region (regionWeights or all eligible regions if none are specified) regardless of how many times mission scripts call for them." Who is writing/overseeing it these days? (I am not particularly fond of getting another account just for this.)
« Last Edit: November 27, 2023, 02:27:36 pm by Juku121 »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8679
    • View Profile
Less "fearing", more "testing" please...

I just tried for example retaliation:

Code: [Select]
missionScripts:
  - type: gameStart
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    regionWeights:
      0:
        STR_EUROPE: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false

  - type: gameStart2
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    regionWeights:
      0:
        STR_EUROPE: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false

Result: both identical missions were generated

Code: [Select]
alienMissions:
  - type: STR_ALIEN_RETALIATION
    region: STR_EUROPE
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 1620
    liveUfos: 0
    uniqueID: 1
    missionSiteZone: -1
  - type: STR_ALIEN_RETALIATION
    region: STR_EUROPE
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 3330
    liveUfos: 0
    uniqueID: 2
    missionSiteZone: -1

Offline Juku121

  • Commander
  • *****
  • Posts: 1660
  • We're all mad here.
    • View Profile
All right, some testing:

Spoiler" Tests":
Code: [Select]
missionScripts:
  - type: gameStart
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    targetBaseOdds: 100
    useTable: false

  - type: gameStart2
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    targetBaseOdds: 100
    useTable: false

  - type: gameStart3
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    targetBaseOdds: 100
    useTable: false

  - type: gameStart4
    missionWeights:
      0:
        STR_ALIEN_RETALIATION: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    targetBaseOdds: 100
    useTable: false
   
  - type: recurringTerror
    missionWeights:
      0:
        STR_ALIEN_TERROR: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false
    targetBaseOdds: 0

  - type: recurringTerror2
    missionWeights:
      0:
        STR_ALIEN_TERROR: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false
    targetBaseOdds: 0

  - type: recurringTerror3
    missionWeights:
      0:
        STR_ALIEN_TERROR: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false
    targetBaseOdds: 0

  - type: recurringTerror4
    missionWeights:
      0:
        STR_ALIEN_TERROR: 100
    regionWeights:
      0:
        STR_EUROPE: 100
        STR_NORTH_AMERICA: 100
    raceWeights:
      0:
        STR_SECTOID: 100
    useTable: false
    targetBaseOdds: 0

Code: [Select]
alienMissions:
  - type: STR_ALIEN_RETALIATION
    region: STR_NORTH_AFRICA   <-------------------- MY BASE WAS IN NORTH AFRICA.
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 120
    liveUfos: 0
    uniqueID: 1
    missionSiteZone: -1
  - type: STR_ALIEN_TERROR
    region: STR_EUROPE
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 150
    liveUfos: 0
    uniqueID: 2
    missionSiteZone: 6
  - type: STR_ALIEN_TERROR
    region: STR_NORTH_AMERICA
    race: STR_SECTOID
    nextWave: 0
    nextUfoCounter: 0
    spawnCountdown: 10590
    liveUfos: 0
    uniqueID: 3
    missionSiteZone: 8
This seems to be the worst of it, though. Removing 'targetBaseOdds: 100' puts non-terror missions (everything but objective=3) back on the table, and terror is the one type that really has this issue. Objectives 0-2 and 4-6 seem to all work the same as far as this goes.

All in all, not as bad as I thought, but since fake terror missions are excessively popular these days, still worse than one would assume without checking. So, "Missions with objective: 3 (mission site/terror) can only happen once per month for each assigned region (regionWeights or all eligible regions if none are specified) regardless of how many times mission scripts call for them. Missions that apply targetBaseOdds can only target a specific base once each month and fail otherwise."?
« Last Edit: November 27, 2023, 03:44:41 pm by Juku121 »