[1.3] Children and Pregnancy - v4.1.0

Started by GhostData, March 22, 2020, 04:32:51 PM

Previous topic - Next topic

Tenshi~Akari

Quote from: BlueTressym on September 12, 2020, 11:35:41 PM
Hi.  I've got an error coming up upon map gen related to clothing textures or something?  (I only know a small amount about how mods work). 

https://gist.github.com/5145406e4a2249968d6912dbcbc23b7d

I'm using the GitHub 1.2 version.  I haven't used this mod before; I'm compiling a mod list for a new run-through and wanted to try it out.

I see you also have Faction Colors installed. I ran across this issue of the error with it and C&P active, and it seems that Faction Colors is literally looking for any worn apparel items for children to show up as "(Apparel Name)_Child", which causes a pink box issue. Disabling Faction Colors removes the issue and C&P will render the clothing per its normal.

Hoping there would be an easier workaround to this issue, as I find both essential somehow for the sake of advanced apparel masking and of course more fleshed out life stages in game at the same time... the only literal workaround was to actually make a related "_Child" texture for all apparel items that require a body type name to them. (That, and there was a mod a few versions back that was an Apparel type resolver of sorts that would allow you to choose alternative body shapes to draw in place of missing textures... I'm not sure if that had been updated to 1.2 or not.)

GhostData

Quote from: Tenshi~Akari on September 13, 2020, 09:40:20 AM
Quote from: BlueTressym on September 12, 2020, 11:35:41 PM
Hi.  I've got an error coming up upon map gen related to clothing textures or something?  (I only know a small amount about how mods work). 

https://gist.github.com/5145406e4a2249968d6912dbcbc23b7d

I'm using the GitHub 1.2 version.  I haven't used this mod before; I'm compiling a mod list for a new run-through and wanted to try it out.

I see you also have Faction Colors installed. I ran across this issue of the error with it and C&P active, and it seems that Faction Colors is literally looking for any worn apparel items for children to show up as "(Apparel Name)_Child", which causes a pink box issue. Disabling Faction Colors removes the issue and C&P will render the clothing per its normal.

Hoping there would be an easier workaround to this issue, as I find both essential somehow for the sake of advanced apparel masking and of course more fleshed out life stages in game at the same time... the only literal workaround was to actually make a related "_Child" texture for all apparel items that require a body type name to them. (That, and there was a mod a few versions back that was an Apparel type resolver of sorts that would allow you to choose alternative body shapes to draw in place of missing textures... I'm not sure if that had been updated to 1.2 or not.)

I've actually considered doing this at runtime to get around mod-added clothing. Writing files to a variety of file systems with varying permissions would be practically impossible, though. I will probably have to implement some form of in-memory store for scaled graphics, as the fix for the memory leak is now causing clothing to be scaled for the thin body type as well, since we're effectively modifying a reference to it. I don't think an inmemory solution would work for other mods though, as I think the graphics database pulls from the filesystem rather than memory, so there probably isn't a way to register any generated graphics.

Starting to think I'm in over my head with this hot mess.

andythehero

I'm pretty sure that Combat Extended also causes pink boxes to appear on the children, but I'm not sure if you guys have already addressed that Combat Extended messes with the mod.

GhostData

#363
Quote from: andythehero on September 14, 2020, 02:50:34 PM
I'm pretty sure that Combat Extended also causes pink boxes to appear on the children, but I'm not sure if you guys have already addressed that Combat Extended messes with the mod.
I don't know how you folks  are even running CE side by side with CNP. When I try, I get harmony patching errors. There should be a hard break when running the two due to conflicting transpiler patches.

Got a giggle out of this one while testing CE:

GhostData

Glad to finally have something worth releasing.

V3.4.0 released
https://gitlab.com/Tragix/children-and-pregnancy-collab/-/releases/v3.4.0

To summarize the changes all the way from 3.3.0:
- Added the ability for caretaker pawns to pick up and carry a toddler or baby pawn when drafted
- Added logic to prevent wholesale slaughter of unarmed toddlers by idle draftees - This does not affect turrets, which will gun down unarmed enemy pawns as usual, even if they're toddlers.
- Increase max age scaling from 12 to 60 - mostly for testing.
- More 1.2 patch fixes, probably more to come as detected
- Fixed adult pawn hair alignment issues
- Fixed adult clothing resizing when the same apparel was equipped by a child pawn
- Preload apparel graphics in-memory before rendering
- Add one integration point with Combat Extended

While trouble shooting some rendering issues, I learned that graphics and materials are all cached, which gave me a more efficient way to handle graphics scaling for pawns. Previously, we would make changes to the size and offset of a material every tick, just before it was rendered. Now, we only perform a check when new apparel is equipped, and if this apparel's graphics are not loaded yet, we will apply and cache those new materials before we start rendering. This means that I was able to remove two patches from the render method entirely, which should help a bit with performance. There are still a ton of patches there, some of which could take advantage of this method as well.
This has an additional effect: Any mod-added apparel that doesn't perform any rendering tricks (like Combat Extended does by defining new layers and rendering rules) will also be preloaded when equipped. This means some mods with custom apparel will now be able to render their graphics properly when used on children. I'm not willing to say all, but in theory most mods should work with this setup.

In addition, I used Combat Extended as a test case for this change. As a result, there is now an integration point for CE - we check for the IsHeadWear config to allow CE headwear to properly render on children. I have tested this with helmets and gas masks. There are probably still some cases that are not supported - I will investigate as they are discovered.

I haven't had time to perform any regression testing, so there may be some other oddities introduced with rendering. Off the top of my head, I suspect it may be possible for hats to be double-resized. More to come.

HohenHeizen

#365
Exception in JobDriver tick for pawn Kaori driver=JobDriver_Goto (toilIndex=0) driver.job=(Goto (Job_5758590) A=(221, 0, 299))
System.NullReferenceException: Object reference not set to an instance of an object
  at RimWorldChildren.API.ChildrenUtility.RaceUsesChildren (Verse.Pawn pawn) [0x00000] in <5dd325a319c041d69189747967fd962c>:0
  at RimWorldChildren.CombatPatches+AttackTargetFinder_BestShootTargetFromCurrentPosition_Patch.ShouldShootToddlers (Verse.Thing t) [0x00007] in <5dd325a319c041d69189747967fd962c>:0
  at Verse.AI.AttackTargetFinder+<>c__DisplayClass5_0.<BestAttackTarget>b__1 (Verse.AI.IAttackTarget t) [0x000e4] in <d72310b4d8f64d25aee502792b58549f>:0
  at Verse.AI.AttackTargetFinder+<>c__DisplayClass5_0.<BestAttackTarget>b__2 (Verse.AI.IAttackTarget x) [0x00026] in <d72310b4d8f64d25aee502792b58549f>:0
  at System.Collections.Generic.List`1[T].RemoveAll (System.Predicate`1[T] match) [0x0004c] in <567df3e0919241ba98db88bec4c6696f>:0
  at (wrapper dynamic-method) Verse.AI.AttackTargetFinder.Verse.AI.AttackTargetFinder.BestAttackTarget_Patch0(Verse.AI.IAttackTargetSearcher,Verse.AI.TargetScanFlags,System.Predicate`1<Verse.Thing>,single,single,Verse.IntVec3,single,bool,bool)
  at (wrapper dynamic-method) Verse.AI.AttackTargetFinder.Verse.AI.AttackTargetFinder.BestShootTargetFromCurrentPosition_Patch1(Verse.AI.IAttackTargetSearcher,Verse.AI.TargetScanFlags,System.Predicate`1<Verse.Thing>,single,single)
  at RunAndGun.Harmony.JobDriver_SetupToils.checkForAutoAttack (Verse.AI.JobDriver_Goto __instance) [0x000f2] in <b794371ac9ff4775865fbf8a3b981e2c>:0
  at RunAndGun.Harmony.JobDriver_SetupToils+<>c__DisplayClass0_0.<Postfix>b__0 () [0x00073] in <b794371ac9ff4775865fbf8a3b981e2c>:0
  at (wrapper dynamic-method) Verse.AI.JobDriver.Verse.AI.JobDriver.DriverTick_Patch1(Verse.AI.JobDriver)
Verse.Log:Error(String, Boolean)
Verse.AI.JobUtility:TryStartErrorRecoverJob(Pawn, String, Exception, JobDriver)
Verse.AI.JobDriver:Verse.AI.JobDriver.DriverTick_Patch1(JobDriver)
Verse.AI.Pawn_JobTracker:JobTrackerTick()
Verse.Pawn:Verse.Pawn.Tick_Patch1(Pawn)
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Verse.Root_Play.Update_Patch1(Root_Play)


All my pawns are locking up, unable to fire/move, while recruited even while being gored to death. So far it's only happened during mechanist or insectoid raids so I'm assuming it's to do with some of them being days if not just hours old.

Also Android Tiers Androids still babytalk.

EDIT: Rebuilt without the edits in CombatPatches, the targeting ones, and everything works fine.

GhostData

Quote from: HohenHeizen on September 18, 2020, 01:47:57 AM
Exception in JobDriver tick for pawn Kaori driver=JobDriver_Goto (toilIndex=0) driver.job=(Goto (Job_5758590) A=(221, 0, 299))
System.NullReferenceException: Object reference not set to an instance of an object
  at RimWorldChildren.API.ChildrenUtility.RaceUsesChildren (Verse.Pawn pawn) [0x00000] in <5dd325a319c041d69189747967fd962c>:0
  at RimWorldChildren.CombatPatches+AttackTargetFinder_BestShootTargetFromCurrentPosition_Patch.ShouldShootToddlers (Verse.Thing t) [0x00007] in <5dd325a319c041d69189747967fd962c>:0
  at Verse.AI.AttackTargetFinder+<>c__DisplayClass5_0.<BestAttackTarget>b__1 (Verse.AI.IAttackTarget t) [0x000e4] in <d72310b4d8f64d25aee502792b58549f>:0
  at Verse.AI.AttackTargetFinder+<>c__DisplayClass5_0.<BestAttackTarget>b__2 (Verse.AI.IAttackTarget x) [0x00026] in <d72310b4d8f64d25aee502792b58549f>:0
  at System.Collections.Generic.List`1[T].RemoveAll (System.Predicate`1[T] match) [0x0004c] in <567df3e0919241ba98db88bec4c6696f>:0
  at (wrapper dynamic-method) Verse.AI.AttackTargetFinder.Verse.AI.AttackTargetFinder.BestAttackTarget_Patch0(Verse.AI.IAttackTargetSearcher,Verse.AI.TargetScanFlags,System.Predicate`1<Verse.Thing>,single,single,Verse.IntVec3,single,bool,bool)
  at (wrapper dynamic-method) Verse.AI.AttackTargetFinder.Verse.AI.AttackTargetFinder.BestShootTargetFromCurrentPosition_Patch1(Verse.AI.IAttackTargetSearcher,Verse.AI.TargetScanFlags,System.Predicate`1<Verse.Thing>,single,single)
  at RunAndGun.Harmony.JobDriver_SetupToils.checkForAutoAttack (Verse.AI.JobDriver_Goto __instance) [0x000f2] in <b794371ac9ff4775865fbf8a3b981e2c>:0
  at RunAndGun.Harmony.JobDriver_SetupToils+<>c__DisplayClass0_0.<Postfix>b__0 () [0x00073] in <b794371ac9ff4775865fbf8a3b981e2c>:0
  at (wrapper dynamic-method) Verse.AI.JobDriver.Verse.AI.JobDriver.DriverTick_Patch1(Verse.AI.JobDriver)
