Hi!
Sorry for a beginner's questions
My goal is to make some units cast spells on auto-attack. I've noticed some FPS drop even with 3-4 players, so I have to upgrade some triggers.
But I'm a bit confused: I've read that large hash tables and multiple if\then\else statements in trigger with "A unit is attacked" event - both can cause lags.
I'm not sure which method is better: create a single hashtable for ~50 unit types, or split it for 25 each? Which one is faster?
Should I worry about the next A unit Is attacked event overwriting the Attacker and Target variables before previous trigger completed, messing up some spells?
If so, I wonder which one is faster (that's in case if multiple unit types use the same trigger):

Sorry for a beginner's questions

My goal is to make some units cast spells on auto-attack. I've noticed some FPS drop even with 3-4 players, so I have to upgrade some triggers.
But I'm a bit confused: I've read that large hash tables and multiple if\then\else statements in trigger with "A unit is attacked" event - both can cause lags.
I'm not sure which method is better: create a single hashtable for ~50 unit types, or split it for 25 each? Which one is faster?
-
Unit Attacked
-
Events
-
Unit - A unit Is attacked
-
-
Conditions
-
Actions
-
-------- Unit Attacked --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Unit Attacked (Dummy Ab) for (Attacked unit)) Greater than 0
-
-
Then - Actions
-
Custom script: set udg_Hash_Id = GetUnitTypeId(GetAttackedUnitBJ())
-
Set VariableSet Unit_Id[Hash_Id] = [Hash_Id]
-
Set VariableSet Attacker[Hash_Id] = (Attacking unit)
-
Set VariableSet Target[Hash_Id] = (Attacked unit)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Unit Hash 1 (Dummy Ab) for (Attacked unit)) Greater than 0
-
-
Then - Actions
-
-------- Hash 1 -------
-
Trigger - Run (Load 0 of Hash_Id in Hash_1.) (ignoring conditions)
-
-
Else - Actions
-
-------- Hash 2 --------
-
Trigger - Run (Load 0 of Hash_Id in Hash_2.) (ignoring conditions)
-
-
-
-
-
-
-
Unit Attacked
-
Events
-
Unit - A unit Is attacked
-
-
Conditions
-
Actions
-
-------- Unit Attacked --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Unit Attacked (Dummy Ab) for (Attacked unit)) Greater than 0
-
-
Then - Actions
-
Custom script: set udg_Hash_Id = GetUnitTypeId(GetAttackedUnitBJ())
-
Set VariableSet Unit_Id[Hash_Id] = [Hash_Id]
-
Set VariableSet Attacker[Hash_Id] = (Attacking unit)
-
Set VariableSet Target[Hash_Id] = (Attacked unit)
-
Trigger - Run (Load 0 of Hash_Id in Hash_1.) (ignoring conditions)
-
-
-
-
Should I worry about the next A unit Is attacked event overwriting the Attacker and Target variables before previous trigger completed, messing up some spells?
If so, I wonder which one is faster (that's in case if multiple unit types use the same trigger):
-
Actions
-
Set VariableSet Temp_Id[1] = Unit_Type[1]
-
Set VariableSet Temp_Id[2] = Unit_Type[2]
-
Set VariableSet Temp_Id[3] = Unit_Type[3]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Unit_Id[Temp_Id[1]] Greater than 0
-
-
Then - Actions
-
Set VariableSet Ab1_Id = Unit_Id[Temp_Id[1]]
-
Set VariableSet Unit_Id[Temp_Id[1]] = 0
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Unit_Id[Temp_Id[2]] Greater than 0
-
-
Then - Actions
-
Set VariableSet Ab1_Id = Unit_Id[Temp_Id[2]]
-
Set VariableSet Unit_Id[Temp_Id[2]] = 0
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Unit_Id[Temp_Id[3]] Greater than 0
-
-
Then - Actions
-
Set VariableSet Ab1_Id = Unit_Id[Temp_Id[3]]
-
Set VariableSet Unit_Id[Temp_Id[3]] = 0
-
-
Else - Actions
-
-
-
-
-
Unit - Order Attacker[Ab1_Id] to Neutral - Firebolt Target[Ab1_Id]
-
Set VariableSet Attacker[Ab1_Id] = No unit
-
Set VariableSet Target[Ab1_Id] = No unit
-
Set VariableSet Ab1_Id = 0
-
-
-
Actions
-
Set VariableSet Temp_Id[1] = Unit_Type[1]
-
Set VariableSet Temp_Id[2] = Unit_Type[2]
-
Set VariableSet Temp_Id[3] = Unit_Type[3]
-
Set VariableSet Ab1_Id = ((Unit_Id[Temp_Id[1]] + Unit_Id[Temp_Id[2]]) + Unit_Id[Temp_Id[3]])
-
Unit - Order Attacker[Ab1_Id] to Neutral - Firebolt Target[Ab1_Id]
-
Set VariableSet Unit_Id[Temp_Id[1]] = 0
-
Set VariableSet Unit_Id[Temp_Id[2]] = 0
-
Set VariableSet Unit_Id[Temp_Id[3]] = 0
-
Set VariableSet Attacker[Ab1_Id] = No unit
-
Set VariableSet Target[Ab1_Id] = No unit
-
Set VariableSet Ab1_Id = 0
-
-
Actions
-
Set VariableSet Temp_Id[1] = Unit_Type[1]
-
Set VariableSet Temp_Id[2] = Unit_Type[2]
-
Set VariableSet Temp_Id[3] = Unit_Type[3]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Attacker[Temp_Id[1]] Not equal to No unit
-
-
Then - Actions
-
Unit - Order Attacker[Temp_Id[1]] to Neutral - Firebolt Target[Temp_Id[1]]
-
Set VariableSet Attacker[Temp_Id[1]] = No unit
-
Set VariableSet Target[Temp_Id[1]] = No unit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Attacker[Temp_Id[2]] Not equal to No unit
-
-
Then - Actions
-
Unit - Order Attacker[Temp_Id[2]] to Neutral - Firebolt Target[Temp_Id[2]]
-
Set VariableSet Attacker[Temp_Id[2]] = No unit
-
Set VariableSet Target[Temp_Id[2]] = No unit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Attacker[Temp_Id[3]] Not equal to No unit
-
-
Then - Actions
-
Unit - Order Attacker[Temp_Id[3]] to Neutral - Firebolt Target[Temp_Id[3]]
-
Set VariableSet Attacker[Temp_Id[3]] = No unit
-
Set VariableSet Target[Temp_Id[3]] = No unit
-
-
Else - Actions
-
-
-
-
-
-

Last edited: