Questions about a custom race mod, new to modding.

Started by Sig, January 25, 2018, 02:17:05 PM

Previous topic - Next topic

Sig

Hello, I'm currently working on a custom race mod using the Alien races framework. I'm new to this and I have some questions that I would be grateful if someone could answer.

I'm trying to emulate how some insect hives work in real life, and most of my doubts are about gender dimorphism.

- Is there any way in which the pawn size can be set differently for each gender? I've already made females (queens) spawn chance less common, but I would also like them to be bigger in size (both basebodysize and customdrawsize) compared to males.

- I want the faction leader of this race to be a hive queen, so is it possible to set it so only females can be faction leaders?

- How can I make a custom list of faction names that the Hive faction can get? The tribal vanilla names don't really fit with the theme.

- To reflect the hive mentality I want to disable the "cramped space" and "very cramped space" thoughts. I know for example that the variable that rules eating raw food is AteRawFood, but how can I find the variables for the cramped space thoughts?

jamaicancastle

For the first two, I suspect your best bet is to create two (or more) totally different species for your males and females. Use the gender commonality to differentiate them, and then throw in other traits as you want. Each race will need its own set of PawnKindDefs, so you can easily assign say faction leadership to only a PawnKindDef for the female subspecies, or make males more common as fighters/caravan guards, or whatnot. A player faction will need to use one or the other by default, but you can use HAR to assign pawn kind(s) of the other subspecies to that faction.