Verse.Log:Error(String, Boolean)
Verse.AI.JobUtility:TryStartErrorRecoverJob(Pawn, String, Exception, JobDriver)
Verse.AI.JobDriver:Verse.AI.JobDriver.DriverTick_Patch1(JobDriver)
Verse.AI.Pawn_JobTracker:JobTrackerTick()
Verse.Pawn:Verse.Pawn.Tick_Patch1(Pawn)
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Verse.Root_Play.Update_Patch1(Root_Play)


All my pawns are locking up, unable to fire/move, while recruited even while being gored to death. So far it's only happened during mechanist or insectoid raids so I'm assuming it's to do with some of them being days if not just hours old.

Also Android Tiers Androids still babytalk.

EDIT: Rebuilt without the edits in CombatPatches, the targeting ones, and everything works fine.
I'm not sure I follow that last line. You were running the mod with additional modifications on top?
I assume the android problem is still present?

HohenHeizen

After I had the issue stated and it nearly cost my colony twice I went in and rebuilt the assembly without the combatpatches pertaining to targeting and it the pawn lock up went away instantly. I like this mod, but I wasn't about to be eaten because of it.

I barely understand coding so I can't really help fixing it or resolving things, only making my own game work. However, I only made the modifications after I initially noticed the problem and made the post. Like I said, I don't know what I'm doing and after reading the error logs a few times something clicked and I knew how to go about fixing it so my game could be played.


