Back Previous Next

All kinds of dialogs

An instruction in a BHAV tree consists of a header declaring the number of parameters/variables, and lines consisting of a function number and eight (if you count them as bytes, four if you count them as double bytes) parameters. The function number most often used is 2, "Expression", but there are some fifty or so functions. One of them is 36, "Dialog", to manage and display all dialogs available depending on what expansion packs have been installed. There are 16 possible dialogs, listed in order of parameter value (00 - 0F):

00 Message
01 Choice Yes/No
02 Choice Yes/No/Cancel
03 Text entry
04 Tutorial (only used in tutorial mode, I assume)
05 Choose Downtown lot
06 Choose clothes from wardrobe
07 Choose Vacation lot
08 Choose Community lot
09 Choose pet
0A Phone book
0B Choose Studio Town lot
0C Spellbook
0D Choose Magic Town lot
0E Choose Magic outfit
0F Cookery book

The first five dialogs are available in all Sims versions. The next two were introduced in Hot Date, the next in Vacation, the next three in Unleashed and the last ones in, obviously, Superstar and Makin' Magic. (Earlier solutions for phoning neighbours and changing clothes were to build a menu from GUIDs and to tediously change the Sim into the next wardrobe outfit until the player approves one.)

A dialog is called by using function number 36, with 8 single-byte parameters to determine what dialog is shown and how it affects the game. Parameters 6 and 8 are display parameters, the others are all string parameters. These are the parameters and what they do:

1 Cancel-button text string (tri-choice dialogs)
2 Icon name (for values 6-9 of parameter 8)
3 Main text string
4 OK-button text string (Yes-button for choice dialogs)
5 No-button text string
6 Dialog type (the 16 dialogs listed above)
7 Title text string (not for phonebook, spellbook or lot dialogs)
8 Icon and effect on gameplay

The text strings referred to by the string parameters are in resource 301 of the STR# block, called "Dialog prim string set". The strings are numbered from 0 onwards, but - and this applies to any displayed string, not just dialog strings - since a parameter value of "0" means "no string", the parameter value becomes 1 for string #0, 2 for string #1 andsoforth. For the Yes, No and Cancel buttons, a value of 0 means the default value, ie. "Yes", "No" and "Cancel" in the installation language; all the translations of these default values are found in STR# blocks #142 and #152 in "GameData\UItext.iff". A value of 0 for the dialog title just means an empty title bar. The one parameter that must have a non-zero value for any dialog that isn't a phonebook, spellbook or choose-lot dialog is parameter 3, the main text string; if it is empty or the string referred to isn't found, the dialog displays the message "string error". (If on the other hand the string in the STR# block exists but is empty, the dialog displays what it finds in the string: nothing.) Title, text and button strings are ignored for "choose lot" dialogs (except UL lots, apparently), the phone book and the spellbook. (I haven't tried this out, and am basing myself on the instruction strings shown in IFF Pencil. Although I've seen that a tri-choice dialog, when the dialog type was changed to 0E, simply showed "Dialog", so maybe filled string parameters block these no-strings dialogs.)

The values for the eighth parameter are:

0 = icon auto
1 = return and block sim, icon auto
2 = no icon
3 = return and block sim
4 = icon neighbour
5 = return and block sim, icon neighbour
6 = icon: BMP_#5000)
7 = return and block sim, icon: BMP_#5000)
8 = icon: name 0
9 = return and block sim, icon: name 0

Values 10 to 19 produce the same instruction strings as values 0-9, 0A-0F just produces a question mark. The values are in pairs: icon, or icon plus "return and block sim". This second bit means "pause game until dialog is closed" and is very convenient for dialogs that don't want PersonGlobals milling in the background. The "return and block sim" should never be used for (tri)choice dialogs, which pause the game automatically of themselves; if it is, all choices will return "True". The icon choices speak for themselves: automatic icon (ie. icon of current stack object), no icon, Sim icon (the "neighbour" bit just means a living Sim, as opposed to an inanimate object), the image that is in the BMP_ block at resource number #5000 (by way of comparison: the catalogue thumbnail is BMP_ #2000) or the icon with "name 0" (the filename reference in string #0 of the dialog strings block, STR#301). For instance, this is how "PhoneGlobals.iff" refers to the icons shown in crank call dialogs:

