Need help with adding heroes with dialogs

Bitterstone

New Member
Reaction score
1
Hi there, i got a rather weird problem... I want to add heroes with a dialog, the thing that happens is that first it adds the selected hero then it add everyone else asweell, so i get all the heroes when i push one button. I followed AceHart's guide and I have exactly the same triggers and codes etc etc, except: i've added some heroes, instead of 8 heroes i have 16 so i have 4 dialogs instead of 2. I have double-checked the code SEVERAL times and as i can see i have the same code as AceHart showed in the Guide.
Ok, this is the code I have in my trigger:
(Dia means Dialog)

Heroes (the Heroes is being set)

Code:
Events -
    Map initialization
Conditions -
Actions -
    Set Heroes[1] = Paladin
    Set Heroes[2] = Archmage
    Set Heroes[3] = Mountain King
    Set Heroes[4] = Blood Mage
    Set Heroes[5] = No unit-type
    Set Heroes[6] = Blademaster
    Set Heroes[7] = Far Seer
    Set Heroes[8] = Tauren Chieftain
    Set Heroes[9] = Shadow Hunter
    Set Heroes[10] = No unit-type
    Set Heroes[11] = Death Knight
    Set Heroes[12] = Lich
    Set Heroes[13] = Dreadlord
    Set Heroes[14] = Crypt Lord
    Set Heroes[15] = No unit-type
    Set Heroes[16] = Keeper of the Grove
    Set Heroes[17] = Priestess of the Moon
    Set Heroes[18] = Demon Hunter
    Set Heroes[19] = Warden
    Set Heroes[20] = No unit-type
DiaHeroes (the dialog with the Heroes)

Code:
Events -
    Dialog - A dialog button is clicked for MyDialog
Conditions -
    ((Clicked dialog button) Equal to DiaBtn[3]) or ((Clicked dialog button) Equal to DiaBtn[4])
Actions -
    Dialog - Clear HeroDia1
    Dialog - Change the title of HeroDia1 to Choose a Hero (1/4)
    Dialog - Create a dialog button for HeroDia1 labelled Paladin
    Set HeroBtn[1] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia1 labelled Archmage
    Set HeroBtn[2] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia1 labelled Mountain King
    Set HeroBtn[3] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia1 labelled Blood Mage
    Set HeroBtn[4] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia1 labelled to page 2
    Set HeroBtn[5] = (Last created dialog Button)
    Dialog - Clear HeroDia2
    Dialog - Change the title of HeroDia2 to Choose a Hero (2/4)
    Dialog - Create a dialog button for HeroDia2 labelled Blademaster
    Set HeroBtn[6] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia2 labelled Far Seer
    Set HeroBtn[7] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia2 labelled Tauren Chieftain
    Set HeroBtn[8] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia2 labelled Shadow Hunter
    Set HeroBtn[9] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia2 labelled to page 3
    Set HeroBtn[10] = (Last created dialog Button)
    Dialog - Clear HeroDia3
    Dialog - Change the title of HeroDia3 to Choose a Hero (3/4)
    Dialog - Create a dialog button for HeroDia3 labelled Death Knight
    Set HeroBtn[11] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia3 labelled Lich
    Set HeroBtn[12] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia3 labelled Dreadlord
    Set HeroBtn[13] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia3 labelled Crypt Lord
    Set HeroBtn[14] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia3 labelled to page 4
    Set HeroBtn[15] = (Last created dialog Button)
    Dialog - Clear HeroDia4
    Dialog - Change the title of HeroDia4 to Choose a Hero (4/4)
    Dialog - Create a dialog button for HeroDia4 labelled Keeper of the Grove
    Set HeroBtn[16] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia4 labelled Priestess of the Mo...
    Set HeroBtn[17] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia4 labelled Demon Hunter
    Set HeroBtn[18] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia4 labelled Warden
    Set HeroBtn[19] = (Last created dialog Button)
    Dialog - Create a dialog button for HeroDia4 labelled to page 1
    Set HeroBtn[20] = (Last created dialog Button)
    Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        Loop - Actions
            Dialog - Show HeroDia1 for (Picked player)
DoDiaHeroes (Activating the Buttons in the Dialog)

Code:
Events -
    Dialog - A dialog button is clicked for HeroDia1
    Dialog - A dialog button is clicked for HeroDia2
    Dialog - A dialog button is clicked for HeroDia3
    Dialog - A dialog button is clicked for HeroDia4
