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
retired moderator
#126 Old 25th Feb 2008 at 6:07 PM Last edited by Grapholina : 25th Feb 2008 at 8:43 PM.
Default I have a problem
Hi!

Edited: Nevermind. I found the problem and was able to correct it on my own. Woo Hoo!!

You gotta have faith . . .
www.Grapholina.com
Advertisement
Lab Assistant
#127 Old 8th Mar 2008 at 1:34 PM
I have a question and if it's been answered elsewhere, please feel free to toss me in the right direction.
I am trying to add either a thought or talk bubble to a custom interaction with a woohoo icon in it. I know how to add either bubble but have no clue when it comes to the bhav parameters.

Once the can is open - The worms are free!
Test Subject
#128 Old 26th May 2008 at 8:53 PM
Hi,

I am new to Sims2 and modding the game, but have a question I hope some of you could help me with.

I have a lot with two sims: Father and Son. I to create a BHAV in which, if the Son invokes the BHAV, the fun motive of the Father increases and then the Father does an animation (whatever animation it is).

In other words, when the Son does something (click on a pie menu), it effects the Father sim, and not the Son.

I was able to accomplish most of the above BHAV, but not all of it. I was able to get the Father’s fun motive to increase, but I was not able to have an animation run on the Father (instead, the animation always runs on the Son).

I am able to get the motive of the Father to increase by switching the Stack Object to that of the father (which makes sense)

However, when I go into the SimPE wizzard for sim animation, it seems like it should be pretty easy to have the Father sim be animated (since he is already on the Stack Object). But, every combination I attempt still results in the Son being animated (remember the Son was the sim who originally invoked the BHAV).

Any ideas? Thanks,

-Adam
The ModFather
retired moderator
Original Poster
#129 Old 26th May 2008 at 11:23 PM
It seems that you have done everything correctly...
However, the "Animate Sim" function operates on the sim currently selected as Stack Object only if in the wizard the "IK Target" is set to Stack Object ID 0x0000.

Also, be sure that nothing changes the stack object between the moment the Father's motives are increased and the moment when you try to animate the Father.

If you want me to take a look at the code, post the package here.

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
Test Subject
#130 Old 27th May 2008 at 3:49 PM
Numenor,

Thanks for your quick reply. I just got sims2 a few weeks ago, and I am a programmer, so I thought I would take a stab at some modding.

I have uploaded my package file. The BHAV is called, "Make Elder Happy."

Perhaps you could suggest some commands for the arguments of the AnimateSim (Line 0B) primitive to make it accomplish its goal of animating the Father.

Here are some of my major lines of code and what I want them to do. Everything works as I expect until Line0B (which currently is just set to my last test, not anything particular).

Line 03 - loop through each person, place on stack object
Line 05 - print each persons Object Id for debugging purposes
Line 06 - if the persons age is greater than 50 (thus he is the Father)
Line 07 - print yep! - another debug command
Line 08 - max that person’s fun motive
Line09 - store some variables (deprecated line)
Line0A- Have the Son walk to the Father (this works)
Line0B- Father whooping in thanksgiving for the Son increasing his fun value (does not work)

Suggestions are welcome!

Thanks,

-Adam
Attached files:
File Type: rar  AdamHackedPainting.rar (80.8 KB, 12 downloads) - View custom content
The ModFather
retired moderator
Original Poster
#131 Old 28th May 2008 at 12:19 AM
Uhm... I think I've told you some inaccurate info...

The "IK Target" is the object (and I mean really "object", not sim) that the animated sim needs interacting with. For example, when a sim opens the oven lid, the oven is the IK target. In case you are curious, IK stands for Inverse Kinematics, and is an invisible point contained in an object mesh that the sim needs to reach in order to perform the animation. In this example, the IK point is the oven handle: if you move the mesh of the oven vertically or horizontally, the hand of the sim will always try to reach the IK point before performing the "open lid" animation.

Apart from the theoretical facts I was wrong when I said that setting the IK target to the Stack Object (the Elder) forces the Elder to be animated: the truth is that the only sim affected by the "Animate Sim" is the one that is currently performing the interaction. And after all it can't be different! In this case, we can't know what is doing the Elder when the young sim "operates" the picture: the Elder may be swimming, or sleeping, or making a shower... Performing a happy animation means checking the current interaction of the elder, stop it (if possible), make him face the youngster and lastly perform the animation.
Therefore, the simplest solution I can think of is a "Push Interaction".

