- Joined
- Mar 16, 2014
- Messages
- 169
Anything I can change to detect units with locust? I need to deal knockback to them with my knockback system that is using this indexer. They are ignored by these triggers.
-
Unit Indexer
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Custom script: call ExecuteFunc("InitializeUnitIndexer")
-
Custom script: endfunction
-
-------- --------
-
-------- This is the core function - it provides an index all existing units and for units as they enter the map --------
-
-------- --------
-
Custom script: function IndexUnit takes nothing returns boolean
-
Custom script: local integer pdex = udg_UDex
-
Custom script: local integer ndex
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
IsUnitPreplaced[0] Equal to False
-
-
Then - Actions
-
-------- --------
-
-------- Check for removed units for every (32) new units created --------
-
-------- --------
-
Set VariableSet UDexWasted = (UDexWasted + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
UDexWasted Equal to 32
-
-
Then - Actions
-
Set VariableSet UDexWasted = 0
-
Set VariableSet UDex = UDexNext[0]
-
Custom script: loop
-
Custom script: exitwhen udg_UDex == 0
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Custom value of UDexUnits[UDex]) Equal to 0
-
-
Then - Actions
-
-------- --------
-
-------- Remove index from linked list --------
-
-------- --------
-
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 VariableSet UDexPrev[UDex] = 0
-
Set VariableSet IsUnitPreplaced[UDex] = False
-
-------- --------
-
-------- Fire deindex event for UDex --------
-
-------- --------
-
Set VariableSet UnitIndexEvent = 2.00
-
Set VariableSet UnitIndexEvent = 0.00
-
-------- --------
-
-------- Recycle the index for later use --------
-
-------- --------
-
Set VariableSet UDexUnits[UDex] = No unit
-
Set VariableSet UDexNext[UDex] = UDexRecycle
-
Set VariableSet UDexRecycle = UDex
-
Custom script: set udg_UDex = ndex
-
-
Else - Actions
-
Set VariableSet UDex = UDexNext[UDex]
-
-
-
Custom script: endloop
-
-
Else - Actions
-
-
-
Else - Actions
-
-
-------- --------
-
-------- You can use the boolean UnitIndexerEnabled to protect some of your undesirable units from being indexed --------
-
-------- - Example: --------
-
-------- -- Set UnitIndexerEnabled = False --------
-
-------- -- Unit - Create 1 Dummy for (Triggering player) at TempLoc facing 0.00 degrees --------
-
-------- -- Set UnitIndexerEnabled = True --------
-
-------- --------
-
-------- You can also customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
-
-------- --------
-
If (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
-
-------- --------
-
-------- Generate a unique integer index for this unit --------
-
-------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
UDexRecycle Equal to 0
-
-
Then - Actions
-
Set VariableSet UDex = (UDexGen + 1)
-
Set VariableSet UDexGen = UDex
-
-
Else - Actions
-
Set VariableSet UDex = UDexRecycle
-
Set VariableSet UDexRecycle = UDexNext[UDex]
-
-
-
-------- --------
-
-------- Link index to unit, unit to index --------
-
-------- --------
-
Set VariableSet UDexUnits[UDex] = (Matching unit)
-
Unit - Set the custom value of UDexUnits[UDex] to UDex
-
Set VariableSet IsUnitPreplaced[UDex] = IsUnitPreplaced[0]
-
-------- --------
-
-------- Use a doubly-linked list to store all active indexes --------
-
-------- --------
-
Set VariableSet UDexPrev[UDexNext[0]] = UDex
-
Set VariableSet UDexNext[UDex] = UDexNext[0]
-
Set VariableSet UDexNext[0] = UDex
-
-------- --------
-
-------- Fire index event for UDex --------
-
-------- --------
-
Set VariableSet UnitIndexEvent = 0.00
-
Set VariableSet UnitIndexEvent = 1.00
-
Set VariableSet UnitIndexEvent = 0.00
-
-
Else - Actions
-
-
Custom script: set udg_UDex = pdex
-
Custom script: return false
-
Custom script: endfunction
-
-------- --------
-
-------- The next function initializes the core of the system --------
-
-------- --------
-
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()
-
Custom script: local boolexpr b = Filter(function IndexUnit)
-
Set VariableSet UnitIndexEvent = -1.00
-
Set VariableSet UnitIndexerEnabled = True
-
Set VariableSet IsUnitPreplaced[0] = True
-
Custom script: call RegionAddRect(re, r)
-
Custom script: call TriggerRegisterEnterRegion(CreateTrigger(), re, b)
-
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), b)
-
Custom script: set i = i + 1
-
Custom script: exitwhen i == bj_MAX_PLAYER_SLOTS
-
Custom script: endloop
-
Custom script: set b = null
-
-------- --------
-
-------- This is the "Unit Indexer Initialized" event, use it instead of "Map Initialization" for best results --------
-
-------- --------
-
Set VariableSet IsUnitPreplaced[0] = False
-
Set VariableSet UnitIndexEvent = 3.00
-
-