Trait Globals

This global mod adds the following global BHAVs

  • 0x0BC0 - "Traits - Get Like Colours for P0 (OID/NID) in T0/1/2 (1 - 12)" : Gets a Sim's preferred colours.
  • 0x0BC1 - "Traits - Get Hate Colours for P0 (OID/NID) in T0/1/2 (1 - 12)" : Gets a Sim's disliked colours.

Each BHAV takes the following parameters

  • Param0 - Sim OID/NID
  • Param1 - Exclusion flags
  • Param2 - Maximum colours wanted
  • Param3 - Idle (0) or Exit (1) After 1000 Items

The global BHAV gets the first N liked/disliked colours from the Sim's inventory into Temp0, Temp1 and Temp2 where 1 is black and 12 is yellow.

Param1 can be used to exclude colours, set flag X to exclude colour X, for example, to exclude brown (colour 3) set flag 3 (ie 0x0004), to exclude both brown and grey (colour 5) set both flags 3 and 5 (ie 0x0014), useful if you're only interested in a subset of colours.

Param2 is used to limit the number of colours returned, if you only want 1 or 2 colours, set this to 1 or 2 and the search will return quicker.

Param3 controls how to deal with an excessively large number of items in a Sim's inventory - idle (to avoid the max iterations exceeded error) or exit. If using this BHAV in a situation where idle is not permitted (eg animation events), you MUST set this parameter to non-zero.


Background

I don't play with traits but I've been looking at the colour traits recently for a couple of mods, and the common approach to this seems to be to use hexagonal-bipyramid's "Easy Inventory Check" to search the Sim's inventory for each colour trait token in order.

ETC ...

This approach has two major issues

1) It is very easy to generate the "max iterations exceeded" error. Consider a Sim with 200 items in their inventory (a lot I know, but apparently not uncommon) whose favourite colour is yellow. The code is going to scan those 200 items 11 times (black thru white) before it gets around to looking for the yellow trait token, for an average of 2,300 items scanned. If the scanning code takes more than 4 primitives per item to check, that's the iterations exceeded. Even using LazyDuchess' RPC Launcher to up the iterations to 100,000, at 8 primitives per item, the search will blow-up around 1000 items - which seems excessive to me but has been reported in various forums.

2) Only a single colour preference is supported, as the first found colour token (usually alphabetically) will win, so a Sim with a primary (first occuring) colour preference for turquoise will never get an item of that colour if their secondary preference is blue (lower alpahabetically).

These global BHAVs only scan the Sim's inventory ONCE, picking out the colour trait tokens in order, into Temps 0 thru 2 (at the most, but you can use Param 2 to limit this).

Also, if you know that the possible colours are limited (for example, my "Change Appropriately After Bathing" mod only supports blue, green, red and white towels) you can exclude certain colours (eg brown, grey, yellow) from the search via Param 1.

Finally, Param 3 controls what to do as the 10,000 iterations is approached (around 1000 inventory items) - idle or exit.


Example

My "Ask Favourite Colour" mod shows how to use these global BHAVs.


Installation

Copy this mod into your downloads folder, if you split my mods into a seperate sub-folder, I suggest you place it there as a number of my mods need it.


Installation - SimPe

If you use SimPe to delve into my mods, you can get SimPe to recognise the new global BHAVs as follows.

  • Start SimPe
  • From the "Extra" menu, select "Preferences..."
  • Click on the "File Table" in the left-hand ribbon
  • Click on "add" (left most item of the "add" "delete" "change" triple)
  • Click the "Load File" button
  • Browse to the sub-folder you copied the WH_TraitGlobals.package file to and select the package
  • Click the "Open" button
  • Click the "OK" button
  • There will be a new entry at the top of the "Advanced Settings" area that refers to the WH_TraitGlobals.package file, check the box to its left
  • Click the "Reload" button
  • Click the "OK" button

Conflicts

The mod adds global BHAVs starting at 0x0BC0 as listed above, so will conflict with any other mod that does the same.

No known conflicts


Simblr Links


Credits

  • The developers of SimPE.

Files