• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Pack Aura (Attack Damage Increase) - MUI Ability

Status
Not open for further replies.
Level 4
Joined
Sep 25, 2018
Messages
81
I am trying to create an ability, based off Command Aura, which increases the attack damage of all other units, who carry the same ability, by [(+2 attack damage) x (number of units with ability)] - 2.

So my wolves have the Pack Aura ability which increases their attack damage based on the number of other wolves with Pack Aura nearby. (If there is only one wolf, he should not get any attack damage bonus).

I have done a quick test to see if it the attack damage increase is possible.

I picked all units on the map, at map initialisation, then edited the ability’s Real Level Field to increase the damage by the number of wolves on the map.

  • PackAuraTimer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Level of Pack Aura (Wolf) for (Matching unit)) Greater than or equal to 1)) and do (Actions)
        • Loop - Actions
          • Ability - Set Ability: (Unit: (Picked unit)'s Ability with Ability Code: Pack Aura (Wolf))'s Real Level Field: Attack Damage Increase ('Cac1') of Level: 0 to ((2.00 x (Real((Number of units in (Units in (Playable map area) matching ((Level of Pack Aura (Wolf) for (Matching unit)) Greater than or equal to 1)))))) - 2.00)
          • Unit - Increase level of Pack Aura (Wolf) for (Picked unit)
          • Unit - Decrease level of Pack Aura (Wolf) for (Picked unit)
I am just wondering how best to create this Aura using triggers. Whether I should use timers and just add/remove units when they enter/leave the range of the aura of another wolf.

Please help!

Edit: Had a go, the current trigger is a little jankey but does work. Only issue is that it will briefly remove the buff from all units when the number of wolves changes, and subsequently, remove the bonus attack damage. I would rather it did not do that.

  • PackAuraTimer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Level of Pack Aura (Wolf) for (Matching unit)) Greater than or equal to 1)) and do (Actions)
        • Loop - Actions
          • Ability - Set Ability: (Unit: (Picked unit)'s Ability with Ability Code: Pack Aura (Wolf))'s Real Level Field: Attack Damage Increase ('Cac1') of Level: 0 to ((2.00 x (Real((Number of units in (Units within 600.00 of (Position of (Picked unit)) matching ((((Matching unit) belongs to an ally of (Owner of (Picked unit)).) Equal to True) and ((Level of Pack Aura (Wolf) for (Matching unit)) Greater than or equal to 1)
          • Unit - Increase level of Pack Aura (Wolf) for (Picked unit)
          • Unit - Decrease level of Pack Aura (Wolf) for (Picked unit)
Any advice/improvements are appreciated!

Edit Edit: Ok, looks like I have someone working with what appears to be no unintended effects!

  • PackAuraTimer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has buff Pack Aura (Wolf)) Equal to True)) and do (Actions)
        • Loop - Actions
          • -------- Add AttackDamageBonus (Pack Aura) --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Attack Damage Bonus (Pack Aura) for (Picked unit)) Less than or equal to 0
            • Then - Actions
              • Unit - Add Attack Damage Bonus (Pack Aura) to (Picked unit)
            • Else - Actions
          • -------- - --------
          • -------- Edit units attack damage --------
          • Ability - Set Ability: (Unit: (Picked unit)'s Ability with Ability Code: Attack Damage Bonus (Pack Aura))'s Integer Level Field: Attack Bonus ('Iatt') of Level: 0 to ((2 x (Number of units in (Units within 600.00 of (Position of (Picked unit)) matching ((((Matching unit) belongs to an ally of (Owner of (Picked unit)).) Equal to True) and (((Matching unit) has buff Pack Aura (Wolf)) Equal to True)).))) - 2)
          • Unit - Increase level of Attack Damage Bonus (Pack Aura) for (Picked unit)
          • Unit - Decrease level of Attack Damage Bonus (Pack Aura) for (Picked unit)
 
Last edited:

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,936
1) Use a unit group to contain all of the wolves. Add them to the group upon creation/map initialization and remove them from said group upon death.

2) Turn on your Pack Aura Timer trigger only when it's needed. So it should be off by default, then turned on when adding the first wolf to the unit group and turned off again after removing the last wolf from the unit group.

3) You're leaking a lot of points/unit groups. Memory Leaks

4) Add the Attack Damage Bonus (Pack Aura) ability to the units in the Object Editor instead of through triggers.

5) The periodic interval doesn't need to be so short, this is a performance heavy trigger so you want to find a nice balance here.


I attached a map with an Aura I made a while back. It's not too comparable to your setup but I figured maybe it could help anyway.
 

Attachments

  • Celerity Aura v.3.w3m
    26.8 KB · Views: 15
Level 4
Joined
Sep 25, 2018
Messages
81
1) Use a unit group to contain all of the wolves. Add them to the group upon creation/map initialization and remove them from said group upon death.

2) Turn on your Pack Aura Timer trigger only when it's needed. So it should be off by default, then turned on when adding the first wolf to the unit group and turned off again after removing the last wolf from the unit group.

3) You're leaking a lot of points/unit groups. Memory Leaks

4) Add the Attack Damage Bonus (Pack Aura) ability to the units in the Object Editor instead of through triggers.

5) The periodic interval doesn't need to be so short, this is a performance heavy trigger so you want to find a nice balance here.


