1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'Triggers & Scripts' started by old_edge5, Aug 22, 2019.

  1. old_edge5

    old_edge5

    Joined:
    Mar 15, 2018
    Messages:
    27
    Resources:
    0
    Resources:
    0
    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: Aug 22, 2019
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    In what specific scenario does it skip the mana setting? Can you reproduce it? Show us the Move Arrow <gen> trigger. Best guess is it's occasionally overwriting one of the variables used in those mana set lines. Or upload the map.
     
  3. old_edge5

    old_edge5

    Joined:
    Mar 15, 2018
    Messages:
    27
    Resources:
    0
    Resources:
    0
    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: Aug 23, 2019
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.
     
  5. old_edge5

    old_edge5

    Joined:
    Mar 15, 2018
    Messages:
    27
    Resources:
    0
    Resources:
    0
    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:
     
  6. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    So for the order of turns you're counting down, not up? The order of the turns goes 3, 2, 1, not 1, 2, 3? (I'm presuming there are 3+ players based on how you've described the triggers.)
     
  7. old_edge5

    old_edge5

    Joined:
    Mar 15, 2018
    Messages:
    27
    Resources:
    0
    Resources:
    0
    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.