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

[Solved] Inconsistent trigger that once worked perfectly

Status
Not open for further replies.
Level 8
Joined
Mar 17, 2016
Messages
133
Hi, I recently asked for help on these forums to ask for a way to call for variables in a randomized checklist format. I've since made 2 changes and am faced with a trigger that is, for reasons that I cannot identify; inconsistent.
The changes are turning "Take the Questionnaire" (the thing being bought from the shop) from an Item to a Unit. This was to allow the shop to work flawlessly when adding and removing items to it through triggers, rather than having it stocked from the units page in the object editor.
The second change was adding the system that stops showing dialog boxes after the 7th question - "RQMaxQuestions[a]". Well, that's what it was supposed to do.

These are the triggers that I'm using:
  • ShopQuestionnaireStart
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Take the Questionnaire
    • Actions
      • Set VariableSet RQThingPlayer = (Owner of (Buying unit))
      • Set VariableSet RQThingPlayerInteger = (Player number of RQThingPlayer)
      • Set VariableSet RQNotGivenCount = 0
      • Set VariableSet RQMaxQuestions[RQThingPlayerInteger] = 0
      • For each (Integer A) from 1 to RQMAX_THINGS, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RQThingPlayer is in RQHasBeenGivenThing[(Integer A)].) Equal to False
            • Then - Actions
              • Set VariableSet RQNotGivenCount = (RQNotGivenCount + 1)
              • Set VariableSet RQRandomThing[RQNotGivenCount] = (Integer A)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RQNotGivenCount Greater than 0
        • Then - Actions
          • Set VariableSet RQThingToGive = RQRandomThing[(Random integer number between 1 and RQNotGivenCount)]
          • Player Group - Add RQThingPlayer to RQHasBeenGivenThing[RQThingToGive]
          • Dialog - Show Race_Dialog[RQThingToGive] for RQThingPlayer
          • Set VariableSet RQMaxQuestions[RQThingPlayerInteger] = (RQMaxQuestions[RQThingPlayerInteger] + 1)
        • Else - Actions
      • Unit - Remove (Sold unit) from the game
  • RandomQuestions
    • Events
      • Dialog - A dialog button is clicked for Race_Dialog[1]
      • Dialog - A dialog button is clicked for Race_Dialog[2]
      • Dialog - A dialog button is clicked for Race_Dialog[3]
      • Dialog - A dialog button is clicked for Race_Dialog[4]
      • Dialog - A dialog button is clicked for Race_Dialog[5]
      • Dialog - A dialog button is clicked for Race_Dialog[6]
      • Dialog - A dialog button is clicked for Race_Dialog[7]
      • Dialog - A dialog button is clicked for Race_Dialog[8]
      • Dialog - A dialog button is clicked for Race_Dialog[9]
      • Dialog - A dialog button is clicked for Race_Dialog[10]
      • Dialog - A dialog button is clicked for Race_Dialog[11]
      • Dialog - A dialog button is clicked for Race_Dialog[12]
      • Dialog - A dialog button is clicked for Race_Dialog[13]
      • Dialog - A dialog button is clicked for Race_Dialog[14]
      • Dialog - A dialog button is clicked for Race_Dialog[15]
      • Dialog - A dialog button is clicked for Race_Dialog[16]
      • Dialog - A dialog button is clicked for Race_Dialog[17]
      • Dialog - A dialog button is clicked for Race_Dialog[18]
      • Dialog - A dialog button is clicked for Race_Dialog[19]
      • Dialog - A dialog button is clicked for Race_Dialog[20]
      • Dialog - A dialog button is clicked for Race_Dialog[21]
    • Conditions
    • Actions
      • Set VariableSet RQThingPlayer = (Triggering player)
      • Set VariableSet RQThingPlayerInteger = (Player number of RQThingPlayer)
      • Set VariableSet RQNotGivenCount = 0
      • For each (Integer A) from 1 to RQMAX_THINGS, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RQThingPlayer is in RQHasBeenGivenThing[(Integer A)].) Equal to False
            • Then - Actions
              • Set VariableSet RQNotGivenCount = (RQNotGivenCount + 1)
              • Set VariableSet RQRandomThing[RQNotGivenCount] = (Integer A)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RQNotGivenCount Greater than 0
          • RQMaxQuestions[RQThingPlayerInteger] Less than or equal to 7
        • Then - Actions
          • Set VariableSet RQThingToGive = RQRandomThing[(Random integer number between 1 and RQNotGivenCount)]
          • Player Group - Add RQThingPlayer to RQHasBeenGivenThing[RQThingToGive]
          • Dialog - Show Race_Dialog[RQThingToGive] for RQThingPlayer
          • Set VariableSet RQMaxQuestions[RQThingPlayerInteger] = (RQMaxQuestions[RQThingPlayerInteger] + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RQMaxQuestions[1] Greater than or equal to 8
            • Then - Actions
              • Trigger - Run Calculations P1 <gen> (ignoring conditions)
            • Else - Actions

Now, let me explain...

If I press the "Test Map" button in the world editor and launch the map, go to the shop, and buy the "take the questionnaire" unit from the shop (initializing the first trigger sequence) it will do nothing. If I purchase it again, it will do nothing. But on the THIRD purchase of that unit it will launch the trigger sequence. Now, that's a problem on it's own and I can't seem to understand why. But...

The way I've set it up it's meant to take 7 questions from any given player and on the 7th question it will run the calculations. However, it typically takes 6 answers before closing and therefore not running the calculations.


Now, if I launch WC3 and host a custom game with my map selected, go in as the only player and buy "Take the Questionnaire" it will provide inconsistent results. As in....

If I do the same thing here, run up to the shop and buy the same unit from the shop as before it works on the first purchase... However this time it only shows 3 questions before disappearing and not running the calculations trigger.

Mind you, the option "Use fixed random seed" is unchecked in the world editor preferences, so I really do not understand why it would make a difference how the map was launched.


I've bitten off more than I can chew here and it's starting to give me a headache. I would appreciate any help/suggestions.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
First, start by putting increment before showing a dialog. Instead of this:
  • Dialog - Show Race_Dialog[RQThingToGive] for RQThingPlayer
  • Set VariableSet RQMaxQuestions[RQThingPlayerInteger] = (RQMaxQuestions[RQThingPlayerInteger] + 1)
do this:
  • Set VariableSet RQMaxQuestions[RQThingPlayerInteger] = (RQMaxQuestions[RQThingPlayerInteger] + 1)
  • Dialog - Show Race_Dialog[RQThingToGive] for RQThingPlayer
in both triggers.

Secondly, is your player group array RQHasBeenGivenThing initialized with correct size?
 
Level 8
Joined
Mar 17, 2016
Messages
133
Thanks for the response,

I noticed that I didn't set the playergroup from 15 to 21 (as it was set to 15 when the triggers worked), as well as I've changed the order of functions to both triggers as you've suggested but it seems to have the same results nonetheless.

Edit: I also tried moving "RQMaxQuestions +1" to run without any conditions (eg. at the top of the trigger) and that also changed nothing.

My biggest question right now is what is it about these triggers that could possibly change based on how the map was launched. Even if it has to do with the "use fixed random seed" option, why would that change how the trigger fires when a unit is bought in the first place?... Because it seems to me, and I'm sure there's something else going on underneath that I cannot identify, that the integer "RQMaxQuestions" being set and the "Unit - A unit sells a unit" are the 2 main questions to this, as they are either battling each other or have inconsistencies with how the functions are run in the first place.
 
Last edited:
Level 8
Joined
Mar 17, 2016
Messages
133
Update: I've just managed to find something that's quite strange...

So, I thought that maybe the problem could be that I'm exceeding the max number of playergroups or something like that, so I change the 21 (set in the variable RQMAX_THINGS) back to 15, along with the playergroup array and the dialog array.

To my surprise, it works. But the game is running in slow motion. I'm not kidding. However, the games FPS was consistently above 120 and the portraits were animating at a normal speed.

After seeing it work I closed the game and restarted it and it was no longer in slow motion but the trigger still worked flawlessly, so I returned to the editor and set the arrays and variable back to 21. For whatever reason that was what I needed to do... Pretty strange. Maybe I'm missing something here? Anyways, it's finally resolved.
 
Status
Not open for further replies.
Top