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!
Test Subject
Original Poster
#1 Old 15th May 2012 at 2:47 PM
Default Best scripting way to detect a new sim
I've been trying to make a sim customizer mod that will randomize any plain, zeroed-out aspects of a seem upon their creation. I was using kSimInstantiated, but that event doesn't fire when a sim is created, and fires every time a sim is brought into the game world. This causes the code to fire every time a sim is instantiated (rather just have it go the once) and does not catch townies that haven't been witnessed by active sims.

I know the method I want to watch/alter is Sims3.Gameplay.CAS.Genetics.MakeSim but there is no event fired by it. Is there any way to add an event to a method or any EventType that would serve my purpose?

I'll keep at it, and I'll report if I find it myself.
Advertisement
1978 gallons of pancake batter
#2 Old 15th May 2012 at 4:53 PM
You could store the SimDescriptionId of every sim in a list on startup and then everytime a sim got instantiated check whether they're in the list or not.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
Original Poster
#3 Old 15th May 2012 at 5:02 PM
Quote: Originally posted by Buzzler
You could store the SimDescriptionId of every sim in a list on startup and then everytime a sim got instantiated check whether they're in the list or not.


Thanks for that. I was thinking of something like that (actually I was thinking of adding a boolean to each sim) but I wasn't sure how to do either (my c# muscles are weak from lack of use). How would I make a list persistent for gameplay, or are they by default? I should be able to sort that out, I guess.

I'd still love to hook that MakeSim event, but without a core mod, the method doesn't throw an event. If that's the case is there no way to listen for it?
1978 gallons of pancake batter
#4 Old 15th May 2012 at 5:15 PM
Well, personally I'd just recreate the list every time a world was loaded. There is no actual reason why it should survive save&reload, is there? In general, non-static fields are persistable by default if it's built-in stuff (int, float, List, Dictionary etc.) or if the respective class was declarated with the [Persistable] attribute and has a parameterless constructor. So a non-static List<ulong> would persist by default.

If you want static fields to be persistable, you need to add [assembly: PersistableStatic] to your project's AssemblyInfo.cs and add the [PersistableStatic] attribute to the respective field. You need to nullify that when the world quits to the main menu, though. If you don't do that, the data from the savegame won't be assigned.


And yes, if something happens "quietly", there's no way to catch it without actively looking for it.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
Original Poster
#5 Old 15th May 2012 at 7:02 PM
Thanks for your input on this Buzzler! I am hesitant to use a list as I can forsee a few problems. Testing has shown me that sims get created and instantiated all the time and the two never seem to coincide. A list of properly randomized sims created at load/startup would not catch unrandomized sims that hadn't been instantiated yet.

I think it would be better to mark a sim as having been randomized or having non-zero values already. This would allow for a simple boolean check of each sim as its instantiated to determine whether it needs to be checked/randomized and it wouldn't run on a sim twice.

The problem I have, though is how to mark a sim as checked/randomized. I've thought about adding an unhandled facialblend to the SimDescription, but that would have a chance of being inherited. I cannot think of another persistent method of marking a sim that wouldn't garble game-play or run the risk of being reset by the game.

SimFlags looks interesting, but I can't figure how to make a custom flag as yet...
1978 gallons of pancake batter
#6 Old 15th May 2012 at 7:22 PM
Well, I actually suggested to store the SimDescriptionId which belongs to the SimDescription. Whether or not the related Sim existed at the time, wouldn't matter that way and all SimDescription that already existed when the world was loaded would basically be blacklisted. You'd still have to implement sanity checks to detect "naturally born" sims, though.

A cleaner way would be to actually detect sims with default faces. I didn't investigate that, but that should be possible as well. That way you wouldn't need any persistent data at all.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
Original Poster
#7 Old 15th May 2012 at 7:32 PM
Detecting Sims with defaults is how I'm implementing it now. The problems there is the mod also deals with fitness, fatness, bust, muscle definition, 0 traits and potentially freckles, body hair, beards etc.

If I check for zeroed faces only I could end up overwriting a purposefully zeroed character. If I check each item separately, checking for all zeroes, I'll miss the sims that the game actually did make fat/thin.

The way I was going to go was to check each section individually, but then I compound the risk of overwriting purposefully zeroed or empty sections of a sim's description. I don't think it's likely that a person would leave a sim zeroed out, but I would hate for someone to be surprised when a sim they created shows up fat with body hair and freckles because they had specified 50% thin/fatness and 0% fitness should I ever publish the mod.
Back to top