• 🏆 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] Condition for two dialogs not to be executed at the same time

Status
Not open for further replies.
Level 23
Joined
Dec 24, 2019
Messages
400
Hello everyone, I have encountered a problem that I don't know how to solve.
01oesS2.png
I have these two triggers that separately work perfectly, but when both heroes level up at the same time they overlap and everything fails. I need to know how to make them not run at the same time even though both heroes go up at the same time, let one be run first and then another.

Thanks, I hope someone can help me.
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
If it's just these two triggers, you could make a few boolean variables and use them to determine if you should show the dialog now or after a button from the other dialog was clicked. Something like this:
  • PathsPLx
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Leveling Hero) Equal to PLx
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogAlreadyDisplayed Equal to True
        • Then - Actions
          • Set VariableSet RunPathsPLxLater = True
          • Skip remaining actions
        • Else - Actions
      • Set VariableSet DialogAlreadyDisplayed = True
      • -------- Rest of the trigger where you create dialog buttons, etc. --------
The trigger above will check if the DialogAlreadyDisplayed is True - if yes, it will set RunPathsPLxLater to True and end the trigger, so no dialog for the PLx unit will be shown at the moment. If DialogAlreadyDisplayed is not True, it will set it to True to prevent the dialog for DLx from showing.
The trigger for DLx should be set up the same way, just use RunPathsDLxLater variable instead of the PLx one.

In your trigger(s) that react when you click a button from the dialog created before, you do whatever you do now and at the end you also add this:
  • Actions
    • -------- At the end, when dialog button for DLx was clicked --------
    • Set VariableSet DialogAlreadyDisplayed = False
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • RunPathsPLxLater Equal to True
      • Then - Actions
        • Trigger - Run PathsPLx <gen> (ignoring conditions)
      • Else - Actions
So the above assumes that you clicked on a dialog button for the DLx unit. You do something and at the end you check if you should re-run the PathsPLx trigger via RunPathsPLxLater variable.
If yes, you run the trigger - ignoring conditions. This should work in case like this, because the actions in those triggers do not seem to have anything to do with the units themselves and the player is also static.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
Nichilus beat me to the punch!

I guess I'll post my method anyway, it's basically the same thing:

Create an Integer variable and use it to know when the other dialog is open. If it is already open, don't run the Dialog actions yet.
  • Show Path Dialog DLx
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Learning Hero) Equal to DLx
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Equal to 0
        • Then - Actions
          • -------- Setup DLx dialog --------
          • Dialog - Change the title of PathsDLx to ...
          • Dialog - Show PathsDLx for Player 7 (Green)
        • Else - Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter + 1)
  • Show Path Dialog PLx
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Learning Hero) Equal to PLx
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Equal to 0
        • Then - Actions
          • -------- Setup PLx dialog --------
          • Dialog - Change the title of PathsPLx to ...
          • Dialog - Show PathsPLx for Player 7 (Green)
        • Else - Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter + 1)
  • Click DLx Button
    • Events
      • Dialog - A dialog button is clicked for PathsDLx
    • Conditions
    • Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Greater than 0
        • Then - Actions
          • Trigger - Run Show Path Dialog PLx <gen> (ignoring conditions)
        • Else - Actions
  • Click PLx Button
    • Events
      • Dialog - A dialog button is clicked for PathsPLx
    • Conditions
    • Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Greater than 0
        • Then - Actions
          • Trigger - Run Show Path Dialog DLx <gen> (ignoring conditions)
        • Else - Actions
I believe this should work and allow for multiple levels to stack Dialog uses.
 
Level 23
Joined
Dec 24, 2019
Messages
400
If it's just these two triggers, you could make a few boolean variables and use them to determine if you should show the dialog now or after a button from the other dialog was clicked. Something like this:
  • PathsPLx
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Leveling Hero) Equal to PLx
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogAlreadyDisplayed Equal to True
        • Then - Actions
          • Set VariableSet RunPathsPLxLater = True
          • Skip remaining actions
        • Else - Actions
      • Set VariableSet DialogAlreadyDisplayed = True
      • -------- Rest of the trigger where you create dialog buttons, etc. --------
The trigger above will check if the DialogAlreadyDisplayed is True - if yes, it will set RunPathsPLxLater to True and end the trigger, so no dialog for the PLx unit will be shown at the moment. If DialogAlreadyDisplayed is not True, it will set it to True to prevent the dialog for DLx from showing.
The trigger for DLx should be set up the same way, just use RunPathsDLxLater variable instead of the PLx one.

In your trigger(s) that react when you click a button from the dialog created before, you do whatever you do now and at the end you also add this:
  • Actions
    • -------- At the end, when dialog button for DLx was clicked --------
    • Set VariableSet DialogAlreadyDisplayed = False
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • RunPathsPLxLater Equal to True
      • Then - Actions
        • Trigger - Run PathsPLx <gen> (ignoring conditions)
      • Else - Actions
So the above assumes that you clicked on a dialog button for the DLx unit. You do something and at the end you check if you should re-run the PathsPLx trigger via RunPathsPLxLater variable.
If yes, you run the trigger - ignoring conditions. This should work in case like this, because the actions in those triggers do not seem to have anything to do with the units themselves and the player is also static.
Nichilus beat me to the punch!

I guess I'll post my method anyway, it's basically the same thing:

Create an Integer variable and use it to know when the other dialog is open. If it is already open, don't run the Dialog actions yet.
  • Show Path Dialog DLx
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Learning Hero) Equal to DLx
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Equal to 0
        • Then - Actions
          • -------- Setup DLx dialog --------
          • Dialog - Change the title of PathsDLx to ...
          • Dialog - Show PathsDLx for Player 7 (Green)
        • Else - Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter + 1)
  • Show Path Dialog PLx
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Learning Hero) Equal to PLx
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Equal to 0
        • Then - Actions
          • -------- Setup PLx dialog --------
          • Dialog - Change the title of PathsPLx to ...
          • Dialog - Show PathsPLx for Player 7 (Green)
        • Else - Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter + 1)
  • Click DLx Button
    • Events
      • Dialog - A dialog button is clicked for PathsDLx
    • Conditions
    • Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Greater than 0
        • Then - Actions
          • Trigger - Run Show Path Dialog PLx <gen> (ignoring conditions)
        • Else - Actions
  • Click PLx Button
    • Events
      • Dialog - A dialog button is clicked for PathsPLx
    • Conditions
    • Actions
      • Set VariableSet PathDialogCounter = (PathDialogCounter - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PathDialogCounter Greater than 0
        • Then - Actions
          • Trigger - Run Show Path Dialog DLx <gen> (ignoring conditions)
        • Else - Actions
I believe this should work and allow for multiple levels to stack Dialog uses.
Thanks to both of you, I've finally managed to make it work properly although I had to add a few things, without you I wouldn't have done it. The project I'm working on is giving me a lot of headaches so it wouldn't be strange if I come back here to ask you for more help.

Thanks again, regards.
 
Status
Not open for further replies.
Top