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

[Solved] Damage negation problem

Status
Not open for further replies.
Level 22
Joined
Jul 25, 2009
Messages
3,091
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • DamageEventTarget Equal to TempUnit
      • DamageEventAmount Less than 99999.00
    • Then - Actions
    • Else - Actions
      • Unit - Cause DamageEventSource to damage TempUnit, dealing DamageEventAmount damage of attack type Normal and damage type Normal
      • Unit - Set life of DamageEventTarget to 100.00%
Why does this cause 0 damage to the TempUnit? TempUnit is the leader of the squad and not a member, the idea is to redistribute damage from members to the leader equally (which works until I added Unit - Set life of DamageEventTarget to 100.00% which is simply to negate damage done to members so that they will always be full HP and only the leader will take damage.)

Why does Unit - Set life of DamageEventTarget to 100.00% interfere with the distribution of damage from members to the leader?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
The action will fire another damage event. Then DamageEventTarget is set to TempUnit, because you damage TempUnit. So basically you set the hp of TempUnit to 100%.
Using the action "unit - damage target" will overwrite all variables connected to the damage engine.
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
So how do I negate damage to DamageEventTarget while still causing DamageEventAmount to TempUnit?

Also is this causing there to be a discrepancy between the damage done directly to TempUnit (squad leader) and the damage done to DamageEventTarget (squad members?)
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You can use a local variable to store TempUnit and/or DamageEventTarget. This way they cannot be overwritten.
However to use locals, you need custom scripts.

You can declare locals at the beginning of the trigger like this:
  • Custom script: local unit u = udg_TempUnit
"u" is the name of the local variable and you set it's value to TempUnit.

However accessing local variables in GUI triggers is not possible, so you cannot do:
Set Life of u to 100%

To avoid this problem, you create a new variable called LocalUnit or something.
Then you can use:
  • Custom script: local unit udg_LocalUnit = udg_TempUnit
Now LocalUnit is both a local and a normal (global) variable. But in this trigger you will always refer to the local variable. So you use
Set Life of LocalUnit to 100%
and it will change the life of the unit that is described by the local variable.

In total you should have:
A unit variable called "LocalUnit"
At the beginning of your trigger use:
  • Custom script: local unit udg_LocalUnit = udg_TempUnit
Instead of changing life of "DamageEventTarget", use "LocalUnit".
After that you should null the local variable to prevent a leak:
  • Custom script: set udg_LocalUnit = null
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You can turn this trigger off, but DamageEventTarget will still be overwritten by other triggers using the damage event.
I don't think there is a way right now, but you can easily modify the damage engine, so you can (de)activate it.
You could also simply change life instead of dealing damage.

Anyway if the damage engine is used twice, it's bad. If a member is damaged, the leader should be damaged by the exact amount, the member was damaged.
If you would have a debuff increasinf damage taken by 2 on both member and leader, the damage would be multipled by 4 in total.
 
Last edited:
Level 22
Joined
Jul 25, 2009
Messages
3,091
I thought Bribe's DDS had the ability to make damage instances not overlap?

Changing life instead of causing damage seems like the best way to fix this in the shirt term.

If I change it from cause damage to set life to -- I can keep the function that negates damage to members right? Meaning I can keep everything exactly the same except change it from cause damage to set life and it'll work fine.
 
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
The easiest way is setting the life of TempUnit:

Unit - Set life of TempUnit to (Life of TempUnit) - DamageEventAmount
Unit - Set life of DamageEventTarget to 100.00%

Bribe's DDS works correctly. You can deal with each damage instance seperately.
It only detects, when a damage event triggers itself again resulting in an infinte loop. For example:
a unit is damaged
cause damage source to deal 10 damage to damaged unit

In your case it is two damage events at most:
member is damaged
deal damage to leader
 
Level 18
Joined
Nov 21, 2012
Messages
835
maybe something like this
  • dmg
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to SquadMember
    • Actions
      • Unit - Cause DamageEventSource to damage SquadLeader, dealing DamageEventAmount damage of attack type Spells and damage type Normal
      • Set DamageEventAmount = 0.00
so you're damaging leader and after that nulling damage dealt to member
 
Status
Not open for further replies.
Top