• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Any damage type just like this? (does not returns damage but armor affects)

Level 17
Joined
Jun 2, 2009
Messages
1,161
Hello everyone. I want to create spell like this.
Spell deals 200 damage and armor of the target decreases or increases damage. Just like the auto-attack.
BUT i do not want this damage reflected by Spiked Shell ability.
Is there any easy solution?
 
Level 21
Joined
Aug 29, 2012
Messages
855
I don't think triggered damage is reflected by Spiked Shell, does it?

  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 500.00 damage of attack type Hero and damage type Normal
The important thing is "damage type Normal" that will act as a physical ability
 
Level 17
Joined
Jun 2, 2009
Messages
1,161
I don't think triggered damage is reflected by Spiked Shell, does it?

  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 500.00 damage of attack type Hero and damage type Normal
The important thing is "damage type Normal" that will act as a physical ability
Yes it does. And yes, if i will try to damage just like this, damage reflecting to me.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,622
Might find an answer here:
 
Level 21
Joined
Aug 29, 2012
Messages
855
Bummer, well you can use Set life instead, with a bit of math you can take into account the armor formula. Should be something like this

  • Set VariableSet ArmorFormula = (((Armor of (Target unit of ability being cast)) x 0.06) / (1.00 + (0.06 x (Armor of (Target unit of ability being cast)))))
  • Unit - Set life of (Target unit of ability being cast) to ((Life of (Target unit of ability being cast)) - (YourDamage x (1.00 - ArmorFormula)))
So if a unit has 25% damage reduction from armor, your damage will be multiplied by 1-0.25 = 0.75

That's a bit too much math for me but you probably see the point
 
Level 17
Joined
Jun 2, 2009
Messages
1,161
Bummer, well you can use Set life instead, with a bit of math you can take into account the armor formula. Should be something like this

  • Set VariableSet ArmorFormula = (((Armor of (Target unit of ability being cast)) x 0.06) / (1.00 + (0.06 x (Armor of (Target unit of ability being cast)))))
  • Unit - Set life of (Target unit of ability being cast) to ((Life of (Target unit of ability being cast)) - (YourDamage x (1.00 - ArmorFormula)))
So if a unit has 25% damage reduction from armor, your damage will be multiplied by 1-0.25 = 0.75

That's a bit too much math for me but you probably see the point
But sadly i have a too many damage block items. There is no exact damage reduce or increase formula in my map.

@Uncle I have checked but it seems there is no attack and damage type for me. Or i do not see.

@Nichilus Honestly i do not understand because of my English or the system you mentioned it. Can you give me the example please if it is possible?

By the way let me tell you "what exactly i want"

When you deal damage to the enemy via triggers, i want to make this damage reduced or increased (just like the normal attack) by enemy armor. BUT in the same time
I DO NOT WANT this damage reflected.
My triggers reflecting damage to attacker IF the attacked unit have the damage return item or ability.


I can deal the damage with dummy unit but i want to make this as a last resort. Because i have to change many triggers if i will do it with this way.
 
Level 25
Joined
Sep 26, 2009
Messages
2,395
When dealing damage via trigger action "Unit - Damage Target", you specify an "Attack type" and "Damage type" of the damage you deal.
All spells and base attacks in WC3 have both "Attack type" and "Damage type".

There is an event "Unit - Takes damage". There are actions to get the "Attack" and "Damage" type dealt to targeted unit.
In such trigger you can even modify the amount of damage taken.

Spiked carapace's Attack Type is "Spells" and Damage Type is "Defensive".
So if you check for this combination of Attack and Damage type in a trigger with the "Unit - Takes damage" event and the combination matches, then you can modify the amount of damage taken to be 0.00, effectively nulling damage taken.

The only issue is to ignore such combination of Attack and Damage type only when you are dealing 200.00 damage via trigger.