It works this way:

1) the youngster selects the "Make Elder Happy" from the picture, the BHAV searches for an elder, boosts his fun and forces the youngster to move in front of the elder.

2) the BHAV is concluded by a line that forces (pushes) the elder to choose a different interaction from the painting: a hidden interaction (something like "Interaction - Animate Elder") that contains an "Animate Sim" line.

The "Push Interaction" function requires you to pass some values:
- who is the sim pushed to run the interaction
- what is the object whose TTAB contains the interaction
- the line in the TTAB that contains the interaction to be performed.

Pushing a sim to choose an interaction from an object has the very same effects of selecting the sim and clicking on the object manually: only, the user doesn't need to do anything, it's everything automatic.

I hope to have given you enough information to let you explore how the "Push Interaction" works: the lesson would be very long if I had to tell you every single bit of info about this but you seem to be a modder that can walk with his own legs, so to speak


PS: there are many BHAVs in the game that use the Push Interaction; but if you want a simpler exaple, look into my "ZX Spectrum": when a sim deletes the program created by another sim, this action causes a reaction obtained by a Push Interaction.

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
Test Subject
#132 Old 28th May 2008 at 3:11 PM
Numenor and all,

Cool, that makes sense about the push command. I had not heard of that command, but that seems like it should work. I will look into that. We will see if I can walk yet!

Perhaps you could give me another conceptual answer (I am not looking for the exact details, but just a conceptual response would be great)…

Is there any way to have a behavior automatically invoked based on a timer?

For example, lets say that there is a bottle of pills in the room. Every three hours (lets say), a behavior of the pills is automatically invoked that lowers the motives of the Elder. However, if the Elder “takes” a pill, it restarts the three hour clock.

Wow there is a lot here. And I know this is probably way complicated (I like challenges).

But, I guess the first question is simply: can behaviors be automatically “pushed” on a sort of timer? Any ideas?

Anyway, I am just getting into to Sims2 and find it to be a lot of fun, and a cool way to do some AI type scripting.

Thanks again!

-Adam
The ModFather
retired moderator
Original Poster
#133 Old 28th May 2008 at 4:11 PM Last edited by Numenor : 28th May 2008 at 4:17 PM.
Yes, pushed interactions can be automated on a timed basis.
Of course if you embed a timer into an object (the pills), the timed "push interaction" will occur only if the pills are on the lot: if you delete them, no more interactions -

That said, there are at least two methods to simulate a timed action.
A) The first method is exactly what you ask for: a timer; but if I remember well the timer functions have been implemented in the game with some EP, they were not included in the base game; therefore, the object will not be compatible with all the games, but it will require that EP. At the moment I can't be more precise, because I can't check the game files, so I'll write about it later on.

B) This second method is simpler and it's perfectly compatible with the base game.
The "Function - Main" of the pills should include a check (performed via a "0x0002 Expression" opcode) for the hour of the day, that is a Global Variable.
It should look like this:

1 - Global (Hour) == 0? If true, goto 9; if false goto 2
2 - Global (Hour) == 3? If true, goto 9; if false goto 3
3 - Global (Hour) == 6? If true, goto 9; if false goto 4
4 - Global (Hour) == 9? If true, goto 9; if false goto 5
5 - Global (Hour) == 12? If true, goto 9; if false goto 6
6 - Global (Hour) == 15? If true, goto 9; if false goto 7
7 - Global (Hour) == 18? If true, goto 9; if false goto 8
8 - Global (Hour) == 21? If true, goto 9; if false goto 1 (thus restarting the loop)
9 - (search for elder, lower his motives and then idle for 1 hour to prevent multiple executions in the same hour)

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
Test Subject
#134 Old 29th May 2008 at 8:55 PM
Numenor,

I checked out your ZX Spectrum, and it was very helpful in figuring out the Push Interaction. BTW, great object, I hope to study it more.

Also, I was able to figure out how to use the main() function to make the Elder sick if he does not take a pill by a certain time (thanks for the pointers).

I was trying to think of a way to determine if the Elder had already taken the pill or not (because I do not want to make him sick if he did take the pill). To accomplish this, I used manage inventory to place an item in the Elder’s inventory (in this case a water bottle)… and if this item is found in the inventory, then he will not get sick a the appointed time. I am sure there is a better way to do this, but I have a limited bag of tricks right now.