Conditions -
Actions -
    -------- Switch to page 2 --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Clicked dialog button) Equal to HeroBtn[5]
        Then - Actions
            Dialog - Change the title of HeroDia2 to Choose a Hero (2/4)
            Dialog - Show HeroDia2 for (Triggering player)
            Skip remaining actions
        Else - Actions
    -------- Switch to page 3 --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Clicked dialog button) Equal to HeroBtn[10]
        Then - Actions
            Dialog - Change the title of HeroDia3 to Choose a Hero (3/4)
            Dialog - Show HeroDia3 for (Triggering player)
            Skip remaining actions
        Else - Actions
    -------- Switch to page 4 --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Clicked dialog button) Equal to HeroBtn[15]
        Then - Actions
            Dialog - Change the title of HeroDia4 to Choose a Hero (4/4)
            Dialog - Show HeroDia4 for (Triggering player)
            Skip remaining actions
        Else - Actions
    -------- Switch to page 1 --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Clicked dialog button) Equal to HeroBtn[20]
        Then - Actions
            Dialog - Change the title of HeroDia1 to Choose a Hero (1/4)
            Dialog - Show HeroDia1 for (Triggering player)
            Skip remaining actions
        Else - Actions
    -------- Hero Selection --------
    For each (Integer A) from 1 to 20, do (Actions)
        Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    (Clicked dialog button) Equal to HeroBtn[(Integer A)]
                Then - Actions
                    Unit - Create 1 Heroes[(Integer A)] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
                    Selection - Select (Last created unit) for (Triggering player)
                    Game - Display to (Player group((Triggering player))) the text: (Name of (Last created unit))
                Else - Actions
And here is the variables i'm using:

HeroBtn - Dialog Button Array (20) - - none -
HeroDia1 - Dialog - New Dialog (Default)
HeroDia2 - Dialog - New Dialog (Default)
HeroDia3 - Dialog - New Dialog (Default)
HeroDia4 - Dialog - New Dialog (Default)
Heroes - Unit-Type Array (20) - - none -

Oh mi gosh, its alot of code... I REALLY hope someone will bother reading this and try to help me :).
Well well, thanks for reading and trying to help (If you did).
 

rodead

Active Member
Reaction score
42
first of all what is your problem i don't really get it second use code tags and tird you can copy trigger as text so it is easy to show someone else.
 

Bitterstone

New Member
Reaction score
1
lawl stupid me

first of all what is your problem i don't really get it second use code tags and tird you can copy trigger as text so it is easy to show someone else.

Well, i was kinda tired yesterday so... well the problem is that when i push a button in the dialog it firstly adds the selected hero then it adds everone else... And with the code, i did actually copy as text and just pasted it in!
 

Exide

I am amazingly focused right now!
Reaction score
448
Code:
    -------- Hero Selection --------
    For each (Integer A) from 1 to 20, do (Actions)
        Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    (Clicked dialog button) Equal to HeroBtn[(Integer A)]
                Then - Actions
                    Unit - Create 1 Heroes[(Integer A)] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
                    Selection - Select (Last created unit) for (Triggering player)
                    Game - Display to (Player group((Triggering player))) the text: (Name of (Last created unit))
                Else - Actions
Not sure about using a loop and Integer A here.. Looks like it could cause trouble for you, when clicking a button.
Could you give us a link to AceHart's Guide?
 

Exide

I am amazingly focused right now!
Reaction score
448
After reading the tutorial in the link, I can't see anything wrong with your triggers. You should double-check your variables, though. Make sure they have an array of 20, and not 10, like in the Tutorial. Other than that I don't know.

Does your trigger show the name of ALL your heroes as well, or just the last one?

Maybe this trigger wasn't tested before becoming a Tutorial.. I doubt that, though.

If all else fails, you could do a looong trigger like: If Clicked Dialog button was DiaBtn1 then add Paladin, If blabla was DiaBtn2 then add Archmage .. and so on..

EDIT: Also make sure that you show the dialog after map init. Like; 'Elapsed game time is 1.00 seconds.', so that the Hero Index is set properly.
 

Bitterstone

New Member
Reaction score
1
After reading the tutorial in the link, I can't see anything wrong with your triggers. You should double-check your variables, though. Make sure they have an array of 20, and not 10, like in the Tutorial. Other than that I don't know.

Does your trigger show the name of ALL your heroes as well, or just the last one?

Maybe this trigger wasn't tested before becoming a Tutorial.. I doubt that, though.

If all else fails, you could do a looong trigger like: If Clicked Dialog button was DiaBtn1 then add Paladin, If blabla was DiaBtn2 then add Archmage .. and so on..

EDIT: Also make sure that you show the dialog after map init. Like; 'Elapsed game time is 1.00 seconds.', so that the Hero Index is set properly.

I've checked the variables, they are set to 20.
The trigger shows all heroes, not just the last one.
The trigger is tested for the guide, s/he attached a demo file for the trigger aswell, and in that demo the trigger works.
The Hero Index is properly set.

I geuss i'll have to make the looooong one then
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top