Yes, the androids from Android Tiers still actively babytalk. Excessively so. I'm unsure of the ones from the Androids mod.

I only have under the hood knowledge of AT and that's just from dabbling. All the androids lifeStageAges are HumanlikeAdult at minAge 0. So they should all read as adults. I'll offer any help I can and will gladly test all releases as I see them.

GhostData

#368
v3.5.1 released
https://gitlab.com/Tragix/children-and-pregnancy-collab/-/releases/v3.5.1

This is a first pass for prison babies. Prisoners may now become pregnant and give birth. You will get a special notification when this happens.
Babies, toddlers, and children may all be prisoners as well. Babies and toddlers may be adopted to immediately force them into the colony. This is the preferred method to recruit them, and I do not intend to patch the actual prisoner recruitment feature.
There is a new memory when a child or younger is executed. Currently we don't make any special considerations on the type of execution.

I've also tweak the "child died" memory. There is already a ton of vanilla memories for when a pawns family dies, I don't believe we need a high powered general debuff every time a child is killed. I've reduced it from 20 to 10.
I've tweaked the crying children memory as well, and may reduce it further in the future. Reduced from a max debuff of 25 to 15.
Modders have a tendency to over value the impact of their memories, and often even stack them on top of existing memories that ultimately cause an unreasonable shift in mood.
Consider that a pawn's child dying is a -20 impact. If we also throw in the original child death memory CNP adds, the net debuff is -40, with the entire colony taking a -20 for 15 days. This is an absurdly high debuff when you compare it to other memories.
I suspect before the final release, a complete rebalance of memories will be in order.

