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

Dealed/Taken damage calculating

Status
Not open for further replies.
Level 3
Joined
Sep 20, 2010
Messages
29
Hey guys! I need a skill that will reflect half of damage with n% chance.
I have only one idea - to add damage taken value to attacked unit's hp and subtract damage dealed/2 value from attacking unit's hp. The question is simple - how to calculate dealed and taken damage values? Tried to use default Damage Taken func, but it doesn't want to work (because of my nooby skill, of course)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You implement this system in your map.
Then, when damage is detected, check if a random integer between 1 and 100 is less than or equal to n (this will give an n% chance).
If so, deal 0.5 * DamageEventAmount damage.

  • Reflect Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to 50
        • Then - Actions
          • Set DamageEventOverride = True
          • Unit - Cause DamageEventTarget to damage DamageEventSource, dealing (0.50 x DamageEventAmount) damage of attack type Spells and damage type Normal
          • Set DamageEventOverride = False
        • Else - Actions
This does not make a difference between spells/physical attacks.
It's still a great system though :D.
 

Cokemonkey11

Spell Reviewer
Level 29
Joined
May 9, 2006
Messages
3,537
If you just want physical (auto attack) damage to be reflected, you can also use the defend ability, but I recommend using a damage detection system.

There's been a recent discovery that's much better for detecting physical attacks - jass versions are already available for both DamageEvent and StructuredDD libraries. Surely a GUI one will be available soon.
 
Status
Not open for further replies.
Top