• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Get your art tools and paintbrushes ready and enter Hive's 34th Texturing Contest: Void! Click here to enter!

[General] How to put the green bonus damage from a unit in a variable?

Level 13
Joined
Sep 11, 2013
Messages
497
Greetings!

I wanted to put in a floating text the entire damage that a specific unit has before reduction.
For example - My unit has..
16 - Base Damage
1 - Number of Dice
21 - Sides per Die

If I want to calculate the average damage per hit, I will use this formula.
  • Set VariableSet IntegerBaseDamageStryg = ((((Unit: (Damage source)'s Weapon Integer Field: Attack Damage Base ('ua1b') at Index:0) + (Unit: (Damage source)'s Weapon Integer Field: Attack Damage Number Of Dice ('ua1d') at Index:0)) + ((Unit: (Damage source)'s Weapon Integer Field: Attack Damage Base
[(16+1) + (16+21)] / 2 - And that works well.

The problem appear when I want to put the bonus (green) damage in this formula.
For example. My unit will use Roar (25% bonus (green) damage) or other kind of (green) bonus damage.
I don't know how to put that bonus (green) damage in the above formula.

I want to put that average damage + bonus green damage in a floating text integer.

Is there a way to do that? :peasant-confused:

The help will be appreaciated!

Edit: Another good question is.. How can I find and put in a variable the damage deal by a specific unit before reduction?
 
Last edited:

Rheiko

Spell Reviewer
Level 27
Joined
Aug 27, 2013
Messages
4,254
I am not very well informed on how the new native event for damage detection works (I'm still using 1.26 up to this day, 1.31.1 only occasionally).

But in the old days, we would use Damage Engine 5.A.0.0 for this kind of stuff and I believe it's still relevant even on newer patches (Please correct me if I'm mistaken). It's a powerful system that allows you to detect damage not only the moment when it's taken by a unit but also before and after that.

So with that, you could easily get the damage dealt before armor reduction by utilizing "PreDamageEvent Becomes Equal to <any value>" and reference DamageEventAmount which holds the damage value.
 
AtivEnergy said:
Edit: Another good question is.. How can I find and put in a variable the damage deal by a specific unit before reduction?

You can use the event "about to take damage":
  • Events
    • Unit - A unit About to take damage
Then you can use the value "Event Response - Damage Taken" to determine the amount of damage the attack would have done before any armor reductions, spell reductions, etc. are applied.

For your original question, sadly you can't natively detect the bonus green damage that a unit has. Your main options are to either:
  1. Check which buffs/items the attacker has and calculate the bonus granted. This is pretty manual and depends on what abilities/items your map uses.
  2. (Preferred, but requires a lot more investment) You can use a custom bonus mod system (e.g. New Bonus [vJASS][LUA]), and trigger all your bonuses. That way you can easily just use GetUnitBonus(u, BONUS_DAMAGE) to see how much bonus damage that unit has. But that means you'll have to manually trigger all your damage bonus spells/items (that system has some really helpful functions though, e.g. to tie a bonus to a buff or item).
 

Uncle

Warcraft Moderator
Level 74
Joined
Aug 10, 2018
Messages
7,939
Here's a method to get + green damage that could work well depending on the situation.

If your map is multiplayer then the above solution will likely desync, which is why I made this:
Same idea, but syncs the data between players. I can't guarantee that it works, though.
 
Last edited:
Top