[Spell] How do you achieve Spirit Link, which cannot target specific units?

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
195
Hello, for my game I need to make it so that the Spirit Walker Spirit Link skill cannot be used on certain units (e.g. Shaman, Priest, Necromancer). Ideally, it would not be possible to use it on certain units at all (i.e. selecting them as a target for the skill would end with an appropriate message that it cannot be done). However, should this prove impossible, I would like to simply remove the effect from them when they are affected by it. I would like to point out that this should not affect other aspects so adding magic resistance to these units is out. Does anyone have an idea how this could be done?
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
Ideally, it would not be possible to use it on certain units at all (i.e. selecting them as a target for the skill would end with an appropriate message that it cannot be done).
I don't think this is possible. I can't come up with anything to achieve this.

However, should this prove impossible, I would like to simply remove the effect from them when they are affected by it. I would like to point out that this should not affect other aspects so adding magic resistance to these units is out. Does anyone have an idea how this could be done?
You can remove the buff from the units. Removing a buff will also remove its effects. Something like this should work:
  • Spirit Link Remove
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to False
              • ((Picked unit) has buff Spirit Link) Equal to True
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Unit - Remove Spirit Link buff from (Picked unit)
            • Else - Actions
However, there could be a performance overhead since the timer will go on forever, it will continuously check for every unit in the map. You can adjust this by limiting the scope to only check when a unit casts spirit link. Then pause the timer after a few seconds. So you could do this instead:
  • Spirit Link Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spirit Link
    • Actions
      • -------- How long the check duration is --------
      • Set SpiritLink_CheckDuration = 2.00
      • -------- Start the periodic timer if it's not already on --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Spirit Link Remove <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Spirit Link Remove <gen>
        • Else - Actions
  • Spirit Link Remove
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • -------- Check if the duration is greater than 0 --------
      • -------- Which means Spirit Link has been casted before --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpiritLink_CheckDuration Greater than 0.00
        • Then - Actions
          • -------- Decrement the duration every loop, so it eventually reaches zero --------
          • Set SpiritLink_CheckDuration = (SpiritLink_CheckDuration - 0.20)
          • -------- Prevent group leak --------
          • Custom script: set bj_wantDestroyGroup = true
          • -------- Check all the units in the map --------
          • -------- And make sure they are: --------
          • -------- [*] Alive --------
          • -------- [*] Has spirit link buff --------
          • -------- [*] Is a Shaman --------
          • -------- [*] Is a Priest --------
          • -------- [*] Is a Necromancer --------
          • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is dead) Equal to False
                  • ((Picked unit) has buff Spirit Link) Equal to True
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to Priest
                      • (Unit-type of (Picked unit)) Equal to Shaman
                      • (Unit-type of (Picked unit)) Equal to Necromancer
                • Then - Actions
                  • -------- Remove the buff --------
                  • Unit - Remove Spirit Link buff from (Picked unit)
                • Else - Actions
        • Else - Actions
          • -------- It's over, pause the timer --------
          • Trigger - Turn off (This trigger)
This way, everytime Spirit Link is casted, the trigger will check for every unit in the map, whether they are the units you want to exclude or not, the trigger will do this every 0.2 seconds for 2 seconds.

Some might wonder why don't I just remove the buff right after the spirit link is casted. This is because there is a slight delay before the buff is placed on the units after you cast spirit link. So if you try to remove the buff immediately, it will not work properly. I believe you could also use wait to simplify the process depending on circumstances.

Hope this helps.
 
Top