• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Using more than one unit indexer in one map?

Status
Not open for further replies.
Level 14
Joined
Jun 27, 2008
Messages
1,325
Only one will work
and that one is much slower than the other one

what? Guess ur refering to one indexer using hashtables instead of custom values?

You certainly don't need 2 unit indexers in your map. They nearly always use the same method (changing the custom value of units), so you can safely remove one of them without any negative consequences.

no that only works if the indexers use the exactly same names for the methods.


@Sunchips - you can use one of the two indexers and replace the other one with a wrapper so the systems dont have to be altered.

Example:
1. library Indexer1
2. library SomeLibrary requires Indexer1
3. library Indexer2
4. library SomeOtherLibrary requires Indexer2
-> you import 1, 2, 4 and replace 3 by a wrapper:
3. library Indexer2 requires Indexer1

Link us the two indexer systems and we can help you building the wrapper.
 
Level 30
Joined
Jul 23, 2009
Messages
1,029
Thanks for the reply muzzel.

Here is the first indexer which I currently use for a threat system:

  • Unit Indexer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • Custom script:
      • Custom script: function ClearUnitIndex takes nothing returns nothing
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Custom value of UDexUnits[UDex]) Equal to (==) 0
          • Then - Actions
            • Set UnitIndexLock[UDex] = (UnitIndexLock[UDex] - 1)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitIndexLock[UDex] Equal to (==) 0
                • Then - Actions
                  • Set UDexNext[UDexPrev[UDex]] = UDexNext[UDex]
                  • Set UDexPrev[UDexNext[UDex]] = UDexPrev[UDex]
                  • Set UDexPrev[UDex] = 0
                  • Set UnitIndexEvent = 0.00
                  • Set UnitIndexEvent = 2.00
                  • Set UnitIndexEvent = 0.00
                  • Set UDexUnits[UDex] = No unit
                  • Set UDexNext[UDex] = UDexRecycle
                  • Set UDexRecycle = UDex
                • Else - Actions
          • Else - Actions
      • Custom script: endfunction
      • Custom script:
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • -------- - --------
      • -------- You can customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
      • -------- - --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UnitIndexerEnabled Equal to (==) True
            • (Custom value of (Matching unit)) Equal to (==) 0
          • Then - Actions
            • Set UDexWasted = (UDexWasted + 1)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UDexWasted Equal to (==) 15
                • Then - Actions
                  • Set UDexWasted = 0
                  • Set UDex = UDexNext[0]
                  • Custom script: loop
                  • Custom script: exitwhen udg_UDex == 0
                  • Custom script: set ndex = udg_UDexNext[udg_UDex]
                  • Custom script: call ClearUnitIndex()
                  • Custom script: set udg_UDex = ndex
                  • Custom script: endloop
                • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UDexRecycle Equal to (==) 0
                • Then - Actions
                  • Set UDex = (UDexGen + 1)
                  • Set UDexGen = UDex
                • Else - Actions
                  • Set UDex = UDexRecycle
                  • Set UDexRecycle = UDexNext[UDex]
            • Set UDexUnits[UDex] = (Matching unit)
            • Unit - Set the custom value of UDexUnits[UDex] to UDex
            • Set UDexPrev[UDexNext[0]] = UDex
            • Set UDexNext[UDex] = UDexNext[0]
            • Set UDexNext[0] = UDex
            • Set UnitIndexLock[UDex] = 1
            • Set UnitIndexEvent = 0.00
            • Set UnitIndexEvent = 1.00
            • Set UnitIndexEvent = 0.00
            • Custom script: set udg_UDex = pdex
          • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = 16
      • Custom script: local boolexpr b = Filter(function IndexUnit)
      • Custom script: local region re = CreateRegion()
      • Custom script: local trigger t = GetTriggeringTrigger()
      • Custom script: local rect r = GetWorldBounds()
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(t, re, b)
      • Custom script: call TriggerClearActions(t)
      • Custom script: call TriggerAddAction(t, function ClearUnitIndex)
      • Set UnitIndexerEnabled = True
      • Custom script: loop
      • Custom script: set i = i - 1
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), b)
      • Custom script: exitwhen i == 0
      • Custom script: endloop
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: set t = null
      • Custom script: set b = null
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00
And here is the other one that I need for a stun system:

  • Unit indexer by Bribe
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UnitIndexerEnabled Equal to (==) True
          • Then - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • UDexRecycle Equal to (==) 0
              • Then - Actions
                • Set UDex = (UDexGen + 1)
                • Set UDexGen = UDex
              • Else - Actions
                • Set UDex = UDexRecycle
                • Set UDexRecycle = UDexNext[UDex]
            • Set UDexUnits[UDex] = (Matching unit)
            • Unit - Set the custom value of UDexUnits[UDex] to UDex
            • Set UDexPrev[UDexNext[0]] = UDex
            • Set UDexNext[UDex] = UDexNext[0]
            • Set UDexNext[0] = UDex
            • Set UnitIndexEvent = 0.00
            • Set UnitIndexEvent = 1.00
            • Set UnitIndexEvent = 0.00
            • Custom script: set udg_UDex = pdex
          • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script: function IndexNewUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • Set UDexWasted = (UDexWasted + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UDexWasted Equal to (==) 15
          • Then - Actions
            • Set UDexWasted = 0
            • Set UDex = UDexNext[0]
            • Custom script: loop
            • Custom script: exitwhen udg_UDex == 0
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of UDexUnits[UDex]) Equal to (==) 0
                • Then - Actions
                  • Custom script: set ndex = udg_UDexNext[udg_UDex]
                  • Custom script: set udg_UDexNext[udg_UDexPrev[udg_UDex]] = ndex
                  • Custom script: set udg_UDexPrev[ndex] = udg_UDexPrev[udg_UDex]
                  • Set UDexPrev[UDex] = 0
                  • Set UnitIndexEvent = 2.00
                  • Set UnitIndexEvent = 0.00
                  • Set UDexUnits[UDex] = No unit
                  • Set UDexNext[UDex] = UDexRecycle
                  • Set UDexRecycle = UDex
                  • Custom script: set udg_UDex = ndex
                • Else - Actions
                  • Set UDex = UDexNext[UDex]
            • Custom script: endloop
            • Custom script: set udg_UDex = pdex
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Custom value of (Matching unit)) Equal to (==) 0
          • Then - Actions
            • Custom script: call IndexUnit()
          • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = 0
      • Custom script: local region re = CreateRegion()
      • Custom script: local rect r = GetWorldBounds()
      • Set UnitIndexerEnabled = True
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(CreateTrigger(), re, Filter(function IndexNewUnit))
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: loop
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), Filter(function IndexUnit))
      • Custom script: set i = i + 1
      • Custom script: exitwhen i == 16
      • Custom script: endloop
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Thanks for the reply muzzel.

