Get the damage dealt in triggers?

Insanewarlock

Active Member
Reaction score
2
I'm making a self-cast spell "Electric Shield" for Goblin Shredder. When the spell is active and Goblin is being attacked it automatically deals some percentage of the damage back to attacker, just like Thorns Aura does, but unlike Thorns Aura it drains mana when it's active and can be deactivated of course. Trigger looks like this (eShield is a boolean toggled by other trigger)
Trigger:
  • TRIGGER
    • Events
      • Unit - A unit is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Goblin Shredder
      • eShield Equal to True
    • Actions
      • Unit - Cause (Attacked unit) to damage (Attacking unit), dealing ??? damage of attack type Magic and damage type Lightning


So "???" should be say 10% of damage dealt by the attacker. Is there a way to get how much damage was dealt?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
The attack event is fired before any damage is dealt. It fires when the Animation starts playing.
What you want is the "Unit takes damage" event. This will let you get the damage dealt. However, it is fired for ANY kind of damage dealt, not just melee damage.
You would have to figure out a way to detect melee attacks.
 

Insanewarlock

Active Member
Reaction score
2
The attack event is fired before any damage is dealt. It fires when the Animation starts playing.
What you want is the "Unit takes damage" event. This will let you get the damage dealt. However, it is fired for ANY kind of damage dealt, not just melee damage.
You would have to figure out a way to detect melee attacks.
Well, that's easy, I will set the requirement that range between the Goblin and the attacker must be less than, say 120, but "Attacking unit" won't work in this case I think so that's the problem.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Theres Damage Source for the unit dealing the damage and Triggering Unit for the unit taking the damage.
Checking the range is not a sure way to solve your problem. Ranged units will not work correctly, but spells cast from short range will. Immolation and Auras will too.
 

Insanewarlock

Active Member
Reaction score
2
Theres Damage Source for the unit dealing the damage and Triggering Unit for the unit taking the damage.
Checking the range is not a sure way to solve your problem. Ranged units will not work correctly, but spells cast from short range will. Immolation and Auras will too.

That's not a big problem, let any kind of damage be returned back.

I've created an action inside a trigger which toggles eShield bool, it looks like this:
Trigger:
  • Trigger - Add to eShield <gen> the event (Unit - (Triggering unit) Takes damage)

Since there may be other shredders on the and they do not exist initially on the map. And I don't seem to find "Damage Source" function and "Damage Taken (or something like this)" function.
 

Insanewarlock

Active Member
Reaction score
2
That's not a big problem, let any kind of damage be returned back.

I've created an action inside a trigger which toggles eShield bool, it looks like this:
Trigger:
  • Trigger - Add to eShield <gen> the event (Unit - (Triggering unit) Takes damage)

Since there may be other shredders on the and they do not exist initially on the map. And I don't seem to find "Damage Source" function and "Damage Taken (or something like this)" function.

And I think it's leaking memory since I don't know how to delete the event from the trigger after Shredder dies....
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Its not only leaking memory, it will also end up adding the same event multiple times to the trigger, making the trigger run several times at once. At some point you will instant kill anything that touches your hero.

Instead, make sure you only ever add this event to your trigger once per unit. For example you could do it the first time the unit enters the game.
 

Insanewarlock

Active Member
Reaction score
2
Its not only leaking memory, it will also end up adding the same event multiple times to the trigger, making the trigger run several times at once. At some point you will instant kill anything that touches your hero.

Instead, make sure you only ever add this event to your trigger once per unit. For example you could do it the first time the unit enters the game.
LOL that's funny :D I've actually came up with another idea on how to make the effect of this ability with no triggers. I'll add actual Thorns Aura to the unit but it will have a requirement, for instance Dummy unit and that unit will be created when you activate the spell (which drains mana from you in the process) and removed from the map when you deactivate it. But there is a minor problem, I don't want Thorns Aura to be displayed in spellbar, can it be done?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Put the thorns aura ability into a custom spellbook ability.
Give your unit the spellbook ability.
Disable the spellbook ability with triggers.

The thorns aura will stille be enabled and active, but the spellbook will be disabled and removed, thus the thornsaura will also become invisible since it is inside the spellbook.
 

Insanewarlock

Active Member
Reaction score
2
I think I gave up on that.... Nothing seems to be working. Thorns Aura works with 2-3 second latency ;P Other things just either don't work or require tons of scripts including periodics which I'm not going to use (and still it's still uncertain will they work or not) so I'll simply make it passive and will use no triggers what so ever.
 
Last edited:

thorhunter

You can change this now in User CP.
Reaction score
32
You should give it a shot and try integrating some DDE system into your map (check hiveworkshop's resources). If you can force yourself to integrate existent systems and use them you will benefit from it much more than from creating and troubleshooting your own.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top