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
Scholar
Original Poster
#1 Old 9th Dec 2022 at 7:21 PM
Default Spawning a Sim?
So lately I have been slowly looking at sim spawning. Looking at the sim builder class.
It's been a little bit overwhelming. Like how do I spawn a sim of a certain species, occult type, age, traits. And then there's sliders and stuff.

Does anyone have any experience on this and wish to share?

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Advertisement
Field Researcher
#2 Old 10th Dec 2022 at 1:41 PM
Not sure how relevant it is to your use case, but here's some code for setting up a SimBuilder to copy the appearance (clothes, morphs, sliders, skin, age, everything) of an existing sim (human or animal) whose characteristics were stored earlier in the variables called things like ''mAgeGenderSpecies" and "mSkinToneKey":
All I needed was the original sim's appearance, not a real sim, so after doing all that I just took the outfit from the SimBuilder and never actually tried to build a sim; but if you can figure out how the sim-building step works, maybe this could be useful to you for getting the new sim to look how you intended?
Space Pony
#3 Old 10th Dec 2022 at 5:15 PM
this is something i use in the abductor mod to spawn a new alien at the point the palyer clicked on

Code:
		public override bool Run()
		{
			
			var btnp = Sims3.UI.ThreeButtonDialog.Show("Alien Sex","Female","Male","Cancel");
			if(btnp == Sims3.UI.ThreeButtonDialog.ButtonPressed.ThirdButton){return false;}
			CASAgeGenderFlags aAge = CASAgeGenderFlags.YoungAdult;
		
			
			SimDescription simDescription = Genetics.MakeAlien(aAge, (btnp==Sims3.UI.ThreeButtonDialog.ButtonPressed.FirstButton)?CASAgeGenderFlags.Female:CASAgeGenderFlags.Male, GameUtils.GetCurrentWorld(), 1f, true);
			simDescription.SkillManager.AddElement(SkillNames.Logic);
			simDescription.SkillManager.AddElement(SkillNames.Handiness);
			Skill element = simDescription.SkillManager.GetElement(SkillNames.Logic);
			if (element != null)
			{
				element.ForceSkillLevelUp(RandomUtil.GetInt(AlienUtils.kAlienHouseholdLogicSkill[0], AlienUtils.kAlienHouseholdLogicSkill[1]));
			}
			element = simDescription.SkillManager.GetElement(SkillNames.Handiness);
			if (element != null)
			{
				element.ForceSkillLevelUp(RandomUtil.GetInt(AlienUtils.kAlienHouseholdHandinessSkill[0], AlienUtils.kAlienHouseholdHandinessSkill[1]));
			}
			Household.AlienHousehold.AddSilent(simDescription);
			simDescription.OnHouseholdChanged(Household.AlienHousehold, false);
			var aliensim = simDescription.Instantiate(Hit.mPoint);
			aliensim.GreetSimOnLot(Actor.LotCurrent);

			return true;
		}



where Genetics.MakeAlien is the most important part you can adapt into your own method
Scholar
Original Poster
#4 Old 11th Dec 2022 at 6:58 PM
@Lizcandor @Battery Thank you so much! Both of you.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Scholar
Original Poster
#5 Old 3rd Jan 2023 at 11:06 AM
@lizacandor @Battery if I want to copy from a bin Sim or a downloaded Sim. How can I access that Sim through code?

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Virtual gardener
staff: administrator
#6 Old 3rd Jan 2023 at 3:26 PM
Quote: Originally posted by PuddingFace
@lizacandor @Battery if I want to copy from a bin Sim or a downloaded Sim. How can I access that Sim through code?


I've done something similair for the RPG manager, and Bin sims are a whole other beast

I'm not sure what type of info you'd like to gather from them, but bin sims only contain the bare basics. With that I mean: Gender, name, traits, zodiac signs, what clothing they're wearing (including hair/makeup). So anything you can select inside CAS basically.


To get the descriptions, this is how I did it: https://github.com/Lyralei1/RPGMana...agerRPG.cs#L216


The most important part of this is:

