• 🏆 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] add mana to unit when attacked

Status
Not open for further replies.
Level 7
Joined
Sep 3, 2020
Messages
191
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.
 
Level 27
Joined
May 18, 2018
Messages
397
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
191
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 ..." ? :)
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
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: 29
Last edited:
Status
Not open for further replies.
Top