Code: 36:00 01 93 00 00 00 00 06
Dialog (message: id#-110, icon: BMP_#5001)

Since "PhoneGlobals.iff", like any global IFF, can't have its own dialog strings, the string parameters refer to "phones.iff", which has the name "PhoneGlobals.iff" in its GLOB block, and so has access to the global's routines just as the global has access to the IFF's resources. Going down the list of parameters: #1 is not needed. #2 would refer to an icon if #8 was set to a value between 6 and 9, which is the case. The value 6 means "use a bitmap in the #5000 range" and #2 is 1, which means, use bitmap resource BMP_#5001. This is an image baked into the IFF. The main text string, #3, is not, as IFFPencil shows it, -110 but 147 (or, in the hexadecimal system, 93) and #4, the string for the OK button is 0, meaning default "OK". #5 and #7 are also not needed, since the dialog has neither title nor cancel-button. #6 is 0, the one-button "message" dialog.

The screencap below shows resource BMP_#5001. This can be exported to a bitmap file.

And here's how "CarPortal.iff" refers to the job icon in the coming home after work dialog:

Code: 36: 00 2E 05 00 10 00 04 08
Dialog (message: id#4, icon: id#45) {Title: id#3}

To start with the last parameter: the value 8 means the icon is referenced by a name (and that the dialog doesn't block the game while it's open) and the name can be found in #2: 2E, or, as IFFPencil correctly translates it, id#45. This would be string #45 in STR#-block #301 of "CarPortal.if", which reads: "job $Local:4". What is $Local? It stands for the value of a local variable, and $Local:4 is the value of local variable 4. Elsewhere in the BHAV block calling the dialog, I see:

Local Variable 4 Assign To: my person data Job Type
and:
Local Variable 0 Assign To: job data [temp 0,1] salary

"My person data job type" is the job number of the Sim; each career track has its own number, from 1 to 10 for the original Sims, 1 to 21 since UL. So the name of the icon is "job [Sim's career track number]", which the game translates into the appropriate icon from "sprites.iff".

Parameters #3 (message) and #7 (title) are:

(string #4) Welcome home! You brought home $$Local:0 today.
and:
(string #3) $Me

The first speaks for itself: the job salary is being displayed, and the second shows the "name" (CTSS string) of the active Sim. Parameters #1 and #5 are not needed - the value in #5 is ignored - and #6 is again the ordinary message dialog.

The above should be enough information to create any dialog the game can display. Now for the info which dialogs return to the game. Two obvious values are True for the OK/Yes button and False for the No-button. In Yes/No/Cancel dialogs, Temporary Storage 0 is used to distinguish between No and Cancel; in both cases the dialog returns False, but for No, TS0=0, and for Cancel, TS0=1. These are the values returned by choice dialogs.

The text entry dialog accepts a string of text, but only seems to do anything with this string when creating a baby or pet using function 19, "Make new character". I haven't found a way of using this dialog to rename an existing Sim.

All the "choose lot" dialogs return the lot number in Temporary Storage 0.

The phone book returns the GUID of a Sim in Temporary Storage 0.

The wardrobe and "choose magic outfit" dialogs return the number of an outfit and make the Sim dress in that outfit number. Sadly, there's not a lot the Sim hacker can do with this, because for normal outfits, the game internally numbers the skins as it loads them, so the number may be different each time. The "magic" outfits are hard-coded into the game executable.

The pet choice dialog is basically a wardrobe dialog for animal Sims.

I don't see what value the book dialogs should return, as they are read for information, not used to make a choice. They can't be used to select something.

That's it for dialogs. A warning when messing with dialogs: misapplying the phone book, other book and wardrobe dialogs won't have serious effects, but simply pasting lot-choosing dialogs into a BHAV makes the cab screen for that lot type come up - and stay up. Basically, the game is frozen. Also: when using a dialog specific to an expansion pack, always check if that expansion pack is installed. The instruction for this is included in the next page, Menu misery and version detection.





Back Previous Next