Detecting Spell Damage

Sil3nt

SUP?
Reaction score
134
Part of my spell involves blocking damage taken from both attacks and spells. The only way i could think of doing this is by adding the spell damage taken back to the units hp. What condition would i use? I tried Damage Taken but i think that only works for normal attacks. Im basically adding the damage taken into a integer variable and then using a periodic trigger to detect the damage taken.

Also is there any other way to completely block out spell/physical damage other than what im doing? Thx for reading.

edit - For those who play DotA it has a similar effect to Lord of Avernus' shield.
If i was to use a modified spell reduction/defend/magic resist/etc is the damage taken considered as 0?
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
> I tried Damage Taken but i think that only works for normal attacks.

No, it works for spells too.
Any damage counts.

You can just detect the Taken Damage while your ability is active, then store it to a Real variable and add it to your unit's HP.
 

Tom Jones

N/A
Reaction score
437
My guess is that they used attack detection and then damage detection in dota, it goes something like this:
Code:
Attack Detection
    Events
        Unit - A unit Is attacked
    Conditions
        //I would check if the unit attacked has the ability here.
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) is in Detected_Units) Equal to False
            Then - Actions
            Else - Actions
                Unit Group - Add (Triggering unit) to Detected_Units
                Trigger - Add to Damage Detection <gen> the event (Unit - (Triggering unit) Takes damage)
Code:
Damage Detection
    Events
    Conditions
        //You should check for the abilities buff here.
    Actions
        Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
 

vypur85

Hibernate
Reaction score
803
Hmm.. There is a weakness in damage taken event I think. If the unit's hp is 500 and the spell deals more than 500 damage, the unit will still die. I've tested it before once (not too sure though). But if you use magic reduction spell like Elune's Grace (forgot the name) or physical damage reduction spell like Defend and Berserk, the killing damage can be avoided (as if the unit is not damaged at all). So I presume LOA's ability has Elune's Grace added when the ability is activated?

Edit: Damn it. What I've suggested is for LOA's ultimate.... Not Shield =.=... Sorry for the misunderstanding.
 

Sil3nt

SUP?
Reaction score
134
> I tried Damage Taken but i think that only works for normal attacks.

No, it works for spells too.
Any damage counts.

You can just detect the Taken Damage while your ability is active, then store it to a Real variable and add it to your unit's HP.
Thx but what would the event for spells be? Does Unit is attacked work for both spells and physical?

I also just tried this trigger
Code:
Frozen Wall Dmg
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacked unit) Equal to FWTarget
    Actions
        Unit - Set life of FWTarget to ((Life of FWTarget) + (Damage taken))
        Set FWDmgTaken = (FWDmgTaken + (Integer((Damage taken))))
        Game - Display to (All players) the text: (String(FWDmgTaken))
The event must be working since it does show messages but it keeps repeating 0 so im assumnig the damage taken condition isnt working for some reason. And yes i checked all variables
My guess is that they used attack detection and then damage detection in dota, it goes something like this:
Code:
Attack Detection
    Events
        Unit - A unit Is attacked
    Conditions
        //I would check if the unit attacked has the ability here.
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) is in Detected_Units) Equal to False
            Then - Actions
            Else - Actions
                Unit Group - Add (Triggering unit) to Detected_Units
                Trigger - Add to Damage Detection <gen> the event (Unit - (Triggering unit) Takes damage)
Code:
Damage Detection
    Events
    Conditions
        //You should check for the abilities buff here.
    Actions
        Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
Wow after looking for a few minutes i just learnt that theres an event like that. So whats the point of all those damage detection systems then? lol edit[omg too specific ...]
Hmm.. There is a weakness in damage taken event I think. If the unit's hp is 500 and the spell deals more than 500 damage, the unit will still die. I've tested it before once (not too sure though). But if you use magic reduction spell like Elune's Grace (forgot the name) or physical damage reduction spell like Defend and Berserk, the killing damage can be avoided (as if the unit is not damaged at all). So I presume LOA's ability has Elune's Grace added when the ability is activated?

Edit: Damn it. What I've suggested is for LOA's ultimate.... Not Shield =.=... Sorry for the misunderstanding.
Actually i forgot about his ulti. That wouldve made a much more better example because the should prevent the damage. Im just doing it this way because it was the first thing that came in mind.
 

Drunken_God

Hopes to get back into Mapmaking with SC2 :)
Reaction score
106
did you ever make the shield + the ult at the same time as LoA ? (its healing you)
 

Cohadar

master of fugue
Reaction score
209
There is a passive manashield ability in Pyramidal Defence that does not "leak" damage.

You can request for code here
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
>did you ever make the shield + the ult at the same time as LoA ? (its healing you)
because they use Set Life, and when the shield+ulti, the LoA's life will be set twice and he get healing.

>If the unit's hp is 500 and the spell deals more than 500 damage, the unit will still die

yeah,but remember, when the Unit Damaged event occurs, the unit doesn't lose life yet you can add a life bonus ability for this unit and set life, it will not die (as long as the damage deal is less than the life bonus+max life of this unit, I refer it to the Culling Blade (ulti of Axe in DotA) I think the damage is 99999999, lol)

I have attached the Energy Shield spell of the_Immortal below.
If you set the cooldown of this spell to 0 and cast it twice, the Paladin will get healing, but if the maximum life of the Paladin is 1 he will die (because the_Immortal didn't add life bonus ability)
 

Attachments

  • Energy Shield.w3x
    21.9 KB · Views: 131

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
> when the Unit Damaged event occurs, the unit doesn't lose life yet

Wrong.
Because it takes damage, so it has lost its HP.

> but what would the event for spells be?

'Unit Takes Damage'
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
>Wrong. Because it takes damage, so it has lost its HP.
have you tested it, that unit's life doesn't lose life until the next 0.0s timer (when this event occurs, display life of this unit and start a 0.0s timer, when the timer expired, check life of this unit again - or you can use TriggerSleepAction(0.0) )
EDIT: oh, Cohadar correct it for me, :D
 

Sil3nt

SUP?
Reaction score
134
> when the Unit Damaged event occurs, the unit doesn't lose life yet

Wrong.
Because it takes damage, so it has lost its HP.

> but what would the event for spells be?

'Unit Takes Damage'

When i use the specific event it doesnt work, it asks for a specific unit thats already on the map. Variables also cant be chosen
Ive also found out how to block damage completely (Hardened Skin//unit ability and Spell damage redution//item ability) and add those to disabled spellbook

So all i need is a trigger that adds up the damage taken so that it can remove the spellbook once it reaches a certain limit
 

Cohadar

master of fugue
Reaction score
209
It is not as simple as it sounds, you will have to use jass.
And also use some attachment system.
 

Chjoodge

New Member
Reaction score
14
When i use the specific event it doesnt work, it asks for a specific unit thats already on the map. Variables also cant be chosen
That is why Tom Jones gave you this:
Code:
Trigger - Add to Damage Detection <gen> the event (Unit - (Triggering unit) Takes damage)
 

Sil3nt

SUP?
Reaction score
134
Ahh i got it now, except the damage taken is now 0 .. stupid spellbook.. dw ill think of something thanks to those who helped
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
You can add the Casting Unit / Triggering Unit to the event for another trigger with the event 'Casting Unit (Triggering Unit) Takes Damage'

@my stupid mistake
Aw damn.
Strange logic >_>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top