Thanks again.

-Adam
The ModFather
retired moderator
Original Poster
#135 Old 30th May 2008 at 1:40 PM
Usually the game uses the "tokens" instead of a real object, but the method used is the same: putting something (the token) in the inventory. Therefore, "bravo!" for having found by yourself the right solution

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
Test Subject
#136 Old 9th Jun 2008 at 8:31 PM
Numenor and all,

Thanks again for all your help. I have a couple more conceptual questions you might be able to help me with.

[1] In the game, the sims automatically gravitate towards certain things when a motive reaches a level. For example, they go to the bed when they are tired, or they eat when they are hungry. I assume we can do something similar with our own objects? When they reach a threshold of a motive, they automatically gravitate towards a behavior of an object. I know I could probably handle this with a main() timer loop that checks motives, but is there any way to add that functionality at a higher level within the object: say link it up with a particular motive (or a combination of motives)?

[2] I see in the game that there are services like housekeeping. A person comes over and does a particular task. Is it possible to do a new type of service? I’ll just make something up here: a sim that shows up, does a particular behavior, and then leaves?

Thanks,

-Adam
The ModFather
retired moderator
Original Poster
#137 Old 9th Jun 2008 at 9:50 PM
[1] This is simple: in the TTAB, you can set the motives that will "attract" the sim toward a specific interaction. I mean, this is not a "per object" setting, but a "per interaction" one.

For example, let's say that your object has two interactions: "View" (supposed to give fun) and "Use" (supposed to give social); for the first interaction, you should set the "Fun" motive in the TTAB to a non-zero value; for the "Use" interaction, set a non-zero value for the "Social" motive.
As a result, the sims in need of fun will "View" the object and the sims in need of Social will "Use" it. You only have to tweak carefully the level of Motives set in the TTAB, so to avoid sims to become "addicted" to the object, or ignore it.


[2]Custom NPC's are definitely possible. Echo has created some of them, if I remember well (for sure, she created a Easter Bunny): I suggest you to download and examine it to understand how custom NPC work; in few words, the "magic" is performed by the "Function - Main" BHAV the you write for that NPC: this BHAV will instruct the NPC to perform what you want.

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
Retired Duck
retired moderator
#138 Old 10th Jun 2008 at 5:35 AM
As an interesting side note...

[1] The 'attraction' you're talking about is called 'advertising'. The object 'advertises' all the motives that it thinks it's good at filling, and the sim makes a judgement based on all the available advertisements. The TTAB lets you specify a fixed attraction for different age groups etc, but if you want to do something a bit clever you can actually change the advertising on the fly in the guard function. For example, if you look at the guard code on a bed, it checks if the sim's sleep need is less than a certain threshold (25% or something). If it isn't, then the sleep advertising level is really low. If it is, its sleep advertising level is quite high. That's why sims won't autonomously sleep in a bed until they're really quite tired - if the code wasn't there to adjust the advertising on a per-sim basis, the sims would want to go to sleep every time their sleep need dipped below all their other needs.

[2] There are two types of NPCs in the game - Unique NPCs and Templated NPCs.

The kind you mention, the maids and the gardeners and the repairmen and the like are templated. That means that the game has a template for these sims - what they wear, how old they are, what gender they should be - and when you need one in the game it generates a sim according to that template. Templated NPCs can be moved in, married, made controllable, all of the above, because they're basically just regular sims with some special code added in. If a templated NPC moves in and becomes controllable, the game can just generate a new NPC according to the template to take their place. Templated NPCs are, essentially, unclonable. (That's not strictly true of course, anything is clonable with enough determination, but doing so here would either require extensive global hacks which would need to be different for every EP, or an enormous amount of global file importing and changing. It's a pretty spectacularly nasty hack to try and do).

The other kind is unique NPCs. These include the Grim Reaper, Mrs Crumplebottom and the Hula Zombie girls, amongst others. These are definitely cloneable, and I have done so several times now. They are mostly self-contained as packages, so if you want a cloneable base package you're welcome to hack apart the Easter Bunny or the Carnival clowns under my profile. They're not *simple* by any means, and you have to do a fair amount of homework regarding the structure of bodyshop files as well as the obvious object knowledge, but they're definitely possible.