Code:
           ResKeyTable SimDescriptions = DownloadContent.GetImportedSimResourceKeys(false);
            if (SimDescriptions == null)
            {
                return null;
            }

            List<SimDescription> arrayList = new List<SimDescription>();
            for (int i = 0; i < SimDescriptions.Count; i++)
            {
                ResourceKeyContentCategory resourceKeyContentCategory = ResourceKeyContentCategory.kInstalled;
                SimDescription simDescription = CASLogic.Instance.LoadSimDescription(SimDescriptions[i], ref resourceKeyContentCategory);

                if(simDescription == null) { continue; }
                SimDescription CopiedDescription = simDescription;
                // Do coding magic here....
           }



However, if this returns null, you probably will have to import them and try again: https://github.com/Lyralei1/RPGMana...nagerRPG.cs#L24

Make sure to either only import the sims you need, or either all of them. Simply loop through: BinModel.Singleton.mExportBin,

Code:

                        bool flag = content.IsLoaded();
                        if (!flag && !mHasDoneHouseholdDownload)
                        {
                            content.Import(false);
                        }




I do need to add that I'm still working out some weird bugs, like for example, you can't double import a household (household here is also simply one sim). Otherwise your list will be empty, despite it being already imported. Not sure if that's an EA side issue or me, but I'll have to check that myself :p


I know it's not much, but hopefully this helps! Went through quite a lot of sweat, tears and pain to get this even to remotely work lol... it's still hacky as hell but it's something!
Scholar
Original Poster
#7 Old 3rd Jan 2023 at 5:02 PM
@Lyralei Thank you. I am basically trying to make a clone of a bin sim. Trying to make summoning/conjuration magic happen in Sims 3.

I am still really confused though lol. But I think by studying your code it will give me an idea.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#8 Old 3rd Jan 2023 at 5:48 PM
Quote: Originally posted by Lyralei
I've done something similair for the RPG manager, and Bin sims are a whole other beast

I'm not sure what type of info you'd like to gather from them, but bin sims only contain the bare basics. With that I mean: Gender, name, traits, zodiac signs, what clothing they're wearing (including hair/makeup). So anything you can select inside CAS basically.


To get the descriptions, this is how I did it: https://github.com/Lyralei1/RPGMana...agerRPG.cs#L216


The most important part of this is:


I do need to add that I'm still working out some weird bugs, like for example, you can't double import a household (household here is also simply one sim). Otherwise your list will be empty, despite it being already imported. Not sure if that's an EA side issue or me, but I'll have to check that myself :p


I know it's not much, but hopefully this helps! Went through quite a lot of sweat, tears and pain to get this even to remotely work lol... it's still hacky as hell but it's something!


Interesting when i tried something similar:




i always needed to recreate the outfits is that different for you @Lyralei ?
Scholar
Original Poster
#9 Old 4th Jan 2023 at 11:56 AM
Hey so what is wrong with this code?
Code:
SimDescription simDescription = GeneticsPet.MakeRandomPet(CASAgeGenderFlags.Adult, Actor.SimDescription.Gender, CASAgeGenderFlags.Cat);

                Sim sim = simDescription.Instantiate(Vector3.Empty);
                

                if (sim != null)
                {
                    
                    Actor.Household.Add(sim.SimDescription);
                    InteractionInstance entry = BeenSummoned.Singleton.CreateInstance(Actor, sim, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), false, false);
                    sim.InteractionQueue.AddNext(entry);
                }
It's not working. What am I doing wrong?

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#10 Old 4th Jan 2023 at 12:52 PM Last edited by Battery : 4th Jan 2023 at 1:05 PM.
Do you have an Error message for that ?

if not heres a full run method, my assumption would be that you need to add it to some household before instantiation

Virtual gardener
staff: administrator
#11 Old 4th Jan 2023 at 1:55 PM
I think using Battery's line (rather than what i'm doing, which is getting ALLL the bin sims, including the one on the world screen) may be better in your case

(This line I mean: )

Code:
					SimDescription simDescription = CASLogicSingleton.LoadSimDescription(CASLogicSingleton.SimDescriptions[i], ref category);



There are a few problems though with the code logistically:

