XCOM 2
[WOTC] Multiple Sitreps 2.0: Guaranteed & Categories
RedDobe 3 May, 2020 @ 9:44pm
Code Feedback
NightNinja - I set the sitrep chance to 50, which should average about 1 or 2 sitreps per mission, with 0 and 3 sitreps each having the same small chance. But I have noticed a lot more 0 sitrep missions than 3 stirep missions. So I did some digging through your code, (I know I am noisy my apolgies) and found this.

if(`SYNC_RAND_STATIC(100) < default.SitRepChance){ PulledSitrep = `SYNC_RAND_STATIC(AllSitreps.length); SitRepTemplate = class'X2SitRepTemplateManager'.static.GetSitRepTemplateManager().FindSitRepTemplate(AllSitreps[PulledSitrep]); if(SitRepTemplate != none && SitRepTemplate.MeetsRequirements(MissionState)) { ActiveSitreps.AddItem(AllSitreps[PulledSitrep]); } else { i--; } }

This code is going to have less than a 50% for a sitrep to be rolled because of what you have in the else {i--}. The reason being is that if a sitrep is rolled but doesn't meet the criteria, it has to roll again. That would bring the chance to actually 25%. And if that sitrep doesn't mean the criteria it has to roll again, which really lowers the chance.

Using a preceding for loop You could simply determine the number of sitreps first and then use your for loop the way it is without rolling inside the loop. I can provide an example of what I am talking about tomorrow if needed.

At 100% chance you will never have this problem because each reset of i-- always succeeds.

Something like this will work added to the GetSitrepsGeneric.
local int NumSitReps; NumSitReps = 0; for(i=0; i<default.SitrepAmount; i++) { if(`SYNC_RAND_STATIC(100) < default.SitRepChance) { NumSitReps++; } } for(i=0; i<NumSitReps; i++) { PulledSitrep = `SYNC_RAND_STATIC(AllSitreps.length); SitRepTemplate = class'X2SitRepTemplateManager'.static.GetSitRepTemplateManager().FindSitRepTemplate(AllSitreps[PulledSitrep]); if(SitRepTemplate != none && SitRepTemplate.MeetsRequirements(MissionState)) { ActiveSitreps.AddItem(AllSitreps[PulledSitrep]); } else { i--; } }

Last edited by RedDobe; 4 May, 2020 @ 8:01am
< >
Showing 1-3 of 3 comments
NightNinja54  [developer] 4 May, 2020 @ 5:45pm 
You're absolutely right - good call! I'll take this into account. Thank you
Last edited by NightNinja54; 4 May, 2020 @ 5:45pm
NightNinja54  [developer] 4 May, 2020 @ 5:55pm 
I just pushed an update live with your recommendations. Appreciate it :)
RedDobe 4 May, 2020 @ 6:13pm 
You are welcome. Thank you.
< >
Showing 1-3 of 3 comments
Per page: 1530 50