Blocking/Healing damage for a unit at full health

Trithilon-V2

New Member
Reaction score
20
I asked this question before...but the solution wasnt practical and MUI.
So here is the problem....If a unit is at say 50% health and he takes damage and i heal him in the same event, it will look as if the unit never took damage.
However, if the unit is at full health the unit will take damage but because there is no scope of healing the unit (cuz the HP bar is 100% at the time of damage event), thus the trigger fails to restore the lost HP.
I am talking about GUI....is it possible to make this thing in GUI.
Or if not....could any one just write a small JASS function so that i can call it to heal the unit at the damage point?
 

Cheddar

This is the way it was meant to be.
Reaction score
126
If its health is at 100% and should stay that way, why not just heal it for some inordinately insanely high number, like 99999999999?
 

Trithilon-V2

New Member
Reaction score
20
Just check the Map i have attached you will know what i mean...

The high value is not the point here......lemme explain....
Over here Heal = setting the life via triggers
Now the problem is that in the event:
Suppose X is a unit with 1000 Max HP and current HP is 500.
Now he takes 100 Damage.
so the trigger fires...
Unit X takes takes damage.
Actions
Set D = Damage Taken (// 100)
Set life of X (// 500) = (Life of X) + (D)

The above trigger will work because the trigger has some thing to Heal....
So at the Damage point the HP of the unit will be 500 + 100 = 600.
After the Damage Point, the HP will be 600 - 100 = 500.
So it appears to the player that the unit did not take any damage.

However if the case is that the Units HP is 100% then,
Max Life of X = 1000
Current Life of X = 1000
Damage Taken = 100

The trigger will try to Set the life to (Current Life + Damage Taken) or (1000 + 100).
However, the Maxlife is 1000, so the addition of HP will have no effect at all.
And at the Damage point the Unit will take damage, and the result would be,
(1000 - 100 = 900)
Thus the HP of the unit still remains unsuccessful.
 

Attachments

  • Damage Block.w3x
    8.8 KB · Views: 84

Trithilon-V2

New Member
Reaction score
20
I just want to know, how they did it in other spells, like Aphotic Shield in dota or the Shield system etc.

My last solution was the same...i used to have a timer of 0.0 seconds, and used another trigger to heal the unit....however.....if in an event, a unit is dealt more than 1 damage simultaeniously, then the latter damage will be healed, and the previous damage/es wont.
Also the 0.0 delay before the heal means its not MUI, and sometimes if the damage to be heale is very high, then the HP bar reduces and comes bac to full for a moment. That looks bad.
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Why don't you use a modified restistant skin? Then you wont have to break your head over triggers.
 

Trithilon-V2

New Member
Reaction score
20
I had that idea in mind...but hardned skin doesnt heal the unit after damage, but it actually
reduces the damage its-self....so purpose of the trigger i.e detect and record the actual damage gets defeated.
 

Flare

Stops copies me!
Reaction score
662
Code:
Damage Block
    Events
        Unit - Mountain King 0001 <gen> Takes damage
    Conditions
    Actions
        Countdown Timer - Start T as a One-shot timer that will expire in 0.00 seconds
        Set U = (Triggering unit)
        Set L = (Life of (Triggering unit))
        Unit - Add Damage Block  to (Triggering unit)
        Skip remaining actions
        Game - Display to (All players) the text:    
        Game - Display to (All players) the text: (Damage Taken :-  + (String((Damage taken))))
        Game - Display to (All players) the text: (Current Life :-  + (String((Life of (Triggering unit)))))
        Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
        Game - Display to (All players) the text: (Current Life after Heal :-  + (String((Life of (Triggering unit)))))
        Game - Display to (All players) the text: (Max Life :-  + (String((Max life of (Triggering unit)))))
        Game - Display to (All players) the text:    


---------------------------------------

Zero Timer
    Events
        Time - T expires
    Conditions
    Actions
        Unit - Remove Damage Block  from U
        Unit - Set life of U to L

That'll be MUI (since it's as good as impossible to get 2 hits within 0 seconds of each other) and it works (Mountain King's health didn't drop at all) and you can't see any momentary health drop

(Damage Block is an ability based on Item Life Bonus, with a 10,000 life bonus)
 

Trithilon-V2

New Member
Reaction score
20
Code:
Damage Block
    Events
        Unit - Mountain King 0001 <gen> Takes damage
    Conditions
    Actions
        Countdown Timer - Start T as a One-shot timer that will expire in 0.00 seconds
        Set U = (Triggering unit)
        Set L = (Life of (Triggering unit))
        Unit - Add Damage Block  to (Triggering unit)
        Skip remaining actions
        Game - Display to (All players) the text:    
        Game - Display to (All players) the text: (Damage Taken :-  + (String((Damage taken))))
        Game - Display to (All players) the text: (Current Life :-  + (String((Life of (Triggering unit)))))
        Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
        Game - Display to (All players) the text: (Current Life after Heal :-  + (String((Life of (Triggering unit)))))
        Game - Display to (All players) the text: (Max Life :-  + (String((Max life of (Triggering unit)))))
        Game - Display to (All players) the text:    


---------------------------------------

Zero Timer
    Events
        Time - T expires
    Conditions
    Actions
        Unit - Remove Damage Block  from U
        Unit - Set life of U to L

That'll be MUI (since it's as good as impossible to get 2 hits within 0 seconds of each other) and it works (Mountain King's health didn't drop at all) and you can't see any momentary health drop

