• 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.

Am I crazy? It skips actions in the middle of the trigger.

Status
Not open for further replies.
Level 3
Joined
Mar 15, 2018
Messages
31
Hey community,

I can't figure it out. Please have a glimpse at this trigger:

  • Whose turn is it
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Category Equal to 2
        • Then - Actions
          • Set P3_WhoseTurn = 1
        • Else - Actions
      • Game - Display to (All players) for 190.00 seconds the text: blablabla
      • Special Effect - Destroy P3_Arrow
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (P3_CheckThese[1] is alive) Equal to False
          • P3_Category Equal to 2
        • Then - Actions
          • Game - Display to (All players) for 190.00 seconds the text: blablabla
          • Trigger - Run FightEnd <gen> (checking conditions)
          • Skip remaining actions
        • Else - Actions
      • Special Effect - Create a special effect at (Position of P3_CheckThese[P3_WhoseTurn]) using Abilities\Spells\Other\Aneu\AneuTarget.mdl
      • Set P3_Arrow = (Last created special effect)
      • Special Effect - Set Position - Z of P3_Arrow to (400.00 + TEST_GetLocationZ_2)
      • Special Effect - Set Color of P3_Arrow to color of (Owner of P3_CheckThese[P3_WhoseTurn])
      • Special Effect - Set Scale of P3_Arrow to 4.00
      • Set P3_ArrowUnit = P3_CheckThese[P3_WhoseTurn]
      • Game - Display to (All players) for 190.00 seconds the text: NOW blabalbalba
      • Trigger - Turn on Move Arrow <gen>
      • Unit - Set Max Mana of P3_CheckThese[P3_WhoseTurn] to 1
      • Unit - Set mana of P3_CheckThese[P3_WhoseTurn] to 100.00%
      • Game - Display to (All players) the text: (Player + ((String((Player number of (Owner of P3_CheckThese[P3_WhoseTurn])))) + to move!))
This trigger works most times, but only in one specific situation it doesn't, and then it seemingly and evidentially only skips one or two actions from the trigger:

  • Unit - Set Max Mana of P3_CheckThese[P3_WhoseTurn] to 1
  • Unit - Set mana of P3_CheckThese[P3_WhoseTurn] to 100.00%
Am I crazy? It seems impossible!

Every message you see in the trigger above got displayed in the right order just when the trigger is supposed to be fired.
I checked with a trigger if P3_CheckThese[P3_WhoseTurn] is the correct variable and it is perfectly correct.
There is no other action in the map that touches the mana of this unit or even in any other array of the variable.
It is also only triggered once, but even if it would be triggered twice it shouldn't be a problem.

I just don't get it. I always end up with a unit without mana (because this trigger is supposed to refill its mana), but also with all the messages. (except the one in the If/Then/else part)

Does somebody have a theory on this?

Thanks in advance for your thoughts!

old_edge
 
Last edited:
Level 3
Joined
Mar 15, 2018
Messages
31
It's a long chain of triggers:

It starts off here:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • P3_Category Equal to 3
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (P3_CurrentBB is dead) Equal to True
        • Then - Actions
          • Game - Display to (All players) for 300.00 seconds the text: BLACKBEARD IS DEAD!
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (P3_CountfCheckThese - P3_Dead) Greater than 1
            • Then - Actions
              • Game - Display to (All players) for 300.00 seconds the text: THERE ARE STILL MORE THAN ONE PLAYERS ON THE ISLAND
              • Set P3_CategoryChange = 1
              • Set P3_FightCategory[P3_CurrentIsland] = 1
              • Set P3_Category = P3_Fightcategory[P3_CurrentIsland]
              • Trigger - Run Preparation <gen> (checking conditions)
            • Else - Actions
              • [...]
        • Else - Actions
          • [...]

Goes on here (Preparation):
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • P3_Category Equal to 1
    • Then - Actions
      • For each (Integer P3_LoopFightships) from 1 to 5, do (Actions)
        • Loop - Actions
          • Unit - Remove Attack legendary Ship from P3_CheckThese[P3_LoopFightships]
          • Unit - Add Attack Hull to P3_CheckThese[P3_LoopFightships]
          • Unit - Add Attack Sail to P3_CheckThese[P3_LoopFightships]
          • Unit - Add Attack Canons to P3_CheckThese[P3_LoopFightships]
          • Unit - Add Attack Crew to P3_CheckThese[P3_LoopFightships]
          • Unit - Add Flee to P3_CheckThese[P3_LoopFightships]
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • P3_CategoryChange Equal to 0
    • Then - Actions
      • [...]
    • Else - Actions
      • Set P3_WhoseTurn = P3_CountfCheckThese
      • Trigger - Run WhoseTurn <gen> (checking conditions)

Goes on here (WhoseTurn):
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • P3_Category Equal to 1
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • P3_WhoseTurn Greater than 1
          • Then - Actions
            • Set P3_WhoseTurn = (P3_WhoseTurn - 1)
          • Else - Actions
            • Set P3_WhoseTurn = P3_CountfCheckThese
        • For each (Integer A) from 1 to P3_CountfCheckThese, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (P3_CheckThese[P3_WhoseTurn] is dead) Equal to False
              • Then - Actions
                • Trigger - Run Whose turn is it <gen> (checking conditions)
                • Skip remaining actions
              • Else - Actions
                • [...]

