• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Dialogs

Ralle

Owner
Level 77
Joined
Oct 6, 2004
Messages
10,098
Introduction
Many maps are using dialogs for choosing races and different settings. Dialogs are smart because it spares you for writing lots of lots of commands to do the different things.

Requirements
A dialog requires triggers for each function, a trigger to popup the dialog and a trigger to set up the dialog buttons with variables.

Variables
You will need the following variables.

A variable defining the dialog,
Variable Name: MyDialog
Variable Type: Dialog


Variables defining the different dialog buttons, (make one for each button: Dialog Button1, Dialog Button2 etc..)

Variable Name: Dialog Button1
Variable Type: Dialog Button

Variable Name: Dialog Button2
Variable Type: Dialog Button

Variable Name: Dialog Button3
Variable Type: Dialog Button


Setup the dialog
This trigger will set up a dialog for us:
[trigger:1:ccffeed823]Setup Dialog
Events
Time - Elapsed game time is 0.01 seconds
Conditions
Actions
Dialog - Change the title of MyDialog to DialogTitle
Dialog - Create a dialog button for MyDialog labelled RaceA
Set DialogButton1 = (Last created dialog Button)
Dialog - Create a dialog button for MyDialog labelled RaceB
Set DialogButton2 = (Last created dialog Button)
Dialog - Create a dialog button for MyDialog labelled RaceC
Set DialogButton3 = (Last created dialog Button)
Dialog - Create a dialog button for MyDialog labelled Cancel[/trigger:1:ccffeed823]
When running a trigger only once in the beginning of a map, it's best to use an event like:
Time - Elapsed game time is 0.01 seconds
instead of the event:
Map initialization
Because sometimes when using the map initializaion, it either doesn't run or it messes up the game.

Display Dialog
Displaying the dialog is very simple. You just decide when and who it will be showed to:
[trigger:1:ccffeed823]Run MyDialog
Events
Player - Player 1 (Red) types a chat message containing run dialog as An exact match
Player - Player 2 (Blue) types a chat message containing run dialog as An exact match
Player - Player 3 (Teal) types a chat message containing run dialog as An exact match
Conditions
Actions
Dialog - Show MyDialog for (Triggering player)[/trigger:1:ccffeed823]
The events makes the trigger run if player 1, 2 or 3 types "run dialog"

When using the player Triggering player it refers to the playing doing the action. So it doesn't matter which player opening the dialog, it will do the function to him.

Dialog Actions
This is the part using most triggers, you will have to define a trigger for each action in the dialog.

This is for the first function of our dialog, it runs when someone clicked on a dialog button for MyDialog
[trigger:1:ccffeed823]Run Dialog Function 1
Events
Dialog - A dialog button is clicked for MyDialog
Conditions
(Clicked dialog button) Equal to DialogButton1
Actions
Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees [/trigger:1:ccffeed823]
Second it checks the condition: the clicked dialog button is equal to DialogButton1, if true, it runs the actions.
The action here is that it gives triggering player a Footman at the center of the map. It isn't really useful for anything but it describes well how to make the action of a dialog button.

I made two more triggers which I will list here:
[trigger:1:ccffeed823]Run Dialog Function 2
Events
Dialog - A dialog button is clicked for MyDialog
Conditions
(Clicked dialog button) Equal to DialogButton2
Actions
Unit - Create 1 Grunt for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees[/trigger:1:ccffeed823]
[trigger:1:ccffeed823]Run Dialog Function 3
Events
Dialog - A dialog button is clicked for MyDialog
Conditions
(Clicked dialog button) Equal to DialogButton3
Actions
Unit - Create 1 Archer for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees[/trigger:1:ccffeed823]
These triggers are very much the same as the first one, they just check for DialogButton2 and DialogButton3 and has different actions:
The first one creates a grunt.
The second one creates an archer.

This is how our dialog will look like when ingame:
dialogs.jpg

Remember to type "run dialog" to display the dialog!
 

Attachments

  • dialog_402.w3m
    17 KB · Views: 112
Top