To get them to show up on the lot though, you need to place an object on the lot which will create them (although it can be an out-of-world controller object if you want it to happen more spontaneously). You won't be able to make them controllable, they won't be marryable, and they will always look, sound, and be named exactly the same thing, since they are unique. But they are still NPCs.
Test Subject
#139 Old 10th Jun 2008 at 6:45 PM
Numenor, Echo and Everyone,

Thanks again for your suggestions. I loaded up the Bunny and the clown. Cool stuff. I was able to make the bunny do some different things by editing the behaviors. This will be a great starting place for me.

But, I want to make the Bunny look different. As I said, I am trying to make a new service NPC, and it would be cool if I could make her dress the role (in this case a nurse). So, I saw that I could change the outfit of the Bunny with some of the Sims2 preset outfits (this worked fine), and then of course without any outfit she just looks like Hula Girl. But, how do I put different clothes on her?

For example, I have a Sim that I dressed up, and I want to make the Bunny have that outfit (or import the Bunny’s behavior data into my Sim, whichever is easier).

I thought I could just load up Echo’s Bunny into Body Shop, and change the base clothes (so she would not be hula). However, Body shop was not finding echo’s bunny NPC package when I put it in my “SavedSims” directory (perhaps Body shop is not able to load such a package, or maybe this is the wrong way to load it into Body Shop). -- My idea was to load her into body shop, clone her, change clothes, and then re-link the crest to the clone’s new guid.

I also saw that there are some tutorials on how we can change the clothes of the NPC townies, maids and such. However, I am not trying to change any archetypes, instead I am just trying to change the clothes on this unique NPC Sim (or will the method in those tutorials work for me also?)

So, again, if you have any conceptual answers on how I can change the base clothes of the Bunny so she is no longer wearing a Hula outfit, that would be great.

Thanks,

-Adam
Retired Duck
retired moderator
#140 Old 10th Jun 2008 at 11:48 PM
That's... er.... because when I made the bunny I did it wrong. Actually, I just didn't know how I was supposed to do it with the bunny, and I only figured it out when I was making the clown.

Basically, what you have to do is pull out all of the bodyshop files from the existing NPC package, export a sim from bodyshop who looks like what you want, then import those files from that exported sim into the NPC package. You have to tweak a couple of the group and instance numbers so that they match the originals though - the ones at the top of the bodyshop scenegraph. I can't remember exactly which ones they were that I had to change, although I could probably figure it out again looking at the clowns. (They're exactly the same object, just different GUIDs and different bodyshop files). My memory says it was the ones which had really low instance IDs - 0 or 1 or 2...

The clowns are actually better templates than the bunny, because the bunny was an early NPC prototype whereas I actually had some idea of what I was doing by the time I made the clowns. The only thing they don't have is a default locomotion (since they don't walk around!) but you can copy that line from the bunny's init.
Test Subject
#141 Old 11th Jun 2008 at 2:46 AM
Hi,

Echo, I followed your instructions. Like magic, I now have my own Sim juggling and making a fool of herself on the podium. I just imported everything from the body shop clone into your male clown, and it worked. I did not need to change anything in the scene graph (actually I really don’t know what the scene graph is in this context, but I am fine with that because it worked, well at least my Sim is acting like your clown, which is all I wanted for a start).

Now comes the fun! - adding behaviors to my new NPC.

Thanks again!!

-Adam
Retired Duck
retired moderator
#142 Old 11th Jun 2008 at 2:57 AM
Yay! Excellent news, and very fast too!
Test Subject
#143 Old 19th Jun 2008 at 8:52 PM
Hi all,

Some more questions. I am working on an object in which I want to change custom states attached to any sim. By custom state, I mean that I want to add a new “motive like” state to a Sim that can go up and down depending on how the sim interacts with objects. For example, there could a be new state called “silly” attached to a sim - interactions with objects could move the value of silly up or down (and I could use this “silly” state to effect how the sim interacts with other objects).

So, I am trying to create the custom “silly” stat by simply adding items to the inventory. If an item is in the inventory, then the person is “silly”, else the person is not. I currently know how to do this, by hiding tokens in the inventory.

However, I am not looking for an on/off value, but it would be nice to have a range of possible values of the state. In other words, a silly value of 100 would be higher than a silly value of 20.

I could accomplish this by just changing the count of the token in the inventory. If I have a count of 100 silly objects, then this would be more silly than a count of 10.

