Help with critical strike aura

Level 9
Joined
Jun 10, 2013
Messages
473
I've tried to make a critical strike aura and although it works perfectly it lags like hell thus i'm sure it leaks like crazy to.... is their any way to make this leakless or unlaggy?

  • Variables
    • Events
    • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
    • If ((Unit-type of (Entering unit)) Equal to Blood Ranger (Range Support)) then do (Unit Group - Pick every unit in (Units of type Blood Ranger (Range Support)) and do (Set MasterRangerHero = (Picked unit))) else do (Do nothing)
  • Precision Aura
    • Events
    • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
    • Set tempGroup1 = (Units in (Playable map area))
    • Unit Group - Pick every unit in tempGroup1 and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Level of Presicion Aura for MasterRangerHero) Equal to 1
    • ((Picked unit) has buff Precision Aura L1) Equal to True
    • Then - Actions
    • Unit - Add Presicion Aura Spell Book L1 to (Picked unit)
    • Player - Disable Presicion Aura Spell Book L1 for (Owner of (Picked unit))
    • Else - Actions
    • Unit Group - Pick every unit in tempGroup1 and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Level of Presicion Aura for MasterRangerHero) Equal to 2
    • ((Picked unit) has buff Precision Aura L2) Equal to True
    • Then - Actions
    • Unit - Add Presicion Aura Spell Book L2 to (Picked unit)
    • Player - Disable Presicion Aura Spell Book L2 for (Owner of (Picked unit))
    • Else - Actions
    • Unit Group - Pick every unit in tempGroup1 and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Level of Presicion Aura for MasterRangerHero) Equal to 3
    • ((Picked unit) has buff Precision Aura L3) Equal to True
    • Then - Actions
    • Unit - Add Presicion Aura Spell Book L3 to (Picked unit)
    • Player - Disable Presicion Aura Spell Book L3 for (Owner of (Picked unit))
    • Else - Actions
    • Custom script: call DestroyGroup (udg_tempGroup1)
  • Precision Aura Remove
    • Events
    • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
    • Set tempGroup1 = (Units in (Playable map area))
    • Unit Group - Pick every unit in tempGroup1 and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Picked unit) has buff Precision Aura L1) Equal to False
    • Then - Actions
    • Unit - Remove Presicion Aura Spell Book L1 from (Picked unit)
    • Else - Actions
    • Unit Group - Pick every unit in tempGroup1 and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Picked unit) has buff Precision Aura L2) Equal to False
    • Then - Actions
    • Unit - Remove Presicion Aura Spell Book L2 from (Picked unit)
    • Else - Actions
    • Unit Group - Pick every unit in tempGroup1 and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Picked unit) has buff Precision Aura L3) Equal to False
    • Then - Actions
    • Unit - Remove Presicion Aura Spell Book L3 from (Picked unit)
    • Else - Actions
    • Custom script: call DestroyGroup (udg_tempGroup1)
 
Level 9
Joined
Jun 10, 2013
Messages
473
Try not picking every unit on the map. That can be a very expensive operation on maps with a lot of units.

Maybe only pick units around aura owners?
well I did that and it seemed to help that and me adding a custom script "Bj...want destoy group = true" before every "pick every unit...." and it has reduced the lag quite a bit there is still a tiny persistent lag every 2 seconds (btw I changed the periodic timer events to 2.00 seconds)
 

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,083
Do 1 single group loop, instead of 1 loop for every level. This is slightly more efficient.

When you add the dummy to a unit you then add that unit to a unit group. Your remove trigger then picks all units in that unit group and if they are missing the buff then removes the dummy ability.

Post triggers after these changes. Please try to keep the formatting intact as reading GUI without it is near impossible. To paste formatted GUI into the forums you need to "Use BB Code Editor" (located top right of quick reply panel) and paste the trigger in that. This way indentation is correctly preserved. Remember you can copy entire GUI triggers, formatting and all, by right clicking the trigger root node and pressing copy as text.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Do 1 single group loop, instead of 1 loop for every level. This is slightly more efficient.

When you add the dummy to a unit you then add that unit to a unit group. Your remove trigger then picks all units in that unit group and if they are missing the buff then removes the dummy ability.

Post triggers after these changes. Please try to keep the formatting intact as reading GUI without it is near impossible. To paste formatted GUI into the forums you need to "Use BB Code Editor" (located top right of quick reply panel) and paste the trigger in that. This way indentation is correctly preserved. Remember you can copy entire GUI triggers, formatting and all, by right clicking the trigger root node and pressing copy as text.

