More Awesome Than You!

TS2: Burnination => The Podium => Topic started by: rufio on 2009 November 04, 00:42:24



Title: [Modding Question] How do you detect what a sim is doing?
Post by: rufio on 2009 November 04, 00:42:24
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?


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: J. M. Pescado on 2009 November 04, 00:52:07
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.


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: rufio on 2009 November 04, 02:55:52
Yeah, that's what I was thinking.  How do you identify the object?  That's actually more what I'm interested in here.


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: J. M. Pescado on 2009 November 04, 03:06:29
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.


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: rufio on 2009 November 04, 03:25:33
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?


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: J. M. Pescado on 2009 November 04, 08:19:02
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.


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: rufio on 2009 November 04, 14:38:55
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.


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: J. M. Pescado on 2009 November 04, 15:59:14
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.


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: rufio on 2009 November 04, 16:21:34
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?)


Title: Re: [Modding Question] How do you detect what a sim is doing?
Post by: J. M. Pescado on 2009 November 06, 09:43:44
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.