More changes coming to handle faction babies.

Quote from: HohenHeizen on September 18, 2020, 10:26:56 PM
After I had the issue stated and it nearly cost my colony twice I went in and rebuilt the assembly without the combatpatches pertaining to targeting and it the pawn lock up went away instantly. I like this mod, but I wasn't about to be eaten because of it.

I barely understand coding so I can't really help fixing it or resolving things, only making my own game work. However, I only made the modifications after I initially noticed the problem and made the post. Like I said, I don't know what I'm doing and after reading the error logs a few times something clicked and I knew how to go about fixing it so my game could be played.


Yes, the androids from Android Tiers still actively babytalk. Excessively so. I'm unsure of the ones from the Androids mod.

I only have under the hood knowledge of AT and that's just from dabbling. All the androids lifeStageAges are HumanlikeAdult at minAge 0. So they should all read as adults. I'll offer any help I can and will gladly test all releases as I see them.
I tried replicating with Android Tiers T1 and T3 androids at age 0 with 0 recreation. I couldn't get any pawns trying to play with the androids.
If you're experiencing this error with the latest dll as downloaded - unmodified - from by git repo, post your modlist and maybe I can replicate with some of the other mods you're using.

HohenHeizen

#369
https://imgur.com/a/m0b1X5H

https://gist.github.com/HugsLibRecordKeeper/5691ebbefc616225cb71a52d7e1157cf