- Indeed, the description cannot be empty. So make sure to check for null references there, just in case. (also because it makes debugging easier)
- As battery said, the sim should be in a household. Even if it's the NPC household for the moment (or one you create specifically temporarily, through code). Otherwise, the cleanup code will nuke your sim immediately.
- You're currently creating the sim off-screen. While we, the player, see the world edges, the world itself is actually a bit bigger than what we see. The Vector3.Empty (also known as Vector3.Zero) in this case is basically under the terrain and completely away from the terrain.
- Because your sim is being instantiated off-screen, it finds itself possibly either getting destroyed by nraas (the game does this too, but on a later date, Nraas is just more consistent there). OR, the interaction is failing because something inside the generic interaction checking has gone wrong (meaning, not your own Test() function, but the one EA has set in place for bare basic checking, such as if the sim is in the world, inside a household).



Quote:
i always needed to recreate the outfits is that different for you @Lyralei ?


Technically, I didn't really have to deal with that for the RPG manager itself (since all I did was change the money value for the household), but I have had to do that in the past. That's probably because a lot of that data is covered inside the Sim class.

Because, something to remember is that the SimDescription === the sim's brain. the Sim class === the physical being of said sim.

That's why NPCs (maids, repairman, etc) for example, keep switching from ghosty (I guess with my logic, brainy but bodyless) beings. And therefore need to have their entire beings re-instantiated once they re-visit the world.



Also! I was thinking, it may be worth checking how Bonehilda is being spawned in. That's how I figured out how to instantiate sims
Scholar
Original Poster
#12 Old 4th Jan 2023 at 4:35 PM
Thank you both for your suggestions. Currently I am not copying from Bin but trying to create a totally random Sim. I will try copying a Bin Sim later.

I thought simply doing this
SimDescription simDescription = GeneticsPet.MakeRandomPet(CASAgeGenderFlags.Adult, Actor.SimDescription.Gender, CASAgeGenderFlags.Cat);
will create a randomized cat sim description. But I guess that was just wishful thinking and the actual process is a lot more complicated. I am going to keep researching and working on it.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Scholar
Original Poster
#13 Old 4th Jan 2023 at 5:35 PM
OMG it's working. My cat spawned in. @Lyralei @Battery



How can I add to NPC household instead of Actor Sim's household?
And is there a way to permanently invite a Sim into your household? The summoned sim will only be here temporarily tbf (moodlet based)but I wanted to know if I can have like many minon summoned spirits that aren't part of the household. Kinda like Bonehilda.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#14 Old 4th Jan 2023 at 5:50 PM
Quote: Originally posted by PuddingFace
OMG it's working. My cat spawned in. @Lyralei @Battery



How can I add to NPC household instead of Actor Sim's household?

Code:
Household.NpcHousehold.Add(YourSim);


Also you could look into the roommate code if thats the direction you wanted to go .
Scholar
Original Poster
#15 Old 4th Jan 2023 at 5:59 PM
Thank you Battery.
I will look into roommate code.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Virtual gardener
staff: administrator
#16 Old 6th Jan 2023 at 7:36 PM
Yay! Good to see it work :D

Quote: Originally posted by Battery
Code:
Household.NpcHousehold.Add(YourSim);


Also you could look into the roommate code if thats the direction you wanted to go .


Quick note though on that! Some people may have roommates turned as an option in their save (In fact I believe it's even a thing in Nraas' settings). So then nothing basically happens. I wouldn't rely on it... I made that mistake with the randomizer mod lol... just to save you the bug reports.
Scholar
Original Poster
#17 Old 25th Jan 2023 at 6:20 PM
@Lyralei and @Battery
I am also interested in changing skin tone and outfit of a spawned Sim. How do I find out ID of skin tone? Like Red Skin that came with Supernatural for eg. And the Buisness Suit and Tie Outfit or Butler outfit from Late Night.
I'm going to do more research on it.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#18 Old 25th Jan 2023 at 10:01 PM
Quote: Originally posted by PuddingFace
@Lyralei and @Battery
I am also interested in changing skin tone and outfit of a spawned Sim. How do I find out ID of skin tone? Like Red Skin that came with Supernatural for eg. And the Buisness Suit and Tie Outfit or Butler outfit from Late Night.
I'm going to do more research on it.