(Damage Block is an ability based on Item Life Bonus, with a 10,000 life bonus)

Dude...my on-attack system keeps checking for on-attack skills and then keeps damaging the unit accordingly. So within 1 trigger i can have like 5-6 extra bonus damage bursts, not to mention bonus damage from stuns.
So, there is no MUI ness to this. Or suppose, if there is an action like that picks all units on the map and damages them for 100 damage and 2 units have to be healed at the same time...how will that work?
Even if any one made a JASS map for this i would +rep him...plz.
 

Flare

Stops copies me!
Reaction score
662
Here - simply do
JASS:
call DamageBlock_Start ()

in your Takes Damage trigger, and you're done (assuming you've followed the importing instructions correctly)

You need NewGen to use this

(Haven't tested it alot, but the Peasant seems to indicate that it works fine)

EDIT: That will always block 100% of the damage, just so you know (can't think of an effective way to reduce damage by a %, and allow for kill credit)
 

Attachments

  • DB test.w3x
    21.2 KB · Views: 81

Flare

Stops copies me!
Reaction score
662
OK, found a way to support percentage blocking, and still allow proper kill credit

Just do
JASS:
call DamageBlock_BlockFactor (factor)

within your Takes Damage trigger (factor is a value between 0 and 1, higher value means more damage blocked) - if the remaining damage is greater than the unit's life, nothing will happen, otherwise it'll block whatever % of the damage you specified
 

Attachments

  • DB test updated.w3x
    21.7 KB · Views: 76

Trithilon-V2

New Member
Reaction score
20
Amazing...works like a charm....
Just one problem......how will i make the unit vunerable again once the damage is dealt?
Also...how does the Function know which unit is the one when the function takes no unit input?
Also can you add a function that reduces damage to a value or Block a particular amount...for eg. say 1 (Damage Block = Damage taken - 1)

If you want you can delete the above attachments.....for posting the updated ones..i have both of these.
 

Flare

Stops copies me!
Reaction score
662
Just determine when DamageBlock_Start should be called (buff check would probably be the simplest way of doing it, assuming you have some skill that can apply a buff)

Random number comparison?

There's tonnes of different ways you an do it, depending on how you want it to work (whether it's % chance, constant damage block for X duration, constant block below Y health, etc)

Also...how does the Function know which unit is the one when the function takes no unit input?
Called functions are capable of using event responses if the function they were called in has an event response to use (if you take a look, you'll see that BlockFactor and Start both use GetTriggerUnit () even though those functions wouldn't normally have event responses)

Also can you add a function that reduces damage to a value or Block a particular amount...for eg. say 1 (Damage Block = Damage taken - 1)
Just do a bit of math i.e.
Code:
Set BlockFactorVar = (Intended flat damage reduction / Damage Taken)
call DamageBlcok_BlockFactor (udg_BlockFactorVar)

So, if you had 20 damage, and wanted to block 6
6/20 = 0.30 -> 30% block
 

Trithilon-V2

New Member
Reaction score
20
In the updated map...dude there is something wrong with the Bash damage and the units being healed..... can you check it out whats the problem?

Btw remember your attack detection system which used the poison buff to detect the damage? Well i am using a modded (I remove the buff every time a unit takes attack damage - cuz it will report even magical damage as physical cuz there is still a buff placed by someone else.) version of the same.
So...how can i use that in synchronization with you idea?

off topic :- Btw, take your time....i'll be back in 15 mins havin food.
 

Flare

Stops copies me!
Reaction score
662
OK, that's messed up, but that seems to an issue with Bash (since it's capable of healing to full HP, regardless of target's health/bash damage) - you could trigger Bash with a dummy unit that casts Storm Bolt? I can't see why that would be happening :\

Test it with a triggered bash (dummy unit + stormbolt) and see if that works

EDIT: OK, I've found a temporary solution -BUT- it's not a great option since the unit will only take damage from the Bash hit (so if you deal 100 physical damage, and 50 bash damage, and have a 0.5x damage reduction factor, the unit will take 1/2 the bash damage, and none of the main attack damage) since the Bash damage occurs before the attack damage

Well i am using a modded (I remove the buff every time a unit takes attack damage - cuz it will report even magical damage as physical cuz there is still a buff placed by someone else.
1) Check the Critical Strike in the demo map (link) - I removed the buff, so you haven't really modified it in any way :p

2) Highly unlikely that a unit will take physical damage, then magical damage 0.01 seconds later
 

