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

Find difference between two variables

Status
Not open for further replies.
Hello,

How can I find the difference between two variables? I want to make a trigger that saves the HP of the hero at two points in time, then deals damage/heals equal to the difference percentage.

Example:

A buff you place on a unit that lasts for 5 seconds. When those 5 seconds expires the target of the ability takes damage equal to X% damage done to the triggering unit (multiple spell levels, 40% for lvl 1 and 50% for lvl 2), and triggering unit is healed X% (20% lvl 1 and 30% lvl 2) of that damage.

Meaning if the caster took 1000 damage within those 5 seconds the unit with the buff will be damaged 500, and the caster will be healed 300 (at spell lvl 2).


Please ask if anything is unclear :)

It needs to detect this as a damage source as well:

Set HPCaster = ((Life of WarlockCaster) x 0.50)
Unit - Set life of WarlockCaster to HPCaster
 
You dds for that, here's the link Damage Engine 3.8.0.0

Simply set a real variable which equals to real + damage then deal damage to the target after 5 seconds

Is there a workaround without the DDS? I have never used a DDS before, and I don't fully understand what the Damage Engine does/is? Does it give me a whole new set of events to choose from?
 
Level 7
Joined
Apr 17, 2017
Messages
316
Is there a workaround without the DDS? I have never used a DDS before, and I don't fully understand what the Damage Engine does/is? Does it give me a whole new set of events to choose from?
Basically yes, in gui there is not an easy way to detect if generic unit is damaged, so dds system allows you to keep track of damage source, damage type, damaged target etcetera. I am afraid there is no other way.
 
Level 5
Joined
Jun 13, 2017
Messages
83
As Aeryn said you gonna need Damage Engine for it to work the easy way, and trust me you will regret not getting it earlier lol

here is how to do it using Damage Engine:
  • Untitled Trigger 001
    • Events
      • Game - DamageEvent becomes Equal to 1.00 ---- this detect starting of damage
    • Conditions
      • (DamageEventTarget has buff YourBuff) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage+ DamageEventAmount) ---- damage event amount is from
    • damage engine it get the total damage that started the event.

Every time the unit with buff get hit TotalDamage Variable will add it

with timer event after 5 sec Heal your unit a percentage of TotalDamage Variable
 
Last edited:
Does not sound like damage engine is needed, since damage detection is not needed to accomplish this.

Finding the difference between two variables is just subtraction. If you want to find the damage dealt between buff cast, and buff expiration, you just subtract the health at buff extraction from buff cast:

original health - current health



You don't need to store damage taken, when you have the original health and the health after taking damage stored in variables.
 
Thank you all for the help.


As Aeryn said you gonna need Damage Engine for it to work the easy way, and trust me you will regret not getting it earlier lol

here is how to do it using Damage Engine:
  • Untitled Trigger 001
    • Events
      • Game - DamageEvent becomes Equal to 1.00 ---- this detect starting of damage
    • Conditions
      • (DamageEventTarget has buff YourBuff) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage+ DamageEventAmount) ---- damage event amount is from
    • damage engine it get the total damage that started the event.

Every time the unit with buff get hit TotalDamage Variable will add it

with timer event after 5 sec Heal your unit a percentage of TotalDamage Variable

Is the Damage engine just plug and play? Can it break the map if done incorrectly? I will give it a go when I get home from new years celebration.
 
Level 5
Joined
Jun 13, 2017
Messages
83
it will not effect your map at all, it just give you more options to do things when it come to damaging, and it can even tell if the damage is spell or not.
Might take some time to understand it but it is worth it.

The only thing about copying it is, there is 2 spells you need to copy 1 called cheat death the other is isdamagespell and then put them in the right variable in damage engine. Then copy unit indexing, they all come together so just follow the how to copy steps and you should be fine.

Read damage engine page to get more info there but there is a lot of things that you wont use for now, so just follow the simple damage detect like i did in my post above and you will learn more later on.
 
it will not effect your map at all, it just give you more options to do things when it come to damaging, and it can even tell if the damage is spell or not.
Might take some time to understand it but it is worth it.

The only thing about copying it is, there is 2 spells you need to copy 1 called cheat death the other is isdamagespell and then put them in the right variable in damage engine. Then copy unit indexing, they all come together so just follow the how to copy steps and you should be fine.