Faction namers are found in RulePackDefs, you can add new ones the same as any other def. The syntax is pretty self-explanatory, but I can go into more detail on it if you want. The raw rules refer to files in Your Mod/Languages/English/[your path]. (If a user has a language other than English, it will try to find them in that language's folder, then fall back on using English.) Pawn and settlement namers are defined in the same way.

Finally, because "space" is handled as a need, its thought is defined in Thoughts_Situation_Needs; specifically it is NeedSpace. Be aware that disabling this thought will remove both the good and bad thoughts from space (which might be what you want anyway). If you want a version that will only be good and not bad, you'll have to add some simple C# code of your own.

Sig

Thank you, that clarifies a lot of things. I think I will abandon for now the idea of different body sizes, since the solution seems way too hard for my current level, and conflicts with other ideas I have for the mod.

Sig

I have some more doubts:

To modify their body and organs (changing names and/or adding or removing parts by default) the files that I have to edit are Bodies/Bodies_Humanlike, Bodies/BodyParts_Organs and Bodies/BodyParts_General? If so, how can I make those changes be applied only to my race and not to every humanlike pawn?

jamaicancastle

You'll need to define a new BodyDef (my advice is just copy-paste the human one, rename it, and make changes to it) that contains the unique body part configuration for your new pawns. Depending on what's available, you may be able to construct it all with vanilla BodyPartDefs, or you may need to define some of your own. In either case, as long as your BodyDef and any new BodyPartDefs don't have the same names as vanilla ones, vanilla pawns will be unaffected in any way.

You'll then need to go into your alien race def(s), inside the race tag, and add or modify the "body" tag to contain the def of your new body so that they will use the new configuration.

Sig

So If I understand it right, it would be like this then?

In "Race_Myrace" in the folder "ThingDefs_Races"
<race>
       <body>Myrace</body>
        etc
</race>

In "Bodies_Myrace" in the folder "Bodies"
<BodyDef>
       <defName>Myrace</defName>
       etc
</BodyDef>

And then: BodyParts_OrgansMyrace and BodyParts_HumanoidMyrace will automatically be applied to my race then, just by modifying the file name like that, right? because I don't see any defName I can modify in those, besides the names of the organs and limbs themselves.

jamaicancastle

That looks good as far as associating your race with its custom body.

Inside the body def, you should see a bunch of body parts, starting with the torso and branching off from there. Each one of them starts with a <def> that points to a specific BodyPartDef. That def can be one of the vanilla ones, or a modded one. Think of it like Legos: the BodyPartDefs determine what bricks are made, and then the BodyDef shows the game how to assemble a body out of those bricks.

So let's say you wanted to replace your pawn's hands with pincers. You'd create a BodyPartDef and give it the defName LeftPincer along with whatever other properties you think best. (Maybe it should be tougher, or whatever.) Then you'd navigate in the BodyDef to the LeftHand node and replace the Def there with LeftPincer. (You'd also want to remove the fingers, which are children of that node under its "parts" tag - unless you want pincers with fingers on them, which, ick.)

Sig

Thank you very much for your help, it really solves a problem I was stuck in for quite a while.


Sig

I've finished modding the body, all is working as intended but im getting a yellow warning sometimes. I checked the torso coverage but the total sum is around 0.39:

BodyDef Mantodean has BodyPartRecord of Torso whose children have more or equal total coverage than 1. This means parent can't be hit independently at all.
Verse.Log:Warning(String)
Verse.BodyDef:CacheDataRecursive(BodyPartRecord)
Verse.BodyDef:ResolveReferences()
Verse.DefDatabase`1:ResolveAllReferences(Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.GenGeneric:InvokeStaticMethodOnGenericType(Type, Type, String, Object[])
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()


I'm also getting this other warning sometimes, but I don't know what is it about:

RandomElementByWeight with totalWeight=0 - use TryRandomElementByWeight.
Verse.Log:Error(String)
Verse.GenCollection:RandomElementByWeight(IEnumerable`1, Func`2)
Verse.HediffGiveUtility:TryApply(Pawn, HediffDef, List`1, Boolean, Int32, List`1)
Verse.HediffGiver:TryApply(Pawn, List`1)
Verse.HediffGiver_Birthday:TryApplyAndSimulateSeverityChange(Pawn, Single, Boolean)
RimWorld.AgeInjuryUtility:GenerateRandomOldAgeInjuries_Patch1(Pawn, Boolean)
Verse.PawnGenerator:GenerateInitialHediffs_Patch1(Pawn, PawnGenerationRequest)
Verse.PawnGenerator:TryGenerateNewNakedPawn(PawnGenerationRequest&, String&, Boolean)
Verse.PawnGenerator:GenerateNewNakedPawn(PawnGenerationRequest&)
Verse.PawnGenerator:GeneratePawnInternal(PawnGenerationRequest)
Verse.PawnGenerator:GeneratePawn_Patch1(PawnGenerationRequest)
Verse.PawnGenerator:GeneratePawn(PawnKindDef, Faction)
Verse.<DoListingItems_MapTools>c__AnonStorey34:<>m__0()
Verse.DebugTool:DebugToolOnGUI()
Verse.DebugTools:DebugToolsOnGUI()
RimWorld.UIRoot_Play:UIRootOnGUI()
Verse.Root:OnGUI()


What do they mean? How can I fix them?

I also have another question, I'm trying to create a starting scenario in which they start with a set number of chickens instead of random animals:

<li Class="ScenPart_StartingAnimal">
<def>StartingAnimal</def>
<count>7</count>
<bondToRandomPlayerPawnChance>0.0</bondToRandomPlayerPawnChance>
</li>

I tried to add <thingDef>Chicken</thingDef> to it, but it doesn't work. Is there any way of making these animals be chickens?

jamaicancastle

#10
The yellow one seems pretty clear-cut to me. Can you post your body def XML? Maybe there's something non-obvious that's counting against its coverage.

The red one appears to be giving an age-related hediff to a pawn, but all of the body parts that hediff can affect have 0 coverage, which leads to problems when it tries to pick one at random. Depending on which hediff it's trying to give out, that could be the torso, brain, heart, eyes, or ears, IIRC. You'll want to make sure all of those have nonzero coverage.

Edit: looking at it, I believe the animal scenario part wants a PawnKindDef property named "animalKind". You should be able to find the animal PawnKindDef in the same file as their ThingDef.

Also, if you create a scenario with the in-game scenario editor, save the game once you're on the map, and then open the save file, you should be able to find a list of scenario parts - these are exactly the same syntax as in a mod-defined scenario.

Sig

The scenario tip was a smart one, it indeed needed to be <animalKind>Chicken</animalKind>. Now it's working well.

I'm attaching the Bodies folder, in general the main changes were:
- Removed both lungs and added one organ called breathing sac instead.
- Added an organ called acid gland, that serves as another liver.
- Renamed parts of the head.
- Removed fingers, hands renamed as pincers, arms renamed as pedipalps.
- Added another two legs.

[attachment deleted due to age]

jamaicancastle

I think the torso problem is the two extra legs are tipping it over the limit. The way RW's body system works, the torso is the "core" part, and everything else attaches to it. The limbs do so directly, so they're counted against the coverage total of the torso's sub-parts.

In order for the torso to take as many hits as it normally does, you'll want to take .28 coverage out of its sub-parts, whether that's .7 from each leg, or a lesser amount from the legs and some from the arms, or whatever seems logical to you.

As far as the other error goes, try this: go to Core/Defs/HediffGiverSetDefs. There should be one file there with one def in it. Copy it to your mod, rename the def, you know the drill. Then go through and, in the modified def, look for the body part defs. Any of them that you replaced with a new body part in your alien, do the same here. So lung -> breathing sac, eye -> eye set, etc. Then go to your alien def, in the race tag at the bottom, and look for hediffGiverSets. Change the entry there to your new giver set.

Sig

I managed to fix the errors, thanks to your help.

I released it for testing here: https://ludeon.com/forums/index.php?topic=38978.0