Trithilon-V2

New Member
Reaction score
20
Code:
Can i call this only in a Unit Damage Event?
If not...how do i give the function a unit u or a Picked or a matching unit?

-----:nuts: Sry....Btw how do you transfer Data from 1 trigger to another without return bug?:confused:
Cuz i have recently discovered a Return Bug in GUI, which returns the Units Unique ID and i am working on it.
 

Flare

Stops copies me!
Reaction score
662
Only usable in Takes Damage event (and you shouldn't have any reason to use Picked Unit)

And you're gonna need to trigger bash with Storm Bolt dummy (slight problem though, the HP flickers at an very large value occasionally, for a tiny fraction of a second - you can see it change, but it's impossible to even read the value -AND- I probably increased the frequency of the flickering by doing 100 attacks per second, but it only appears maybe 2 times a second, if even that)

Play around with the modified version, and fix the leak if needs be :p Once you learn Bash, you will start doing 1 damage per hit (since I've set it so that the dummy-sourced damage is reduced by 99%, and Mountain King-sourced damage is fully negated)
 

Attachments

  • DB more testing.w3x
    22.7 KB · Views: 77

Trithilon-V2

New Member
Reaction score
20
Dude...somehow the bash is working fine with the system so far....
Could you please remove the need of having newgen?
Because my map is around 2.95 MB with 185+ triggers and 10+ resource heavy systems.
Newgen requires a very long time to save a map this big. And to test maps i need to save it everytime even for a small change.
When i tried saving the map with normal WE, i get errors saying that the triggers ABCT and Damage Block do not have initialization functions.
Further more, the map becomes unsuable if a new patch is released.
Also, on other PC's you dont find newgen.
Can you do that plz...?
That would be 2X credit for you in my map.....cuz i already use ur AD system.
 
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