Ends here as above:
  • Whose turn is it
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Category Equal to 2
        • Then - Actions
          • Set P3_WhoseTurn = 1
        • Else - Actions
      • Game - Display to (All players) for 190.00 seconds the text: blablabla
      • Special Effect - Destroy P3_Arrow
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (P3_CheckThese[1] is alive) Equal to False
          • P3_Category Equal to 2
        • Then - Actions
          • Game - Display to (All players) for 190.00 seconds the text: blablabla
          • Trigger - Run FightEnd <gen> (checking conditions)
          • Skip remaining actions
        • Else - Actions
      • Special Effect - Create a special effect at (Position of P3_CheckThese[P3_WhoseTurn]) using Abilities\Spells\Other\Aneu\AneuTarget.mdl
      • Set P3_Arrow = (Last created special effect)
      • Special Effect - Set Position - Z of P3_Arrow to (400.00 + TEST_GetLocationZ_2)
      • Special Effect - Set Color of P3_Arrow to color of (Owner of P3_CheckThese[P3_WhoseTurn])
      • Special Effect - Set Scale of P3_Arrow to 4.00
      • Set P3_ArrowUnit = P3_CheckThese[P3_WhoseTurn]
      • Game - Display to (All players) for 190.00 seconds the text: NOW blabalbalba
      • Trigger - Turn on Move Arrow <gen>
      • Unit - Set Max Mana of P3_CheckThese[P3_WhoseTurn] to 1
      • Unit - Set mana of P3_CheckThese[P3_WhoseTurn] to 100.00%
      • Game - Display to (All players) the text: (Player + ((String((Player number of (Owner of P3_CheckThese[P3_WhoseTurn])))) + to move!))

Here is the Move Arrow Trigger. It's harmless:
  • Move Arrow
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Special Effect - Set Position of P3_Arrow to (Position of P3_ArrowUnit)
      • Special Effect - Set Position - Z of P3_Arrow to (400.00)


I made one change and it works now, but it should work without the change as well! Do you agree?

The change is in the second trigger (see above):

From:
  • Set P3_WhoseTurn = P3_CountfCheckThese
to:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • P3_WhoseTurn Equal to 1
    • Then - Actions
      • Set P3_WhoseTurn = (P3_CountfCheckThese + 1)
    • Else - Actions
      • Set P3_WhoseTurn = P3_CountfCheckThese

EDIT: Ah and the specific event was that went through that very chain with the P3_CategoryChange variable been set to 1. Also the bug only happened with P3_WhoseTurn set to 1. If the P3_WhoseTurn variable is 2 it was fine.

Also note that: P3_CheckThese are player heros in a region and P3_CountfCheckThese is an integer set to the number of player heros in a region. P3_WhoseTurn is an integer supposed to run through the array in order to control the turns. In this problematic case a special enemy ship gets destroyed and with it gone there are only players left to fight each other hence the category change, which indicates the fight constellation in that region hence other abilities. However in this problematic case the trigger would cause the ship to have its turn twice in a row and with the change I made the other player get to move after the enemy gets destroyed instead. However I don't see why it would only work this way.

I still very much like to figure out, what went wrong.

Do you see something I don't?
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Best guess is it's getting decremented by this line in WhoseTurn: Set P3_WhoseTurn = (P3_WhoseTurn - 1). Since the if condition that runs that is WhoseTurn > 1 and it will always be at least 2 since there are 2 players left that line will always run. Honestly, though, I don't really follow your triggers so perhaps you meant to do that there. I have a feeling this whole sequence of triggers could be significantly simplified in some way, but I can't see enough of them to really understand how it all works together.
 
Level 3
Joined
Mar 15, 2018
Messages
31
I am absolutely sure that my triggers are probably overcomplicated. :D That's why I didn't post them right away. It is my first serious project and I wanna keep going and learn on the flow, so there is alot to optimize I suppose. If you have a specific tip on your mind just tell me. :)

The P3_WhoseTurn variable in this problematic case comes in being set to 1 and then is set to 2 in Preparation, then it gets decremented in WhoseTurn and ends up being 1 again. Hence the same player will have its turn twice in a row.
If P3_WhoseTurn would have been 2 in the first place it would be set to 2 again and then decremented to 1, in which case the other player gets to move next.

That is the logic that is supposed to work and it kinda does, because I get the messages from the trigger Whose Turn is it, but the mana thing doesn't happen :vw_wtf:
 
Level 3
Joined
Mar 15, 2018
Messages
31
Yes, the first starts with P3_CountfCheckThese which represents the number of players and counts down to 1.

It is that way because in another trigger I sort them in the right order by various factors so it ends in the following structure, if we have 3 players in that fight:

P3_CountfCheckThese = 3

P3_CheckThese[0] = not used
P3_CheckThese[1] = last
P3_CheckThese[2] = second
P3_CheckThese[P3_CountfCheckThese] = first

There are at maximum 5 players.
 
Status
Not open for further replies.
Top