I am currently working of an update of the utility mod. these methods could be implemented without much trouble since they are already used as part of other already existing methods, so if using the utility is still an option for you let me know and i can speed up the process to a release within the next few days

You can use the simbuilder to set the outfit of an sim and then access the SkinTone property to get the reskey (the id you have been asking for)
you can change that in the same process. To change the SkinToneIndex you can use the very same method but use the SkinToneIndex property instead.
Scholar
Original Poster
#19 Old 27th Jan 2023 at 9:38 AM
Cool yea Script Utility would be cool. This is for my Enhanced Witches mod which already uses it. reskey? Ok I will look at it.

Thank you so much for replying.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#20 Old 27th Jan 2023 at 3:52 PM
Quote: Originally posted by PuddingFace
Cool yea Script Utility would be cool. This is for my Enhanced Witches mod which already uses it. reskey? Ok I will look at it.

Thank you so much for replying.



Hi PuddingFace, i have attached a new version of the utility mod

Unfortunately ive broken every other mod in the process since i changed the namespace from Battery to Battery.Utility i will keep the old version up but if you want to take the oportunity while working on your mod to update this could save you some headaches.
I know this is a inconvenience, so if yo need help with anything let me know

Here are the Methods you might be interested in

Get a list of all installed skins


Set Skintoneindex for Sim


Set Skintoneindex for Sim as addin for Simbuilder process
Attached files:
File Type: 7z  Battery_Utility_1.041.package.7z (767.3 KB, 0 downloads)
Scholar
Original Poster
#21 Old 1st Feb 2023 at 11:41 AM
Excellent. Will have to try this out.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Scholar
Original Poster
#22 Old 12th Mar 2023 at 4:56 PM
Hi @Battery @Lyralei I have come back to this I already added animal familiar summoning in the previous update. And now I am looking to make Demon Summoning. So Make human Sim summons.

I plan on using Genetics.MakeSim instead of GeneticsPet.MakePet

Specificially, this method:

MakeSim(SimBuilder builder, CASAgeGenderFlags age, CASAgeGenderFlags gender, ResourceKey skinTone, float skinToneIndex, Color[] hairColors, WorldName homeWorld, uint outfitCategoriesToBuild, bool isAlien)

My main issue is ResourceKey skinTone, float skinToneIndex, Color[] hairColors and uint outfitCategoriesToBuild. Like how do I find out what to put in those spaces? S3oc?

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#23 Old 12th Mar 2023 at 5:08 PM
Quote: Originally posted by PuddingFace
Hi @Battery @Lyralei I have come back to this I already added animal familiar summoning in the previous update. And now I am looking to make Demon Summoning. So Make human Sim summons.

I plan on using Genetics.MakeSim instead of GeneticsPet.MakePet

Specificially, this method:

MakeSim(SimBuilder builder, CASAgeGenderFlags age, CASAgeGenderFlags gender, ResourceKey skinTone, float skinToneIndex, Color[] hairColors, WorldName homeWorld, uint outfitCategoriesToBuild, bool isAlien)

My main issue is ResourceKey skinTone, float skinToneIndex, Color[] hairColors and uint outfitCategoriesToBuild. Like how do I find out what to put in those spaces? S3oc?


Well i would create a sim that just looks like the demon you want to create and then look at its data.
Scholar
Original Poster
#24 Old 12th Mar 2023 at 5:59 PM
Ah ok thank you! I will try this.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Space Pony
#25 Old 13th Mar 2023 at 8:01 PM
Quote: Originally posted by PuddingFace
Ah ok thank you! I will try this.


in case you were unsure what to put into the color array heres the decoding:

indexHairType
0-3Main Hair
4Eyebrow
5-8Facial Hairs
9Body Hair


for the outfitCategoriesToBuild just put in the outfitcategories you want to use like (uint)(OutfitCategories.Naked|OutfitCategories.Everyday|OutfitCategories.Formalwear|OutfitCategories.Sleepwear ) etc
Page 1 of 2
Back to top