• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Waits and Dialogs don't work well together..?

Status
Not open for further replies.
Level 5
Joined
Dec 3, 2012
Messages
117
Making some quests for my map and I've come across a problem whilst giving the person a series of messages through "game - Text message " and putting waits between these messages ending in creating and showing a dialog with 2 buttons "Yes, No" now, this all works fine without the waits, but when I added the waits, somehow the dialog doesnt (always) show. Sometimes it does, sometimes it doesn't which makes no sense at all to me.


  • Actions
    • Set TEMPInteger = (Player number of (Owner of (Casting unit)))
    • Set TEMPPlayerGroup = (Player group((Owner of (Casting unit))))
    • -------- Taking the Test --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • QUESTJobChangeQuests[TEMPInteger] Equal to 1
      • Then - Actions
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Dialog - Clear DIAQIzluSwordsmanQ[TEMPInteger]
        • Dialog - Change the title of DIAQIzluSwordsmanQ[TEMPInteger] to |cffffcc00Go to tra...
        • Dialog - Create a dialog button for DIAQIzluSwordsmanQ[TEMPInteger] labelled |cfff5f5f5Yes|r
        • Set DIAButtons[(TEMPInteger + 12)] = (Last created dialog Button)
        • Dialog - Create a dialog button for DIAQIzluSwordsmanQ[TEMPInteger] labelled |cfff5f5f5No|r
        • Set DIAButtons[(TEMPInteger + 18)] = (Last created dialog Button)
        • Wait SETTINGSQuestMsgDelay seconds
        • Dialog - Show DIAQIzluSwordsmanQ[TEMPInteger] for (Player(TEMPInteger))
      • Else - Actions
the "SETTINGSQuestMsgDelay" variable is a real which the player can set him/herself for quest convenience
 
What are the events/conditions of the trigger?

When the dialog doesn't display, do you still receive all the game messages in that trigger? Try adding a game message right after the "Dialog - Show..." line that displays TEMPInteger to (All Players). When the trigger run and the dialog doesn't display, check if the message shows up. If so, see if it shows the correct number.
 
Level 5
Joined
Dec 3, 2012
Messages
117
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Interact (Basic Skills)
    • (Target unit of ability being cast) Equal to Swordsman Examiner 0106 <gen>
  • Actions
    • Set TEMPInteger = (Player number of (Owner of (Casting unit)))
    • Set TEMPPlayerGroup = (Player group((Owner of (Casting unit))))
    • -------- Taking the Test --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • QUESTJobChangeQuests[TEMPInteger] Equal to 1
      • Then - Actions
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Wait SETTINGSQuestMsgDelay seconds
        • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
        • Dialog - Clear DIAQIzluSwordsmanQ[TEMPInteger]
        • Dialog - Change the title of DIAQIzluSwordsmanQ[TEMPInteger] to |cffffcc00Go to tra...
        • Dialog - Create a dialog button for DIAQIzluSwordsmanQ[TEMPInteger] labelled |cfff5f5f5Yes|r
        • Set DIAButtons[(TEMPInteger + 12)] = (Last created dialog Button)
        • Dialog - Create a dialog button for DIAQIzluSwordsmanQ[TEMPInteger] labelled |cfff5f5f5No|r
        • Set DIAButtons[(TEMPInteger + 18)] = (Last created dialog Button)
        • Wait SETTINGSQuestMsgDelay seconds
        • Dialog - Show DIAQIzluSwordsmanQ[TEMPInteger] for (Player(TEMPInteger))
      • Else - Actions
This is the whole trigger, and yes I do get all the messages, but the dialog just doesnt show up


I also did what you suggested and did a little troubleshooting to find out where the TEMPInteger is getting mixed up.
Apparently at some point it changes to 7 (Instead of 1) and this happens right after the first Wait command.
 
Last edited:
Ah, then that is the problem. It is probably showing it to the wrong player. Player(7) is most likely casting the spell within the wait duration, and then the global variable becomes overwritten. Or it may be that you are using TEMPInteger in some other trigger while the dialog trigger is running--and that TEMPInteger was probably changed to 7 during the "waits".

The easiest fix would probably be to shadow those global variables with locals. The technique is explained here:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/things-gui-user-should-know-233242/#Section%202%20SubCh%201
And you would most likely implement it something like this:
  • Actions
    • Custom script: local integer udg_TEMPInteger
    • Custom script: local force udg_TEMPPlayerGroup
    • Set TEMPInteger = (Player number of (Owner of (Casting unit)))
    • Set TEMPPlayerGroup = (Player group((Owner of (Casting unit))))
Untested, but adding those two lines should fix the issue.

