More Awesome Than You!

TS2: Burnination => The Podium => Topic started by: rufio on 2009 December 19, 21:14:44



Title: [Modding Question] BHAV calling scope
Post by: rufio on 2009 December 19, 21:14:44
I understand the concept of globals: any BHAV from any group can call them, but they can't call BHAVs from other groups.  Does this extend to BHAVs defined in a package file that contains overridden globals with the group 0xFFFFFFFF?  E.g., say I have written a new version of global BHAV 0x0XYZ and in the same package where my version of 0x0XYZ is, there is a private BHAV with instance 0x1001 and group 0xFFFFFFFF.  Can I call the 0x1001 BHAV from 0x0XYZ, or do I have to create a new global?  I did create new globals in my family hack, but I do (and did) realize that that's not a great thing to do, and I want to know if there's a way around it.


Title: Re: [Modding Question] BHAV calling scope
Post by: J. M. Pescado on 2009 December 20, 03:59:41
0xFFFFFFFF is automatically remapped to a random group, so 0xFFFFFFFFs cannot call others not in their package. An 0x2XXX semiglobal can call a local 0x1XXX, with the resulting local that runs being the one attached to that object. It is not known what happens if an 0x0XXX global tries this, as there is no telling what will run if this happens. If you wish to invoke a specific effect, it is best to use RTBN, so that the BHAV will be invoked by name instead of by instance number.


Title: Re: [Modding Question] BHAV calling scope
Post by: rufio on 2009 December 22, 22:30:27
I see.  If the 0xFFFFFFFF BHAV is in the same package as the OBJD/OBJf of the current stack object than it can be called via RTBN, right?

I have another question about tokens, too - I have gotten one to work as I want it to, but it does not seem to be saving when the game is saved.  I've looked through multiple token-using hacks made by other people, and I can't see what I'm doing wrong.  HALP?  Token has OBJD, OBJf, unique GUID, can be added to neighborhood memory and have its properties modified, etc., but when the game reloads it can't be found.


Title: Re: [Modding Question] BHAV calling scope
Post by: J. M. Pescado on 2009 December 31, 02:54:24
I see.  If the 0xFFFFFFFF BHAV is in the same package as the OBJD/OBJf of the current stack object than it can be called via RTBN, right?
Any BHAV may be called by RTBN, regardless of whether it is global, semiglobal, or local, whether or not is an 0x7FXXXXXX, or an 0xFFFFFFFF. That's the entire point of RTBN. Any "local" will always be run in preference over a semiglobal over a global. It does not matter what groups are involved here, or whether the instance numbers are the same across all objects that may the RTBN may be invoked on.


Title: Re: [Modding Question] BHAV calling scope
Post by: rufio on 2010 January 01, 07:36:39
Right - but just to be clear, it's local/semiglobal where the current stack object is concerned, right?  So, like with the spell code, you get something like:

Ensure that SO is an instance of (Spell GUID)
RTBN "CT - Cast Spell"

which will run the CT - Cast Spell that's in the same group as the spell object, if it exists, and otherwise some general semiglobal version, and this is completely independent of the group number of the calling BHAV.  (Right?)


Title: Re: [Modding Question] BHAV calling scope
Post by: J. M. Pescado on 2010 January 01, 07:43:15
Right - but just to be clear, it's local/semiglobal where the current stack object is concerned, right?
Depends on the arguments. Using an RTBN-2, yes, the BHAV run will be the one associated with the stack object in aforementioned order of precedence. RTBN-3, however, will let you invoke a BHAV by a GUID of an object that may or may not actually be present, which will also be invoked in aforementioned order of precedence, only the stack object will be twaddle and no physical object will exist, and the BHAVs run will be those associated with the GUID.


Title: Re: [Modding Question] BHAV calling scope
Post by: rufio on 2010 January 03, 18:16:39
The -2/-3 is the version/format/whatever-it-was setting when setting opcodes and operands, then?  I haven't messed with it much, but I have noticed that the Relationship primitive seems to have different incarnations based on what goes there.

"Associated with the GUID" just means "in the same group as the OBJD of the object with that GUID", right?

(Slightly) related question: NREFs determine group numbers, right?  If I put an NREF with a unique name/number into a package with one OBJD (and the same instance as that OBJD) then when the package is loaded, everything in the package will be considered to be in the group corresponding to the NREF - correct?  If there are multiple OBJDs in the package (and multiple NREFs corresponding to them by instance number) does this divide all the non-immediately-OBJD-associated resources (like general-purpose non-Pie-Menu-related BHAVs and BCONs) into different groups?  What does including NREFs in a package do, from a purely functional standpoint?  Are they necessary/do things break if they aren't there?  Sims 2 Wiki just says something about unknown EAxian hash functions.

If it is possible to hand-pick group numbers using NREFs, is it also possible to set up one's own semiglobal groups and determine which private groups have access to their resources?  Are the semiglobal groups determined by some mathematical function of the group numbers, or are they hardcoded?


Title: Re: [Modding Question] BHAV calling scope
Post by: J. M. Pescado on 2010 January 04, 01:19:49
"Associated with the GUID" just means "in the same group as the OBJD of the object with that GUID", right?
Or its semiglobal, or its global.

(Slightly) related question: NREFs determine group numbers, right?  If I put an NREF with a unique name/number into a package with one OBJD (and the same instance as that OBJD) then when the package is loaded, everything in the package will be considered to be in the group corresponding to the NREF - correct?
Nope. Everything in 0xFFFFFFFF in one package is associated and shares a group. Everything outside that package isn't, unless explicitly given a group.

If there are multiple OBJDs in the package (and multiple NREFs corresponding to them by instance number) does this divide all the non-immediately-OBJD-associated resources (like general-purpose non-Pie-Menu-related BHAVs and BCONs) into different groups?
No.

What does including NREFs in a package do, from a purely functional standpoint?  Are they necessary/do things break if they aren't there?  Sims 2 Wiki just says something about unknown EAxian hash functions.
They show up in error logs. Other than that, nothing we can tell.

If it is possible to hand-pick group numbers using NREFs, is it also possible to set up one's own semiglobal groups and determine which private groups have access to their resources?  Are the semiglobal groups determined by some mathematical function of the group numbers, or are they hardcoded?
They are determined by a reference type, GLOB, or something.


Title: Re: [Modding Question] BHAV calling scope
Post by: rufio on 2010 January 04, 21:38:54
Ahh.  I had thought they might have something to do with the group number, because the NREFs in objects.package seem to have numbers corresponding to the groups they are in.