- Joined
- Oct 17, 2009
- Messages
- 1,579
I made a spell that summons units to move around randomly and damage enemies they pass. Now when I activate the spell, everything goes along smoothly unit one of the summons pass through a couple of enemy units and the games starts lagging until the ability ends.
So I put in a bunch of text message actions around the trigger to find where the problem lies and apparently, the variable SE_Max_Index_2 over-indexes enemies. I put a text message action to print out the value of the variable every time it indexes and tested the ability. I was shocked to see that the variable suddenly jumps from 1, 2, or 3 to a staggering 2726.
So can someone look at this trigger and tell me what I did wrong:
So I put in a bunch of text message actions around the trigger to find where the problem lies and apparently, the variable SE_Max_Index_2 over-indexes enemies. I put a text message action to print out the value of the variable every time it indexes and tested the ability. I was shocked to see that the variable suddenly jumps from 1, 2, or 3 to a staggering 2726.
So can someone look at this trigger and tell me what I did wrong:
-
Move Loop
-
Events
- Time - Every 0.03 seconds of game time
- Conditions
-
Actions
-
For each (Integer SE_Index_2) from 1 to SE_Max_Index_2, do (Actions)
-
Loop - Actions
- Set SE_Dmg_CD[SE_Index_2] = (SE_Dmg_CD[SE_Index_2] - 0.03)
-
Loop - Actions
-
For each (Integer SE_Index) from 1 to SE_Max_Index, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (SE_Unit[SE_Index] is dead) Equal to False
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- SE_Move_Left[SE_Index] Equal to 1
-
Then - Actions
- Set SE_Summon_Loc = (Position of SE_Unit[SE_Index])
- Set SE_Summon_Move = (SE_Summon_Loc offset by 20.00 towards SE_Angle[SE_Index] degrees)
- Unit - Move SE_Unit[SE_Index] instantly to SE_Summon_Move, facing SE_Angle[SE_Index] degrees
- Set SE_Angle[SE_Index] = (SE_Angle[SE_Index] + SE_Add[SE_Index])
- Set SE_Roll = (Random integer number between 1 and SE_Chance[SE_Index])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- SE_Roll Less than or equal to 1
-
Then - Actions
- Set SE_Move_Left[SE_Index] = 0
- Set SE_Chance[SE_Index] = 100
- Set SE_Add[SE_Index] = (Random real number between 3.00 and 6.00)
- Set SE_Angle[SE_Index] = (SE_Angle[SE_Index] - SE_Add[SE_Index])
-
Else - Actions
- Set SE_Chance[SE_Index] = (SE_Chance[SE_Index] - 1)
-
If - Conditions
-
Else - Actions
- Set SE_Summon_Loc = (Position of SE_Unit[SE_Index])
- Set SE_Summon_Move = (SE_Summon_Loc offset by 20.00 towards SE_Angle[SE_Index] degrees)
- Unit - Move SE_Unit[SE_Index] instantly to SE_Summon_Move, facing SE_Angle[SE_Index] degrees
- Set SE_Angle[SE_Index] = (SE_Angle[SE_Index] - SE_Add[SE_Index])
- Set SE_Roll = (Random integer number between 1 and SE_Chance[SE_Index])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- SE_Roll Less than or equal to 1
-
Then - Actions
- Set SE_Move_Left[SE_Index] = 1
- Set SE_Chance[SE_Index] = 100
- Set SE_Add[SE_Index] = (Random real number between 3.00 and 6.00)
- Set SE_Angle[SE_Index] = (SE_Angle[SE_Index] + SE_Add[SE_Index])
-
Else - Actions
- Set SE_Chance[SE_Index] = (SE_Chance[SE_Index] - 1)
-
If - Conditions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- SE_Max_Index_2 Equal to 0
-
Then - Actions
- Custom script: set bj_wantDestroyGroup=true
-
Unit Group - Pick every unit in (Units within SE_Pass_AOE of SE_Summon_Move) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked unit) belongs to an enemy of (Owner of SE_Unit[SE_Index])) Equal to True
-
Then - Actions
- Set SE_Max_Index_2 = (SE_Max_Index_2 + 1)
- Set SE_Enemy[SE_Max_Index_2] = (Picked unit)
- Set SE_Dmg_CD[SE_Max_Index_2] = 0.50
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Else - Actions
-
For each (Integer SE_Index_2) from 1 to SE_Max_Index_2, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (SE_Enemy[SE_Index_2] is dead) Equal to False
-
Then - Actions
- Custom script: set bj_wantDestroyGroup=true
-
Unit Group - Pick every unit in (Units within SE_Pass_AOE of SE_Summon_Move) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked unit) belongs to an enemy of (Owner of SE_Unit[SE_Index])) Equal to True
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Picked unit) Not equal to SE_Enemy[SE_Index_2]
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- SE_Index_2 Equal to SE_Max_Index_2
-
Then - Actions
- Set SE_Max_Index_2 = (SE_Max_Index_2 + 1)
- Set SE_Enemy[SE_Max_Index_2] = (Picked unit)
- Set SE_Dmg_CD[SE_Max_Index_2] = 0.50
- Unit - Cause SE_Unit[SE_Index] to damage SE_Enemy[SE_Max_Index_2], dealing SE_Pass_Dmg[(Level of SE_Ability for SE_Unit[SE_Index])] damage of attack type SE_Pass_Dmg_Type and damage type Normal
- Game - Display to (All players) the text: (String(SE_Max_Index_2))
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- SE_Dmg_CD[SE_Index_2] Less than or equal to 0.00
-
Then - Actions
- Unit - Cause SE_Unit[SE_Index] to damage SE_Enemy[SE_Index_2], dealing SE_Pass_Dmg[(Level of SE_Ability for SE_Unit[SE_Index])] damage of attack type SE_Pass_Dmg_Type and damage type Normal
- Set SE_Dmg_CD[SE_Index_2] = 0.50
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Else - Actions
- Set SE_Enemy[SE_Index_2] = SE_Enemy[SE_Max_Index_2]
- Set SE_Dmg_CD[SE_Index_2] = SE_Dmg_CD[SE_Max_Index_2]
- Set SE_Max_Index_2 = (SE_Max_Index_2 - 1)
- Set SE_Index_2 = (SE_Index_2 - 1)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer SE_Index_2) from 1 to SE_Max_Index_2, do (Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Else - Actions
- Set SE_Add[SE_Index] = SE_Add[SE_Max_Index]
- Set SE_Angle[SE_Index] = SE_Angle[SE_Max_Index]
- Set SE_Chance[SE_Index] = SE_Chance[SE_Max_Index]
- Set SE_Move_Left[SE_Index] = SE_Move_Left[SE_Max_Index]
- Set SE_Unit[SE_Index] = SE_Unit[SE_Max_Index]
- Set SE_Max_Index = (SE_Max_Index - 1)
- Set SE_Index = (SE_Index - 1)
-
If - Conditions
- Custom script: call RemoveLocation(udg_SE_Summon_Loc)
- Custom script: call RemoveLocation(udg_SE_Summon_Move)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer SE_Index_2) from 1 to SE_Max_Index_2, do (Actions)
-
Events