Author Topic: [DONE] more debug logging for mission scripts processing?  (Read 1482 times)

Offline psavola

  • Commander
  • *****
  • Posts: 837
    • View Profile
[DONE] more debug logging for mission scripts processing?
« on: October 22, 2023, 12:16:44 pm »
I've had several campaigns where mission scripts have had really strange RNG, like a mission with 0.33 probability not occurring for 12 months in a row even though the requirements are met (the mathematical probability for something like this being less than 1 %).

Would it be possible to include a debug log, for example before this check in GeoscapeState::determineAlienMissions()? If the debug log showed which potential missions proceeded to the RNG check, at least you might be able to rule out any bugs before that? (Looking at the RNG code it would be far more intrusive and spammy to add debugging there.)

                                // level three condition check: does random chance favour this command's execution?
                                if (triggerHappy && RNG::percent(eventScript->getExecutionOdds()))
                                {
                                        relevantEventScripts.push_back(eventScript);
                                }


Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #1 on: October 22, 2023, 12:37:51 pm »
it's possible

I didn't add it because it would make the log 10x longer (and it's already too long)

Offline psavola

  • Commander
  • *****
  • Posts: 837
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #2 on: October 22, 2023, 12:42:24 pm »
it's possible

I didn't add it because it would make the log 10x longer (and it's already too long)

Doesn't this run only once a month? If so, is this such a bad thing? And it wouldn't need to be printed except when debug is true.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #3 on: October 22, 2023, 01:41:00 pm »
yes, it runs once a month
with mods like XCF having most odds around 3%, it would be more like 30x more than just 10x more

I don't need this if it runs only when debug mode is turned on (nobody plays a campaign in debug mode)
(if you meant debug: true in options.cfg, then I also don't need that because practically everyone has it turned on)


Offline psavola

  • Commander
  • *****
  • Posts: 837
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #4 on: October 22, 2023, 02:36:45 pm »
I'm thinking of a use case where you have a suspicion that something is could be wrong, so you save just before the end of month. Then enable extra logging and wait for the end of the month, then look at the logs if you can figure out anything. After that you could continue the campaign until the next end-of-month as normal.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #5 on: October 22, 2023, 03:05:15 pm »
probably `verboseLogging` user config is what you search for, its already spam heavy logs with different details.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #6 on: October 22, 2023, 04:07:26 pm »
Added: https://github.com/MeridianOXC/OpenXcom/commit/f1777b086338195a498ce41127b33c2fdf0a66a2
Requires "verboseLogging: true" in options.cfg

"rng: 0" means false
"rng: 1" means true

Sample output:

Code: [Select]
geoscapeDebugLog:
  - "month: 3 script: shipTerror odds: 60 rng: 0"
  - "month: 3 script: recurringTerror odds: 100 rng: 1"
  - "month: 3 script: recurringTerror id: 9 type: STR_ALIEN_SURFACE_ATTACK race: STR_GILLMAN region: STR_INDIAN_OCEAN targetZone: 3 targetArea: 4"
  - "month: 3 script: recon odds: 100 rng: 1"
  - "month: 3 script: recon id: 10 type: STR_ALIEN_INTERDICTION race: STR_GILLMAN region: STR_NORTH_SEA targetZone: -1 targetArea: -1"
  - "month: 3 script: researchRetaliation odds: 100 rng: 1"
  - "month: 3 script: researchRetaliation id: 11 type: STR_ALIEN_RETALIATION race: STR_LOBSTERMAN region: STR_SOUTH_ATLANTIC targetZone: -1 targetArea: -1"

Offline psavola

  • Commander
  • *****
  • Posts: 837
    • View Profile
Re: more debug logging for mission scripts processing?
« Reply #7 on: October 22, 2023, 05:35:40 pm »
Very nice, this was more than I had hoped for.  ;D

The update was very timely. My very strange run with the cumulative probability <1% continued for another month. But at least I now I can blame the RNG with clear conscience.

  - "month: 25 script: frontierPsychiatrist odds: 33 rng: 0"
« Last Edit: October 22, 2023, 08:00:22 pm by psavola »