Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent (starting) pawns from having both Nomadism and Undergrounder traits #8

Closed
hiergiltdiestfu opened this issue Dec 17, 2022 · 20 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@hiergiltdiestfu
Copy link
Owner

During playtesting the Nomadism scenario in v.1.0.0, we had random starting pawns that had both the Nomadic and Undergrounder traits, despite Nomadic declaring a conflict with Undergrounder. Research why the conflict is ignored by the scenario manager.
Do I need to use a fully qualified defname for the vanilla trait "Undergrounder"?

@hiergiltdiestfu hiergiltdiestfu added the bug Something isn't working label Dec 17, 2022
@hiergiltdiestfu hiergiltdiestfu added this to the v1.1.0 milestone Dec 17, 2022
@hiergiltdiestfu hiergiltdiestfu changed the title Starting pawns that have both Nomadism and Undergrounder traits Prevent (starting) pawns from having both Nomadism and Undergrounder traits Dec 17, 2022
@hiergiltdiestfu hiergiltdiestfu added the help wanted Extra attention is needed label Dec 17, 2022
@hiergiltdiestfu hiergiltdiestfu self-assigned this Dec 29, 2022
@hiergiltdiestfu hiergiltdiestfu pinned this issue Dec 29, 2022
@hiergiltdiestfu
Copy link
Owner Author

I think RimWorld is aware of the declared conflict in the Nomadism trait, but this might get overridden by backstories, as the vanilla definition for Undergrounder notes:

There are several backstories that force this trait

@hiergiltdiestfu
Copy link
Owner Author

Rolling the dice for a couple starting pawns, those backstories are probably forcing Undergrounder:

  • Childhood: Cave Child, Scavenger (? based on Digger-combo, for which we have a counter-example),
  • Adulthood: (Digger - counterexample found), Hearth Tender

Next up:

  • check backstory defs
  • research way to prio conflicting traits or exclude/force backstories

@hiergiltdiestfu
Copy link
Owner Author

Backstories that force Undergrounder
In Vanilla:

  • CaveworldIlluminator95
  • CaveworldTender26
  • CaveworldTunneler48
  • Digger66 (! despite the counter-example Oo)
  • HearthTender66
  • CaveChild30
  • CaveChild17

In Royalty:

  • PlanetaryMiner64
  • ShipboundLordling12

In Biotech:
(none)

@hiergiltdiestfu
Copy link
Owner Author

The ConflictingTraits code in TraitDef looks sane, so the backstory obviously has higher prio. Looking for ways to exclude Undergrounder backstories in the scenario now.

(Alternatively: stop bothering.. ?)

@hiergiltdiestfu
Copy link
Owner Author

possibly:

excludeChildhood | excludeAdulthood < BackstoryCategoryFilter < backstoryFilters < PawnKindDef < AvailableKinds < ScenPart_ConfigPage_ConfigureStartingPawns_KindDefs < Scenario

@hiergiltdiestfu
Copy link
Owner Author

hiergiltdiestfu commented Dec 29, 2022

Maybe easiest to define backstoryFilters in a new Faction.

FactionDef ParentName="PlayerFactionBase"
defName>PlayerTribe</defName

@hiergiltdiestfu
Copy link
Owner Author

BackstoryCategoryFilter#Matches honors the exclude* tags, looks at BackstoryDef#spawnCategories

@hiergiltdiestfu
Copy link
Owner Author

