[Solved] Trigger partially not working if wait more than 4 seconds

Level 3
Joined
Jul 5, 2022
Messages
15
Hello everyone! I've stumbled upon a very strange bug in my trigger. If I set wait action to more than 4 seconds part of the script will not work.

  • Teleport
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[1]
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[2]
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[3]
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[4]
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[5]
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[6]
    • Actions
      • Set VariableSet intTmpNum = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet unitTeleTarget[intTmpNum] = (Triggering unit)
      • Special Effect - Create a special effect attached to the origin of unitTeleTarget[intTmpNum] using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
      • Set VariableSet sfxGr[intTmpNum] = (Last created special effect)
      • Unit - Pause unitTeleTarget[intTmpNum]
      • Animation - Play unitTeleTarget[intTmpNum]'s spell,channel animation
      • Wait 4.00 seconds
      • Special Effect - Destroy sfxGr[intTmpNum]
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If ((Item-type of (Item being manipulated)) Equal to itemsTeleport[(Integer A)]) then do (Unit - Move unitTeleTarget[intTmpNum] instantly to (Center of regWaypoint[(Integer A)])) else do (Do nothing)
      • Animation - Reset unitTeleTarget[intTmpNum]'s animation
      • Unit - Unpause unitTeleTarget[intTmpNum]
      • Special Effect - Create a special effect attached to the origin of unitTeleTarget[intTmpNum] using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
      • Set VariableSet sfxGr[intTmpNum] = (Last created special effect)
      • Wait 2.00 seconds
      • Special Effect - Destroy sfxGr[intTmpNum]

The problem is in the first "wait" action. If it is set for more than 4 seconds (5 seconds for example) this part:
  • For each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
      • If ((Item-type of (Item being manipulated)) Equal to itemsTeleport[(Integer A)]) then do (Unit - Move unitTeleTarget[intTmpNum] instantly to (Center of regWaypoint[(Integer A)])) else do (Do nothing)
fails to work.

Everything else (even parts that goes after "for each") works perfectly. There are no reassignment of variables or something of that sort. I'm out of ideas what can possibly go wrong... I've uploaded two short videos demonstrating the issue.

 
Last edited:
Level 24
Joined
Feb 27, 2019
Messages
833
Per heaps the item is removed from the game after 4 seconds. Try storing the index for regWaypoint before the wait.
  • For each (IntL) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to itemsTeleport[IntL])
        • Then - Actions
          • Set VariableSet regWaypointIndex[intTmpNum] = IntL
          • Custom script: exitwhen true
        • Else - Actions
  • Wait 6.00 game-time seconds
  • Set VariableSet intTmpNum = (Player number of (Owner of (Triggering unit)))
  • Unit - Move unitTeleTarget[intTmpNum] instantly to (Center of regWaypoint[regWaypointIndex[intTmpNum]])
Since intTmpNum is a temporary value that should be used instantly, it must be set again after a wait/delay because it may have been overwritten during the wait/delay.
 
Last edited:
Level 3
Joined
Jul 5, 2022
Messages
15
Per heaps the item is removed from the game after 4 seconds. Try storing the index for regWaypoint before the wait.
Thanks a lot for the reply! Looks like it is the issue. I've changed script close to your advice and now it finally works!
  • Actions
    • ...
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item-type of (Item being manipulated)) Equal to itemsTeleport[(Integer A)]
          • Then - Actions
            • Set VariableSet intTeleNum = (Integer A)
            • Custom script: exitwhen true
          • Else - Actions
    • Wait 6.00 seconds
    • Unit - Move unitTeleTarget[intTmpNum] instantly to (Center of regWaypoint[intTeleNum])
    • ...

But still I don't understand why it happens that way. Is there some logic underneath, or was it a wild guess?
 
Level 24
Joined
Feb 27, 2019
Messages
833
Thanks a lot for the reply! Looks like it is the issue. I've changed script close to your advice and now it finally works!
  • Actions
    • ...
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item-type of (Item being manipulated)) Equal to itemsTeleport[(Integer A)]
          • Then - Actions
            • Set VariableSet intTeleNum = (Integer A)
            • Custom script: exitwhen true
          • Else - Actions
    • Wait 6.00 seconds
    • Unit - Move unitTeleTarget[intTmpNum] instantly to (Center of regWaypoint[intTeleNum])
    • ...

But still I don't understand why it happens that way. Is there some logic underneath, or was it a wild guess?
Youre very welcome.

(Item being manipulated) is a reference to the item itself. When a power up is bought, its used by the buying unit, dies and is removed from the game after a short time. After the longer wait the item had been removed from the game so the reference (Item being manipulated) referenced an item that didnt exist anymore so it was referencing nothing, null.

The item is removed by the game after it dies to clear it from game memory and its simply the parameters put in place by the developers to clear up memory and resources from things that are not in use any more.
 
Last edited:
Level 3
Joined
Jul 5, 2022
Messages
15
Youre very welcome.

(Item being manipulated) is a reference to the item itself. When a power up is bought, its used by the buying unit, dies and is removed from the game after a short time. After the longer wait the item had been removed from the game so the reference (Item being manipulated) referenced an item that didnt exist anymore so it was referencing nothing, null.

The item is removed by the game after it dies to clear it from game memory and its simply the parameters put in place by the developers to clear up memory and resources from things that are not in use any more.
Another mistery of war3 editing have been unraveled 😁
Thanks for the explanation, and another thanks for "ExitWhen true" - nice and very useful trick, will use it in my future edits.
 
Top