hairlessorphan Posted February 15, 2016 Share Posted February 15, 2016 (edited) Has anyone figured out what these two functions are trying to do, specifically with the local array SoldierClassDeck? They're in XComGameState_HeadquartersXCom and XComGameState_HeadquartersResistance. It looks like they're used to randomly determine the classes of soldiers, with a (seemingly ridiculous algorithm that attempts a) slight bias towards classes you're short on. But there must be some kind of hidden side-effect going on wrt SoldierClassDeck, because SelectNextSoldierClass() calls this BuildSoldierClassDeck() function every three lines. And all that function does is populate SoldierClassDeck with a random set of classes. What is the SoldierClassDeck's secret job, and why does it need to be reset with new random picks every three lines? And why does this bias algorithm work like this? And, especially, what the Hell is the SelectNextSoldierClass with the ForcedClass param trying to do, and why doesn't it just fukn validate the forced class and then select it? Why does it have to reset the SoldierClassDeck every three lines? // If not in the class deck rebuild the class deck if(SoldierClassDeck.Find(ForcedClass) == INDEX_NONE) { BuildSoldierClassDeck(); } Like, why? So it wasn't in there before, it probably won't be in there after, and it definitely won't be in there 20 lines later when you call: SoldierClassDeck.Remove(SoldierClassDeck.Find(RetName), 1); I swear to God, some of this scripting just makes me mad. It's like a measured insult to good programming practices. Edited February 15, 2016 by hairlessorphan Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 15, 2016 Share Posted February 15, 2016 it's probably just to check you dont force an invalid class on the game. i havnt really researched it much Link to comment Share on other sites More sharing options...
hairlessorphan Posted February 15, 2016 Author Share Posted February 15, 2016 (edited) Yeah, it does that by checking against the SoldierClassDistribution, which that part makes sense. But here's what I'm scared of. At the point I quoted above, where it calls BuildSoldierClassDeck(), the array SoldierClassDeck isn't read from again within this function except to remove the validated class... ... ... so this code looks, to me, like: If (I can't find class in SoldierClassDeck){ call a relatively expensive function that only has a 25% chance of adding it to SoldierClassDeck} ... so I can remove it 20 lines later. Like, why? As far as I can see, it's either because some side effect relies on having a % chance of SoldierClassDeck including the selected class, or because this is nonsense code EDIT: or because array.Find() is destructive in UnrealScript? Maybe? I'm scared to change it because I can't figure it out. Edited February 15, 2016 by hairlessorphan Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 15, 2016 Share Posted February 15, 2016 What are you trying to do exactly? i would leave that part standing and just extend the function. Link to comment Share on other sites More sharing options...
hairlessorphan Posted February 15, 2016 Author Share Posted February 15, 2016 I'm just trying to understand when, how, and why the game ranks up the soldiers in the recruits pool. I'm totally willing to override this function, but I'm worried that if I don't manage SoldierClassDeck properly, some other component is gonna try to read from it in another thread or something similarly bonkers, and ten hours later one of my recruits is gonna be a Muton. Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 15, 2016 Share Posted February 15, 2016 oh so you are looking at creating at a "commander's choice" too? i've tried overriding the 'PromoteSoldier' even that get's called but it dosnt fire for some reason, might just be me though,yeah i think that i'll just not touch that whole promotion event and override it by going and while you are on that screen with a squaddie just let you switch their class, that should be easier and less likely to break things Link to comment Share on other sites More sharing options...
hairlessorphan Posted February 15, 2016 Author Share Posted February 15, 2016 Not really a commander's choice, actually looking at managing class restrictions based on delegates. I was thinking of playing with requirements on randomized rookies to be eligible for classes, having those reqs read from .ini's to allow for things like "must be from these countries," "must have minimum x will state," "must be male," or whatever. Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 15, 2016 Share Posted February 15, 2016 Not really a commander's choice, actually looking at managing class restrictions based on delegates. I was thinking of playing with requirements on randomized rookies to be eligible for classes, having those reqs read from .ini's to allow for things like "must be from these countries," "must have minimum x will state," "must be male," or whatever.if you want that maybe change the class template on the soldier himself after getting promoted using those restrictions?i'll look into how to do it when looking at commander's choice and how to get the units to load the new classes Link to comment Share on other sites More sharing options...
Recommended Posts