oh man, spawnCategories is at the level of "Tribal", would have needed it to be on the defName level or so.. this way I can only exclude all tribal backstories and not cherry-pick single backstories :(

@hiergiltdiestfu
Copy link
Owner Author

hiergiltdiestfu commented Dec 29, 2022

Asked in the RimWorld modding discord, and got some pointers from Killathon and Aelanna.

  • Patch pawn generation via Harmony, to remove Undergrounder when my trait is present.
  • Go ahead with the custom faction, using a custom PawnKindDef, declaring a disallowedTraits entry for Undergrounder, which would force post-start pawns to also obey this rule.
    • The alternative is to create custom copies of both the PawnKindDef and the PlayerTribe FactionDef via inheritance and that will ensure that all future pawns will obey the same restriction

  • As the lesser version of the faction, make only a custom PawnKindDef and specify that in the ScenPart_StartingHumanlikes for the ScenarioDef

@hiergiltdiestfu
Copy link
Owner Author

hiergiltdiestfu commented Dec 31, 2022

Using the tribe definitions as parents for the custom faction and the custom tribe fails..

XML error: Could not find parent node named "PlayerTribe" for node "FactionDef". Full node: <FactionDef ParentName="PlayerTribe"><defName>NP_NomadicTribe</defName><label>Nomadic Tribe</label><description>Some Nomads on the hike.</description><isPlayer>true</isPlayer><pawnSingular>nomad</pawnSingular><pawnsPlural>nomads</pawnsPlural><basicMemberKind>NP_Nomad</basicMemberKind><backstoryFilters><li><categories><li>Tribal</li></categories></li></backstoryFilters></FactionDef>
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.XmlInheritance:GetBestParentFor (Verse.XmlInheritance/XmlInheritanceNode,string)
Verse.XmlInheritance:ResolveParentsAndChildNodesLinks ()
Verse.XmlInheritance:Resolve ()
Verse.LoadedModManager:ParseAndProcessXML 
...

XML error: Could not find parent node named "Tribesperson" for node "PawnKindDef". Full node: <PawnKindDef ParentName="Tribesperson"><defName>NP_Nomad</defName><label>member</label><disallowedTraits><li>Undergrounder</li></disallowedTraits><forcedTraits><li>NP_Nomadism_Nomad</li></forcedTraits><initialResistanceRange>10~18</initialResistanceRange></PawnKindDef>
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.XmlInheritance:GetBestParentFor (Verse.XmlInheritance/XmlInheritanceNode,string)
Verse.XmlInheritance:ResolveParentsAndChildNodesLinks ()
Verse.XmlInheritance:Resolve ()
Verse.LoadedModManager:ParseAndProcessXML 
...

// follow-up errors:
Config error in NP_NomadicTribe: NP_NomadicTribe has no tech level.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.DefDatabase`1<RimWorld.FactionDef>:ErrorCheckAllDefs ()
...

Config error in NP_NomadicTribe: raidLootValueFromPointsCurve must be defined
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.DefDatabase`1<RimWorld.FactionDef>:ErrorCheckAllDefs ()

Config error in NP_Nomad: no race
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.DefDatabase`1<Verse.PawnKindDef>:ErrorCheckAllDefs ()
...

Config error in NP_Nomad: NP_Nomad has no combatPower.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.DefDatabase`1<Verse.PawnKindDef>:ErrorCheckAllDefs ()
...

Exception in ConfigErrors() of NP_Nomad: System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.PawnKindDef+<ConfigErrors>d__113.MoveNext () [0x0025d] in <3126aca1aad041dcbdeda807cfe004bf>:0 
  at Verse.DefDatabase`1[T].ErrorCheckAllDefs () [0x0006b] in <3126aca1aad041dcbdeda807cfe004bf>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.DefDatabase`1<Verse.PawnKindDef>:ErrorCheckAllDefs ()
...

@hiergiltdiestfu
Copy link
Owner Author

Changing from inheritance to just copying... that'll generate a todo to clean that up later and get rid of the redundancy.

@hiergiltdiestfu
Copy link
Owner Author

NP_Nomadism_Nomad found no data at degree 0, returning first defined.

@hiergiltdiestfu
Copy link
Owner Author

Changing from inheritance to just copying... that'll generate a todo to clean that up later and get rid of the redundancy.

Unfortunately, copying works - too bad, had hoped for inheritance.

@hiergiltdiestfu
Copy link
Owner Author

Faction and Pawn Kind look good in the pawn generator screen, even sure backstory bets for Undergrounder no longer make it show up.

@hiergiltdiestfu
Copy link
Owner Author

NP_Nomadism_Nomad found no data at degree 0, returning first defined.

started cropping up again.. maybe from the trait "request" in the pawn kind def...

hiergiltdiestfu pushed a commit that referenced this issue Dec 31, 2022
* Changed scenario to be based on a new tribe faction
* Added new nomad tribe faction based on a new pawn kind
* Added new nomad pawn kind to disallow Undergrounder trait, which is
  added by certain backstories, despite the Nomadic trait declaring a
conflict with Undergrounder. The disallow in the pawnkind def takes
precedent over the backstory. This fixes #8.Prevent Undergrounder trait
for Nomads

* Changed scenario to be based on a new tribe faction
* Added new nomad tribe faction based on a new pawn kind
* Added new nomad pawn kind to disallow Undergrounder trait, which is
  added by certain backstories, despite the Nomadic trait declaring a
conflict with Undergrounder. The disallow in the pawnkind def takes
precedent over the backstory. This fixes #8.
hiergiltdiestfu pushed a commit that referenced this issue Dec 31, 2022
* Changed scenario to be based on a new tribe faction
* Added new nomad tribe faction based on a new pawn kind
* Added new nomad pawn kind to disallow Undergrounder trait, which is
  added by certain backstories, despite the Nomadic trait declaring a
conflict with Undergrounder. The disallow in the pawnkind def takes
precedent over the backstory. This fixes #8.
@hiergiltdiestfu
Copy link
Owner Author

Consider removing degrees for the trait altogether if possible

@hiergiltdiestfu
Copy link
Owner Author

NP_Nomadism_Nomad found no data at degree 0, returning first defined.

started cropping up again.. maybe from the trait "request" in the pawn kind def...

Also shows up in the Xenotype editor when hovering over the inherently nomadic/sedentary genes, fix this with #4, or get rid of the degrees, as mentioned before..

@hiergiltdiestfu
Copy link
Owner Author

Moving forced trait from scenario to pawnkind -- forcing in pawnkind definitely leads to the trait always being added first, cool. Checking if declaration in scenario is now redundant.

@hiergiltdiestfu
Copy link
Owner Author

Tried renaming the traits' defnames so they make more sense regarding the new factions and pawnkinds, but that'd break existing savegames, so we'll take care of this somewhen else, see #18.

@hiergiltdiestfu
Copy link
Owner Author

Moving the forced traits from the scenario to the factions worked for both nomadic and sedentary, and might even help with the inheritance stuff I was going for with the genes - might make the genes redundant, need to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant