Changing an object’s placement flags

Some weeks ago someone named Lynn Drescher asked me by mail how to enable an object to be placed on water. After receiving a link to the website of Simophor I downloaded some objects that can be placed on water and started experimenting. As I didn’t remember to have seen something like water-placement in the Object Definition (OBJD) resource, I started the search using Script Station.

It turned out that the “init tree” subroutine is the most important piece in the puzzle. Whenever someone wants to use a certain object, this subroutine is called. It initialises some variables in the object, including some flag fields and placement flags. I compared several of these subroutines and came to some conclusions.

Using primitive 2, the “expression” primitive, the subroutine alters these things. The first parameter equals 42 decimal, the second is the flag index number, the third 2304 decimal (set flag or 0900 hex) or 2560 decimal (clear flag or 0A00 hex) and the fourth equals 1795 decimal. By setting or clearing this flags the properties of the objects are set. It seems that by default all flags are cleared.

For Placement, flag 1 indicates that an object can be placed on the floor and flag 2 that it can be placed on terrain (grass and such). When flag 3 is set the object can be placed on water. Then there are some unknowns. When flag 12 is set that means the object can be placed on a pool and flag 13 means it can only be placed on a pool tile. Of course, only setting flag 13 doesn’t mean you can place it on a pool tile: you need a combination of flags for that.

Unfortunately, I haven’t been able to determine the meaning of the other flags at this moment. It is possible that I find it later, but you’ll notice when I do. Of course any help from your side to determine these flags or the flags from flag fields 1 and 2 are appreciated very much.

Of course you’d like to know how to add these things to your favourite home-made object… what you need is Script Station, to which you can find a download link on the forums of Fusion Creations. You should then locate the “init tree” subroutine. Usually this is also the name of that subroutine. Alternative names are “init common” and such for multi-object IFF files. It goes beyond this document to find the exact subroutine, but usually it isn’t that tough to localize it. When you’ve opened the subroutine in Script Station you need to optimize the code (by pressing “Optimize”) and find the last line where it says “return TRUE” and “return FALSE” or “return ERROR“. Note the line number. Click “add line”. Double-click the new line. Click “Expert Edit”. Change “Function” to 2. Change “parameter 1” to 42 (decimal) in the SECOND edit box (which was “0” before changing). Change “parameter 2” to the flag number. Change “parameter 3” to 0900 (hexadecimal) for setting or 0A00 (hexadecimal) for clearing in the FIRST edit box (which was “0000” before changing). Change “parameter 4” to 1795 (decimal) in the second box. Finally, set “true” to the line number you noted and “false” to “FE”. Click OK to continue. When you press the optimisation button again you should see the new line just above the last line. If all goes right the translation will be something like “My placement Set Flag XX” or “My placement Clear Flags XX” with “XX” being the flag number. Well done, your object’s placement flags are now changed. Don’t forget to press OK some times and save the files manually (Script Station won’t warn you if you forget that).

Tom.