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 29th Nov 2014 at 12:22 PM
Scripting to add behavior - can someone hlep
Hi everyone

I'm a mediocre (c#) developer and I thought that it should be possible to add some behavior for Sims by scripting.

My problem is, I don't know where to start. I've seen the pyton tutorials, which don't really cover what I'd need to know (they cover things like adding a new menu command).

What I'm thinking of is adding some behavior for a Sim when he encounters another Sim wearing a specific piece of clothing (like party or formal). Or when he sees another Sim doing an interaction like swimming in a pool. That sort of thing.

Has someone got a clue how to go about this or could you direct me to a tutorial that does this sort of thing?

Thanks
Advertisement
Deceased
#2 Old 13th Dec 2014 at 4:45 AM
Quote: Originally posted by Gardan
I'm a mediocre (c#) developer and I thought that it should be possible to add some behavior for Sims by scripting.

What I'm thinking of is adding some behavior for a Sim when he encounters another Sim wearing a specific piece of clothing (like party or formal). Or when he sees another Sim doing an interaction like swimming in a pool. That sort of thing.

Has someone got a clue how to go about this or could you direct me to a tutorial that does this sort of thing?


These kinds of things would be extremely hard to accomplish through scripting, but could be done by adding broadcasts to the actions you want other sims to react to. A broadcaster does just what it sounds like it would do, broadcasts something to other sims in range and can be used to trigger an interaction, or buff, etc. What follows is way shy of an actual tutorial, but since you're familiar with coding I imagine you can probably follow it. You'll want to get the Custom Content Guide to reference the various XML tuning descriptions to get a complete understanding.

Get the XML Extractor, extract all the XML files and look at the ones in the broadcaster folder for examples. For instance, the file S4_DEBAFB73_00000000_00000000000185DF contains the broadcaster that controls sims reacting to a streaking sim.

It starts out with the contraints on who receives the broadcast, those in a line of sight within a range of 300. Following that are the effects, which in this case pushes an affordance #99812 on the receiving sims. That affordance is the interaction that the receiving sim will perform, called "reactions_streaking" which is in S4_E882D22F_00000000_00000000000185E4 (185E4 is 99812 in hex) in the interaction folder of the XML. This interaction then makes the sim react in astonishment, gives them a thought balloon, and so forth.

The broadcaster #99807 (again, that's just 185DF in decimal) is triggered as active around a sim performing the "sim_streak_around" interaction from S4_E882D22F_00000000_0000000000018365.

So, in short, the streaking interaction sets the broadcaster around the streaker, which is then checked against all sims within the constraints of the broadcast and those sims that meet the constraint then perform the reaction interaction.

To add reactions then, you just need to do the same sort of thing - add a new broadcaster, trigger that broadcaster from some existing interaction - for example the swimming idea you had, and finally create the reaction interaction. Simple!

Well, okay, maybe not really simple. It is a lot of work, especially creating the new reaction interaction. But you can use the reactions already existing in the game as templates for your work.

Hope this helps! Should at least point you in the right direction.
Test Subject
Original Poster
#3 Old 13th Dec 2014 at 10:11 AM
Thank you, I think I get the concept behind your description.

I'll have to figure out how Sims get a broadcaster in the first place. I think I've seen examples for broadcasters for interactions, however I wonder if I put a broadcaster on "Change clothes" that I can check what kind of clothing the sim dons, to give them the appropriate broadcaster. I'll scour through the files once again.

Thanks!
Back to top