Why does it work? Well, I can explain that to you if you'd like. However, you must first understand the problem behind it. The overarching issue here is instanceability, which you can read about here (you only need to read the MUI section, the rest is for achieving MUI for spells):
http://www.hiveworkshop.com/forums/tutorial-submission-283/visualize-dynamic-indexing-241896/#B
There are many ways to circumvent the issue. The way I described is known as shadowing, where you create a local variable (these values won't be overwritten in their function--each time the trigger runs there will be separate local variables with separate values) and name it like the global variable. All this does is it allows GUI'ers to use locals in their functions without having to resort to too many custom scripts.
 
Level 5
Joined
Dec 3, 2012
Messages
117
Aaahhh, I kinda get the point yeah.

Only, player 7 (Green) isn't even in the game so thats kinda weird..

But I adjusted the trigger and added the 2 lines of custom script like you said, but now the whole trigger doesn't active anymore :eek:

I was wondering, shouldnt those lines be something like:

Custom Script: local integer udg_TEMPInteger = Get Player nr of trig unit
&
Custom Script: local integer udg_TEMPPlayerGroup = Get player group, owner of trig unit ?
Problem is, I'm not sure how to do that in custom script :p
 
Oops sorry I forgot to mention that you need Jass NewGen Pack for that technique to properly work. The regular editor won't handle shadowing properly. Vexorian added a phase to jasshelper's preprocessor to properly handle local variable shadowing.

You may have to resort to an alternate method to get it to work. Or you can use Jass NewGen Pack and make your life easier. :) As long as you save the map in JNGP editor, it should work.
 
Level 5
Joined
Dec 3, 2012
Messages
117
I am using the Newgen pack, but it still doesnt work ?

I'll post the new trigger;
  • Swordsman Q Exam
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Interact (Basic Skills)
      • (Target unit of ability being cast) Equal to Swordsman Examiner 0106 <gen>
    • Actions
      • Custom script: local integer udg_TEMPInteger
      • Custom script: local force udg_TEMPPlayerGroup
      • Set TEMPInteger = (Player number of (Owner of (Casting unit)))
      • Set TEMPPlayerGroup = (Player group((Owner of (Casting unit))))
      • Game - Display to (All players) the text: (String(TEMPInteger))
      • -------- Taking the Test --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • QUESTJobChangeQuests[TEMPInteger] Equal to 1
        • Then - Actions
          • Cinematic - Clear the screen of text messages for TEMPPlayerGroup
          • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
          • Wait SETTINGSQuestMsgDelay seconds
          • Cinematic - Clear the screen of text messages for TEMPPlayerGroup
          • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
          • Wait SETTINGSQuestMsgDelay seconds
          • Cinematic - Clear the screen of text messages for TEMPPlayerGroup
          • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
          • Wait SETTINGSQuestMsgDelay seconds
          • Cinematic - Clear the screen of text messages for TEMPPlayerGroup
          • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
          • Wait SETTINGSQuestMsgDelay seconds
          • Cinematic - Clear the screen of text messages for TEMPPlayerGroup
          • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
          • Dialog - Clear DIAQSwordsmanQ[TEMPInteger]
          • Dialog - Change the title of DIAQSwordsmanQ[TEMPInteger] to |cffffcc00Go to tra...
          • Dialog - Create a dialog button for DIAQSwordsmanQ[TEMPInteger] labelled |cfff5f5f5Yes|r
          • Set DIAButtons[(TEMPInteger + 12)] = (Last created dialog Button)
          • Dialog - Create a dialog button for DIAQSwordsmanQ[TEMPInteger] labelled |cfff5f5f5No|r
          • Set DIAButtons[(TEMPInteger + 18)] = (Last created dialog Button)
          • Wait SETTINGSQuestMsgDelay seconds
          • Dialog - Show DIAQSwordsmanQ[TEMPInteger] for (Player(TEMPInteger))
        • Else - Actions
      • -------- Test Completion --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • QUESTJobChangeQuests[TEMPInteger] Equal to 2
        • Then - Actions
          • Wait 0.01 seconds
          • Set QUESTJobChangeQuests[TEMPInteger] = 3
          • Cinematic - Clear the screen of text messages for TEMPPlayerGroup
          • Game - Display to TEMPPlayerGroup the text: |cffffcc00Examiner:...
          • Set TEMPPoint = (Center of COPOUTIzludeSwordsmanGuild <gen>)
          • Unit - Move HEROPlayerHero[TEMPInteger] instantly to TEMPPoint
          • Camera - Pan camera for (Player(TEMPInteger)) to TEMPPoint over 1.00 seconds
          • Custom script: call RemoveLocation(udg_TEMPPoint)
        • Else - Actions
 
That's strange. It should be passing the condition and displaying a message. The only thing I can think of is that TEMPPlayerGroup could be pointing to something else.

Do you mind if I have a look at the map? You can upload it on the pastebin and then send me the link through a private message (if you don't want anyone else to see it). That way I can quickly test things and check if it works.
 
Status
Not open for further replies.
Top