• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Tha bilities make the game lag

Status
Not open for further replies.
Level 10
Joined
Mar 17, 2012
Messages
579
Hello, guys. I really need your help optimizing a couple of my spells cause they make the game lag the more I use them.

1 - Mind Trap - AoE spell that keeps everyone stunned for 5 sec.

Cast:
  • Mind Trap init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Trap new
    • Actions
      • Set Mind_Trap_Int = (Player number of (Owner of (Triggering unit)))
      • Set Mind_Trap_Caster[Mind_Trap_Int] = (Triggering unit)
      • Set Mind_Trap_Point[Mind_Trap_Int] = (Target point of ability being cast)
      • Set Mind_Trap_Counter[Mind_Trap_Int] = 5.00
      • Unit Group - Add Mind_Trap_Caster[Mind_Trap_Int] to Mind_Trap_Casters
      • Trigger - Turn on Mind Trap expiration <gen>
Loop:
  • Mind Trap expiration
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mind_Trap_Casters is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Skip remaining actions
        • Else - Actions
          • For each (Integer Mind_Trap_Int) from 1 to 13, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Mind_Trap_Counter[Mind_Trap_Int] Greater than 0.00
                • Then - Actions
                  • Special Effect - Create a special effect at Mind_Trap_Point[Mind_Trap_Int] using MindTrap.mdx
                  • Special Effect - Destroy (Last created special effect)
                  • Set Mind_Trap_Group[Mind_Trap_Int] = (Units within 350.00 of Mind_Trap_Point[Mind_Trap_Int] matching ((((Matching unit) belongs to an enemy of (Owner of Mind_Trap_Caster[Mind_Trap_Int])) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is A structu
                  • Set Mind_Trap_Counter[Mind_Trap_Int] = (Mind_Trap_Counter[Mind_Trap_Int] - 0.20)
                  • Unit Group - Pick every unit in Mind_Trap_Group[Mind_Trap_Int] and do (Actions)
                    • Loop - Actions
                      • Unit - Create 1 Mind Trap dummy for (Owner of Mind_Trap_Caster[Mind_Trap_Int]) at Mind_Trap_Point[Mind_Trap_Int] facing Default building facing degrees
                      • Unit - Add a 0.10 second Generic expiration timer to (Last created unit)
                      • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is An Ancient) Equal to True
                        • Then - Actions
                          • Set Mind_Trap_Damage[Mind_Trap_Int] = ((((((Real((Level of Mind Trap new for Mind_Trap_Caster[Mind_Trap_Int]))) x 25.00) + 0.00) + ((Real((Intelligence of Mind_Trap_Caster[Mind_Trap_Int] (Include bonuses)))) x (((Real((Level of Mind Trap new for Mind_Trap_Caster[Mind_Trap_Int]))) x 0.40) + 0.80))
                          • Unit - Cause Mind_Trap_Caster[Mind_Trap_Int] to damage (Picked unit), dealing Mind_Trap_Damage[Mind_Trap_Int] damage of attack type Spells and damage type Fire
                        • Else - Actions
                  • Custom script: call DestroyGroup (udg_Mind_Trap_Group[udg_Mind_Trap_Int])
                • Else - Actions
                  • Custom script: call RemoveLocation(udg_Mind_Trap_Point[udg_Mind_Trap_Int])
                  • Unit Group - Remove Mind_Trap_Caster[Mind_Trap_Int] from Mind_Trap_Casters
P.S. Dummies are removed fwiw.

2 - Might of heaven - AoE spell around the hero. It damages all enemies around him if the apropriaye skill is on and if not, heals every ally.

Init:
  • Might of Heaven init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Might of Heaven
    • Actions
      • Set Might_of_Heaven_Int = (Player number of (Owner of (Triggering unit)))
      • Set Might_of_Heaven_Caster[Might_of_Heaven_Int] = (Triggering unit)
      • Set Might_of_Heaven_Bool[Might_of_Heaven_Int] = True
      • Set Might_of_Heaven_Timer[Might_of_Heaven_Int] = 5.00
      • Unit - Add Might of Heaven effect (+1) to Might_of_Heaven_Caster[Might_of_Heaven_Int]
      • Unit Group - Add Might_of_Heaven_Caster[Might_of_Heaven_Int] to Might_of_Heaven_Casters
      • Trigger - Turn on Might of Heaven loop <gen>
Loop:
  • Might of Heaven loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Might_of_Heaven_Casters is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Skip remaining actions
        • Else - Actions
          • For each (Integer Might_of_Heaven_Int) from 1 to 12, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Might_of_Heaven_Bool[Might_of_Heaven_Int] Equal to True
                  • Might_of_Heaven_Timer[Might_of_Heaven_Int] Greater than 0.00
                • Then - Actions
                  • Set Might_of_Heaven_Timer[Might_of_Heaven_Int] = (Might_of_Heaven_Timer[Might_of_Heaven_Int] - 0.10)
                  • Set Might_of_Heaven_Caster_Point[Might_of_Heaven_Int] = (Position of Might_of_Heaven_Caster[Might_of_Heaven_Int])
                  • Set Might_of_Heaven_Enemy_Group[Might_of_Heaven_Int] = (Units within 500.00 of Might_of_Heaven_Caster_Point[Might_of_Heaven_Int] matching ((((Matching unit) belongs to an enemy of (Owner of Might_of_Heaven_Caster[Might_of_Heaven_Int])) Equal to True) and ((((Matching unit) is An Ancient) Not equal to True) and ((
                  • Set Might_of_Heaven_Ally_Group[Might_of_Heaven_Int] = (Units within 500.00 of Might_of_Heaven_Caster_Point[Might_of_Heaven_Int] matching ((((Matching unit) belongs to an ally of (Owner of Might_of_Heaven_Caster[Might_of_Heaven_Int])) Equal to True) and ((((Matching unit) is An Ancient) Not equal to True) and (((
                  • Set Might_of_Heaven_Damage[Might_of_Heaven_Int] = (((((Real((Level of Might of Heaven for Might_of_Heaven_Caster[Might_of_Heaven_Int]))) x 5.00) + 10.00) + ((Real((Intelligence of Might_of_Heaven_Caster[Might_of_Heaven_Int] (Include bonuses)))) x (((Real((Level of Might of Heaven for Might_of_Heaven_Caster
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Holy Mark for Might_of_Heaven_Caster[Might_of_Heaven_Int]) Greater than 0
                    • Then - Actions
                      • Unit Group - Pick every unit in Might_of_Heaven_Ally_Group[Might_of_Heaven_Int] and do (Actions)
                        • Loop - Actions
                          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (Might_of_Heaven_Damage[Might_of_Heaven_Int] x 2.00))
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Retribution Mark for Might_of_Heaven_Caster[Might_of_Heaven_Int]) Greater than 0
                        • Then - Actions
                          • Unit Group - Pick every unit in Might_of_Heaven_Enemy_Group[Might_of_Heaven_Int] and do (Actions)
                            • Loop - Actions
                              • Unit - Cause Might_of_Heaven_Caster[Might_of_Heaven_Int] to damage (Picked unit), dealing (Might_of_Heaven_Damage[Might_of_Heaven_Int] x 2.00) damage of attack type Spells and damage type Fire
                        • Else - Actions
                          • Unit Group - Pick every unit in Might_of_Heaven_Ally_Group[Might_of_Heaven_Int] and do (Actions)
                            • Loop - Actions
                              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + Might_of_Heaven_Damage[Might_of_Heaven_Int])
                          • Unit Group - Pick every unit in Might_of_Heaven_Enemy_Group[Might_of_Heaven_Int] and do (Actions)
                            • Loop - Actions
                              • Unit - Cause Might_of_Heaven_Caster[Might_of_Heaven_Int] to damage (Picked unit), dealing Might_of_Heaven_Damage[Might_of_Heaven_Int] damage of attack type Spells and damage type Fire
                  • Custom script: call RemoveLocation(udg_Might_of_Heaven_Caster_Point[udg_Might_of_Heaven_Int])
                  • Custom script: call DestroyGroup(udg_Might_of_Heaven_Ally_Group[udg_Might_of_Heaven_Int])
                  • Custom script: call DestroyGroup(udg_Might_of_Heaven_Enemy_Group[udg_Might_of_Heaven_Int])
                • Else - Actions
                  • Set Might_of_Heaven_Timer[Might_of_Heaven_Int] = 0.00
                  • Set Might_of_Heaven_Bool[Might_of_Heaven_Int] = False
                  • Unit - Remove Might of Heaven effect (+1) from Might_of_Heaven_Caster[Might_of_Heaven_Int]
                  • Unit Group - Remove Might_of_Heaven_Caster[Might_of_Heaven_Int] from Might_of_Heaven_Casters

Do they leak or what? I can't understand why they make the map lag. I mean creating dummies will definitely load the map, but I remove one before another one appears... Any help, please? :(
 
Level 4
Joined
Jan 18, 2019
Messages
71
Have you checked to see if the trigger is perhaps going infinite on you? Try adding a game message on and off to the triggers, both when the group is empty and when it is not, and see if it is infinite looping. I don’t think creating many dummy units would lag, unless they leaked, as my map has many of them happening all the time.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Hmm, I'm no expert on the matter of what leaks or not (as far as I can tell you did a good job cleaning up the leaks) but I'll list some things that I did notice. These may or may not be issues, someone more experienced would have to clarify.

1. You're looping through all of the players to check if they're casting the spell. Instead, you could loop through all of the units. Since there's a chance that only 1 unit would be casting the spell at a time this would help with performance.

2. You turn on your Loop Triggers regardless of whether they're already on or not. Not sure if that's a problem, but maybe it is.

3. This one is a suggestion. Throw in a text message to see if your loops are turning off properly when you check to see if the unit group is empty.

Edit:
Do you ever cast the same spell again while an older cast is still running? Because if you were to cast Mind Trap new while it was still running, you would leak the old Mind Trap Point as well as probably cause other problems like adding a unit to a unit group that it's already in, etc... This brings me back to #1, looping through units instead of players. If you used an Indexing system for this you could avoid issues like these.

Come to think of it, your spells are all synced up so they will always run at the same time regardless of when you cast the spell. If I cast Mind Trap, then 0.10 seconds later my ally casts it too, and then the timer goes off, both of our spells effects will go off at the same time, even though my ally cast the spell later than me. This isn't much of an issue with smaller intervals, but it becomes very apparent when you do something like "Every 1 second do stuff".

The way I get around stuff like this is by having one timer for ALL of my spells, like this one:
It runs every 0.01 seconds so it's very precise and it even recycles itself! We can then detect when our Elapsed Time is equal to our set Spell Interval (Mind Trap new's spell interval would be 0.20 seconds), and run a trigger containing all of the effects that you would normally run inside of your loop.
  • Spell Loop
    • Events
      • Time - Spell_Timer expires
    • Conditions
    • Actions
      • For each (Integer Spell_Loop) from 1 to Spell_Index_Size, do (Actions)
        • Loop - Actions
          • Set Spell_Array = Spell_Index[Spell_Loop]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Spell_IsOn[Spell_Array] Equal to True
            • Then - Actions
              • Set Spell_ElapsedTime[Spell_Array] = (Spell_ElapsedTime[Spell_Array] + 0.01)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Spell_ElapsedTime[Spell_Array] Equal to Spell_Interval[Spell_Array]
                • Then - Actions
                  • Set Spell_ElapsedTime[Spell_Array] = 0.00
                  • Set Spell_Fix = Spell_Array
                  • Trigger - Run Spell_Trigger[Spell_Array] (ignoring conditions)
                • Else - Actions
            • Else - Actions
              • Set Spell_Index[Spell_Loop] = Spell_Index[Spell_Index_Size]
              • Set Spell_Index[Spell_Index_Size] = Spell_Array
              • Set Spell_Index_Size = (Spell_Index_Size - 1)
              • Set Spell_Loop = (Spell_Loop - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Spell_Index_Size Equal to 0
                • Then - Actions
                  • Countdown Timer - Pause Spell_Timer
                  • Trigger - Turn off (This trigger)
                  • Skip remaining actions
                • Else - Actions

Here is an example of a spell I made taking advantage of the loop. This is how you add it to the Spell Index.
  • Lightning Hammer Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lightning Hammer (Ability)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spell_Index_Size Equal to 0
        • Then - Actions
          • Trigger - Turn on Spell Loop <gen>
          • Countdown Timer - Start Spell_Timer as a Repeating timer that will expire in 0.01 seconds
        • Else - Actions
      • Set Spell_Index_Size = (Spell_Index_Size + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spell_Index_Size Greater than Spell_Index_maxSize
        • Then - Actions
          • Set Spell_Index[Spell_Index_Size] = Spell_Index_Size
          • Set Spell_Index_maxSize = Spell_Index_Size
        • Else - Actions
      • Set Spell_Array = Spell_Index[Spell_Index_Size]
      • Set Spell_IsOn[Spell_Array] = True
      • Set Spell_Trigger[Spell_Array] = Lightning Hammer Effect <gen>
      • Set TempPoint[1] = (TempPoint[0] offset by 50.00 towards TempReal[0] degrees)
      • Unit - Create 1 Lightning Hammer Dummy (Zeus) for TempPlayer[0] at TempPoint[1] facing TempReal[0] degrees
      • Set Zeus_LBDummy[Spell_Array] = (Last created unit)
      • Set Zeus_LBAngle[Spell_Array] = TempReal[0]
      • Set Spell_ElapsedTime[Spell_Array] = 0.00
      • Set Spell_Interval[Spell_Array] = 0.03

And here is the effect that you would normally have inside of your Loop trigger.
  • Lightning Hammer Effect
    • Events
    • Conditions
    • Actions
      • Set Zeus_LBElapsedTime[Spell_Array] = (Zeus_LBElapsedTime[Spell_Array] + 0.03)
      • Set Zeus_LBMod[Spell_Array] = (Zeus_LBMod[Spell_Array] + 3)
      • Set TempPoint[0] = ((Position of Zeus_LBDummy[Spell_Array]) offset by 15.00 towards Zeus_LBAngle[Spell_Array] degrees)
      • Custom script: set bj_wantDestroyGroup=true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Zeus_LBMod[Spell_Array] mod 60) Equal to 0
        • Then - Actions
          • Special Effect - Create a special effect at TempPoint[0] using Abilities\Weapons\Bolt\BoltImpact.mdl
          • Special Effect - Set Scale of (Last created special effect) to 1.25
          • Special Effect - Destroy (Last created special effect)
          • Custom script: set bj_wantDestroyGroup=true
          • Unit Group - Pick every unit in (Units within 500.00 of TempPoint[0]) and do (Actions)
            • Loop - Actions
              • Set TempUnit[0] = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit[0] is alive) Equal to True
                  • (TempUnit[0] is invulnerable) Equal to False
                  • (TempUnit[0] is A structure) Equal to False
                  • (TempUnit[0] is Undead) Equal to False
                  • (TempUnit[0] is Magic Immune) Equal to False
                  • (TempUnit[0] belongs to an enemy of (Owner of Zeus_LBDummy[Spell_Array])) Equal to True
                • Then - Actions
                  • Unit Group - Add TempUnit[0] to TempUG
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TempUG) Greater than 0
            • Then - Actions
              • Set TempUnit[0] = (Random unit from TempUG)
              • Unit - Create 1 Dummy for (Owner of Zeus_LBDummy[Spell_Array]) at TempPoint[0] facing Default building facing degrees
              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Lightning Hammer (Chain Lightning) to (Last created unit)
              • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning TempUnit[0]
            • Else - Actions
          • Unit Group - Remove all units from TempUG
        • Else - Actions
      • Unit Group - Pick every unit in (Units within 150.00 of TempPoint[0]) and do (Actions)
        • Loop - Actions
          • Set TempUnit[0] = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit[0] is in Zeus_LBUG[Spell_Array]) Equal to False
              • (TempUnit[0] is alive) Equal to True
              • (TempUnit[0] is invulnerable) Equal to False
              • (TempUnit[0] is A structure) Equal to False
              • (TempUnit[0] is Undead) Equal to False
              • (TempUnit[0] is Magic Immune) Equal to False
              • (TempUnit[0] belongs to an enemy of (Owner of Zeus_LBDummy[Spell_Array])) Equal to True
            • Then - Actions
              • Special Effect - Create a special effect attached to the chest of TempUnit[0] using Abilities\Spells\Human\StormBolt\StormBoltMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Cause Zeus_LBDummy[Spell_Array] to damage TempUnit[0], dealing 100.00 damage of attack type Spells and damage type Universal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit[0] is alive) Equal to True
                • Then - Actions
                  • Unit Group - Add TempUnit[0] to Zeus_LBUG[Spell_Array]
                  • -------- Stun --------
                  • Unit - Create 1 Dummy for (Owner of Zeus_LBDummy[Spell_Array]) at TempPoint[0] facing Default building facing degrees
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                  • Unit - Add Lightning Hammer (Stun) to (Last created unit)
                  • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt TempUnit[0]
                  • -------- Knockback --------
                  • Set KnockbackSource = Zeus_LBDummy[Spell_Array]
                  • Set KnockbackTarget = TempUnit[0]
                  • Set Knockback2DDistance = 200.00
                  • Set Knockback2DTime = 0.50
                  • Set CenterPoint = (Position of KnockbackSource)
                  • Set TargetPoint = (Position of KnockbackTarget)
                  • Set Knockback2DAngle = (Angle from CenterPoint to TargetPoint)
                  • Custom script: call RemoveLocation(udg_CenterPoint)
                  • Custom script: call RemoveLocation(udg_TargetPoint)
                  • Set Knockback2DUnit = KnockbackTarget
                  • Trigger - Run Knockback 2D <gen> (checking conditions)
                • Else - Actions
            • Else - Actions
          • Set TempUnit[0] = No unit
      • Set X = (X of TempPoint[0])
      • Set Y = (Y of TempPoint[0])
      • Custom script: call SetUnitX( udg_Zeus_LBDummy[udg_Spell_Array], udg_X )
      • Custom script: call SetUnitY( udg_Zeus_LBDummy[udg_Spell_Array], udg_Y )
      • Custom script: call RemoveLocation (udg_TempPoint[0])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Zeus_LBElapsedTime[Spell_Array] Equal to 3.00
        • Then - Actions
          • Unit - Kill Zeus_LBDummy[Spell_Array]
          • Custom script: call DestroyGroup(udg_Zeus_LBUG[udg_Spell_Array])
          • Custom script: set udg_Zeus_LBUG[udg_Spell_Array] = null
          • Set Spell_IsOn[Spell_Array] = False
        • Else - Actions
 
Last edited:
Level 10
Joined
Mar 17, 2012
Messages
579
Maybe related to the local agent variable reference counter leak on return bug? Most GUI functions that return groups cause the handle index of the group to leak permanently.

Is there any way to handle that?

Hmm, I'm no expert on the matter of what leaks or not (as far as I can tell you did a good job cleaning up the leaks) but I'll list some things that I did notice. These may or may not be issues, someone more experienced would have to clarify.

1. You're looping through all of the players to check if they're casting the spell. Instead, you could loop through all of the units. Since there's a chance that only 1 unit would be casting the spell at a time this would help with performance.

2. You turn on your Loop Triggers regardless of whether they're already on or not. Not sure if that's a problem, but maybe it is.

3. This one is a suggestion. Throw in a text message to see if your loops are turning off properly when you check to see if the unit group is empty.

Edit:
Do you ever cast the same spell again while an older cast is still running? Because if you were to cast Mind Trap new while it was still running, you would leak the old Mind Trap Point as well as probably cause other problems like adding a unit to a unit group that it's already in, etc... This brings me back to #1, looping through units instead of players. If you used an Indexing system for this you could avoid issues like these.
Thanks for your answer. The thing is that in usual conditions there can be only 2 same units who can cast the same spell. Currently it's only one, so there is nothing to overlap. The problem is I have numerous triggers run on 0.03 loops but only a couple of them cause lags.

Now I have removed the for each loop and selected all units who have cast the spell within 5 seconds. I'm not sure it really can help, but it's supposed to improve the performance a little.
 
Last edited:
Level 10
Joined
Mar 17, 2012
Messages
579
Can I see your new trigger? Also, are you positive that you narrowed it down to these two spells?
Do you mean send you the map with only these 2 spells?

  • Mind Trap init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Trap new
    • Actions
      • Set Mind_Trap_Int = (Player number of (Owner of (Triggering unit)))
      • Set Mind_Trap_Caster[Mind_Trap_Int] = (Triggering unit)
      • Set Mind_Trap_Point[Mind_Trap_Int] = (Target point of ability being cast)
      • Set Mind_Trap_Counter[Mind_Trap_Int] = 5.00
      • Unit Group - Add Mind_Trap_Caster[Mind_Trap_Int] to Mind_Trap_Casters
      • Trigger - Turn on Mind Trap expiration <gen>
  • Mind Trap expiration
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mind_Trap_Casters is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Skip remaining actions
        • Else - Actions
          • Unit Group - Pick every unit in Mind_Trap_Casters and do (Actions)
            • Loop - Actions
              • Set Mind_Trap_Int = (Player number of (Owner of (Picked unit)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Mind_Trap_Counter[Mind_Trap_Int] Greater than 0.00
                • Then - Actions
                  • Special Effect - Create a special effect at Mind_Trap_Point[Mind_Trap_Int] using MindTrap.mdx
                  • Special Effect - Destroy (Last created special effect)
                  • Set Mind_Trap_Group[Mind_Trap_Int] = (Units within 350.00 of Mind_Trap_Point[Mind_Trap_Int] matching ((((Matching unit) belongs to an enemy of (Owner of Mind_Trap_Caster[Mind_Trap_Int])) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is A structu
                  • Set Mind_Trap_Counter[Mind_Trap_Int] = (Mind_Trap_Counter[Mind_Trap_Int] - 0.03)
                  • Unit Group - Pick every unit in Mind_Trap_Group[Mind_Trap_Int] and do (Actions)
                    • Loop - Actions
                      • Unit - Order (Picked unit) to Stop
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is An Ancient) Equal to True
                        • Then - Actions
                          • Set Mind_Trap_Damage[Mind_Trap_Int] = ((((((Real((Level of Mind Trap new for Mind_Trap_Caster[Mind_Trap_Int]))) x 25.00) + 0.00) + ((Real((Intelligence of Mind_Trap_Caster[Mind_Trap_Int] (Include bonuses)))) x (((Real((Level of Mind Trap new for Mind_Trap_Caster[Mind_Trap_Int]))) x 0.40) + 0.80))
                          • Unit - Cause Mind_Trap_Caster[Mind_Trap_Int] to damage (Picked unit), dealing Mind_Trap_Damage[Mind_Trap_Int] damage of attack type Spells and damage type Fire
                        • Else - Actions
                  • Custom script: call DestroyGroup (udg_Mind_Trap_Group[udg_Mind_Trap_Int])
                • Else - Actions
                  • Custom script: call RemoveLocation(udg_Mind_Trap_Point[udg_Mind_Trap_Int])
                  • Unit Group - Remove Mind_Trap_Caster[Mind_Trap_Int] from Mind_Trap_Casters
I've even got rid of the dummies, but still no use. The map still lags when I use it... Maybe the problem is in the effect...
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
Every 0.20 seconds is too slow, 0.03 would be better and more accurate. You can even have 20 triggers running 0.01 seconds and still have no lag, really depends how you do it.

Maybe related to the local agent variable reference counter leak on return bug? Most GUI functions that return groups cause the handle index of the group to leak permanently.
I don't think thats enough to make the game lag so easily.
Edit: meh you just posted. It could be special effect if you were actually spamming it like crazy. You should loop through players not through that first unit group. So if only a few players are casting the spell, the trigger ignores the rest of them.
 
Level 10
Joined
Mar 17, 2012
Messages
579
Every 0.20 seconds is too slow, 0.03 would be better and more accurate. You can even have 20 triggers running 0.01 seconds and still have no lag, really depends how you do it.


I don't think thats enough to make the game lag so easily.
Edit: meh you just posted. It could be special effect if you were actually spamming it like crazy. You should loop through players not through that first unit group. So if only a few players are casting the spell, the trigger ignores the rest of them.

What if I loop through the unit group? Will it cause crush or something?
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
No, it won't. It is just not the best option in this context. Also i forgot to say that when you're going to loop through players go loop from integer., like the already existing loops for integer (A) and (B).
 
Level 10
Joined
Mar 17, 2012
Messages
579
No, it won't. It is just not the best option in this context. Also i forgot to say that when you're going to loop through players go loop from integer., like the already existing loops for integer (A) and (B).
I used to have it before, but after the 100th (A) I reworked every single loop adding custom raviables as there were a lot of bugs :)

So, I've added the third trigger with a smaller frequency which plays the spacial effect and it seems that it helped :)
 
Status
Not open for further replies.
Top