Im making kind of Hero Defence and i want to randomize creeps type of each wave.
At first I put every creep in one tileset (about 300 unit types) then i was trying to make simple "create random creep of lvl" this maked lags even with 3 units... I was thinking that happends because of a lot of types of creeps .Аfter that I decided to store everything in the hashtables at the beginning of the game (calculate all randoms and just getting data at the moment of spawning) But I still get lags... If i spawn one type of creeps or 2-3 types its ok... But if i getting data from hashtable it lags a lot and i cant get WHY?!
Here are my triggers:
Init:
At first I put every creep in one tileset (about 300 unit types) then i was trying to make simple "create random creep of lvl" this maked lags even with 3 units... I was thinking that happends because of a lot of types of creeps .Аfter that I decided to store everything in the hashtables at the beginning of the game (calculate all randoms and just getting data at the moment of spawning) But I still get lags... If i spawn one type of creeps or 2-3 types its ok... But if i getting data from hashtable it lags a lot and i cant get WHY?!
Here are my triggers:
Init:
-
Creeps init
-
Events
- Map initialization
- Conditions
-
Actions
- Hashtable - Create a hashtable
- Set VariableSet Creeps_Table = (Last created hashtable)
- -------- Basic Lvl for creeps --------
- Set VariableSet Creeps_Loop_Hash_Lvl = 1
- -------- Count waves per creeps level up --------
- Set VariableSet Creeps_C_Waves_Lvl = 5
- -------- Count of waves by levels 1-9 lvl --------
- Set VariableSet Creeps_C_Waves_All = (Creeps_C_Waves_Lvl x 9)
- -------- Creeps per Player --------
- Set VariableSet Creeps_C_Waves_Per_Player = 4
- Set VariableSet Creeps_C_Waves_Per_Player = (Creeps_C_Waves_Per_Player x (Number of players in Players_users))
-
For each (Integer A) from 1 to Creeps_C_Waves_All, do (Actions)
-
Loop - Actions
- -------- Calculate lvl up for creeps waves --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Creeps_Loop_Hash_Lvl_i Equal to Creeps_C_Waves_Lvl
-
Then - Actions
- Set VariableSet Creeps_Loop_Hash_Lvl = (Creeps_Loop_Hash_Lvl + 1)
- Set VariableSet Creeps_Loop_Hash_Lvl_i = 1
-
Else - Actions
- Set VariableSet Creeps_Loop_Hash_Lvl_i = (Creeps_Loop_Hash_Lvl_i + 1)
-
If - Conditions
-
For each (Integer B) from 1 to Creeps_C_Waves_Per_Player, do (Actions)
-
Loop - Actions
- Set VariableSet Creeps_Random_Temp = (Random level Creeps_Loop_Hash_Lvl creep unit-type)
- Custom script: set udg_Creeps_Type_Temp = udg_Creeps_Random_Temp
- Hashtable - Save Creeps_Type_Temp as (Integer A) of (Integer B) in Creeps_Table.
-
Loop - Actions
-
Loop - Actions
- Custom script: set udg_Creeps_Random_Temp = udg_Creeps_Type_Temp
- Set VariableSet Creeps_Level = 0
- Trigger - Run Creeps spawn <gen> (checking conditions)
- Custom script: call DestroyTrigger(GetTriggeringTrigger())
-
Events
-
Creeps spawn
- Events
- Conditions
-
Actions
- Wait (Random real number between 15.00 and 20.00) seconds
- Set VariableSet Creeps_Count = ((Players_In_Game_Count + 1) + (Random integer number between 1 and 2))
- Set VariableSet Creeps_Count_Wave = (Creeps_Count_Wave + 1)
- Set VariableSet Creeps_Level = ((Creeps_Count_Wave / 5) + 1)
- Set VariableSet Creeps_Count_Loop = Creeps_Count
- Trigger - Turn on Creeps create <gen>
- Wait 5.00 seconds
- Trigger - Run (This trigger) (checking conditions)
-
Creeps create
-
Events
- Time - Every 0.50 seconds of game time
- Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Creeps_Count_Loop Not equal to Creeps_Count
-
Then - Actions
- Set VariableSet Temp_locB_Spawn = (Position of Castle 0002 <gen>)
- Unit - Order Temp_Creep_Spawn[1] to Attack-Move To.Temp_locB_Spawn
- Custom script: call RemoveLocation(udg_Temp_locB_Spawn)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Creeps_Count_Loop Greater than 0
-
Then - Actions
- Set VariableSet Temp_locA_Spawn = (Random point in 2GatesMainTop <gen>)
- Set VariableSet Creeps_Type_Temp = (Load Creeps_Count_Wave of Creeps_Count_Loop from Creeps_Table.)
- Custom script: set udg_Creeps_Random_Temp = udg_Creeps_Type_Temp
- Set VariableSet UnitIndexerEnabled = No
- Unit - Create 1.Creeps_Random_Temp for Player_Attack at Temp_locA_Spawn facing 270.00 degrees
- Set VariableSet UnitIndexerEnabled = Yes
- Set VariableSet Temp_Creep_Spawn[1] = (Last created unit)
- Set VariableSet Creeps_Count_Loop = (Creeps_Count_Loop - 1)
- Custom script: call RemoveLocation(udg_Temp_locA_Spawn)
-
Else - Actions
- Trigger - Turn off (This trigger)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events