• 🏆 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!

[Trigger] Dialog/Unit Malfunction, help!

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
I'm having problems with this trigger, its a "select your hero" dialog but no matter what choice you take it's only spawning the first hero of the list.

Can anyone shed a light here, please ?

  • DoDialog
    • Events
      • Dialog - A dialog button is clicked for HeroDialog1
      • Dialog - A dialog button is clicked for HeroDialog2
    • 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 DialogButtons[5]
        • Then - Actions
          • Dialog - Change the title of HeroDialog2 to Choose a Hero (2/2)
          • Dialog - Show HeroDialog2 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 DialogButtons[10]
        • Then - Actions
          • Dialog - Change the title of HeroDialog1 to Choose a Hero (1/2)
          • Dialog - Show HeroDialog1 for (Triggering player)
          • Skip remaining actions
        • Else - Actions
      • -------- Create the chosen Hero --------
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to DialogButtons[(Integer A)]
            • Then - Actions
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Picked player) Not equal to Player 2 (Blue)
                      • (Picked player) Not equal to Player 3 (Teal)
                    • Then - Actions
                      • Set Playerss[(Player number of (Picked player))] = (Picked player)
                    • Else - Actions
              • For each (Integer A) from 1 to 10, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Playerss[(Integer A)] slot status) Equal to Is playing
                    • Then - Actions
                      • Camera - Lock camera target for (Player((Integer A))) to Unit[(Integer A)], offset by (0.00, 0.00) using The unit's rotation
                      • Camera - Set (Player((Integer A)))'s camera Distance to target to 250.00 over 0.00 seconds
                      • Camera - Set (Player((Integer A)))'s camera Angle of attack to 345.00 over 0.00 seconds
                      • Camera - Set (Player((Integer A)))'s camera Field of view to 1000.00 over 0.00 seconds
                      • Set Angle[(Integer A)] = 0.00
                      • Set Speed[(Integer A)] = 0.00
                      • Set AnimationSpeed[(Integer A)] = 0.50
                      • Set Location[(Integer A)] = (Random point in (Playable map area))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Playerss[(Integer A)] is an ally of Player 2 (Blue)) Equal to True
                        • Then - Actions
                          • Unit - Create 1 Heroes[(Integer A)] for (Player((Integer A))) at (Center of Time1 <gen>) facing (Center X of Centro <gen>) degrees
                          • Set Unit[(Integer A)] = (Last created unit)
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Playerss[(Integer A)] is an ally of Player 3 (Teal)) Equal to True
                        • Then - Actions
                          • Unit - Create 1 Heroes[(Integer A)] for (Player((Integer A))) at (Center of Time2 <gen>) facing (Center X of Centro <gen>) degrees
                          • Set Unit[(Integer A)] = (Last created unit)
                        • Else - Actions
                      • Selection - Select Unit[(Integer A)] for Playerss[(Integer A)]
                      • Unit - Make Unit[(Integer A)] face Angle[(Integer A)] over 0.00 seconds
                      • Camera - Set Playerss[(Integer A)]'s camera Rotation to Angle[(Integer A)] over 0.00 seconds
                      • Custom script: call RemoveLocation(udg_Location[1])
                    • Else - Actions
            • Else - Actions
 
Level 11
Joined
Oct 9, 2015
Messages
721
here it is

  • ShowDialog
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- Setup for Dialog 1 --------
      • Dialog - Clear HeroDialog1
      • Dialog - Change the title of HeroDialog1 to Choose a Hero (1/2)
      • Dialog - Create a dialog button for HeroDialog1 labelled Alchemist
      • Set DialogButtons[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog1 labelled Naga Sea Witch
      • Set DialogButtons[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog1 labelled Tinker
      • Set DialogButtons[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog1 labelled Beastmaster
      • Set DialogButtons[4] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog1 labelled ...to page 2
      • Set DialogButtons[5] = (Last created dialog Button)
      • -------- Setup for Dialog 2 --------
      • Dialog - Clear HeroDialog2
      • Dialog - Change the title of HeroDialog2 to Choose a Hero (2/2)
      • Dialog - Create a dialog button for HeroDialog2 labelled Dark Ranger
      • Set DialogButtons[6] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog2 labelled Firelord
      • Set DialogButtons[7] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog2 labelled Pandaren Brewmaster
      • Set DialogButtons[8] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog2 labelled Pit Lord
      • Set DialogButtons[9] = (Last created dialog Button)
      • Dialog - Create a dialog button for HeroDialog2 labelled ...to page 1
      • Set DialogButtons[10] = (Last created dialog Button)
      • -------- Showing the dialog to all players --------
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • Dialog - Show HeroDialog1 for (Picked player)

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Preparing Hero List --------
      • Set Heroes[1] = Alchemist
      • Set Heroes[2] = Naga Sea Witch
      • Set Heroes[3] = Tinker
      • Set Heroes[4] = Beastmaster
      • Set Heroes[5] = No unit-type
      • Set Heroes[6] = Dark Ranger
      • Set Heroes[7] = Firelord
      • Set Heroes[8] = Pandaren Brewmaster
      • Set Heroes[9] = Pit Lord
      • Set Heroes[10] = No unit-type
 
Level 18
Joined
Oct 17, 2012
Messages
821
The hero chosen is always the same because you refer to the player number to choose the correct hero. The index should be the same as the index of the button clicked.

To fix this, change Integer A for the inner loop to a different integer. Once that changes, every action that has an index should use the new integer except for the actions for creating the heroes.

I also think you could have done the hero creation in a more elegant and efficient manner. Why do you create heroes for every player each time a button is clicked? Are you concerned with issues that may arise from two players clicking the same button at the same time?
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
I'm actually using a pre-made trigger and changing it as my desire, i did this and it seemed to work:

  • (Clicked dialog button) Equal to DialogButtons[1]
  • Set Unit[(Player number of (Triggering player))] = (Last created unit)
however, as you said, I'm looking for the most efficient method to do this
 
Status
Not open for further replies.
Top