Understanding primitives
#1 06-01-2016 
Let me know if you tire of my threads Tongue I've been a modding-mood lately, and I'm starting to learn more about the internal bits of BHAVs. I discovered the wiki page on SimAntics, and it explained a lot of things that are good to know. However, I still can't quite grasp expressions and their operands and operators. I have a few questions I hope one of you might be willing to answer Smile It's not for any specific project, just trying to learn to interpret what I see.

I'm currently look at this, trying to work out what it means. I'm using this article that talks about expression structure.
[Image: Expression_zpsmmxhwwb3.jpg]
I understand that this is checking the Sims personality trait, and depending on if it fits the condition or not it sends to 5 or 1. By looking at the article, I understand that the Operant here is >=, which I assume means equal or larger than. Operand AA is personality, and Operand BB is a constant. In this situation, is AA telling it what to look for, oo telling it what to do with the number that comes out, and bb what number to compare it to?

The argument for AA is 05, which I assume is what's telling it to look at playfulness. I tried changing the number around and it brings up different traits like skill level and other personality trait.

The part that I'm totally fussy on are the arguments for BB, 88 and 21, which if I understand correctly is the 0x2003:0x08 part. The wiki article doesn't really explain that, and I don't understand what it means. Based on context I would guess it's supposed to dictate which number it should compare playfulness to decide if it's equal or larger than. It also reminds me of when it's getting a number from a BCON, where 2003 would be instance number and 0x08 would be the line to look at. What does it mean?
EDIT: Looking at it, there is a BCON with that instance number in the same group as the BHAV, and line 0x8 holds the number 0x02EE. Since that's what is written in parenthesis I assume the reason it reminds me of getting data from a BCON is because that is what it's doing. I still don't understand why it's doing that, and what it means, though.
gummilutt, proud to be a member of LeeFish since Jun 2013.
(This post was last modified: 06-01-2016 11:15 PM by gummilutt.)

#2 07-01-2016 
How the numbers 88 21 are formed, and how they relate to the actual value 0x2003:0x08, I cannot explain. But it is true that they do. And yes, the BCON you found is indeed the correct one for this instance. To understand why it is done this way, I will remind you what BCON stands for: it means Behavior CONstant. The trick is, that each BCON can store multiple numbers for multiple cases. For example, every sort of value that might relate to the same personality trait, will be put in the same BCON... It's Top and Bottom values, its bonuses and penalties, etc. For motives, it would also contain a delta (the amount the motive drops per time unit) for several circumstances. And so on...

They do it this way, so it *can* be changed easily without having to change the code in hundreds of BHAVs that all affect the same traits. They simply alter the numbers in a single BCON slightly, and all BHAVs can then use the new values. That's what make modding a lot simpler in many cases.

The value 0x02EE is a hecadecimal (base-16) number, translating to a decimal value of 750. In the personality screen, we normally see only ten blips per trait, so it ranges from 0 to 10. But in reality, each of these blips represents 100, so the TRUE range of each personality trait is from 0 to 1000. 750 in this case means that the sim must have a minimum of seven blips, and half of the eighth to pass this test.

Does this help, @gummilutt?

#3 07-01-2016 
Yes, that does help Smile I was reading constant as in number, but it does make more sense for it to be a BCON, especially considering the name. And part of why it confused me was that the number it produced was 750, when I expected something between 0 and 10, so now now that I know it's 0-1000 it makes a lot more sense. Thank you very much Smile

What is the operand for a literal value, that's held inside the BHAV rather than a BCON? Is that what literal value is for?

#4 08-01-2016 
Exactly! A literal is *literally* a literal: a number spelled out immediately and directly, within the code itself. So you choose the operand "Literal" and then define the number directly - no tables, no calculations or references to a BCON, just the dry and clear-cut number :-)

#5 08-01-2016 
I have a question about the constant operand. Can it only check BCONs with the same group as the BHAV checking? I have a project I'm starting to map out, and it would be infinitely better if I could use a BCON to store values, but there will be a lot of different BHAVs with different group (maxis BHAVs, not my choice for them to be different) and if I have to have one BCON for each one it will get very cluttered.

If the answer is that it can check BCONs with different group, how does one make it do that? I've only ever seen it list instance number and then line in the BHAV, never anything about group.

#6 08-01-2016 
If all the objects are of the same TYPE, and share the same SEMI-global group, you could make your BCON a part of that shared group, so all of the intended objects can make use of it.
However, if the objects are all diverse and have nothing in common, you'll be in trouble. Well, there *was* a way, by means of a BCON in the GLOBAL group. But alas, the EAxians have made that impossible by claiming ALL possible BCON numbers in that group for themselves. They're really ALL used up, and you cannot make a new GLOBAL BCON to save your life.

Now here is the big thing. All BHAVs and BCONs belonging to a single object have - as you may have noticed - a Number in the 0x20xx range. All semi-globals, however, have numbers in the 0x10xx range, and true GLOBALs use the 0x00xx range.

Now since there is only ONE true Global group, using a global BCON is as simple as just using the correct instance number, its personal ID, so to speak. The BHAV will know where to find that.

But with SEMI-Globals, the situation is a little more complex. There are as many semi-global groups as there are different categories of 'objects'. So the object needs to have an file of type GLOB - a semi global file - in which the group instance number of the associated semi global group is defined. Once that is set correctly, you can simply act as if you're dealing with a local or global BCON again. You just use the appropriate BCON number in the 0x10xx range, and the game will know in which semi-global group to look for that BCON.