The whole thing could look like below. This solution is using hashtable to keep track of each unit that should ignore reflected damage:
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet ReflectDamageHashtable = (Last created hashtable)
This should be part of your trigger where you deal 200.00 damage that you do not want to be reflected back:
  • Actions
    • Set VariableSet YourUnit = (The unit that will deal 200.00 damage)
    • -------- ----------------- --------
    • -------- ----------------- --------
    • -------- Increment value of ReflectIgnoreDamage by 1 for YourUnit --------
    • -------- ----------------- --------
    • Custom script: set udg_HandleId = GetHandleId(udg_YourUnit)
    • Set VariableSet CurrentValue = (Load (Key ReflectIgnoreDamage.) of HandleId from ReflectDamageHashtable.)
    • Hashtable - Save (CurrentValue + 1) as (Key ReflectIgnoreDamage.) of HandleId in ReflectDamageHashtable.
    • -------- ----------------- --------
    • -------- ----------------- --------
    • Unit - Cause YourUnit to damage some_other_unit, dealing 200.00 damage of attack type Normal and damage type Normal
    • -------- ----------------- --------
    • -------- ----------------- --------
    • -------- Decrement value of ReflectIgnoreDamage by 1 for YourUnit --------
    • -------- ----------------- --------
    • Custom script: set udg_HandleId = GetHandleId(udg_YourUnit)
    • Set VariableSet CurrentValue = (Load (Key ReflectIgnoreDamage.) of HandleId from ReflectDamageHashtable.)
    • Hashtable - Save (CurrentValue - 1) as (Key ReflectIgnoreDamage.) of HandleId in ReflectDamageHashtable.
This trigger will detect when unit takes damage, check if value in the ReflectDamageHashtable for the given unit is greater than 1 and if the attack and damage type combination matches that of Spiked Carapace, it will assume that the damage is reflected and then null it.
  • Reflected Damage Check
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Load (Key ReflectIgnoreDamage.) of (Key (Damage Target).) from ReflectDamageHashtable.) Greater than 0
    • Actions
      • Custom script: if BlzGetEventAttackType() == ATTACK_TYPE_NORMAL and BlzGetEventDamageType() == DAMAGE_TYPE_DEFENSIVE then
      • Event Response - Set Damage of Unit Damaged Event to 0.00
      • Custom script: endif
Variables:
  • ReflectDamageHashtable: hashtable
  • YourUnit: unit
  • HandleId: integer
  • CurrentValue: integer

Hashtables require two keys. In my triggers:
  • the left key "(Key ReflectIgnoreDamage)" is created using "Hashtable - Get String ID" function with string value "ReflectIgnoreDamage"
  • the right key in "Reflected Damage Check" is created using "Hashtable - Get Handle ID" function with value "Event Response - Damage Target"


--
If you are using a unit indexer, you could completely omit the hashtable approach and just use a single integer array.
For example something like this:
  • IgnoreReflectDamageArray: integer array
  • CV: integer
  • YourUnit: unit
  • Actions
    • Set VariableSet YourUnit = (The unit that will deal 200.00 damage)
    • Set VariableSet CV = (Custom value of YourUnit)
    • -------- ----------------- --------
    • -------- ----------------- --------
    • -------- Increment value of IgnoreReflectDamageArray by 1 for YourUnit --------
    • -------- ----------------- --------
    • Set VariableSet IgnoreReflectDamageArray[CV] = (IgnoreReflectDamageArray[CV] + 1)
    • -------- ----------------- --------
    • Unit - Cause YourUnit to damage some_other_unit, dealing 200.00 damage of attack type Normal and damage type Normal
    • -------- ----------------- --------
    • -------- ----------------- --------
    • -------- Decrement value of IgnoreReflectDamageArray by 1 for YourUnit --------
    • -------- ----------------- --------
    • Set VariableSet IgnoreReflectDamageArray[CV] = (IgnoreReflectDamageArray[CV] - 1)
  • Reflected Damage Check
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • IgnoreReflectDamageArray[(Custom value of (Damage Target))] Greater than 0
    • Actions
      • Custom script: if BlzGetEventAttackType() == ATTACK_TYPE_NORMAL and BlzGetEventDamageType() == DAMAGE_TYPE_DEFENSIVE then
      • Event Response - Set Damage of Unit Damaged Event to 0.00
      • Custom script: endif
 
Level 17
Joined
Jun 2, 2009
Messages
1,161
I was came here for the saying "i have solved it" and make it "solved" but i saw your message @Nichilus you shared great example for me and now i feel bad because of this :( but i believe i can use this system for something else.
I have solved it with simple way. Creating dummy unit and dealing damage with this dummy..
Thank you for your interest.
 
Top