I attached a map with an Aura I made a while back. It's not too comparable to your setup but I figured maybe it could help anyway.
So something more like this? (Your aura has a lot of special effects which seem to make things quite complicated. Mine does not need any of that, but it was interesting seeing how you have done yours!)

  • PackAuraInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Add to PA_UnitGroup --------
      • Set VariableSet PA_UnitGroup = (Units in (Playable map area) matching (((Matching unit) has buff Pack Aura (Wolf)) Equal to True))
      • -------- - --------
      • -------- Turn on PackAuraTimer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (PackAuraTimer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on PackAuraTimer <gen>
        • Else - Actions

  • PackAuraSpawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Entering unit) has buff Pack Aura (Wolf)) Equal to True
    • Actions
      • -------- Add to PA_UnitGroup --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Entering unit) is in PA_UnitGroup.) Equal to False
        • Then - Actions
          • Unit Group - Add (Entering unit) to PA_UnitGroup
        • Else - Actions
      • -------- - --------
      • -------- Turn on PackAuraTimer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (PackAuraTimer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on PackAuraTimer <gen>
        • Else - Actions

  • PackAuraTimer
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PA_UnitGroup and do (Actions)
        • Loop - Actions
          • -------- Add AttackDamageBonus (Pack Aura) --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Not equal to True
            • Then - Actions
              • Unit Group - Remove (Picked unit) from PA_UnitGroup.
            • Else - Actions
              • -------- Add AttackDamageBonus (Pack Aura) --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Attack Damage Bonus (Pack Aura) for (Picked unit)) Less than or equal to 0
                • Then - Actions
                  • Unit - Add Attack Damage Bonus (Pack Aura) to (Picked unit)
                • Else - Actions
              • -------- - --------
              • -------- Edit units attack damage --------
              • Ability - Set Ability: (Unit: (Picked unit)'s Ability with Ability Code: Attack Damage Bonus (Pack Aura))'s Integer Level Field: Attack Bonus ('Iatt') of Level: 0 to ((2 x (Number of units in (Units within 600.00 of (Position of (Picked unit)) matching ((((Matching unit) belongs to an ally of (Owner of (Picked unit)).) Equal to True) and (((Matching unit) has buff Pack Aura (Wolf)) Equal to True)).))) - 2)
              • Unit - Increase level of Attack Damage Bonus (Pack Aura) for (Picked unit)
              • Unit - Decrease level of Attack Damage Bonus (Pack Aura) for (Picked unit)
          • -------- - --------
          • -------- Turn off PackAuraTimer --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in PA_UnitGroup) Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,936
1) You're ALWAYS turning on PackAuraTimer in your Init trigger, regardless of whether or not a wolf exists. Check to see if the number of units in PA_UnitGroup > 0 and turn it on if that's true. If you know for a fact that you'll have wolves in the map at the start of the game then simply keep the Timer trigger on by default.

2) Use the condition (Level of Pack Aura for matching unit > 0) instead of checking for the buff in your PackAuraInit/PackAuraSpawn triggers.

3) You don't have to periodically check if the picked unit is alive, this method isn't terrible but it may be more efficient to handle this in a separate trigger with the "A unit dies" Event. Although, I can't say for certain which method is better so you can ignore this one for now.

Example: A unit dies -> Level of Pack Aura for dying unit > 0 -> Remove dying unit from PA_UnitGroup

4) In the PackAuraTimer trigger, move your "Turn off PackAuraTimer" Actions to outside and below the Pick Every Unit function. With how it's structured now you're checking if the trigger should turn off once for EACH picked unit. This is unnecessary, you only need to ask this question once every 0.50 seconds at the end of the trigger.

5) You're still adding the ability through triggers (If level <= 0 then add ability). Adding the ability to the unit(s) in the Object Editor is more efficient, since it would remove the need to ask this question for every single wolf once every 0.50 seconds.
 
Last edited:
Level 4
Joined
Sep 25, 2018
Messages
81
1) You're ALWAYS turning on PackAuraTimer in your Init trigger, regardless of whether or not a wolf exists. Check to see if the number of units in PA_UnitGroup > 0 and turn it on if that's true. If you know for a fact that you'll have wolves in the map at the start of the game then simply keep the Timer trigger on by default.

2) Use the condition (Level of Pack Aura for matching unit > 0) instead of checking for the buff in your PackAuraInit/PackAuraSpawn triggers.

3) You don't have to periodically check if the picked unit is alive, this method isn't terrible but it may be more efficient to handle this in a separate trigger with the "A unit dies" Event. Although, I can't say for certain which method is better so you can ignore this one for now.

Example: A unit dies -> Level of Pack Aura for dying unit > 0 -> Remove dying unit from PA_UnitGroup

4) In the PackAuraTimer trigger, move your "Turn off PackAuraTimer" Actions to outside and below the Pick Every Unit function. With how it's structured now you're checking if the trigger should turn off once for EACH picked unit. This is unnecessary, you only need to ask this question once every 0.50 seconds at the end of the trigger.

5) You're still adding the ability through triggers (If level <= 0 then add ability). Adding the ability to the unit(s) in the Object Editor is more efficient, since it would remove the need to ask this question for every single wolf once every 0.50 seconds.
Thanks for your help, I really appreciate it! It can be quite difficult to remember to tie up all the loose ends with triggers. The “Things That Leak” was also useful.
 
Status
Not open for further replies.
Top