AdvancedMessageBox Documentation


There are many dialog boxes in HoMM II. Some of them display images; some of them have questions or two choices. 

 

The HoMM II source code has a very complicated function called NormalDialog with 10 parameters, which has all these options. 

 

For your common dialog needs, you can use MessageBox or QuestionBox or InputBox. For a few more common variants, such as displaying a dialog box with one or two images, you can use the functions in the AdvMessageBox Lua module. For common uses that aren't in that module, make a request, and we'll add to that module. But if you really need to do something different, you can use the raw AdvancedMessageBox function.

 

If this function doesn't make sense, that's not because you're stupid. It's because this function doesn't make sense.

 

Thank you to forum user DarkAtom and Ironfist team member Matt Jones for their work reverse-engineering this function.

 

 

Syntax:
AdvancedMessageBox(text, dialogtype, position1, position2, img1type, img1arg, img2type, img2arg, writeOr, a10)

text: A string or a variable that contains a string to be displayed
dialogtype: An integer (will be explained below)
position1 and position2: Controls the alignment of the message box. Explained below.
imgtype and imgarg: The image parameters will be explained below.
writeOr: If you set this to DIALOG_OR (1) then an 'or' text will appear in the middle of the box, between the 2 pictures. If only one picture is used, the 'or' text is displayed on top of it. If anything else is passed for this parameter, the "or" will not be shown.
a10:  This parameter is ignored always set to 0.below.


Returns: Depends on the dialog type. Some dialog types present multiple options, and AdvancedMessageBox will return true or false accordingly. For others, it will return true. See the documentation under Dialog types.

 

Text:

 

If you enclose text between curly braces {} then the text becomes golden.

 

Dialogue types:

 

For now (Ironfist 1.3.0), none of the dialog types return anything, so it only makes sense to use types 1/5 and 3/6.

 

Positions

 

The third parameter, position1, changes the position of the messagebox on a horizontal axis. Setting the parameter to 0 moves it to the complete left of the screen and setting it to -1 moves it completely to the right. The higher the negative value, the more to the left it moves, and the higher the positive value the more to the right it moves. If you move a messagebox completely off screen it will wrap around to the other side of the screen. 

 

Changing the position2 parameter moves it on a vertical axis. However, on this one -1 lowers the message box and 0 raises it. The higher you set the value in the positive direction, the box will move down on the vertical axis. If you change the integer value below -1 the game will crash.



Image types:


The fifth and sixth parameter deal with displaying images in the message box. The fifth decides which "group" the images will be pulled from, and then the sixth parameter determines which image from that group should be displayed. The range for this stops at -1. Anything below it causes a crash. The value -1 itself displays no image. Here is an index for each image group:



Image subtypes (the number in the list represents the type for which the subtype applies)



Skills: Count the skills in the order from the wiki starting from 0 and stop at the one desired. Then multiply by 3 to get the basic picture. Add 1 for advanced, or 2 for expert.
Hero portraits: To display town captains, use 90-95 (knight, barbarian, sorceress, warlock, wizard, necromancer)

 

Resources: If you choose image type resource (0-6), you can set the subtype as negative and it will show the qty/day thing like from the mines. So if I set it to -6, for example, the message will show 6/day.

 

If you want to show negative values (like when taking resources), put the subtype -x-100000, where x is the value. So -100050 would show -50. If you put exactly -100000, it shows 100k/day, not -0.