• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] add mana to unit when attacked

Status
Not open for further replies.
Level 7
Joined
Sep 3, 2020
Messages
193
Hello Hive,

Here I made a basic trigger. I'm very noobie about triggers and mine isnt working at all. I didnt find something in action like "add mana to actual mana".

Hive-Berserker.png

What I want is that, when my unit "Berserker" is attacked (at least, takes damage), then, his amout of mana (not maximum of mana, just his mana) is increased (by 5).

I would like to know if someone could help me to fix and explain me whats wrong, and so, how to make it right ?

Thank you :peasant-ok-hand:

P.S. : I've been trying to find an event that says "a unit deals damage" or "a unit made an attack", to do the same trigger but increasing mana when attacking, but couldnt find an event like that.
 
If you want the unit to recover mana when "attacked", use this:

  • Recover Mana
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Berserker
    • Actions
      • Unit - Set mana of (Attacked unit) to ((Mana of (Attacked unit)) + 5.00)
However, this will activate every time the unit is attacked regardless of whether the damage is eventually dealt or not, so if you want it to recover mana when "damaged", you must use a Damage system. Try with Bribe's Damage Engine 5.7.1.2.
 
Level 7
Joined
Sep 3, 2020
Messages
193
First of all, thanks a lot of your answer.

May I know in which section of "action" you did find set mana ? :)
 
Level 7
Joined
Sep 3, 2020
Messages
193
Damn as simple than that ! Awesome, thank you x100000 sire !

May I abuse from your kindness and know where I cound find a trigger that say "a unit attacks" or maybe, an even saying "a unit is attacked" and a condition saying "attacking unit equat to ..." ? :)
 
Level 7
Joined
Sep 3, 2020
Messages
193
Oh okido, thanks a lot for your fast answers and kindness! Have a good evening and take care!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,868
That Event doesn't run when a unit takes damage, it runs when an attack is initiated against a unit. What that means is that:
1) The attack doesn't actually have to finish for the Event to run.
2) The attack doesn't have to hit (misses still work).
3) It runs much earlier than when the actual damage/projectile goes off.

This is fine in some cases and probably wouldn't get abused in your map, but it's something to be aware of. If you truly want a bug-free, or at least mechanically correct method, you need to use a Damage Engine -> Damage Engine 5.7.1.2

This system provides you with an Event to detect when a unit takes damage. It also provides you with Variables to modify what happens in response to that Event. See the attached map for a tutorial on how to use the system.

It's very useful to learn how to use this system as it opens up many possibilities for creating unique abilities and effects. It's also quite simple once you get over the initial "oh my god there's 200 variables" phase. There's really only a handful of variables that you actually need to remember in order to do most things with the system, the rest can be ignored. You can see these handful of variables put to use in my example map.

Edit: Oh, I didn't see, sorry. Hopefully the attached map can still be of some help.
 

Attachments

  • Damage Engine Example use.w3m
    56.2 KB · Views: 36
Last edited:
Status
Not open for further replies.
Top