Unfortunately, I can not get the counting to work correctly. I am using the wizard, but it is not giving me the results I expect. I am trying to increment the count by a literal, subtract the count by a literal, and save the count into a local.

So, I have posted a test object which is a cloned sunflower, which attempts to add/subtract/count tokens of sunflowers in the inventory (after many tries the behavior functions might be a bit mangled and they do have some test dialogs that pop up with variable values... but you should get the idea). If you have any suggestions, please let me know.

Thanks,

-Adam
Attached files:
File Type: rar  sunflowerCounter.rar (88.0 KB, 6 downloads) - View custom content
Retired Duck
retired moderator
#144 Old 20th Jun 2008 at 12:12 AM
What you're after is a "counting token", not a way of counting multiple tokens. Confusing, nay? A counting token is one that actually has a stack (in the push/pull sense) of numbers in it which you can read or update as you wish.

One of the best examples of counting tokens in-game is the toddler skill token. It's assigned to toddlers, and stores three values in it - walking, talking and potty training skill. They start at zero, then count up to 100 as the toddlers do the learning activities.

If you don't fancy trying to track down the relevant code for that in all the in-game objects, you can check out the magic skill and cauldron/spell books here:
http://www.modthesims2.com/showthread.php?t=145882
and the wand which shares the skill code here:
http://www.modthesims2.com/showthread.php?t=258224

The code in these basically took all the relevant parts of the toddler skill token, and extracted them to be mostly generic. You can pretty much copy all the "Magic - *" BHAVs from the wand files, update the GUIDs to refer to a new token of your creation, then use them as-is for any other custom-skill (or custom motive in this case) object.
Test Subject
#145 Old 20th Jun 2008 at 11:48 PM
Hi,

Echo thanks again. Your suggestion worked like a charm, quite literaly. I was able to create a new counting token and GUID, and keep track of custom states.
Test Subject
#146 Old 17th Jul 2008 at 10:05 PM
Hi,

Quick question regarding the overhead meter. I currently have a meter that hovers over a sim, that is tracking a custom state (this works fine). But then if the sim goes and does something like working out, then my meter will disappear after the work out (which is not entirely unexpected).

I want to find a way to always keep my little meter above my sim, or to have it pop back up after working out (and similar actions).

I was thinking that I could insert into an object's main loop to just pop up the meter if it has disappeared. But, how do I check if a meter is already up? I could not find a command for that. Because, with the command I am using (Global 186 - OverheadMeter track Custom), it seems to toggle to meter on and off (so this would not be very useful, because it would be appearing, and then disappearing).

So, is there an overhead meter command that will make the overhead meter appear (but not disappear if it is already up?)... or is there simply a way to check if a meter is already up?

Thanks,

-Adam
Test Subject
#147 Old 24th Jul 2008 at 6:16 PM
hi,

I did find a solution to my previous post. In a loop, run the update meter function, if it launches a false, then the meter is not up, and it can be placed back up with a track custom meter function. Else, the meter is already up and there are no worries. -Adam
Test Subject
#148 Old 10th Sep 2008 at 10:48 AM
Just a quick question i have read the above information and am still struggling. I want to make a mod that when a visitor, npc ect decides to leave family sims can stall them and even make thhem spend the night.

I have noticed when they are leaving you cant interact with them and i am unsure of how to change this can anyone help.

Thanks
Joe
Retired Duck
retired moderator
#149 Old 10th Sep 2008 at 11:21 AM
I'm pretty sure that's in the core sim BHAVs - they become unselectable and pretty close to unstoppable so that they don't get stuck on the lot accidentally. Take a look in (I think it's called) the Person object.

You'd have to make it as a global hack if you want this to work, and that's code which gets changed pretty much every EP so it's not a simple thing to maintain. Just as a heads up.
One horse disagreer of the Apocalypse
#150 Old 10th Sep 2008 at 11:26 AM
Oh yes, once that empty box comes up in their queue you've had it. I think it's something to do with their brain slot - it's gets an "I am imprisoned" flag or token in it, and once that is there even if you manage to distract them briefly by making them selectable and directing them to do something else, the game just keeps making them start again wandering round looking for a way out. In fact as EPs have come out, they have added more things to help the sim leave, including simply zapping him after a while.

"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
Page 6 of 7
Back to top