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

Question about damage

Status
Not open for further replies.
Level 4
Joined
May 24, 2017
Messages
93
Can someone tell me why units do more then the damage on the command card?

I have footmen attacking a zombie and it tells me how much damage they are doing but the total damage is twice the damage dealt.

I also have a system that reduces the max health by the damage taken would this cause the damage to drop twice?
 
How can I set all damage to just do the displayed damage? and Thank you

You could go into Advanced Settings - Gameplay Constants and set all the amour and attack types to do 100% damage to everything, kinda like chaos damage. Or you could just make every unit use chaos damage.

Remember any unit with an armour value greater or lesser than 0 will also affect damage.
 
Level 4
Joined
May 24, 2017
Messages
93
Thank you for the reminder, I will change what I need to. +rep

EDIT: I tried what you said by changing all the numbers to 1 but it still does more damage then it should.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
I also have a system that reduces the max health by the damage taken would this cause the damage to drop twice?
Is it damage taken twice as large? Or is it that the damage taken is correct but the unit loses twice the health? It is very much possible that by reducing the maximum life of the unit you are making it lose twice the health.

Use triggers to confirm this. If the damage event reports double the expected damage, or the event fires twice then that is your issue. Otherwise you will need some sort of compensation logic when lowering the maximum life so the unit ends up with the intended amount of life.
 
Level 4
Joined
May 24, 2017
Messages
93
You were right, I added a health changing trigger and did the same thing twice. That caused the 2x drop in health. I removed it and it worked. Thank you.

EDIT: Never mind, it is still weird. Please look this triggers over.

  • Max new unit
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Entering unit) is in Damage_detection.) Equal to False
    • Actions
      • Unit Group - Add (Entering unit) to Damage_detection
      • Trigger - Add to Reduce Max <gen> the event (Unit - (Entering unit) Takes damage)
  • Max set up
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Entering unit) is in Damage_detection.) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to Damage_detection
              • Trigger - Add to Reduce Max <gen> the event (Unit - (Picked unit) Takes damage)
            • Else - Actions
              • Do nothing
  • Reduce Max
    • Events
    • Conditions
    • Actions
      • Set VariableSet Damage = (Integer((Damage taken)))
      • Set VariableSet Current_Max = (Max HP of (Damage Target))
      • Unit - Set Max HP of (Damage Target) to (Current_Max - Damage)
      • Game - Display to (All players) the text: (A unit has taken + ((String(Damage)) + Damage.))
      • Game - Display to (All players) the text: (Max health should be + ((String((Current_Max - Damage))) + .))
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
You probably want to use a Damage Engine like Bribes. Also, your Reduce Max trigger is working like this:

Let's say your unit takes 50 damage and has 500 max hp
1) A unit takes 50 damage
2) Set Variable Damage = 50
3) Set Variable Current_Max = 450 (500-Damage)
Set Max HP of Damage Target to 400 (Current_Max-Damage)

You've now reduced it's Max Hp by 100.
 
Level 4
Joined
May 24, 2017
Messages
93
The amount of damage that is taken is not reduced from the max. The health of the unit is reduced because of the damage and the max health should be adjusted to the new current health. The amount of damage taken should not effect the max health reduction before the max health is changed in the trigger.

Step 1 in your list has no effect if it works right.
 
Level 4
Joined
May 24, 2017
Messages
93
I am sorry about that, it makes me sound like a dick. I tried what you said and it did not work. The problem is in that trigger though because I disabled it and the health deceased right. I just need to decrease the health max by the damage now. I want to use these triggers and not a damage detection system. Please keep helping me find the answer. I will be nicer from now on.

EDIT: I experimented a little with what you said and setting the max to Current_Maximum gets rid of the double damage but it does not reduce the max health. The unit just takes the amount of damage to its health. How do I reduce maximum hp without causing the double damage?

EDIT 2: After experimentation, I have found that something in the reduction trigger is causing double damage. The damage variable is correct but when I reduce the max it causes the unit to take double the amount of damage. Why does the reducing the maximum cause another round of damage?
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
I think I may have misread your original post.