Android tiers - HD Androids(HH.ATHDAndroids) is literally just a texture replacement that has an empire relations patch, I just forgot to remove it after I loaded the modlist.  I went ahead and attached a link to a screenshot as well just to make sure we're referencing the same thing. This is a hugslib quickstart android start.

I even cleared configs and redownloaded the mods from the workshop, besides this one which I downloaded from github.

Next Day Edit: https://gist.github.com/7097ef4c358fb65cc14a08043d6a494d

Is a log after I was attacked by a group of insects. Same targeting issue.
Just want to reiterate my thanks for you workings on this. Will help wherever possible.

Kopp

#370
Hello Tragix,

I think I have the same problem as HohenHeizen and just wanted to report it.
https://gist.github.com/HugsLibRecordKeeper/0c5136b5322d6730ba99afb0f390d5dc
A raider should fire at some insects but refuses to and the error pops up.
*Using 3.5.1 or 3.4.0

I tried using a old version (3.3.2) and the problem does not occur.

Thanks for your wonderful mod :)

GhostData

#371
Quote from: Kopp on September 20, 2020, 06:18:05 AM
Hello Tragix,

I think I have the same problem as HohenHeizen and just wanted to report it.
https://gist.github.com/HugsLibRecordKeeper/0c5136b5322d6730ba99afb0f390d5dc
A raider should fire at some insects but refuses to and the error pops up.
*Using 3.5.1 or 3.4.0

I tried using a old version (3.3.2) and the problem does not occur.

Thanks for your wonderful mod :)
Neat. The reason its failing is because we're checking to see if the pawn's race has lifecycles enabled, but something is coming up null. The list we're checking is loaded on launch, so it should always contain every race in your load order, but somehow it's coming up null in your case. I'll try to replicate, but I suspect the error will be specific to your install, as it involves mod configs saved to your PC. I can add some additional null checking as well for a blind fix.

Quote from: HohenHeizen on September 20, 2020, 12:51:55 AM
https://imgur.com/a/m0b1X5H

https://gist.github.com/HugsLibRecordKeeper/5691ebbefc616225cb71a52d7e1157cf

Android tiers - HD Androids(HH.ATHDAndroids) is literally just a texture replacement that has an empire relations patch, I just forgot to remove it after I loaded the modlist.  I went ahead and attached a link to a screenshot as well just to make sure we're referencing the same thing. This is a hugslib quickstart android start.

I even cleared configs and redownloaded the mods from the workshop, besides this one which I downloaded from github.

Next Day Edit: https://gist.github.com/7097ef4c358fb65cc14a08043d6a494d

Is a log after I was attacked by a group of insects. Same targeting issue.
Just want to reiterate my thanks for you workings on this. Will help wherever possible.
Replicated the baby games issue. I'll look into it today and see if I can get a fix.
Edit: Patched. Will drop it with the next release since it's a minor issue.

Wait, The pawns triggering the error are name "Fisher," "tailor," and other strange names. Are those your pawns, or insects?
What mod are the insects from?

I've tried replicating the CE error. I added Vanilla Expanded Factions insectoid module and triggered a large raid with the faction, then spawned pirates. The pirates target the insects just fine. I did notice some insectoids triggered a melee exception, but it came from CE itself.
I equipped colonists with firearms and drafted them, they chose targets and shot without incident.

The cause of the error in the log is pretty simple, but it should also never occur. The fact that your racial settings are missing an entry for a pawn's race indicates a pretty serious config issue.
We reinitialize the racial settings on load, so even adding a new race to an existing save should generate the appropriate record. I'll add a null check to the method that is failing - this will fix the specific issue in your logs. However, since the config is clearly borked, it's highly probable that you will run into additional errors.

I'll drop the fix for this with the next release as well.

HohenHeizen

#372
Quote from: Tragix on September 20, 2020, 12:09:04 PM

Replicated the baby games issue. I'll look into it today and see if I can get a fix.
Edit: Patched. Will drop it with the next release since it's a minor issue.

Wait, The pawns triggering the error are name "Fisher," "tailor," and other strange names. Are those your pawns, or insects?
What mod are the insects from?

