OBJf Resource Format
The following information is not based on any proprietary knowledge or restricted documentation—it was entirely derived from observation, experiment, and public information, thus it may be inaccurate or incomplete.
Analyzed by Greg Noel.
The object function table is an array of functions that perform specific actions. A given operation is always at a fixed offset within the array. It is analogous to a vtbl used in implementing C++ objects or to a dope vector used to implement other languages.
Many of these entry points also occur in "Old tree ID" fields in an OBJD resource. Presumably, if an OBJf resource is present, then the entry points in the OBJD resource are ignored, but this has not been tested.
|12||4||Count (N) of entries|
|16||2||Guard function #0|
|18||2||Action function #0|
|20||2||Guard function #1|
|22||2||Action function #1|
|24||var||. . .|
|var||2||Guard function #N-1|
|var||2||Action function #N-1|
The first twelve bytes are typical of many resources. If this similarity can be trusted, the second zero is the version number (indicating that the format of this resource has not been changed). The third item is the string 'OBJf' encoded as a little-endian integer.
The count specifies how many pairs of entries there are. Objects that come with the game invariably have 31 entries. A scattering of third-party objects have 30 entries. No other values have been observed. It is not known if zero trailing values can be truncated.
Each entry is a pair of function IDs. Each non-zero ID is for a BHAV resource in the same file as this resource. It is possible that the ID could specify a global or semi-global function, but this has never been observed in an actual object.
The first function in each pair is the guard operation. If the guard function returns true, the corresponding action is enabled.
The second function in each pair is the action operation. Executing this function presumably causes the action to occur.
After a number of the entry points had been puzzled out, it was found that the information in Behavior.iff STR# 245 (unsurprisingly titled "entry points") lined up with the known entries perfectly. Inspecting additional objects verified that, for example, a chair offers a "sit" action, a counter offers a "placement" action, a shower offers a "clean" action, and so forth. This offers a great deal of confidence this information is correct.
The information in this table is cited from the Behavior.iff string resource. It has been edited lightly to correct English usage, but no content has been changed. The text calls a function a tree because the GUI used to program objects uses a block-and-line paradigm that looks like a tree.
|0||init||The init tree is called whenever an object is reset. This happens when the object is first being placed, and if "reset" is chosen after an object error.|
|1||main||The main tree is the initial point of entry for the object's main simulation. Parameters may be passed to main if the "create object" primitive specifies.|
|2||load||The load tree is called whenever an instance of the object is loaded from a save file. It is only called if the "object version" instance variable is different from the corresponding variable in the object definition.|
|3||cleanup||The cleanup tree is called whenever an object is about to be deleted, or if a person's interaction with the object had to be aborted.|
|4||queue skipped||The queue skipped tree is called if an interaction in a person's queue was deleted for any reason.|
|This tree is a last resort hook for object intersection tests. If all the normal intersection tests pass, this tree is called to determine if two objects are allowed to intersect. Parameter 0 is the ID of the object that is being tested.|
|This tree is called whenever the wall configuration around an object changed. At that time, the "wall adjacency flags" instance variable will indicate the new configuration.|
|7||room changed||This tree is called whenever the room ID of an object changes. At this time, the "Room ID" instance variable will contain the new room ID.|
|If this function is defined for a multi-tile object, the object is "dynamic". This means that any time one is placed, it is joined with any neighboring objects. When the joining takes place, this tree is called for each object in the multi-tile group.|
|9||placement||This tree is called any time the position of an object changes.|
|10||pick up||This tree is called just before an object is picked up.|
|11||user placement||This tree is called when the user clicks to place an object.|
|12||user pickup||This tree is called when the user clicks to pick up an object. It is called just before the object is actually picked up.|
|13||level info request||This tree is called when the "level info" button is pressed. May not be used in final game.|
|14||serving surface||This tree is used by people who are looking for a place to drop food.|
|15||portal||If this tree is defined for a portal object, then the object may be used to transfer a person from one room to another. If two such objects are part of the same multi-tile group and lie in different rooms, then a person will push the tree to go between the rooms.|
|16||gardening||If this tree is defined, then the gardener will use it to take care of the plants.|
|17||wash hands||This tree is used by any person looking to wash hands.|
|18||prep||This tree is used a person who is trying to prepare food.|
|19||cook||This tree is used by any person trying to cook food.|
|20||surface||This tree is used by a person who is looking for a surface on which to place an object.|
|21||dispose||This tree is used by a person looking to throw away an object.|
|22||food||This tree is used to eat an object. It is only used by the fridge to transfer control of the person to the food after it is created.|
|23||pick up from slot||This tree is used by a person to pick up an object.|
|24||wash dish||This tree is used by a person who is looking to wash a dish.|
|25||eating surface||This tree is used by a person who wants to find a surface suitable for eating.|
|26||sit||This tree seats a person. If the tree is defined, the game considers the object to be a chair.|
|27||stand||If a person is sitting and contained in an object, this tree must be defined so that the person may stand up.|
|28||clean||This tree is used by the maid to clean objects.|
|29||repair||This tree is used by the repair man to repair objects.|
|30||UI event||This tree is called in the current situation object when an event in the user interface occurs. The first parameter is the type of the event. The second parameter is the ID of the event.|
The Sims™ is a trademark of Maxis and Electronic Arts.
This page was last modified Monday, 02-Jun-2003 12:07:56 UTC.