do you mean this ?

  • Precision Aura
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup1 = (Units within 600.00 of (Position of MasterRangerHero))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in tempGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Presicion Aura for MasterRangerHero) Equal to 1
              • ((Picked unit) has buff Precision Aura L1) Equal to True
            • Then - Actions
              • Unit - Add Presicion Aura Spell Book L1 to (Picked unit)
              • Player - Disable Presicion Aura Spell Book L1 for (Owner of (Picked unit))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Presicion Aura for MasterRangerHero) Equal to 2
              • ((Picked unit) has buff Precision Aura L2) Equal to True
            • Then - Actions
              • Unit - Add Presicion Aura Spell Book L2 to (Picked unit)
              • Player - Disable Presicion Aura Spell Book L2 for (Owner of (Picked unit))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Presicion Aura for MasterRangerHero) Equal to 3
              • ((Picked unit) has buff Precision Aura L3) Equal to True
            • Then - Actions
              • Unit - Add Presicion Aura Spell Book L3 to (Picked unit)
              • Player - Disable Presicion Aura Spell Book L3 for (Owner of (Picked unit))
            • Else - Actions
      • Custom script: call DestroyGroup (udg_tempGroup1)
  • Precision Aura Remove
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup1 = (Units within 600.00 of (Position of MasterRangerHero))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in tempGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L1) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L1 from (Picked unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L2) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L2 from (Picked unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L3) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L3 from (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup (udg_tempGroup1)
 
Last edited:

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,083
Both triggers leak a location. The DestroyGroup call is not necessary as you have already destroyed the group. Destroying an already destroyed object is generally a bad idea, and certainly wastes some time.

The second trigger may bug dummy ability removal if the unit is teleported or moves rapidly away from the hero. Do what I mentioned in the previous post and use a global unit group to track units with the buff. When a unit gains the buff it gets added to that global unit group. The removal trigger then checks all units in that unit group and if they are missing the buff then it removes the dummy ability from the unit and the unit from the unit group.

I am pretty sure abilities only need to be disabled once, and not once per acquisition. Move those disable ability calls to map initialization where you apply them to every player.

Abilities inside spell books can be levelled up just like abilities outside spell books. As such you can replace the 3 dummy spell books and 3 dummy abilities with a single dummy spell book and single dummy ability which you level to the buff level. The 3 buffs can then be simplified to a single buff for all 3 ability levels. Combined with you knowing the level of the aura ability this greatly simplifies the loop by removing several conditional tests. This also removes several object types simplifying the map slightly.

These changes should make a considerable difference when it comes to performance. If it is not enough then it may be time to look at a pure JASS solution as GUI inherently produces badly optimized script.
 
Level 4
Joined
Jul 26, 2016
Messages
88
Uhm, as far as I know, your VERY first trigger (the one that iterates every time a unit enters playable map area) also leaks a group. Maybe fix that, especially if units enter your map often. @sarumanthecursed
 
Level 9
Joined
Jun 10, 2013
Messages
473
Uhm, as far as I know, your VERY first trigger (the one that iterates every time a unit enters playable map area) also leaks a group. Maybe fix that, especially if units enter your map often. @sarumanthecursed
Thanks I've done all the above changes that both of you suggested my only problem now is that i'm trying to remove the region in this trigger so that there is no leak but the map can't start because it says there is a script error with my custom script

  • Precision Aura Remove
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Region = (Playable map area)
      • Set tempGroup1 = (Units in Temp_Region)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in tempGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L1) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L1 from (Picked unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L2) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L2 from (Picked unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L3) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L3 from (Picked unit)
            • Else - Actions
      • Custom script: Custom Script: call RemoveRect(udg_Temp_Region)
 
Level 4
Joined
Jul 26, 2016
Messages
88
Thanks I've done all the above changes that both of you suggested my only problem now is that i'm trying to remove the region in this trigger so that there is no leak but the map can't start because it says there is a script error with my custom script

  • Precision Aura Remove
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Region = (Playable map area)
      • Set tempGroup1 = (Units in Temp_Region)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in tempGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L1) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L1 from (Picked unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L2) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L2 from (Picked unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Precision Aura L3) Equal to False
            • Then - Actions
              • Unit - Remove Presicion Aura Spell Book L3 from (Picked unit)
            • Else - Actions
      • Custom script: Custom Script: call RemoveRect(udg_Temp_Region)

You pasted the words custom script into your custom script :D
 
