HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using triggers to give a unit mana when hit

06-19-2004, 07:47 AM#1
kumi333
I want to devise a way to make it so a unit can gain mana when hit by another unit. Here's the catch though, I want the amount of mana gained to be a specific number in accordance to the amount of dmg taken. I think the current editor only allows for setting the amount of mana, not adding.

Also, I would like a way for the mana to gradually decrease over time.

Thanks for any help.
06-19-2004, 07:57 AM#2
Anitarf
To decrease the mana of a unit over time, give it a negative mana regeneration rate.

To get the ammount of damage taken, you need to use, the specific unit event "unit takes damage". The problem with these events is that they can be for only one unit, so whenever you add a unit with this ability to the map, you must add a new event to the trigger (using the action "trigger - add event"). If this is only needed for a few heroes, then that's not such a problem.

And, you can always "add" mana by seting it to (current mana of unit)+(damage taken).
06-19-2004, 11:41 AM#3
kumi333
Ah, I should've known how to make the mana regeneration negative.

Now, as for the adding mana, I'm still a bit in the dark. I'm very clueless when it comes to the editor. I need to be spoon fed the conclusions I'm afraid. If anyone has the paitence to explain step by step to accomplish this I would really appreciate it.

I want 1 specific hero to have the condition where if he is struck for X amount of dmg he will gain X amount of MP.
06-19-2004, 03:39 PM#4
Anitarf
Code:
Damage to mana
    Events
        Unit - Paladin 0000 <gen> Takes damage
    Conditions
    Actions
        Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (Damage taken))
Since you're new to this, some explanations are in order. The event is a specific unit event; here you must select the hero on the map that has this ability (I just placed one palladin to have a unit to choose). If you add another hero to the map while playing with triggers, all you have to do is add to this trigger another event (with the "trigger - add event" action).

((Mana of (Triggering unit)) + (Damage taken)) this is an arithmetic function. Arithmetic function allow you to combine multiple real or integer numbers (in our case we are working with reals) with +, -, * or /. In our case we are adding the (damage taken) to the original mana of the unit.

(Mana of (Triggering unit)) is under "unit - property of unit" in the same drop-down list as the "arithmetic" function. (damage taken) is the "Event response - damage taken" in the same list.

That covers everything, I suppose, I'll just add another, more complex function, that adds mana only if the hero has a specific skill researched:

Code:
Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + ((Damage taken) x ((Real((Level of Devotion Aura for (Triggering unit)))) x 0.25)))

This action will add 25% of the damage taken for each level of devotion aura my paladin has. In your case, this would be some other ability, since you would be using some other hero. If the skill is on level 0, then the hero gets no mana, if it's on level 3, then he gets 75% of the damage back in mana. The percentages can be easily changed by modifying the number (0.25).
Oh, and I almost forgot, there is another function used here, (Real((Level of Devotion Aura for (Triggering unit))) ; because the "unit - level of ability for unit" is an integer, I had to use "conversion - convert integer to real" first to be able to include the integer into my real calculation.
06-19-2004, 06:22 PM#5
kumi333
Wow, Thank you very much! Now I remember why I keep posting here, the people are so helpful! I got it all to work with very little effort! Thanks again Anitar!
02-27-2005, 10:17 PM#6
Guest
My editor won't allow me to give a unti negative mana regen. How did you do it?
02-27-2005, 10:50 PM#7
Anitarf
Some values cannot be modified outside certain boundaries by default. To do this, you must either hold down shift when you double-click a field you wish to modify, or you can set the "allow negative real values in object editor" field under file->preferences->general.