• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[Trigger] Searching an array

Not open for further replies.
Level 7
Jul 29, 2009
when the trigger fires the game crashes:
  • Using Trebuchet
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 8000, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to MachineUser[(Integer A)]
            • Then - Actions
              • Game - Display to (All players) the text: triggerd used
              • If ((Ability being cast) Equal to Inventory (Hero)) then do (Do nothing) else do (Unit - Order (Triggering unit) to Stop)
            • Else - Actions
              • Do nothing
basicly i want to search the array and find if the triggering unit is inside of it. the array may contain a lot of other units and null units.

how do i do it?
Level 40
Dec 14, 2005
Ordering the unit to stop will cause the trigger to fire again, ad infinitum.

Also, add this line at the bottom of your THEN in the if statement:

Custom script: exitwhen true

That will cause the loop to immediately exit rather than needlessly going on.


However, you should look in to hashtables in 1.24.
Level 29
Jul 29, 2007
Am I missing something here? I thought a "new" function process was created each time the trigger is called, thus making exitwhen true useless. o_O

Say it always finds the number at index 1000.
It runs 1000 times, calls the function, runs 1000 times, calls the function runs...

However if it was fixed (with some conditions), it would run 1000 times, do whatever it's supposed to do, and then run the next 7000 iterations for no reason.

You should keep a count of how many indices your array is using, so you don't have to do a loop of 8000 -_-

Thus why Poot told him to use "exitwhen true".
Not open for further replies.