Read damage engine page to get more info there but there is a lot of things that you wont use for now, so just follow the simple damage detect like i did in my post above and you will learn more later on.

Thanks +rep
 
As Aeryn said you gonna need Damage Engine for it to work the easy way, and trust me you will regret not getting it earlier lol

here is how to do it using Damage Engine:
  • Untitled Trigger 001
    • Events
      • Game - DamageEvent becomes Equal to 1.00 ---- this detect starting of damage
    • Conditions
      • (DamageEventTarget has buff YourBuff) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage+ DamageEventAmount) ---- damage event amount is from
    • damage engine it get the total damage that started the event.

Every time the unit with buff get hit TotalDamage Variable will add it

with timer event after 5 sec Heal your unit a percentage of TotalDamage Variable

Is TotalDamage a real var? I can't find it in the DDE vars.

Also the trigger you mentioned will only register actual damage right? If I set the HP of the caster to a different amount that won't technically be any type of damage source, just a trigger that sets the HP to a specific value.

Update:

I added the TotalDamage as a real var and configured the trigger like you showed, but I'm not getting it to work. Maybe you could take a quick look at my map to see what I'm doing wrong if it's not too much to ask?

Update 2:

It also seems like my hero with healing wards instantly gets killed by any form of damage. Any idea how to circumvent this?
 
Last edited:
Level 5
Joined
Jun 13, 2017
Messages
83
you need to do this so they don't instantly die:

trigger off
cause unit to damage
trigger on

otherwise the cause damage will trigger the event again and again

do you mind showing me your trigger so i can get more info on what exactly is wrong.

Do you want the unit to take damage while the buff is on, or do you want to save the damage and unit with buff take 0 damage while the buff still on?
 
you need to do this so they don't instantly die:

trigger off
cause unit to damage
trigger on

otherwise the cause damage will trigger the event again and again

do you mind showing me your trigger so i can get more info on what exactly is wrong.

Do you want the unit to take damage while the buff is on, or do you want to save the damage and unit with buff take 0 damage while the buff still on?


I think I am doing this completely wrong. Here is my trigger:

  • Blood Brothers buff
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has buff Blood Brothers) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Wait 5.00 seconds
      • Trigger - Run Damage Blood Brothers <gen> (checking conditions)

  • Damage Blood Brothers
    • Events
    • Conditions
    • Actions
      • Unit - Cause DamageEventSource to damage DamageEventTarget, dealing TotalDamage damage of attack type Spells and damage type Magic


Update: I realize now that I haven't actually defined DamageEventSource....


Update 2: I made this instead:

  • Blood Brothers buff
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has buff Blood Brothers) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
  • Damage Blood Brothers
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blood Brothers
    • Actions
      • Set DamageEventSource = (Triggering unit)
      • Set DamageEventTarget = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • Unit - Cause DamageEventSource to damage DamageEventTarget, dealing TotalDamage damage of attack type Spells and damage type Magic


Also I want the unit with the buff to take 0 damage while the buff is active, then after 5 seconds be damaged.

The issue with the healing wards is unrelated to this. As long as any hero has the spell healing wards, they will die from any source of damage, regardless of how much health they have. This happens with the basic function of the DDE.


I am attaching my map here, in case you want to take a look. You will find the needed triggers at the bottom of the categories in the trigger manager. If you take a look at the hero I have already placed you will get a general idea of what I wish to accomplish.
 
Last edited:
Level 5
Joined
Jun 13, 2017
Messages
83
this should work but it is not a mui because if a second unit used it before the first wait end, it will not deal the damage. Waits always make things worse, try to avoid them if possible.

  • TotalDamage
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has buff Acid Bomb) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00

this one I just made it make the damage the unit take 0 and calculate the total damage after the effect you can deal % of damage to the unit with the buff but it is not a mui, if you don't know how to make it mui I will help you with that.
 
Last edited:
this should work but it is not a mui because if a second unit used it before the first wait end, it will not deal the damage. Waits always make things worse, try to avoid them if possible.

  • TotalDamage
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has buff Acid Bomb) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00

