• 🏆 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!

[Spell] Triggered Life and Mana Drain ability.

Status
Not open for further replies.
Level 25
Joined
Sep 26, 2009
Messages
2,373
Yes it is possible. You have to create lightning from source to target. The best approach is to use custom scripts here, as they allow you to change the value on Z axis for the lightning.
You have the update the position of source and target for the lightning every 0.03 seconds.
Lastly, you have to deal damage in 1 second intervals, catch when DDS detects the target took damage and heal source for the amount of damage taken (iirc, you have to use some function that is present in DDS, so that it actually heals the source)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
If you trigger it... there is no need to use a DDS.
As Nichilus said, you need some visuals to show that it is draining life...
I recommend the lightning system by Maker (if I recall properly) that can attach a lightning to a unit and it will do the work for you.

About the damage, you indeed want some interval but you dont want to use a 1 second timer in a separate trigger that you turn on and off.
That is because that timer doesnt start when you turn the trigger on but at initialization, so if you start draining half way through a second (still relatively small) you will have different moment that it deals damage and it might even have a bonus interval.

For the damage, you can use my Effect Over Time System as it does create a new countdown (no new timer) that will be able to do anything you want.
It also automatically detects if the buff is still present on the target for example.
And you can stop it as well without problems.
You might need some time to find out how it works though.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
If you just save the amount of life just before you deal the damage and calculate the difference between the original health and new health, you have the most accurate damage calculation that exists.

Triggering the drain itself without DDS is the best IMO.
A DDS is meant to detect damage and do some stuff on the exact same moment.
In this case, you already know the moment so using a DDS can only become worse.
 
Level 19
Joined
Oct 7, 2014
Messages
2,209
If you just save the amount of life just before you deal the damage and calculate the difference between the original health and new health, you have the most accurate damage calculation that exists.

Triggering the drain itself without DDS is the best IMO.
A DDS is meant to detect damage and do some stuff on the exact same moment.
In this case, you already know the moment so using a DDS can only become worse.

So I need to trigger without DDS.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Why do you want a DDS?
Where does it fit in how the spell works?
I really am curious about that.
With the exception that the action "Unit - Damage Target" might be replaced by a custom function, it doesnt really matter anything else.
 
