XCOM 2
[WOTC] Multiple Sitreps 2.0: Guaranteed & Categories
RedDobe 2020 年 5 月 3 日 下午 9:44
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--; } }

最后由 RedDobe 编辑于; 2020 年 5 月 4 日 上午 8:01
< >
正在显示第 1 - 3 条,共 3 条留言
NightNinja54  [开发者] 2020 年 5 月 4 日 下午 5:45 
You're absolutely right - good call! I'll take this into account. Thank you
最后由 NightNinja54 编辑于; 2020 年 5 月 4 日 下午 5:45
NightNinja54  [开发者] 2020 年 5 月 4 日 下午 5:55 
I just pushed an update live with your recommendations. Appreciate it :)
RedDobe 2020 年 5 月 4 日 下午 6:13 
You are welcome. Thank you.
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50