this one I just made it make the damage the unit take 0 and calculate the total damage after the effect you can deal % of damage to the unit with the buff but it is not a mui, if you don't know how to make it mui I will help you with that.


BTW i got the map you can remove it if you don't want it there :)


Ok removed it now :)

I tried the trigger you told me but it still didn't work. I am going out now and will be back in a bit. Thank you for helping me, I am still a noob at this and have never used the DDE before so I appreciate it :p

P.S: It doesn't have to be MUI as there will only be one unit casting that spell at a time, and the cooldown exceeds the 5 seconds.
 
Level 5
Joined
Jun 13, 2017
Messages
83
so here are the problems you had:
1-dont use set damage event source/target = to triggering unit.
Do it like this Anotherunitvariable = damage event source/target.

2- you have a 5 sec wait while the buff last for more than 5 sec.

and here is the fix
  • Blood Brothers buff
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
  • Comment: this will detect the damage before it is dealt make it damage event becomes 1 if you want the damage to be dealt
    • Conditions
      • (DamageEventTarget has buff Doom) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00 Comment: this is only if you are using damage event modifier so the damage is 0 while buff is up

you can even add this condition to trigger above : damage event source = bb_caster . This way only caster damage will be in TotalDamage variable.


  • Damage Blood Brothers
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Faerie Fire
    • Actions
      • Set BB_Caster = (Triggering unit) there is no damage dealt here so cant use damage event source/target
      • Set BB_Target = (Target unit of ability being cast) same like above
      • Wait 5.00 seconds
      • Unit - Remove Doom buff from BB_Target remove the buff because the effect should end here
      • Comment: if you want a % of damage to be dealt to the target make a variable like BB_Heal below and use it as the damage instead of total damage
      • Unit - Cause BB_Caster to damage BB_Target, dealing TotalDamage damage of attack type Spells and damage type Magic
      • Set BB_Heal = ((Life of BB_Caster) + (TotalDamage x 0.30)) the % heal to caster change 0.30 to whatever you want
      • Unit - Set life of BB_Caster to BB_Heal
      • Set TotalDamage = 0.00 Reset total damage to 0 so next cast it start with 0

Copy the triggers from the map below.

If anything is missing tell me to check it again :)
 

Attachments

  • Fix try.w3x
    118.2 KB · Views: 19
Last edited:
so here are the problems you had:
1-dont use set damage event source/target = to triggering unit.
Do it like this Anotherunitvariable = damage event source/target.

2- you have a 5 sec wait while the buff last for more than 5 sec.

and here is the fix
  • Blood Brothers buff
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
  • Comment: this will detect the damage before it is dealt make it damage event becomes 1 if you want the damage to be dealt
    • Conditions
      • (DamageEventTarget has buff Doom) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00 Comment: this is only if you are using damage event modifier so the damage is 0 while buff is up

you can even add this condition to trigger above : damage event source = bb_caster . This way only caster damage will be in TotalDamage variable.


  • Damage Blood Brothers
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Faerie Fire
    • Actions
      • Set BB_Caster = (Triggering unit) there is no damage dealt here so cant use damage event source/target
      • Set BB_Target = (Target unit of ability being cast) same like above
      • Wait 5.00 seconds
      • Unit - Remove Doom buff from BB_Target remove the buff because the effect should end here
      • Comment: if you want a % of damage to be dealt to the target make a variable like BB_Heal below and use it as the damage instead of total damage
      • Unit - Cause BB_Caster to damage BB_Target, dealing TotalDamage damage of attack type Spells and damage type Magic
      • Set BB_Heal = ((Life of BB_Caster) + (TotalDamage x 0.30)) the % heal to caster change 0.30 to whatever you want
      • Unit - Set life of BB_Caster to BB_Heal
      • Set TotalDamage = 0.00 Reset total damage to 0 so next cast it start with 0

Copy the triggers from the map below.

If anything is missing tell me to check it again :)


I tried this but it didn't work. Here is my theory (it might be horribly wrong):

In the first trigger you have the event "Game - DamageModifierEvent becomes Equal to 1.00", but you never actually reference the DamageModifierEvent in the other trigger, which means that the real var TotalDamage is null, ultimately leading to no damage.
 
