What am I doing wrong?

Equivalent

New Member
Reaction score
0
I'm trying to make a dialog box which asks the owner of the unit if they would like to move to a city. I get the box and everything, but the hero doesn't teleport. Here are my trigger codes:

Trigger 1:
Code:
Dialog to City
    Events
        Unit - A unit comes within 100.00 of Admiral Proudmoore 0081 <gen>
    Conditions
    Actions
        Dialog - Clear To_City
        Dialog - Change the title of To_City to Travel to the City ...
        Dialog - Create a dialog button for To_City labelled Yes
        Set ToCity_Answer_Yes[1] = (Last created dialog Button)
        Dialog - Create a dialog button for ToVictoriaIsland labelled No
        Set To_City_Answer_No[2] = (Last created dialog Button)
        Dialog - Show To_City for (Owner of (Triggering unit))

Trigger 2

Code:
Button Yes
    Events
        Dialog - A dialog button is clicked for To_City
    Conditions
        (Clicked dialog button) Equal to ToCity_Answer_Yes[1]
    Actions
        Unit - Move (Triggering unit) instantly to (Center of City Start Region <gen>)

Trigger 3

Code:
Button No
    Events
        Dialog - A dialog button is clicked for To_City
    Conditions
        (Clicked dialog button) Equal to ToCity_Answer_Yes[2]
    Actions
        Dialog - Hide To_City for (Triggering player)


What am I doing wrong? Also, how can I make it so that the player has to pay a certain amount of gold if they choose Yes.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
There is no Triggering Unit when you click a dialog button. You need to set a variable to the unit you want to move. And if they choose yes, you should have an if/then/else to see if [((Triggering Player) Current Gold) greater than or equal to (However much they need to have)], and if so move the unit.
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
You can compress Triggers 2 and 3 into 1 trigger as follows:

Code:
To City Dialog Button Clicked
    Events
        Dialog - A dialog button is clicked for To_City_Dialog
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Clicked dialog button) Equal to To_City_Dialog_Button[1]
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Player 1 (Red) Current gold) Greater than or equal to 100
                    Then - Actions
                        Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - 100)
                        Dialog - Hide To_City_Dialog for Player 1 (Red)
                        Unit - Move (Triggering unit) instantly to (Center of City Start Region <gen>)
                    Else - Actions
                        Dialog - Hide To_City_Dialog for Player 1 (Red)
                        Game - Display to Player Group - Player 1 (Red) the text: You don't have enou...
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Clicked dialog button) Equal to To_City_Dialog_Button[2]
            Then - Actions
                Dialog - Hide To_City_Dialog for Player 1 (Red)
            Else - Actions

NB: To_City_Dialog_Button[1] represents 'Yes' and To_City_Dialog_Button[2] represents 'No'. Also, you got to remember to hide the dialog when you press 'Yes' as well haha.

And as KaerfNomekop said, you have to create a unit variable and set the unit you want to teleport to that variable.

Also as KaerfNomekop said, you must use an If/Else/Then statement to check whether the player has enough gold. I've used 100 gold as an example in my trigger above, but you can use whatever value you want.
 

Equivalent

New Member
Reaction score
0
And as KaerfNomekop said, you have to create a unit variable and set the unit you want to teleport to that variable.

Wait, so if I create the unit variable, how would I attach it to something? Sorry, I'm kind of new :)
 

Equivalent

New Member
Reaction score
0
I got it to work, but I had to set the variable to equal to a specific unit in the game. What if the unit isn't existing and is made when the game starts?

Here's the code though:


Code:
To City Buttons
    Events
        Dialog - A dialog button is clicked for To_City
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Clicked dialog button) Equal to ToCity_Answer_Yes[1]
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Triggering player) Current gold) Greater than or equal to 150
                    Then - Actions
                        Player - Add -150 to (Triggering player) Current gold
                        Set Teleporting_Unit = Map Tester 0005 <gen>
                        Unit - Move Teleporting_Unit instantly to (Center of City Start Region <gen>)
                        Dialog - Hide To_City for (Triggering player)
                    Else - Actions
                        Dialog - Hide To_City for (Triggering player)
                        Game - Display to (All players) the text: You don't have enou...
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Clicked dialog button) ToCity_Answer_No[2]
                    Then - Actions
                        Dialog - Hide To_City for (Triggering player)
                    Else - Actions

Teleporting_Unit = Unit Variable
 

NeuroToxin

New Member
Reaction score
46
You shouldn't use specific unit. In your beginning trigger, A unit comes within range of Proudmoore, set the teleporting unit equal to the triggering unit. Then you can use that for your dialog.
 

death_knight

Dark is the heart of a corrupted man.
Reaction score
24
Equivalent: if the unit doesn't exist when the map starts, then you can set the unit variable to 'Last created unit' when you get around to creating it. But NeuroToxin's suggestion is probably better
 

Ioannes

Oh man, I shot Marvin in the face.
Reaction score
49
to begin with, the title of the thread is fail, because it doesn't mention anything about the problem
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top