Using BHAVs With Arguments

From SimsWiki
Jump to: navigation, search



This guide to Arguments (AKA Parameters) assumes that you already have some knowledge of SimAntics, and will hopefully help you understand how Arguments are used and why they are important.


Arguments are important because they can help you to utilize the many Global and SemiGlobal functions that Maxis utilizes. Many of these BHAVs allow you to test to see if a certain condition exists, or to perform a specific action. However, you must first actually specify what action you want taken or what you want tested. You do this with the help of Arguments.

Usage and Examples

Many times you simply pass on a literal, numerical value in hexadecimal, but other times you can pass on data from other data owners such as an attribute, an object ID, or something else entirely. (Note: Data owners are also commonly known as operands, but will be referred to as data owners throughout this article to prevent confusion due to the fact that the 16 instructional bytes for each line in a BHAV are also labeled as operands in most programs.) For example, if you wanted to call the Global function "Aspiration - Reward Object Success?" you would specify the object ID of the Sim who is currently interacting with the object to see if the reward object should fail or not. You would do so by providing the following operands:

03 0B 00 00 00 00 00 00
00 00 00 00 01 00 00 00

This would give the following information in SimPE's BHAV editor:

[global 0x03BC] Aspiration - Reward Object Success? (1 arg: My 0x000B (object id))

You should understand that you can use any of the same data owners that you would in an expression primitive. It is also important to note that the 12th item in the above operands is nearly always set to 01. This tells the game that you're going to be using the data owners and not just literal numbers. If you didn't set the 12th operand to 01, you'd instead get a readout like this in SimPE's BHAV editor:

[global 0x03BC] Aspiration - Reward Object Success? (1 arg: 0x0B03)

Thus, all numbers you enter would be treated as literal numbers, which is not what you want in all cases. Even if you do just want to feed in a literal number, it's good practice to always set the 12th operand to 01 and just use the 07 (Literal) data owner. An example of this can be seen in the Idle - Hours global. If you provided the following operands:

07 01 00 00 00 00 00 00
00 00 00 00 01 00 00 00

You would get this result:

[global 0x016E] Idle - Hours (1 arg: Literal 0x0001)

Some globals have more than one argument at times. One example of this is the frequently used "Budget - Make Transaction" global function, which has 4 arguments: The amount to transact, to add or subtract, what category it falls under, and who to take it from. Here's an example in which the current Sim using the object is charged 30 dollars as a miscellaneous expense:

07 1E 00 07 00 00 07 00
00 03 0B 00 01 00 00 00

This would produce this result:

[global 0x0294] Budget - Make Transaction (4 args: Literal 0x001E, Literal 0x0000, 
Literal 0x0000, My 0x000B (object id))

Conclusion and Further Info

So as you can see, using BHAVs with arguments can be very useful in editing behaviors, especially if you can make good use of the semi-globals and globals that Maxis provides. You can also make your own BHAVs with arguments for use in your own custom hacked objects. Simply make a new BHAV and specify, with your choice of BHAV editor, that the argument count is 1 or more. (There is a limit of 4 arguments per BHAV, however.)

To use the data that will be passed on to your new BHAV, you will get it via the Parameter (09) data owner by simply specifying which parameter you're trying to use. If you're trying to use the first (or only) argument, then you'll be using Parameter 0x0000; second argument is Parameter 0x0001; and so on. From there you can manipulate whatever data you pass to your BHAV in any way you want to.

Personal tools

game select