Level 5
Joined
Jun 13, 2017
Messages
83
nope not the reason because damage modifier is just to accumulate the damage in TotalDamage variable so what you need in trigger 2 is total damage not damage modifier.
I actually tried it in your map and it worked. Copying it from another map without damage engine might be the reason to null damage modifier, so try to remake it in your map.

I will give it another try.

Edit:working just fine it deal 0 damage after 5 sec deal all the damage and heal the caster for 30%. If that is actually what you are looking for.

Edit 2: Just noticed but the condition in triggers 1 and 2 is the wrong ability, so just set it to the right ability. When moving triggers to other maps, they put a random ability instead of what was there.
 
Last edited:
nope not the reason because damage modifier is just to accumulate the damage in TotalDamage variable so what you need in trigger 2 is total damage not damage modifier.
I actually tried it in your map and it worked. Copying it from another map without damage engine might be the reason to null damage modifier, so try to remake it in your map.

I will give it another try.

Edit:working just fine it deal 0 damage after 5 sec deal all the damage and heal the caster for 30%. If that is actually what you are looking for.

Edit 2: Just noticed but the condition in triggers 1 and 2 is the wrong ability, so just set it to the right ability. When moving triggers to other maps, they put a random ability instead of what was there.

Hmm that is so weird, I can't get it to work. Here are my triggers (I rebuilt them instead of copying them):

  • Buff test 1
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has buff Blood Brothers) Equal to True
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00
  • Buff test 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blood Brothers
    • Actions
      • Set BB_Caster = (Triggering unit)
      • Set BB_Target = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • Unit - Remove Blood Brothers buff from BB_Target
      • Unit - Cause BB_Caster to damage BB_Target, dealing (TotalDamage x 0.50) damage of attack type Spells and damage type Magic
      • Set BB_Heal = ((Life of BB_Caster) + (TotalDamage x 0.30))
      • Unit - Set life of BB_Caster to BB_Heal
      • Set TotalDamage = 0.00
 
do you want me to put your map here so you can test it?

I now understand that we have been talking past each other a little bit. I wanted the damage dealt to the warlock to be dealt to the target of the buff. So if 3 units hits the warlock for 100 each within 5 seconds, the target of the buff would take 300x0.50.

Sorry if I made it hard to understand. I noticed it when I tried damaging the unit with the buff. When I tested earlier I just buffed the unit while being attacked by other units and didn't attack the target of the buff at all.


If you have that in mind then the other spells makes sense as well. The warlock uses his own HP to cast spells, so the total damage he deals to himself through the spells he casts, including external damage done by creeps will be dealt to the target of the buff and then healing the warlock to give him more momentum and resources to cast more spells.
 
Level 5
Joined
Jun 13, 2017
Messages
83
oh lol
if you can have only 1 warlock in your map at a time then just use this condition:
  • Blood Brothers buff
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (Level of Blood Brothers for DamageEventTarget) Greater than 0
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00

and you can remove the buff because the target of ability will be in a variable so you dont need to refer to the unit with a buff.

Edit : you need to do this in second trigger and make Blood Brothers Buff Initially off
  • Damage Blood Brothers
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blood Brothers
    • Actions
      • Trigger - Turn on Blood Brothers buff <gen>
      • Set BB_Caster = (Triggering unit)
      • Set BB_Target = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • Trigger - Turn off Blood Brothers buff <gen>
      • Unit - Remove Blood Brothers buff from BB_Target
      • Unit - Cause BB_Caster to damage BB_Target, dealing TotalDamage damage of attack type Spells and damage type Magic
      • Set BB_Heal = ((Life of BB_Caster) + (TotalDamage x 0.30))
      • Unit - Set life of BB_Caster to BB_Heal
      • Set TotalDamage = 0.00


Edit: just saw that you want the damage dealt when casting to be in there too. Damage engine can't do that you need to do it with variables. Give me a moment will make one.
 
Last edited:
oh lol
if you can have only 1 warlock in your map at a time then just use this condition:
  • Blood Brothers buff
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (Level of Blood Brothers for DamageEventTarget) Greater than 0
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00

and you can remove the buff because the target of ability will be in a variable so you dont need to refer to the unit with a buff.

