erdelf / AlienRaces

Rimworld mod alien race framework
MIT License
103 stars 69 forks source link

Fix Humans being hard-coded as potential starting colonists #94

Closed ghost closed 1 year ago

ghost commented 1 year ago

Issue: Humans will always show up as starting colonists, and there is no surface to apply a patch upon to prevent them from showing up. This is because the basicMember PawnKindDef is being added with a frequency of 100f on the changed line in HarmonyPatches.cs.

Fix: remove the code in HarmonyPatches.cs and add a normal startingColonists definition to the Humans' race settings. This allows a patch to be applied.

Tests: I ran the game with the code below, a patch that set the newly added chance to 0, and a custom race. 100% starting colonists appeared as my custom race. I ran the game with the code below and a custom race. 50% starting colonists appeared as humans and 50% appeared as my custom race. I ran the game with just the code below. 100% starting colonists appeared as humans. I ran the game with the code below and the patch with no custom races added, and humans still appeared; When TryRandomElementByWeight fails (such as when the chance is 0), it selects the basicMember, which is still a human.

Aelanna commented 1 year ago

This seems highly unnecessary, seeing as there are already ways of making custom scenarios with non-human starting colonists: you simply need to create a new ScenarioDef with custom player-eligible PawnKindDefs. The reason that RaceSettings exist is because the human colonist PawnKindDefs are locked in for the vanilla scenarios and this is how you add your race to the vanilla start. If you don't want to start with humans at all, make a custom Scenario. If you'd like some help with this, I'd be happy to help you on the HAR Discord.

ghost commented 1 year ago

I'd like my custom race to be added to all scenarios, which would require overwriting them all, not to mention custom ones added via other mods. I.E., I want my race to be added, essentially, as a variant of a human.

With the current Master code, I can get it to almost work by setting the custom race's chance to a really high number, but there's always a small chance that a human can spawn. As far as I can tell by looking through the AlienRaces code, this change shouldn't break anything nor cause any problems for anyone else.

Aelanna commented 1 year ago

Your change would break any race mod that currently uses both basicMember and RaceSettings to use multiple PawnKindDefs in their own custom ScenarioDefs, which includes at least two of mine. Your specific use case also seems extremely overreaching; many race mods include custom scenarios that are only meant to have their specific race in it, a mechanism that magically allows you to insert your race into scenarios that don't want them seems ill-advised.

Again, would be happy to talk about this on Discord, but I can't support this change.

erdelf commented 1 year ago

Your wish to add your race to all starting scenarios is good and all.. but ignoring faction settings because you don't like them is not the way to go. Humans are absurdly easy to replace if you really wanted to, but the base factions are by default setup with humans. Your Change would force basically all faction mods to rewrite stuff only for alien race, which is not how the framework ever operated.

ghost commented 1 year ago

Sorry, I didn't realize it would break anything. I had tested other mods with custom scenarios, and they didn't break for me, so I thought the code was referring to some other variable for basicMember. I didn't want to break anything for sure, that's why I tested a bunch. So sorry.