Ability with added buffs

Level 7
Joined
Sep 10, 2023
Messages
112
Hello, I need to make an ability with added buffs. The ability itself its Spirit link (well I called it United!). I need that when you cast United! ability, the units with the United buff! have increased life regeneration (3 levels 1, 2 and 3 life regeneration for each level.

I have the following triggers.

  • spiritlinksetup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet regenbonus[1] = (Unit: No unit's Ability with Ability Code: Liferegeneration1 )
      • Set VariableSet regenbonus[2] = (Unit: No unit's Ability with Ability Code: Liferegeneration2 )
      • Set VariableSet regenbonus[3] = (Unit: No unit's Ability with Ability Code: Liferegeneration3 )

  • spiritlinkguardregeneration
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to United We Stand!
    • Actions
      • Set VariableSet unitedduration = 20.00
      • Unit Group - Pick every unit in (Units within 600.00 of (Target point of ability being cast) matching (((Matching unit) has buff United! ) Equal to True).) and do (Actions)
        • Loop - Actions
          • Set VariableSet linkunit = (Picked unit)
          • If ((Level of United We Stand! for (Triggering unit)) Equal to 1) then do (Unit - Add Liferegeneration1 to linkunit) else do (If ((Level of United We Stand! for (Triggering unit)) Equal to 2) then do (Unit - Add Liferegeneration2 to linkunit) else do (If ((Level of United We Stand! for (Triggering unit)) Equal to 3) then do (Unit - Add Liferegeneration3 to linkunit) else do (Do

It doesnt seem to work. I think there is a problem with the variable regen bonus but I cant seem to find to add the ability in the variable. Any help?
 
You'll want to do something like this:
  • spiritlinksetup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Variable united_regen_bonus[1] = Life Regen (+1)
      • Set Variable united_regen_bonus[2] = Life Regen (+2)
      • Set Variable united_regen_bonus[3] = Life Regen (+3)
  • spiritlinkguardregeneration
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to United We Stand!
    • Actions
      • Set Variable united_level = (Level of (Ability being cast))
      • Set Variable united_point = (Position of (Target unit of ability being cast))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 2000.00 of united_point matching (((Matching unit) has buff United! ) Equal to True).) and do (Actions)
        • Loop - Actions
          • Set Variable united_unit = (Picked unit)
          • Unit - Remove united_regen_bonus[1] from united_unit
          • Unit - Remove united_regen_bonus[2] from united_unit
          • Unit - Remove united_regen_bonus[3] from united_unit
          • Unit - Add united_regen_bonus[united_level] to united_unit
      • Custom script: call RemoveLocation( udg_united_point )
united_regen_bonus is meant to be an Ability Code array variable.

Ability Code represents the actual base type ability which you Add/Remove to units. The same thing that you put in the Abilities field in the Object Editor.

Ability represents a unique copy of an ability that an individual unit would have. You generally don't need to use this variable but it could be useful for optimizing a trigger that modifies Ability Fields at runtime.

To remove the Life Regen once the Buff expires you'll want to track these units in a Unit Group variable and periodically check the status of their United! buff. Once they no longer have the buff that means they either died, the buff expired, or it was dispelled, in which case you would Remove all three abilities from them:
  • spiritlink loop
    • Events
      • Time - Every 0.05 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in united_group and do (Actions)
        • Loop - Actions
          • Set Variable united_unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (united_unit has buff United!) Equal to False
            • Then - Actions
              • Unit - Remove united_regen_bonus[1] from united_unit
              • Unit - Remove united_regen_bonus[2] from united_unit
              • Unit - Remove united_regen_bonus[3] from united_unit
              • Unit Group - Remove united_unit from united_group
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (united_group is Empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (this trigger)
        • Else - Actions
You'll also want to make sure that you're Adding these units to the Unit Group in your first trigger and turning on the Loop trigger:
  • Unit - Add united_regen_bonus[united_level] to united_unit
  • Unit Group - Add united_unit to united_group <------------------ NEW
  • Trigger - Turn on spiritlink loop <gen> <----------------- NEW
Some things to think about:

1) Spirit Link is a bouncing Lightning effect like Chain Lightning. It's Area of Effect fluctuates based on how far away targets are from one another. Your first trigger needs a large enough radius to pick up all of these units.

2) These triggers are not very consistent. If multiple units have the United! ability and cast near one another then you can easily give the wrong Life Regen to a unit. Ideally you would design things to be based around the Buff level but that's not as simple as it sounds: How to Detect Buff Level?

3) There might be a timing issue. The Spirit Link buff could be applied AFTER the "Starts the effect" event, meaning you would be checking for the Buffs before they were applied. In that case a short Wait (or ideally a 0.0 second Timer) would help fix this.
 
Last edited:
You'll want to do something like this:
  • spiritlinksetup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Variable united_regen_bonus[1] = Life Regen (+1)
      • Set Variable united_regen_bonus[2] = Life Regen (+2)
      • Set Variable united_regen_bonus[3] = Life Regen (+3)
  • spiritlinkguardregeneration
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to United We Stand!
    • Actions
      • Set Variable united_level = (Level of (Ability being cast))
      • Set Variable united_point = (Position of (Target unit of ability being cast))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 2000.00 of united_point matching (((Matching unit) has buff United! ) Equal to True).) and do (Actions)
        • Loop - Actions
          • Set Variable united_unit = (Picked unit)
          • Unit - Remove united_regen_bonus[1] from united_unit
          • Unit - Remove united_regen_bonus[2] from united_unit
          • Unit - Remove united_regen_bonus[3] from united_unit
          • Unit - Add united_regen_bonus[united_level] to united_unit
      • Custom script: call RemoveLocation( udg_united_point )
united_regen_bonus is meant to be an Ability Code array variable.

Ability Code represents the actual base type ability which you Add/Remove to units. The same thing that you put in the Abilities field in the Object Editor.

Ability represents a unique copy of an ability that an individual unit would have. You generally don't need to use this variable but it could be useful for optimizing a trigger that modifies Ability Fields at runtime.

To remove the Life Regen once the Buff expires you'll want to track these units in a Unit Group variable and periodically check the status of their United! buff. Once they no longer have the buff that means they either died, the buff expired, or it was dispelled, in which case you would Remove all three abilities from them:
  • spiritlink loop
    • Events
      • Time - Every 0.05 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in united_group and do (Actions)
        • Loop - Actions
          • Set Variable united_unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (united_unit has buff United!) Equal to False
            • Then - Actions
              • Unit - Remove united_regen_bonus[1] from united_unit
              • Unit - Remove united_regen_bonus[2] from united_unit
              • Unit - Remove united_regen_bonus[3] from united_unit
              • Unit Group - Remove united_unit from united_group
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (united_group is Empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (this trigger)
        • Else - Actions
You'll also want to make sure that you're Adding these units to the Unit Group in your first trigger and turning on the Loop trigger:
  • Unit - Add united_regen_bonus[united_level] to united_unit
  • Unit Group - Add united_unit to united_group <------------------ NEW
  • Trigger - Turn on spiritlink loop <gen> <----------------- NEW
Some things to think about:

1) Spirit Link is a bouncing Lightning effect like Chain Lightning. It's Area of Effect fluctuates based on how far away targets are from one another. Your first trigger needs a large enough radius to pick up all of these units.

2) These triggers are not very consistent. If multiple units have the United! ability and cast near one another then you can easily give the wrong Life Regen to a unit. Ideally you would design things to be based around the Buff level but that's not as simple as it sounds: How to Detect Buff Level?

3) There might be a timing issue. The Spirit Link buff could be applied AFTER the "Starts the effect" event, meaning you would be checking for the Buffs before they were applied. In that case a short Wait (or ideally a 0.0 second Timer) would help fix this.
Thanks!, as always very helpful. The problem of having multiple units with the united ability wont be an issue because only one hero will have it and the cooldown will allow only to have a few units with the skill.
 
Well I tried with your trigger and it didnt work, asked around with a different approach and it didnt work either.

  • spiritlinkguardregeneration
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to United We Stand!
    • Actions
      • Set VariableSet unitedlevel = (Level of (Ability being cast) for (Casting unit))
      • Set VariableSet positionofunitedunit = (Position of (Target unit of ability being cast))
      • Set VariableSet unitedpoint = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Set VariableSet unitedduration = 20.00
      • Unit Group - Pick every unit in (Units within 2000.00 of positionofunitedunit matching (((Matching unit) has buff United! ) Equal to True).) and do (Actions)
        • Loop - Actions
          • Set VariableSet linkunit = (Picked unit)
          • Unit - Remove regenbonus[1] from linkunit
          • Unit - Remove regenbonus[2] from linkunit
          • Unit - Remove regenbonus[3] from linkunit
          • Unit - Add regenbonus[unitedlevel] to linkunit
      • Custom script: call RemoveLocation( udg_unitedpoint )
  • spiritlinksetup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set VariableSet regenbonus[1] = Liferegeneration1
      • Set VariableSet regenbonus[2] = Liferegeneration2
      • Set VariableSet regenbonus[3] = Liferegeneration3
Maybe it has to do with the variables?
positionofunitedunit = position
unitedlevel = interger
positionofunitedunit = point
regenbonus = ability code with array
 
Try this, I mentioned this potential fix as #3 in my previous post:
  • spiritlinkguardregeneration
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to United We Stand!
    • Actions
      • Custom script: local location loc = GetUnitLoc(GetSpellTargetUnit())
      • Wait 0.10 game-time seconds
      • Set VariableSet unitedlevel = (Level of United We Stand! for (Triggering unit))
      • Custom script: set udg_unitedpoint = loc
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 2000.00 of unitedpoint matching (((Matching unit) has buff United! ) Equal to True).) and do (Actions)
        • Loop - Actions
          • Set VariableSet linkunit = (Picked unit)
          • Unit - Remove regenbonus[1] from linkunit
          • Unit - Remove regenbonus[2] from linkunit
          • Unit - Remove regenbonus[3] from linkunit
          • Unit - Add regenbonus[unitedlevel] to linkunit
      • Custom script: call RemoveLocation( udg_unitedpoint )
      • Custom script: set loc = null
But I left out some important details. A lot of Event Responses aren't safe to use after Waits - They'll either be completely unusable or will act like a global variable that is shared between all of your triggers. (Target unit of ability being cast), (Casting unit), and (Ability being cast) have this issue.
  • So instead we can take advantage of a local variable to track the (Position of (Target unit of ability being cast)) since locals are safe.
  • Then we can use (Triggering unit) since it works similar to a local variable.
  • Then we can avoid (Ability being cast) by referencing the Ability directly.

Note that when an Ability targets a Unit there is never going to be a (Target point of ability being cast). Only abilities that literally target a Point will give you that Event Response. This same concept applies to (Target unit of ability being cast).

In other words:
Blink = (Target point of ability being cast)
Storm Bolt = (Position of (Target unit of ability being cast))
Shockwave = This can use one or the other, it depends on how you cast it -> Did you click a unit directly or click a point on the ground?
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Shockwave
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Target unit of ability being cast) Equal to No unit
      • Then - Actions
        • -------- Shockwave targeted a point --------
      • Else - Actions
        • -------- Shockwave targeted a unit --------
 
Last edited:
Back
Top