Hoping this helps,


#7 08-01-2016 
I see. I sort of understand, but not completely. So, to find the semi global group of an object, I make a clone of it and check what GLOB is attached? (Or perhaps just check the group in Object Workshop and filter by group?)

If I have to I'll just have to make separate BCONs for each object, it'll be more cluttered than I personally like and take longer for the user to setup, but not much I can do about it. Would you mind if I sent you a PM with a few questions? I don't want to talk about it openly until I'm further along the process of making it Smile
(This post was last modified: 08-01-2016 05:53 PM by gummilutt.)

#8 08-01-2016 
You got that right: you look at the GLOB files for other examples of the same object type, and copy it into your own object. And then you use that group for your BCON.
So, if all the objects are of the type 'chair', you'll end up making your BCON in the group named "ChairGlobals".

Personally, I would open the latest Objects.package - M&G in my case -, look for the object by name and finally use a filter to isolate the entire group. But indeed, cloning would also work.
Once you know that it works this way, it isn't really very hard whichever way you do it.

Personally, I would prefer keeping the conversation as public as possible, but a single PM would not really be a problem as long as you can keep it brief. ;-)

#9 08-01-2016 
Yes, I recalled that you prefer public so more people can read and learn Smile

The project involves editing guardian bhavs, just like the snooze one, and I think I need to know more about what it does and what code in it will actually mean. I don't know them enough and I can't always rely on you or someone to go over my work.

What is the purpose of guardian bhavs? I understand that it tests things, but with what purpose? From what you said in the other thread it sounded like it's purely to decide if the menu option should be available or not. But that doesn't seem to always be the case. For example, the same object test in the snooze test hid the option if it came back false, but the personality check in the first post of this thread was also in a guardian bhav and the option appears even though my test Sim has 0 playfulness, after I removed the hide menu line from it.

What I want to be doing, in the end, is making the guardian reject autonomous use of the action, but not player-directed use. I've been looking a bit at other mods that do that, but conflicting information has made me confused.

EDIT: Having poked around more, I've answered some of my own questions. I see now that guardian bhav checks do apply in all situations, I just wasn't following the true/false stuff properly earlier and misinterpreted what I saw. Am I correct in understanding that guardian BHAVs are there to check if the menu option should appear, and nothing else?

How does one go about setting a check in guardian that only stops autonomous behavior, not player-directed? Like I said I've been poking around at mods that do that, but so far I haven't been able to figure it out.
(This post was last modified: 09-01-2016 03:19 AM by gummilutt.)

#10 09-01-2016 
You are right about what the function of a Guardian BHAV is... I'll recap for the commmunity:

The Guardian BHAV has only one function: to make sure that only sensible options appear in the context menu. If you click another sim - for example - you expect to get all kind of social interactions available, right? But you *ONLY* get interactions that make sense with respect to the height of the current relationship between your sim and the other.

Now how is that done? There is a huge TTAB somewhere that contains ALL the social interactions that you could imagine. When you click the other sim, the system will try to populate the menu with those. For each of the interactions in this TTAB, it finds the Guardian BHAV and runs that in order to find out if the accompanying option may be added to the menu. If your sim's relationship to the other, for example, is not romantic in nature, or they have only just begun flirting and are not enough in love yet, the Guardian BHAV belonging to the "Kiss.../Make Out" option will result in a False, and therefor the "Kiss.../Make Out" will NOT appear in your menu. And similar tests will be done for all other options to try and find out which will appear on the menu and which won't.

When you click an object, however, the Guardians of the relevant interactions may test if the sim is even in the same room as the object, or if the sim is fit and strong enough to do what the object would allow him to do. For example, my "Smustle Limited" mod contains an edited Guardian BHAV that makes sure that autonomous smustle is only available to downtownies, or when you are playing in downtown. And even then, it will only give TRUE if the sim is in a room where music is actually being played! Even if you try to direct the sim, you can not order them to smustle in a room without music. Big Grin

The Guardian will also be run when the system is trying to determine what options the sim could choose from when it is not being directed - the so-called autonomous actions.


Now for your question about autonomous versus user-directed actions... this is one that may actually puzzle you. I even have to look it up myself now... Hold on, I'll be right back to edit the message... Tongue

ETA: Ah, THERE it is... When the system starts a guardian BHAV, it sets the variable named Param 0x0000 in the following manner:
  • When you clicked another sim, and it is trying to build up a menu for you, the Param will be set to the value 0 (zero)
  • But when it is checking whether the sim can do something autonomously (i.e. you're not directing it at present), then the Param will be set to the value 1 (one)

So effectively, in a Guardian BHAV, you can find out if a sim is autonomously acting with one of the following simple tests:
  • [prim 0x0002] Expression (Param 0x0000 == Literal 0x0000)
  • [prim 0x0002] Expression (Param 0x0000 <> Literal 0x0001)

Either of the above tests will result in TRUE if you are directing the sim, or FALSE when the sim is autonomous.

And if you use either of the following:
  • [prim 0x0002] Expression (Param 0x0000 <> Literal 0x0000)
  • [prim 0x0002] Expression (Param 0x0000 == Literal 0x0001)

Either of those will result in TRUE if the sim is autonomous, or FALSE when you're directing them...


There *is* also a global BHAV named "Autonomous - Am I?" or something to that effect, but that one does NOT work properly when accessed from a Guardian. So you are advised not to try that, because you will be disappointed with the result.


Sorry, that is a members only option