Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Field Researcher
Original Poster
#1 Old 26th Nov 2022 at 5:53 AM
Default Is there a way for children to inheret custom skills if their parents had said custom skill?
Would anyone have any idea on how to implement a method where sim's children can inherit a custom trait? I can't even think of a potential mod I could reference or what I could look at in terms of EA's code to try to figure out how to implement this method.
Advertisement
Space Pony
#2 Old 26th Nov 2022 at 2:04 PM
0. create a listener to EventTypeId.kHadBaby
1. cast the event to PregnancyEvent and check null
2. get/check desired traits from mActor field / Actor property
3. Apply wanted Traits to mBabies List items as desired
4. Fertig
Forum Resident
#3 Old 26th Nov 2022 at 4:52 PM
You could try to subscribe to the kGotPregnant Event

In there you check if any of the parents has the custom trait

and then try

mothersim.SimDescription.Pregnancy.SetForcedBabyTrait(mycustomtrait);

Haven't tried it but it might work

Find my Mods: Here at MTS, over at Simlogical
Field Researcher
Original Poster
#4 Old 26th Nov 2022 at 9:23 PM
Quote: Originally posted by Battery
0. create a listener to EventTypeId.kHadBaby
1. cast the event to PregnancyEvent and check null
2. get/check desired traits from mActor field / Actor property
3. Apply wanted Traits to mBabies List items as desired
4. Fertig


Thank you for all your suggestions. Although I am rather curious, what is the 4th thing you mentioned? Fertig, I tried looking at the term in ILspy and even tried googling it, but i was not able to find anything.
Field Researcher
Original Poster
#5 Old 26th Nov 2022 at 9:27 PM
Quote: Originally posted by Consort
You could try to subscribe to the kGotPregnant Event

In there you check if any of the parents has the custom trait

and then try

mothersim.SimDescription.Pregnancy.SetForcedBabyTrait(mycustomtrait);

Haven't tried it but it might work


Thank you for your suggestion. I am honestly shocked that it was this easy. I didn't think a simple "private static void AddDNATrait(Sim mothersim, Sim fathersim)" method would work. As I thought the method wouldn't know to get the info from the father. This is a basic method I made for the custom trait inheritance and I just added it to the kGotPregnant Event. It worked great.

Code:
private static void AddDNATrait(Sim mothersim, Sim fathersim)
        {
            if(mothersim.SimDescription.HasTrait((TraitNames)0x48BFC6B3853D079C) && fathersim.SimDescription.HasTrait((TraitNames)0x48BFC6B3853D079C))
            {
                mothersim.SimDescription.Pregnancy.SetForcedBabyTrait((TraitNames)0x48BFC6B3853D079C);

            }

            if(mothersim.SimDescription.HasTrait((TraitNames)0x1DD48B93DB44F056) && fathersim.SimDescription.HasTrait((TraitNames)0x1DD48B93DB44F056))
            {
                mothersim.SimDescription.Pregnancy.SetForcedBabyTrait((TraitNames)0x1DD48B93DB44F056);
            }
            if(mothersim.SimDescription.HasTrait((TraitNames)0x8A063A51B05A851B) && fathersim.SimDescription.HasTrait((TraitNames)0x8A063A51B05A851B))
            {
                mothersim.SimDescription.Pregnancy.SetForcedBabyTrait((TraitNames)0x8A063A51B05A851B);
            }

        }
Back to top