Level 4
Joined
Jul 26, 2016
Messages
88
OMG XD i'm such an idiot wait now i'm having a weird problem where I lose the game after 7 seconds (not a crash just a "you have lost"

Wouldn't want to say anything dumb as I do not have the editor around, but: Do you have melee map triggers enabled? Try removing them. Look into player and force properties, try playing around with those if they seem weird (e.g. only one player in game), though I'm not too sure if anything in those windows could cause your troubles. Try playing with the disable victory/defeat conditions for player trigger. That's all I can think of.
 
Level 9
Joined
Jun 10, 2013
Messages
473
OMG XD i'm such and idiot
the only possible problem I can think of would have to be related to my vic/defeat triggers
  • Wait victory
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Count structures controlled by Player 2 (Blue) (Include incomplete structures)) Greater than 0
          • (Count structures controlled by Player 3 (Teal) (Include incomplete structures)) Greater than 0
          • (Count structures controlled by Player 4 (Purple) (Include incomplete structures)) Greater than 0
    • Actions
      • Trigger - Turn on Victory all <gen>
      • Trigger - Turn off (This trigger)
  • Victory all
    • Events
      • Time - Every 7.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (Number of players), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)) and (((Matching unit) belongs to an enemy of (Player((Integer A)))) Equal to True)))) Equal to 0
            • Then - Actions
              • Game - Victory (Player((Integer A))) (Show dialogs, Show scores)
              • Wait 0.01 seconds
              • Trigger - Run Victory end <gen> (checking conditions)
            • Else - Actions
  • Victory end
    • Events
    • Conditions
      • ((This trigger) is on) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off Victory all <gen>
      • Player Group - Pick every player in (All players matching ((Number of units in (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)) and ((Owner of (Matching unit)) Equal to (Matching player))))) Equal to 0)) and do (Actions)
        • Loop - Actions
          • Game - Defeat (Picked player) with the message: You have lost!
And maybe how I disable the addabilities for my aura

  • Unit Limits
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Limit training of Queen to 1 for (Player((Integer A)))
          • Player - Limit training of Psychic nerub to 1 for (Player((Integer A)))
          • Player - Limit training of Spiderlord (Tank) to 1 for (Player((Integer A)))
          • Player - Limit training of Blood Beatle to 1 for (Player((Integer A)))
          • Player - Limit training of Hatchery to 3 for (Player((Integer A)))
          • Player - Limit training of Blood Mage (Spell Caster Support) to 1 for (Player((Integer A)))
          • Player - Limit training of Blood Ranger (Range Support) to 1 for (Player((Integer A)))
          • Player - Limit training of Magistrate (Debuffer) to 1 for (Player((Integer A)))
          • Player - Disable Presicion Aura Spell Book L1 for (Player((Integer A)))
          • Player - Disable Presicion Aura Spell Book L2 for (Player((Integer A)))
          • Player - Disable Presicion Aura Spell Book L3 for (Player((Integer A)))
          • Player - Limit training of Avenger (Hero Killer) to 1 for (Player((Integer A)))
 
Level 4
Joined
Jul 26, 2016
Messages
88
The problem is probably your victory all trigger. If the condition

If - Conditions
(Number of units in (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)) and (((Matching unit) belongs to an enemy of (Player((Integer A)))) Equal to True)))) Equal to 0

applies to even ONE player, your game ends.

Limit the amount of players your loop scrolls through, because if your loop scrolls though Neutral Passive (which I don't know if it does, but there's a chance) it bones the rest of the trigger.
 
Level 9
Joined
Jun 10, 2013
Messages
473
The problem is probably your victory all trigger. If the condition

If - Conditions
(Number of units in (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)) and (((Matching unit) belongs to an enemy of (Player((Integer A)))) Equal to True)))) Equal to 0

applies to even ONE player, your game ends.

Limit the amount of players your loop scrolls through, because if your loop scrolls though Neutral Passive (which I don't know if it does, but there's a chance) it bones the rest of the trigger.
How should I do that exactly
 
Level 4
Joined
Jul 26, 2016
Messages
88
How should I do that exactly

Limit the amount of players you iterate through, down from

For each (Integer A) from 1 to (Number of players), do (Actions)

to

For each (Integer A) from 1 to 12, do (Actions)

in your victory all trigger, or try even lower numbers than 12 (maybe down to as many players as are possibly playing at once, which from a quick glance at your triggers is 4?).

Tell me if it works.
 

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,083
Under other possibilities it says there is.
Except if you look at the JASS...
JASS:
function GetPlayableMapRect takes nothing returns rect
    return bj_mapInitialPlayableArea
endfunction
As such what is happening is not only unnecessary, it also breaks GetPlayableMapRect so that it returns a destroyed rect rather than a rect of the playable map area.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Except if you look at the JASS...
JASS:
function GetPlayableMapRect takes nothing returns rect
    return bj_mapInitialPlayableArea
endfunction
As such what is happening is not only unnecessary, it also breaks GetPlayableMapRect so that it returns a destroyed rect rather than a rect of the playable map area.
well then I guess it doesn't leak however for some strange reason I still get that 1 lag every 2 seconds
 
Top