Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Mesh Maestro
Original Poster
#1 Old 13th Aug 2005 at 5:42 PM Last edited by leefish : 17th Jan 2014 at 5:38 PM.
Understanding the Object Functions (OBJF) file
[U

UNDERSTANDING THE OBJECT FUNCTIONS (OBJF) FILE

[/U]


DISCLAIMER: This is NOT a tutorial; it is intended to help average-experienced object creators performing specific tasks, or to give users a deeper in-sight on specific modding-related subjects. So, don't expect to find step-by-step explanations, to be performed "blindly". Please DO NOT REPOST the following info, or part of them, on other sites.


-------------------------------------------------------------------------------------

SUMMARY
These notes will try to explain the usage and give explanation of the Object Functions File” and the contained values.
This InfoCenter article is also provided in PDF format. To view it, we strongly suggest to download the Foxisoft PFD Viewer: it's free and small, less than 1Mb!

-------------------------------------------------------------------------------------



1 - INTRODUCTION
The “Objects Function Table”, known as the OBJF file type inside the package of an object, has the same instance number as the OBJD (Object Data) file it goes with. There should be one OBJF for each tile that makes up the object.

The OBJF is a table listing the BHAVs that should be run when certain things ("events") happen in the game. Just for a couple of examples: there is an entry to say what BHAV should be run when a user clicks on an object and picks it up, and another saying what BHAV should be run when a Sim wants to put a bill or his dinner down on your object. These BHAVs would most probably include calls to the animations a Sim must execute as part of the interaction. The guardian BHAVs for the entries might check there wasn’t already a meal on the counter taking up the space.

If you don't fill in a BHAV number for "Serve meal" then Sims will not be able to serve meals on your object – if you delete the BHAV number from all the fields to do with placing objects on it and eating at it, it won't be a table at all as far as the Sims are concerned!
One useful example of this is cloning a sink, and deleting the BHAV number in the "wash dish" field. That means your sink will be a proper bathroom basin for personal hygiene only.

The OBJF is a little like the Pie Menu file, but the difference is that the entries in the Pie Menu are chosen usually by Sims (or the player acting through a Sim) while the Object Functions are chosen directly by an object. For example, for a chair, there is a Sit option on the menu, and a Sit function in the OBJF. If a Sim is thinking about his motives and decides he needs comfort, he’ll use the Sit on the menu. But if he’s picked up a book and wants to read it, the book will choose his chair through the chair’s OBJF table, and direct the Sim to sit there. If you create a Sit entry for a table, the book does not know any better, and the Sim will be sent to do whatever you put into the table’s BHAV that is listed under “Sit”. There are “grey” areas in this distinction, but I chose a fairly simple illustration.

When the book needs to send a Sim to sit, it runs a primitive called “Find best object for function” where one of the parameters means “sit” and checks out all the objects that offer a “sit” function. An object’s init will have lines in it like “my sitting value assign to n” which give the book information about how good a particular chair is. But that will be tempered with things like the distance. In Sims 1 they didn’t take that into account and they’d walk to the other end of the lot if there was a more expensive chair to use.

All OBJFs would be expected to have at least the Main and Init fields filled in, unless it is the OBJF for the Master of a multi-tile object. Masters are not really in the “world”, so they don't need to run anything. The like entries for each tile's OBJF can point to the same BHAVs unless you want different parts of the object to do and allow different things.

Here is the full list (with a brief explanations) of the Object Functions entries, as reported by the WIKI: if you find inaccurate info, please let us know. Anyway, only limited support can be given about Wiki content.
  • 0x01: 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.)
  • 0x02: 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.)
  • 0x03: 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.)
  • 0x04: 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.)
  • 0x05: queue skipped (The queue skipped tree is called if an interaction in a person's queue was deleted for any reason.)
  • 0x06: allow intersection (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.)
  • 0x07: wall adjacency changed (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.)
  • 0x08: 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.)
  • 0x09: dynamic multi-tile update (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.)
  • 0x0A: placement (This tree is called any time the position of an object changes.)
  • 0x0B: pickup (This tree is called when an object is removed from the world (either to be deleted or to be re-placed in the world).)
  • 0x0C: user placement (This tree is called when the user clicks to place an object.)
  • 0x0D: user pickup (This tree is called just before an object is picked up by the user.)
  • 0x0E: level info request (This tree is called when the "level info" button is pressed. May not be used in final game.)
  • 0x0F: serving surface (This tree is used by people who are looking for a place to drop food.)
  • 0x10: 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.)
  • 0x11: gardening (If this tree is defined, then the gardener will use it to take care of the plants.)
  • 0x12: wash hands (This tree is used by any person looking to wash hands.)
  • 0x13: prep (This tree is used a person who is trying to prepare food.)
  • 0x14: cook (This tree is used by any person trying to cook food.)
  • 0x15: surface (This tree is used by a person who is looking for a surface on which to place an object.)
  • 0x16: dispose (This tree is used by a person looking to throw away an object.)
  • 0x17: 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.)
  • 0x18: pickup from slot (This tree is used by a person to pick up an object.)
  • 0x19: wash dish (This tree is used by a person who is looking to wash a dish.)
  • 0x1A: eating surface (This tree is used by a person who wants to find a surface suitable for eating.)
  • 0x1B: sit (This tree seats a person. If the tree is defined, the game considers the object to be a chair.)
  • 0x1C: stand (If a person is sitting and contained in an object, this tree must be defined so that the person may stand up.)
  • 0x1D: clean (This tree is used by the maid to clean objects.)
  • 0x1E: repair (This tree is used by the repair man to repair objects.)
  • 0x1F: 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.)
  • 0x20: Dry Clothes
  • 0x21: Wash Clothes
  • 0x22: Start Live Mode
  • 0x23: Stop Live Mode
  • 0x24: Link Objects (This tree is called so that the object can set links to the previous and next objects in a doubly-linked list of objects. The first parameter is the ID of the previous object in the chain (or -1 if this is the first object). The second parameter is the ID of the next object in the chain (or -1 if this is the last object).)
  • 0x25: Message Handler (This tree is called when the object receives a broadcast message from the message primitive.)
  • 0x26: Pre Route (This tree handles the transition from the idle-neutral pose, to the locomotion neutral pose (if they are different) at the beginning of a route. An example is of a toddler changing from sitting to crawling pose brefore routing.)
  • 0x27: Post Route (This tree handles the transition from the ilocomotion neutral pose, to the idle-neutral pose (if they are different) at the end of a route. An example is of a toddler changing from crawling to a sitting pose brefore routing.)
  • 0x28: Goal Check (This tree checks if the routing goal is still available. Its called on the object that issues the goto command. For example if a sim is trying to route to a seat, and another sim gets there false, this call can return false, allowing the sim to stop and choose another seat.)
  • 0x29: Reaction Handler (This tree is called from a message handler tree, if the message receiver decides to actually handle the message.)
  • 0x2A: Along Route Callback (This tree is called on the sim once per tile along the route, and can interupt it by returning false. This tree can be used to run idles while the sim is routing.)
  • 0x2B: awareness (This tree is used by objects to advertise that they are interesting things to look at.)
  • 0x2C: reset (Called when object is reset on loading of lot. This should never happen in shipped game.)
  • 0x2D: lookatTarget (Called to choose objects to lookat along a route)
  • 0x2E: Walk Over (When an object is walked over, this tree gets called.)
  • 0x2F: Utility State Change (When a utility changes state, this tree gets called.)
  • 0x30: Set Model by Type (Called to change the model based on a type defined in the game code. The first parameter holds the model 'type'. e.x. Modular stair railing types ( None | Left | Right | Both ).)
  • 0x31: Get Model Type (Called to get the model type as defined by the game code. e.x. Modular stair railing types ( None | Left | Right | Both ).)
  • 0x32: delete (Called before an object is killed.)
  • 0x33: user delete (Called before an object is "deleted" or "sold" by the player, even if the object is not immediately killed.)
  • 0x34: Just Moved In (Called on objects that have been created by moving in a sim that have objects they own from another lot.)
  • 0x35: prevent place in slot (Called on container object during placement test for placing in a slot; return true to prevent placement even when all other tests pass.)
  • 0x36: Global Awareness (Added to make Paul B's life easier.)
  • 0x37: Object Updated by Design Mode (Called when Design mode updates an object, so we can set the correct state on it.)



-------------------------------------------------------------------------------------

OTHER USEFUL RESOURCES

Modding InfoCenter Index - Comprehensive list of all the InfoCenter threads
Object Function Table - A discussion about OBJf started by Inge Jones
Object Creation Workshop and Repair Center - If your object doesn't work, no matter what you try
Color Options for "EP-ready" packages - About the texture linking techniques
Sims 2 start to finish Object Creation Tutorial - Learn how to create your own object






-------------------------------------------------------------------------------------
Attached files:
File Type: rar  Understanding the Object Function (OBJF) file.rar (49.5 KB, 716 downloads) - View custom content

Reading is the key to all knowledge, math is the key to everything.
Advertisement
Lab Assistant
#2 Old 16th Jun 2006 at 6:32 AM
"All OBJFs would be expected to have at least the Main and Init fields filled in, unless it is the OBJF for the Master of a multi-tile object. Masters are not really in the “world”, so they don't need to run anything."

o_0 Is "expected" the operative word? Because I've seen (multi-tile) OBJFs without a main function filled in (admittedly, in the middle of a staircase), and I've seen Masters with init and main functions (also in multi-tile).
One horse disagreer of the Apocalypse
#3 Old 16th Jun 2006 at 10:05 AM
I think if they are in the master object they are simply ignored so they may be just left in there from when the programmer copied them over from something else that was single-tile perhaps.

I haven't personally seen OBJfs for in-game non-master tiles without an init - in my experience so far that would cause an object to refuse to be placed. But maybe those ones are not "in game" as such? If anyone wants to experiment, the information would be useful. But in general it will save potential problems to have at least some simple init with every OBJf.
Retired Duck
retired moderator
#4 Old 18th Mar 2007 at 12:58 PM
Can anyone point me in the direction of an object which uses the "prevent place in slot" function option? I think I have a use for that functionality, but I'd like to see how it works in existing objects if possible, before I try and figure it out manually!
The ModFather
retired moderator
#5 Old 18th Mar 2007 at 10:14 PM
Group ID - Name

0x7FBCF087 - Driveway (NL)
0x7F1E93ED - Chessboard (TS2)
0x7F4EBAB0 - Poker Table (NL)
................ - (All the kitchen counters)
0x7FD277DD - Electro Dance Sphere (NL)
................ - (All the desks)

Do you need more?
I basically have sorted the BHAVs in the objects.package by name, found all the "Function - Prevent place in slot" ones, and read their GroupID; most of them are contained in semiglobals (hence the lines "all the counters" etc...)

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
Retired Duck
retired moderator
#6 Old 19th Mar 2007 at 12:38 AM
Cheers! Thank you Numenor! That will do quite nicely.
Lab Assistant
#7 Old 15th Mar 2009 at 8:31 PM
I've been looking all over for a tutorial on how to change action animations for an object (for example, to change the animation for guitar-playing so that the sim will headbang when he plays the guitar.) I'm pretty sure this is possible, but I have no idea how to do it.

If you know a better place to ask this question, that would be nice, too. thanks.
-amy

Viva Pinata: It's not just a game, it's a movement.
One horse disagreer of the Apocalypse
#8 Old 15th Mar 2009 at 8:41 PM
I can tell you it's nothing to do with the OBJf resource. You'd need to edit an animation resource directly.

"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
Back to top