Here is the first indexer which I currently use for a threat system:

  • Unit Indexer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • Custom script:
      • Custom script: function ClearUnitIndex takes nothing returns nothing
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Custom value of UDexUnits[UDex]) Equal to (==) 0
          • Then - Actions
            • Set UnitIndexLock[UDex] = (UnitIndexLock[UDex] - 1)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitIndexLock[UDex] Equal to (==) 0
                • Then - Actions
                  • Set UDexNext[UDexPrev[UDex]] = UDexNext[UDex]
                  • Set UDexPrev[UDexNext[UDex]] = UDexPrev[UDex]
                  • Set UDexPrev[UDex] = 0
                  • Set UnitIndexEvent = 0.00
                  • Set UnitIndexEvent = 2.00
                  • Set UnitIndexEvent = 0.00
                  • Set UDexUnits[UDex] = No unit
                  • Set UDexNext[UDex] = UDexRecycle
                  • Set UDexRecycle = UDex
                • Else - Actions
          • Else - Actions
      • Custom script: endfunction
      • Custom script:
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • -------- - --------
      • -------- You can customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
      • -------- - --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UnitIndexerEnabled Equal to (==) True
            • (Custom value of (Matching unit)) Equal to (==) 0
          • Then - Actions
            • Set UDexWasted = (UDexWasted + 1)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UDexWasted Equal to (==) 15
                • Then - Actions
                  • Set UDexWasted = 0
                  • Set UDex = UDexNext[0]
                  • Custom script: loop
                  • Custom script: exitwhen udg_UDex == 0
                  • Custom script: set ndex = udg_UDexNext[udg_UDex]
                  • Custom script: call ClearUnitIndex()
                  • Custom script: set udg_UDex = ndex
                  • Custom script: endloop
                • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UDexRecycle Equal to (==) 0
                • Then - Actions
                  • Set UDex = (UDexGen + 1)
                  • Set UDexGen = UDex
                • Else - Actions
                  • Set UDex = UDexRecycle
                  • Set UDexRecycle = UDexNext[UDex]
            • Set UDexUnits[UDex] = (Matching unit)
            • Unit - Set the custom value of UDexUnits[UDex] to UDex
            • Set UDexPrev[UDexNext[0]] = UDex
            • Set UDexNext[UDex] = UDexNext[0]
            • Set UDexNext[0] = UDex
            • Set UnitIndexLock[UDex] = 1
            • Set UnitIndexEvent = 0.00
            • Set UnitIndexEvent = 1.00
            • Set UnitIndexEvent = 0.00
            • Custom script: set udg_UDex = pdex
          • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = 16
      • Custom script: local boolexpr b = Filter(function IndexUnit)
      • Custom script: local region re = CreateRegion()
      • Custom script: local trigger t = GetTriggeringTrigger()
      • Custom script: local rect r = GetWorldBounds()
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(t, re, b)
      • Custom script: call TriggerClearActions(t)
      • Custom script: call TriggerAddAction(t, function ClearUnitIndex)
      • Set UnitIndexerEnabled = True
      • Custom script: loop
      • Custom script: set i = i - 1
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), b)
      • Custom script: exitwhen i == 0
      • Custom script: endloop
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: set t = null
      • Custom script: set b = null
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00
And here is the other one that I need for a stun system:

  • Unit indexer by Bribe
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UnitIndexerEnabled Equal to (==) True
          • Then - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • UDexRecycle Equal to (==) 0
              • Then - Actions
                • Set UDex = (UDexGen + 1)
                • Set UDexGen = UDex
              • Else - Actions
                • Set UDex = UDexRecycle
                • Set UDexRecycle = UDexNext[UDex]
            • Set UDexUnits[UDex] = (Matching unit)
            • Unit - Set the custom value of UDexUnits[UDex] to UDex
            • Set UDexPrev[UDexNext[0]] = UDex
            • Set UDexNext[UDex] = UDexNext[0]
            • Set UDexNext[0] = UDex
            • Set UnitIndexEvent = 0.00
            • Set UnitIndexEvent = 1.00
            • Set UnitIndexEvent = 0.00
            • Custom script: set udg_UDex = pdex
          • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script: function IndexNewUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • Set UDexWasted = (UDexWasted + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UDexWasted Equal to (==) 15
          • Then - Actions
            • Set UDexWasted = 0
            • Set UDex = UDexNext[0]
            • Custom script: loop
            • Custom script: exitwhen udg_UDex == 0
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of UDexUnits[UDex]) Equal to (==) 0
                • Then - Actions
                  • Custom script: set ndex = udg_UDexNext[udg_UDex]
                  • Custom script: set udg_UDexNext[udg_UDexPrev[udg_UDex]] = ndex
                  • Custom script: set udg_UDexPrev[ndex] = udg_UDexPrev[udg_UDex]
                  • Set UDexPrev[UDex] = 0
                  • Set UnitIndexEvent = 2.00
                  • Set UnitIndexEvent = 0.00
                  • Set UDexUnits[UDex] = No unit
                  • Set UDexNext[UDex] = UDexRecycle
                  • Set UDexRecycle = UDex
                  • Custom script: set udg_UDex = ndex
                • Else - Actions
                  • Set UDex = UDexNext[UDex]
            • Custom script: endloop
            • Custom script: set udg_UDex = pdex
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Custom value of (Matching unit)) Equal to (==) 0
          • Then - Actions
            • Custom script: call IndexUnit()
          • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = 0
      • Custom script: local region re = CreateRegion()
      • Custom script: local rect r = GetWorldBounds()
      • Set UnitIndexerEnabled = True
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(CreateTrigger(), re, Filter(function IndexNewUnit))
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: loop
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), Filter(function IndexUnit))
      • Custom script: set i = i + 1
      • Custom script: exitwhen i == 16
      • Custom script: endloop
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00

It's the same indexer.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
muzzel u mustve misread something cause dr super good listed a plausible solution to sunchips problem

and another one who didnt read the thread.

@Pharaoh thx for deleting my pictures, took me at least 2 minutes to rescale and upload them.
Why cant i give ppl -rep? They deserve it!

OFFTOPIC: DONT FUCK WITH ME

Last edited by Pharaoh_; Today at 04:01 AM. Reason: None whatsoever, i just enjoy deleting your stuff
 
Status
Not open for further replies.
Top