Edit : you need to do this in second trigger and make Blood Brothers Buff Initially off
  • Damage Blood Brothers
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blood Brothers
    • Actions
      • Trigger - Turn on Blood Brothers buff <gen>
      • Set BB_Caster = (Triggering unit)
      • Set BB_Target = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • Trigger - Turn off Blood Brothers buff <gen>
      • Unit - Remove Blood Brothers buff from BB_Target
      • Unit - Cause BB_Caster to damage BB_Target, dealing TotalDamage damage of attack type Spells and damage type Magic
      • Set BB_Heal = ((Life of BB_Caster) + (TotalDamage x 0.30))
      • Unit - Set life of BB_Caster to BB_Heal
      • Set TotalDamage = 0.00


Edit: just saw that you want the damage dealt when casting to be in there too. Damage engine can't do that you need to do it with variables. Give me a moment will make one.


This is how my triggers looks now:

  • Buff test 1
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (Level of Blood Brothers for DamageEventTarget) Equal to 0
    • Actions
      • Set TotalDamage = (TotalDamage + DamageEventAmount)
      • Set DamageEventAmount = 0.00
      • Game - Display to (All players) the text: (String((Integer(TotalDamage)))) ---- I had to convert Integer to string to get the required results, I think it works like you intended? At least it shows the damage in numbers.
  • Buff test 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blood Brothers
    • Actions
      • Trigger - Turn on Buff test 1 <gen>
      • Set BB_Caster = (Triggering unit)
      • Set BB_Target = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • Trigger - Turn off Buff test 1 <gen>
      • Unit - Remove Blood Brothers buff from BB_Target
      • Unit - Cause BB_Caster to damage BB_Target, dealing (TotalDamage x 0.50) damage of attack type Spells and damage type Magic
      • Set BB_Heal = ((Life of BB_Caster) + (TotalDamage x 0.30))
      • Unit - Set life of BB_Caster to BB_Heal
      • Set TotalDamage = 0.00


Now it still does the same thing as it did first. It buffs the target, making it immune to any kind of damage and then dealing 50% of the damage to the same target after 5 seconds.

I want the damage done to the warlock (not the target of ability being cast) to be TotalDamage. During the 5 seconds I want the warlocks health to go down if he is hit or is the target of spells, and I want the target of ability being cast to take damage like normal if anyone casts spells or hits it (as it is now the target of the buff is immortal during the 5 seconds). After the 5 seconds I want the warlock to deal TotalDamagex0.50 to the target of ability being cast.


An example: The warlock fights 5 spiders. He buffs 1 of the spiders. All of the spiders deals 100 damage each to the warlock within 5 seconds from the buff activating. Accumulated damage would then be 500. Which means that TotalDamage should be 500. The warlock then deals damage equal to TotalDamagex0.50 to target of ability being cast. If you also include the damage he deals to himself with his own spells TotalDamage would be a lot more.
 
Level 5
Joined
Jun 13, 2017
Messages
83
Your triggers are fine just change the condition in trigger one to greater than 0 instead of equal to 0.
You don't really need the display text to all players it is just to see if the numbers are right, so it is better if removed in actual game

Here is how to calculate the damage from when you cast as well
  • Bolt of blood lvl 5
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Level of Bolt of Blood for (Triggering unit)) Equal to 5
      • (Ability being cast) Equal to Bolt of Blood
    • Actions
      • Set LifeCost = (Life of (Triggering unit))
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - 25.00)
      • Special Effect - Create a special effect at (Position of (Triggering unit)) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
      • Set LifeCost = (LifeCost - (Life of (Triggering unit)))
      • Game - Display to (All players) the text: (String(LifeCost))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Blood Brothers buff <gen> is on) Equal to True
        • Then - Actions
          • Set TotalDamage = (TotalDamage + LifeCost)
          • Game - Display to (All players) the text: (String(TotalDamage))
        • Else - Actions

you will need add the addition in this trigger to all triggers that cost health so whenever any of them is cast it add up to totaldamage if the trigger is on

BTW i noticed something that might not be intended. When warlock cast a spell with really low health if the cost is higher than the health it kill the caster, you could add if/then/else on each trigger
if
health is lower than cost
then
order unit to stop
else
start the actions