Level 18
Joined
May 11, 2012
Messages
2,103
Ok, I made custom Life drain that you need.
This is how the triggers should look. You can edit the damage dealt in the "Life Drain Init" trigger to your needs (just change the number inside, that's amount that will be drained per second).

NOTE that you will have to create custom channel ability (I suppose you know about that ability).
When you create it, just recreate the triggers in here exactly. This is MUI, leakless and looks good.
Duration of this is 10 seconds. If you want to change it, just multiply the duration you want it to be with 34 (because trigger runs 34 times a second) and set that number to
  • Set LD_Time[LD_MaxIndex] = YourDurationHere

  • Life Drain Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ========= Life Drain ========= --------
      • Set LD_Damage[1] = 10000.00
      • Set LD_Damage[2] = 20000.00
      • Set LD_Damage[3] = 30000.00
      • Set LD_Damage[4] = 40000.00
  • Life Drain
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Life Drain
    • Actions
      • -------- ============================================ --------
      • Set LD_MaxIndex = (LD_MaxIndex + 1)
      • Set LD_TrigUnit[LD_MaxIndex] = (Triggering unit)
      • Set LD_TargetUnit[LD_MaxIndex] = (Target unit of ability being cast)
      • Set LD_SpellLvl[LD_MaxIndex] = (Level of Life Drain for LD_TrigUnit[LD_MaxIndex])
      • Set LD_Time[LD_MaxIndex] = 340
      • Set LD_DamageDeal[LD_MaxIndex] = LD_Damage[LD_SpellLvl[LD_MaxIndex]]
      • -------- ============================================ --------
      • Set TempPoint = (Position of LD_TrigUnit[LD_MaxIndex])
      • Set TempPoint2 = (Position of LD_TargetUnit[LD_MaxIndex])
      • -------- ============================================ --------
      • Special Effect - Create a special effect attached to the overhead of LD_TrigUnit[LD_MaxIndex] using Abilities\Spells\Other\Drain\DrainCaster.mdl
      • Set LD_SpecialEffect1[LD_MaxIndex] = (Last created special effect)
      • -------- ============================================ --------
      • Special Effect - Create a special effect attached to the overhead of LD_TargetUnit[LD_MaxIndex] using Abilities\Spells\Other\Drain\DrainTarget.mdl
      • Set LD_SpecialEffect2[LD_MaxIndex] = (Last created special effect)
      • -------- ============================================ --------
      • Lightning - Create a Drain Life lightning effect from source TempPoint to target TempPoint2
      • Set LD_Lightning[LD_MaxIndex] = (Last created lightning effect)
      • -------- ============================================ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LD_MaxIndex Equal to 1
        • Then - Actions
          • Trigger - Turn on Life Drain Loop <gen>
        • Else - Actions
      • -------- ============================================ --------
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: set udg_TempPoint = null
      • Custom script: set udg_TempPoint2 = null
      • -------- ============================================ --------
  • Life Drain Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Custom script: local integer zOffset = 120
      • -------- ============================================ --------
      • For each (Integer LD_Loop) from 1 to LD_MaxIndex, do (Actions)
        • Loop - Actions
          • -------- ============================================ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • LD_Time[LD_Loop] Equal to 0
                  • (Life of LD_TargetUnit[LD_Loop]) Less than 0.41
            • Then - Actions
              • -------- ============================================ --------
              • Lightning - Destroy LD_Lightning[LD_Loop]
              • -------- ============================================ --------
              • Special Effect - Destroy LD_SpecialEffect1[LD_Loop]
              • Special Effect - Destroy LD_SpecialEffect2[LD_Loop]
              • -------- ============================================ --------
              • Set LD_TrigUnit[LD_Loop] = LD_TrigUnit[LD_MaxIndex]
              • Set LD_TrigUnit[LD_MaxIndex] = No unit
              • Set LD_TargetUnit[LD_Loop] = LD_TargetUnit[LD_MaxIndex]
              • Set LD_TargetUnit[LD_MaxIndex] = No unit
              • Set LD_DamageDeal[LD_Loop] = LD_DamageDeal[LD_MaxIndex]
              • Set LD_Lightning[LD_Loop] = LD_Lightning[LD_MaxIndex]
              • Set LD_SpecialEffect1[LD_Loop] = LD_SpecialEffect1[LD_MaxIndex]
              • Set LD_SpecialEffect2[LD_Loop] = LD_SpecialEffect2[LD_MaxIndex]
              • Set LD_SpellLvl[LD_Loop] = LD_SpellLvl[LD_MaxIndex]
              • Set LD_Time[LD_Loop] = LD_Time[LD_MaxIndex]
              • Set LD_MaxIndex = (LD_MaxIndex - 1)
              • Set LD_Loop = (LD_Loop - 1)
              • -------- ============================================ --------
            • Else - Actions
              • -------- ============================================ --------
              • Set LD_Time[LD_Loop] = (LD_Time[LD_Loop] - 1)
              • Set TempPoint = (Position of LD_TrigUnit[LD_Loop])
              • Set TempPoint2 = (Position of LD_TargetUnit[LD_Loop])
              • -------- ============================================ --------
              • Custom script: call MoveLightningEx(udg_LD_Lightning[udg_LD_Loop], true, GetLocationX(udg_TempPoint), GetLocationY(udg_TempPoint), GetLocationZ(udg_TempPoint)+zOffset, GetLocationX(udg_TempPoint2), GetLocationY(udg_TempPoint2), GetLocationZ(udg_TempPoint2)+zOffset)
              • -------- ============================================ --------
              • Unit - Set life of LD_TrigUnit[LD_Loop] to ((Life of LD_TrigUnit[LD_Loop]) + (LD_Damage[LD_Loop] x 0.03))
              • Unit - Cause LD_TrigUnit[LD_Loop] to damage LD_TargetUnit[LD_Loop], dealing (LD_DamageDeal[LD_Loop] x 0.03) damage of attack type Spells and damage type Normal
              • -------- ============================================ --------
          • -------- ============================================ --------
      • -------- ============================================ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LD_MaxIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • -------- ============================================ --------
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
@BD
Target runs out of range
caster gains a new order and thus interrupting his current order
caster is silenced by any effect
target or caster is dispelled
Caster dies
When using lfh's dds, shouldnt you use his custom action?
just a few things to consider...
 
Level 18
Joined
May 11, 2012
Messages
2,103
@BD
Target runs out of range
caster gains a new order and thus interrupting his current order
caster is silenced by any effect
target or caster is dispelled
Caster dies
When using lfh's dds, shouldnt you use his custom action?
just a few things to consider...

You are right. I copied this from my own map, so these things aren't really important to me. But maybe he will need those.
Thanks for the suggestions, I'll update the trigger. :)
 
Status
Not open for further replies.
Top