Anyway, this is working for me (I think it's what you want):
  • Untitled Trigger 001
    • Events
      • Unit - Footman 0000 <gen> Takes damage
    • Conditions
    • Actions
      • Set VariableSet Damage = (Integer((Damage taken)))
      • Set VariableSet Current_Max = ((Max HP of (Damage Target)) - Damage)
      • Unit - Set Max HP of (Damage Target) to Current_Max
Edit, not sure about this:
  • Damage
    • Events
      • Unit - Footman 0000 <gen> Takes damage
    • Conditions
    • Actions
      • Set VariableSet Damage = (Damage taken)
      • Set VariableSet Percent = ((Life of (Damage Target)) / (Max life of (Damage Target)))
      • Set VariableSet Percent = (Percent x 100.00)
      • Set VariableSet Current_Max = ((Max HP of (Damage Target)) - (Integer(Damage)))
      • Unit - Set Max HP of (Damage Target) to Current_Max
      • Unit - Set life of (Damage Target) to Percent%
So what's happening is that the Damage Taken is calculated after you set the Max HP of the target.
 
Last edited:
Level 4
Joined
May 24, 2017
Messages
93
2 questions.
1. is this the same trigger
  • Reduce Max
    • Events
      • Unit - Footman 0001 <gen> Takes damage
    • Conditions
    • Actions
      • Set VariableSet Damage = (Integer((Damage taken)))
      • Set VariableSet Current_Max = ((Max HP of (Damage Target)) - Damage)
      • Unit - Set Max HP of (Damage Target) to Current_Max
2. is the health of the unit, not the maximum being reduced by twice the damage?
My footman is at 220/220
then when he is hit he goes to 200/210. After 1 hit of 10 damage. his health is droping to twice the damage while his max is droping once.
Is that happening with you?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
2 questions.
1. is this the same trigger
  • Reduce Max
    • Events
      • Unit - Footman 0001 <gen> Takes damage
    • Conditions
    • Actions
      • Set VariableSet Damage = (Integer((Damage taken)))
      • Set VariableSet Current_Max = ((Max HP of (Damage Target)) - Damage)
      • Unit - Set Max HP of (Damage Target) to Current_Max
2. is the health of the unit, not the maximum being reduced by twice the damage?
My footman is at 220/220
then when he is hit he goes to 200/210. After 1 hit of 10 damage. his health is droping to twice the damage while his max is droping once.
Is that happening with you?
Yep, that's the same result that I had which makes sense.

This is because the Map HP is changed before the damage is dealt. So 220 gets set to 210 (Set Max Hp = 220 - 10), then the unit has 210/210 Hp because no damage has been dealt yet, which means it's still at 100% life, and finally the 10 damage from the attack is applied resulting in 200/210 hp.

The next hit sets the Max Hp to 200, and since the damage happens after then the unit will be at 100% hp again (200/200). Then the damage is applied last and the result is 190/200 hp.

So it's almost like you're healing the unit when you adjust the Max HP, because you've undone the damage that was dealt from the previous attack.
 
Last edited:
Level 4
Joined
May 24, 2017
Messages
93
What kind of trigger would give me 210/210? That explanation would make sense. Do I add a wait action for the damage to apply?

  • Reduce Max
    • Events
    • Conditions
    • Actions
      • Set VariableSet Damage = (Integer((Damage taken)))
      • Set VariableSet Current_Max = ((Max HP of (Damage Target)) - Damage)
      • Wait 0.01 seconds
      • Unit - Set Max HP of (Damage Target) to Current_Max
      • Game - Display to (All players) the text: (String(Damage))
      • Game - Display to (All players) the text: (String(Current_Max))
This trigger worked.
it gave me 210/210
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Set the damage dealt to 0, although that could cause undesired effects.

I know Bribe's Damage Engine has control of these steps so you can adjust things before and after certain calculations are made.

The Wait is not recommended. Damage Target can be changed to a different unit during that time. It's a small window but with a lot of units attacking at once it'll definitely cause problems.

Can you use Triggering Unit instead of Damage Target? If so, use that instead of Damage Target, since Triggering Unit is treated like a local variable and won't have the problem I described.

Otherwise, you could use something like this: local udg_
  • Custom script: local unit udg_tempUnit = BlzGetEventDamageTarget()
  • Custom script: local integer Current_Max
  • Set VariableSet Damage = (Integer((Damage taken)))
  • Set VariableSet Current_Max = ((Max HP of (Damage Target)) - Damage)
  • Wait 0.01 seconds
  • Unit - Set Max HP of tempUnit to Current_Max
  • Custom script: set udg_tempUnit = null
tempUnit is a unit variable
 
Last edited:
Level 4
Joined
May 24, 2017
Messages
93
Yeah, I see what you mean with the wait, I tested and got over whelmed. Are there any other options then using the damage system?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Yeah, I see what you mean with the wait, I tested and got over whelmed. Are there any other options then using the damage system?
I'm not too sure how Bribe handles all of this with his Damage Engine but obviously it's possible to recreate what he did. I think you need to use JASS though, as the GUI editor only has that one Damage Event. At least I think that's the case...

I also uploaded an example trigger with a Wait that uses local variables. The Wait is still undesirable though.
 
Level 4
Joined
May 24, 2017
Messages
93
Would that trigger run everytime a unit is attacked or will it work like
base.gif
Reduce Max
  • join.gif
    events.gif
    Events
  • join.gif
    cond.gif
    Conditions
  • joinbottomminus.gif
    actions.gif
    Actions
    • empty.gif
      join.gif
      set.gif
      Set VariableSet Damage = (Integer((Damage taken)))
    • empty.gif
      join.gif
      set.gif
      Set VariableSet Current_Max = ((Max HP of (Damage Target)) - Damage)
    • empty.gif
      join.gif
      zzz.gif
      Wait 0.01 seconds
    • empty.gif
      join.gif
      unit.gif
      Unit - Set Max HP of (Damage Target) to Current_Max
    • empty.gif
      join.gif
      game.gif
      Game - Display to (All players) the text: (String(Damage))
    • empty.gif
      joinbottom.gif
      game.gif
      Game - Display to (All players) the text: (String(Current_Max))

where is temp_unit defined?
nevermind - I see the first line

The example trigger with he local variables still gets backed up by multiple attacks.
 
Last edited:
Status
Not open for further replies.
Top