I've tried replicating the CE error. I added Vanilla Expanded Factions insectoid module and triggered a large raid with the faction, then spawned pirates. The pirates target the insects just fine. I did notice some insectoids triggered a melee exception, but it came from CE itself.
I equipped colonists with firearms and drafted them, they chose targets and shot without incident.

The cause of the error in the log is pretty simple, but it should also never occur. The fact that your racial settings are missing an entry for a pawn's race indicates a pretty serious config issue.
We reinitialize the racial settings on load, so even adding a new race to an existing save should generate the appropriate record. I'll add a null check to the method that is failing - this will fix the specific issue in your logs. However, since the config is clearly borked, it's highly probable that you will run into additional errors.

I'll drop the fix for this with the next release as well.

All the job named pawns are just androids named after their duties.  I believe all the insects are just from Vanilla Expanded Insectoids, I don't think I have any others that add wild insects.

I also don't have combat extended so I don't know what you mean there. When drafted pawns refused to move when in close range, sometimes will melee, and won't shoot no matter the range. This was from an infestation of mostly vanilla insects.

EDIT: https://youtu.be/PXUWG9c0CYM

GhostData

Yeah, I guess I just put CE in that sentence myself. I tested again without it and still was not able to replicate. That said, I've added code that should address the underlying cause of the error message. The scenario your save seems to be in indicates something is broken, but I believe this patch will correct that, albeit forcefully.

3.5.2 released
https://gitlab.com/Tragix/children-and-pregnancy-collab/-/releases/v3.5.2
This release fixes disabled work types not refreshing when aging up, adds some lessons to certain events, allows other factions to (if on the map at birth) to rescue and leave with children and new mothers, and adds some fixes to baby games and some race checks.
I've also validated caravan functionality and tested that a baby, toddler, and child can leave the map in caravans and be loaded into pawns. I confirmed that a birth in a caravan correctly adds the new baby pawn to the caravan. In my testing, this slowed the caravan to a crawl. I have no intention to fix this, players should know better than to send a 9 month pregnant woman hiking across a mountain. If it forces you to make the decision to abandon the mother and child or risk starving to death, all the better!

This release is an important one, as it marks the completion of the core mod features. Everything I have set out to add or test in the mod has been completed, and no new features are currently planned for CNP. Remaining are bug fixes, general polish to existing features, potential refactoring and handling existing features better, limited mod support, and documentation.
This doesn't mean new features will not come to CNP, just that I am not planning any myself. I believe there is still a lot to do with CNP, but I think as far as new features are concerned, the more ambitious ones should be in a separate mod.

HohenHeizen

Been testing the newest release. From what I can tell babygames seems to be resolved. I'm still getting the same combat issues however.

They briefly had freedom of movement but then continued to repeat the same actions of freezing in place like in the video.

I closed the game, removed the following code in CombatPatches.cs, rebuilt it, and run into no issue with the save that was mid combat.

   [HarmonyPatch(typeof(AttackTargetFinder), "BestShootTargetFromCurrentPosition")]
        public static class AttackTargetFinder_BestShootTargetFromCurrentPosition_Patch {
            [HarmonyPrefix]
            public static bool BestShootTargetFromCurrentPosition_Prefix(ref Predicate<Thing> validator) {
                if (validator == null) {
                    validator = new Predicate<Thing>(ShouldShootToddlers);
                }

                return true;
            }

            /// <summary>
            /// Predicate to decide whether a pawn is a valid target, specifically to filter toddlers
            /// </summary>
            /// <param name="t">A pawn, possibly humanlike</param>
            /// <returns>True if if the pawn is not a toddler or younger</returns>
            private static bool ShouldShootToddlers(Thing t) {
                Pawn pawn = t as Pawn;
                return !ChildrenUtility.RaceUsesChildren(pawn) || (ChildrenUtility.GetLifestageType(pawn) != null && ChildrenUtility.GetLifestageType(pawn) > LifestageType.Toddler);
            }
        }


Hope it helps. I'll log any future errors. Thanks again for the updates and working with me.

Sidenote Question, is there any way to adopt kids besides typical prison recruitment?