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

Dialog Button

Status
Not open for further replies.
Level 4
Joined
Mar 12, 2009
Messages
64
I was wondering, is there a way to merge dialog buttons events together so you can use less triggers.

  • TEST Hero SOldier
    • Events
      • Dialog - A dialog button is clicked for Class_Board
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Class_NO
        • Then - Actions
          • Dialog - Hide Class_Board for (Owner of (Entering unit))
          • Unit - Move (Entering unit) instantly to (Center of Soul Spawn <gen>)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Class_YES
        • Then - Actions
          • Dialog - Hide Class_Board for (Owner of (Entering unit))
          • Unit - Create 1 Soldier for (Owner of (Entering unit)) at (Center of Starting Spawn <gen>) facing 45.00 degrees
        • Else - Actions
          • Do nothing
Something like that? I can't seem to figure it out.
 
Is this your only trigger with dialogs?

For this trigger you can remove the "Do nothing". Never use those just leave it blank. The game will actually "do nothing" instead of not doing anything. Yes, confusing.

Also. Move the "Yes" if/then/else up to the else in the NO if/then/else.

Please remember that using "Entering unit" will not work in this trigger. Instead store your unit in a unit variable and refer to that variable in your trigger.
 
Level 4
Joined
Mar 12, 2009
Messages
64
  • Test Hero Select
    • Events
      • Unit - A unit enters Soldier <gen>
    • Conditions
    • Actions
      • Dialog - Clear Class_Board
      • Dialog - Change the title of Class_Board to Are you sure?
      • Dialog - Create a dialog button for Class_Board labelled Yes
      • Set Class_YES = (Last created dialog Button)
      • Dialog - Create a dialog button for Class_Board labelled No
      • Set Class_NO = (Last created dialog Button)
      • Dialog - Show Class_Board for (Owner of (Entering unit))
That is what i had for the first part.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
(Owner of (Entering unit)) should probably replaced with (Triggering player). The GetOwningPlayer native with retrieve "null" when responding to "Dialog buttun clicked".
If you are familiar with vJass, you could also make use of Dialog & Button - it is made exactly to ease event handling when working with dialogs and extends some of thier functionality.

In regard to leaks DSG mentioned about: e.g (Center of Starting Spawn <gen>) - you should store these locations and remove them when they are no longer needed. Things that leak.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Are these calls necessary?

Dialog - Hide Class_Board for (Owner of (Entering unit))

I recall dialogs automatically hide themselves after a button is clicked.
 
Level 4
Joined
Mar 12, 2009
Messages
64
  • Test Hero Select Soldier
    • Events
      • Unit - A unit enters Soldier <gen>
    • Conditions
    • Actions
      • Set Hero_Unit_Var_Selection[1] = (Entering unit)
      • Dialog - Clear Class_Board
      • Dialog - Change the title of Class_Board to Are you sure?
      • Dialog - Create a dialog button for Class_Board labelled Yes
      • Set Class_YES = (Last created dialog Button)
      • Dialog - Create a dialog button for Class_Board labelled No
      • Set Class_NO = (Last created dialog Button)
      • Dialog - Show Class_Board for (Owner of Hero_Unit_Var_Selection[1])
  • Test Hero Select Mystic
    • Events
      • Unit - A unit enters Mystic Ranger <gen>
    • Conditions
    • Actions
      • Set Hero_Unit_Var_Selection[2] = (Entering unit)
      • Dialog - Clear Class_Board
      • Dialog - Change the title of Class_Board to Are you sure?
      • Dialog - Create a dialog button for Class_Board labelled Yes
      • Set Class_YES = (Last created dialog Button)
      • Dialog - Create a dialog button for Class_Board labelled No
      • Set Class_NO = (Last created dialog Button)
      • Dialog - Show Class_Board for (Owner of Hero_Unit_Var_Selection[2])
  • TEST Hero Button Click
    • Events
      • Dialog - A dialog button is clicked for Class_Board
    • Conditions
    • Actions
      • -------- Mystic Ranger Button --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Class_YES
          • Hero_Unit_Var_Selection[2] Equal to Hero_Unit_Var_Selection[2]
        • Then - Actions
          • Unit - Remove Hero_Unit_Var_Selection[2] from the game
          • Set Loc = (Center of Starting Spawn <gen>)
          • Unit - Create 1 Sylvanas Windrunner for (Owner of Hero_Unit_Var_Selection[2]) at Loc facing 45.00 degrees
          • Custom script: call RemoveLocation(udg_Loc)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Class_NO
          • Hero_Unit_Var_Selection[2] Equal to Hero_Unit_Var_Selection[2]
        • Then - Actions
          • Set Loc = (Center of Soul Spawn <gen>)
          • Unit - Move Hero_Unit_Var_Selection[2] instantly to Loc
          • Custom script: call RemoveLocation(udg_Loc)
        • Else - Actions
      • -------- Soldier Buttons --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Class_YES
          • Hero_Unit_Var_Selection[1] Equal to Hero_Unit_Var_Selection[1]
        • Then - Actions
          • Unit - Remove Hero_Unit_Var_Selection[1] from the game
          • Set Loc = (Center of Starting Spawn <gen>)
          • Unit - Create 1 Soldier for (Owner of Hero_Unit_Var_Selection[1]) at Loc facing 45.00 degrees
          • Custom script: call RemoveLocation(udg_Loc)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Class_NO
          • Hero_Unit_Var_Selection[1] Equal to Hero_Unit_Var_Selection[1]
        • Then - Actions
          • Set Loc = (Center of Soul Spawn <gen>)
          • Unit - Move Hero_Unit_Var_Selection[1] instantly to Loc
          • Custom script: call RemoveLocation(udg_Loc)
        • Else - Actions
I was working around on what you guys said. I figure to try this way out. now, I tested this and it seems to work but I wanted a second opinion on it.
 
Status
Not open for further replies.
Top