More Awesome Than You!
Welcome, Guest. Please login or register.
2024 April 30, 10:32:54

Login with username, password and session length
Search:     Advanced search
540270 Posts in 18066 Topics by 6513 Members
Latest Member: Linnie
* Home Help Search Login Register
+  More Awesome Than You!
|-+  TS2: Burnination
| |-+  The Podium
| | |-+  [Modding Question] How do you detect what a sim is doing?
0 Members and 1 Chinese Bot are viewing this topic. « previous next »
Pages: [1] THANKS THIS IS GREAT Print
Author Topic: [Modding Question] How do you detect what a sim is doing?  (Read 4661 times)
rufio
Non-Standard
Uncouth Undesirable
****
Posts: 3030


More Nonstandard Than You


View Profile WWW
[Modding Question] How do you detect what a sim is doing?
« on: 2009 November 04, 00:42:24 »
THANKS THIS IS GREAT

I know there is something called an "Iteraction Index", which I believe I've seen used by BHAVs in BookshelfGlobals to find out what the sim was trying to study, but I don't know if that's something whose interpretation is specific to particular objects, or if it's a global indication of what interaction they're performing.  If the latter, is there a table of which interaction indexes correspond to which objects, and if the former, how do I determine the current interaction from a BHAV not associated with said interaction?
Logged

I was thinking about these things and I am a feminist.

J. M. Pescado
Fat Obstreperous Jerk
El Presidente
*****
Posts: 26281



View Profile
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #1 on: 2009 November 04, 00:52:07 »
THANKS THIS IS GREAT

The Interaction Index corresponds to the interaction index on the TTAB. So if a sim is performing an action upon an object you have determined to be a bookshelf, and is doing action 0x22, then you consult the TTAB and that is what he is doing. Be sure that you have correctly identified the interaction object, though, or else you will get nonsense results.
Logged

Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off.
rufio
Non-Standard
Uncouth Undesirable
****
Posts: 3030


More Nonstandard Than You


View Profile WWW
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #2 on: 2009 November 04, 02:55:52 »
THANKS THIS IS GREAT

Yeah, that's what I was thinking.  How do you identify the object?  That's actually more what I'm interested in here.
Logged

I was thinking about these things and I am a feminist.

J. M. Pescado
Fat Obstreperous Jerk
El Presidente
*****
Posts: 26281



View Profile
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #3 on: 2009 November 04, 03:06:29 »
THANKS THIS IS GREAT

Objects can be identified by category, using BHAV 0x199 (Object, Category), Is Category, or by GUID, using primitive 0x20 "Test". If this information is not sufficient to identify an object, then you can't. However, this should be sufficient to identify any standard object. Having identified the object, additional state information can be retrieved by examining its attributes, if necessary.
Logged

Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off.
rufio
Non-Standard
Uncouth Undesirable
****
Posts: 3030


More Nonstandard Than You


View Profile WWW
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #4 on: 2009 November 04, 03:25:33 »
THANKS THIS IS GREAT

Is that a "is object X of category Y" function, or a "is sim X using an object of category Y" function?  (I'm not on a computer with SimPE on it right now).  I need something like the latter.

ETA:  Or it is always safe to assume that the Stack Object is the object being used?
Logged

I was thinking about these things and I am a feminist.

J. M. Pescado
Fat Obstreperous Jerk
El Presidente
*****
Posts: 26281



View Profile
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #5 on: 2009 November 04, 08:19:02 »
THANKS THIS IS GREAT

Object X is explicitly passed as mentioned above. How you determine whether a sim is using said object depends entirely on where you got the object from. If you're getting it from a sim, like My/Stack Object's Current Interaction Object (12/13 50 00), then you can pass it in as such. HOW you found the object you want to examine is not something the BHAV cares about.
Logged

Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off.
rufio
Non-Standard
Uncouth Undesirable
****
Posts: 3030


More Nonstandard Than You


View Profile WWW
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #6 on: 2009 November 04, 14:38:55 »
THANKS THIS IS GREAT

Ok, so, given a sim NID, if you do something like:

Stack Object := (sim NID)
Local 0x0 := neighbor in Stack Object's Current Interaction Object

you can then say

Is Category (Local 0x0, 0xwhatever)

which will tell you whether the sim is using a particular kind of object, right?  The first two lines were basically what I wanted to find out.
Logged

I was thinking about these things and I am a feminist.

J. M. Pescado
Fat Obstreperous Jerk
El Presidente
*****
Posts: 26281



View Profile
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #7 on: 2009 November 04, 15:59:14 »
THANKS THIS IS GREAT

Ok, so, given a sim NID, if you do something like:

Stack Object := (sim NID)
Local 0x0 := neighbor in Stack Object's Current Interaction Object
Never do that. You should never access a persondata's instance values from an NID. To do it properly, if you have only an NID to work from, you need to set it to stack object, then extract its "person instance" using 18 00 00, assign THAT to stack object, then do stack object's persondata Current Interaction object (13 50 00). If you attempt to access neighbor's persondata through 20 50 00, you will get nonsense values. In fact, you should NEVER consult the Neighbor's Persondata without first verifying that the person is NOT instanced on the lot (always use the neighbor in stack object's person instance ID instead, then read the persondata of that). Neighbor's Persondata contains old information and should never be used unless you're looking for static information that will never change in-game, or the sim is definitely not instanced on the lot.
Logged

Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off.
rufio
Non-Standard
Uncouth Undesirable
****
Posts: 3030


More Nonstandard Than You


View Profile WWW
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #8 on: 2009 November 04, 16:21:34 »
THANKS THIS IS GREAT

Ah, right, I'd forgotten the difference between using the NID versus the object ID.  I actually can't remember whether it's an NID or an object ID I've got to work with, but I will keep that in mind.  Where is data actually being retrieved from when you refer to "neighbor's ___" versus "(object ID)'s ____"?  I take it that the NID goes back to some general-purpose census entry in the neighborhood with the name and family relationships and such, while the object ID refers to an actual instantiated object representing the sim that contains all the temporary variable information like skills and so forth for later storage in the census entry when the sim leaves the lot?  Family relationship info is something you can access through NID, right?  At least, EAxis family relationship BHAVs mostly seem to use NIDs (and my modded BHAVs using NIDs work as expected).  Would that cause inconsistencies or errors if family relationships were changed on-lot via hacks?  (And have you really got all of the operands for every argument for every BHAV memorized?)
Logged

I was thinking about these things and I am a feminist.

J. M. Pescado
Fat Obstreperous Jerk
El Presidente
*****
Posts: 26281



View Profile
Re: [Modding Question] How do you detect what a sim is doing?
« Reply #9 on: 2009 November 06, 09:43:44 »
THANKS THIS IS GREAT

Relationships can be accessed through either way safely, as these are global values that are not cached on the instance. Different arguments are needed to access it with instance IDs vs. NIDs, though.
Logged

Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off.
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.081 seconds with 20 queries.