Edit: one more thing, HealthRegen make the healing look lower and harder to see while testing I recommend making new non-hero unit and remove healthregen to test how much heal. It will be much easier to see the heal number if right or not.
 
Level 8
Joined
Mar 30, 2013
Messages
180
Not sure if i should help here since you've got something going but there is a fairly simple way of doing this without the taken damage event or a DDS

Make a periodic (Lower the periodic, the more accurate this is), in the initial event set Real1 as the target units hp, set Real2 to 0 every periodic do this

Real1 = The hp of the target before this period
Real2 = The total hp lost overall
Real3 = The hp of the target at this period
Real4 = The hp lost since last period


Set Real3 = Target Hp
If Real3 < Real1 Then - Set Real 4 = Real1 - Real3
Set Real2 = Real2 + Real3
Set Real1 = Real3

Then after it ends, deal damage/heal based on Real4

it's fairly simple and may be slightly inaccurate in some extreme circumstances but it works
 
Your triggers are fine just change the condition in trigger one to greater than 0 instead of equal to 0.
You don't really need the display text to all players it is just to see if the numbers are right, so it is better if removed in actual game

Here is how to calculate the damage from when you cast as well
  • Bolt of blood lvl 5
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Level of Bolt of Blood for (Triggering unit)) Equal to 5
      • (Ability being cast) Equal to Bolt of Blood
    • Actions
      • Set LifeCost = (Life of (Triggering unit))
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - 25.00)
      • Special Effect - Create a special effect at (Position of (Triggering unit)) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
      • Set LifeCost = (LifeCost - (Life of (Triggering unit)))
      • Game - Display to (All players) the text: (String(LifeCost))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Blood Brothers buff <gen> is on) Equal to True
        • Then - Actions
          • Set TotalDamage = (TotalDamage + LifeCost)
          • Game - Display to (All players) the text: (String(TotalDamage))
        • Else - Actions

you will need add the addition in this trigger to all triggers that cost health so whenever any of them is cast it add up to totaldamage if the trigger is on

BTW i noticed something that might not be intended. When warlock cast a spell with really low health if the cost is higher than the health it kill the caster, you could add if/then/else on each trigger
if
health is lower than cost
then
order unit to stop
else
start the actions

Edit: one more thing, HealthRegen make the healing look lower and harder to see while testing I recommend making new non-hero unit and remove healthregen to test how much heal. It will be much easier to see the heal number if right or not.


Thanks, works like a charm now :) Now I just have to add the stuff you said to the other spells. Also good suggestions regarding ordering him to stop at low health, and no regen unit to test healing.

I will be sure to give you a mention in the full release.
 
Not sure if i should help here since you've got something going but there is a fairly simple way of doing this without the taken damage event or a DDS

Make a periodic (Lower the periodic, the more accurate this is), in the initial event set Real1 as the target units hp, set Real2 to 0 every periodic do this

Real1 = The hp of the target before this period
Real2 = The total hp lost overall
Real3 = The hp of the target at this period
Real4 = The hp lost since last period


Set Real3 = Target Hp
If Real3 < Real1 Then - Set Real 4 = Real1 - Real3
Set Real2 = Real2 + Real3
Set Real1 = Real3

Then after it ends, deal damage/heal based on Real4

it's fairly simple and may be slightly inaccurate in some extreme circumstances but it works

Thanks, but I think I have what I need now :)

P.S: Any idea how I solve the problem with my druid hero dying from any damage source? He dies because he has the ability healing wards, and it is due to something in the Damage Engine trigger.

Edit: Just changed the spell serpent ward, works now. Not sure what is wrong with the healing wards spells when using the DDE :p
 
Last edited:
Level 5
Joined
Jun 13, 2017
Messages
83
Real1 = The hp of the target before this period
Real2 = The total hp lost overall
Real3 = The hp of the target at this period
Real4 = The hp lost since last period

the problem with this is, the HealthRegen if the unit is high and there could be other source of healing so it will not accurate.


Thanks, works like a charm now :) Now I just have to add the stuff you said to the other spells. Also good suggestions regarding ordering him to stop at low health, and no regen unit to test healing.

I will be sure to give you a mention in the full release.


Glad it worked, will be waiting for the release :)
 
Status
Not open for further replies.
Top