Help with Healing Trigger

Status
Not open for further replies.

Fheabhas

Level 2
Hello!
I'm working on a map where I need one of my heroes to gain a small amount of mana points each time he kills someone. By this I do not mean that his maximum mana capacity should increase, but that he will recover mana that he has lost.
I found these two:
http://www.hiveworkshop.com/forums/triggers-scripts-269/i-need-triggers-heal-units-176435/
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/trigger-healing-trigger-163593/
... and I thought I'd use that method - the only problem is that I really do not understand how to add a number/variable after the:
Set life of (Attacking unit) to ((Life of (Attacking unit) - part.
The trigger shown in both the links above display the following constellation:
Unit - Set life of (Attacking unit) to ((Life of (Attacking unit)) + 50.00)(or: + XXXvariable)

I really need someone to explain this to me, because I find myself completely lost.

Thank you!

Dr Super Good

Spell Reviewer
Level 64
It is the "arithmetic" function. It takes 2 other functions of the same type and performs an operation between them.

You could also use custom script where you can naturally type such an expression.

Alright

Level 6
DSG is correct, you take two functions (in this case, it would be the integer of a number you want to multiply based on the level of the ability) and multiply it, like 8 * the level of the ability, and then set the unit's existing mana plus the new mana number.

The problem is, the arithmetic is only done if it's a real number, since mana cannot be an integer iirc. What you do is make a new Real variable, and set it as an arithmetic by multiplying the mana you want by the level of the ability (if you want that way).

Here's a really rough trigger, but it should work (I haven't tested it yet, but feel free to report back). I also have no idea if it leaks, either, so someone else should probably cover that.

• Mana gain
• Events
• Unit - A unit Dies
• Conditions
• (Unit-type of (Killing unit)) Equal to Firelord
• (Level of Incinerate for (Killing unit)) Greater than or equal to 1
• Actions
• Set ManaInteger = (8.00 x (Real((Level of Incinerate for (Killing unit)))))
• Unit - Set mana of (Killing unit) to ((Mana of (Killing unit)) + ManaInteger)

Last edited:

Fheabhas

Level 2
The thing is, I'm a complete stranger when it comes to the use of mathematics and even variables to some extent. So, call me stupid, but how would I apply the 'arithmetic' as a function? Is there an easy way to do this via custom script?

Sorry for all the questions, I thought I knew the editor better than I actually did!

Fheabhas

Level 2
I found it! Thanks you guys - really! I appreciate it!

Fheabhas

Level 2
I tried that trigger, couldn't make it work. It was a good idea though, being able to upgrade the mana gain depending on ability level!

Wietlol

Level 24
You cannot immediately change mana regeneration if that is what you meant but this should work:
Set mana of (unit) to (Arithmetics(Mana of (unit) + Arithmetics(100 + Arithmetics(50 x Real(Hero level of (unit))))))

As you see I use 3 arithmetics.
1. Mana of unit + mana that he will gain. because the mana should be added to his current.
2. Raw bonus + amount that depends on something like levels.
3. Scaling amount + level of the unit.

I do not like arithmetics actually but that is just me being JASS-only scripter

The level of a unit/ability or some other stuff is not directly accessable.
Level is an integer and mana is a real (decimal). So you have to use the "Convert Integer to Real" function to do Real(level).
You can use arithmetics in "Integer + Integer" or "Real + Real" but not "Integer + Real"

Alright

Level 6
> I tried that trigger, couldn't make it work.

I tested my trigger using the same exact trigger I posted. It works just fine, you might have to post your trigger so we can see what the problem is. Keep in mind you have to set the ability type to be equal to what your ability that you originally meant to restore mana and make sure the killing type is set on an unit that is meant to have the ability.

Fheabhas

Level 2
I wish I'd understand JASS, then I reckon this wouldn't be a problem. Oh well, maybe one day!

I see what you mean, but what I was going for now was an ability that granted my hero mana recovery points every time he made a kill. I made the trigger look exactly as the one below:
Mana gain
Events
Unit - A unit Dies
Conditions
(Unit-type of (Killing unit)) Equal to Firelord
(Level of Incinerate for (Killing unit)) Greater than or equal to 1
Actions
Set ManaInteger = (8.00 x (Real((Level of Incinerate for (Killing unit)))))
Unit - Set mana of (Killing unit) to ((Mana of (Killing unit)) + ManaInteger)

With this I made a separate trigger for each level of the ability in question, with each level offering larger amount of points being restored. Further I wanted the ability to be able to switch between gaining mana recovery and hitpoint recovery. Everything seems to work perfectly except that the condition 'Level of Incinerate for (Killing unit)) Greater than or equal to 1' does not want to cooperate - which makes me a little bit frustrated.

Does anyone have guess?

Fheabhas

Level 2
By the way, I used the ability that's supposed to be activated for the switch between healing and mana regaining kills. So that level of the switching ability is what controls the amount of hp/mana being restored.

Fheabhas

Level 2
[trigger=My Trigger]MyTrigger
Events
Unit - A unit Dies
Conditions
(Unit-type of (Killing unit)) Equal to Rifleman
(Level of Enchanted Bullets for Rifleman) Greater than or equal to 1
Actions
Set Rifleman = (Killing unit)
Unit - Set mana of Rifleman to ((Mana of Rifleman) + ManaBonus)
Set ManaBonus = (10.00 x (Real((Level of Enchanted Bullets for Rifleman))))

Do Nothing[/trigger]

Alright

Level 6
> With this I made a separate trigger for each level of the ability in question, with each level offering larger amount of points being restored.

Or you could just add a conditional action that takes in checking each level of the ability and set the integer for an exact amount of mana you want to restore. I can show an example if you want.

> Further I wanted the ability to be able to switch between gaining mana recovery and hitpoint recovery.

That would require some more additional triggering, I'm not sure with ability toggles so someone might have to help you with that.

> Everything seems to work perfectly except that the condition 'Level of Incinerate for (Killing unit)) Greater than or equal to 1' does not want to cooperate - which makes me a little bit frustrated.

Try changing it to Greater than 0. It should work.

> By the way, I used the ability that's supposed to be activated for the switch between healing and mana regaining kills. So that level of the switching ability is what controls the amount of hp/mana being restored.

Which ability in question, if you don't mind me asking? The trigger I posted was meant to work as a passive, I used firelord/incinerate as an example, since incinerate works well for being a passive (although a dummy aura would too).

EDIT: I just saw your trigger. You should put the mana bonus at the top of actions, and you don't really need to set the killing unit as a variable since Killing Unit function already does that for you. Get rid of Do nothing, as it, well, does absolutely nothing.

Fheabhas

Level 2
I'd love to see an example, please! That would be most kind!

I thought I had it covered with my system:

[trigger=My Trigger]MyTrigger
EventsUnit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Enchanted Bullets
(Casting unit) Equal to Rifleman
Actions
Trigger - Turn on HitReg1 <gen>
Trigger - Turn on HitReg2 <gen>
Trigger - Turn on HitReg3 <gen>
Trigger - Turn on Hit Reg4 <gen>
Trigger - Turn off ManaReg <gen>
Trigger - Turn off ManaReg1 <gen>
Trigger - Turn off ManaReg2 <gen>
Trigger - Turn off ManaReg3 <gen>
Trigger - Turn off (This trigger)
Trigger - Turn on Switch1 <gen>
[/trigger]
Switch1 does the same thing but in reverse.
ManReg1, 2, etc. and HitReg 1, 2, etc. consists of the same components as the first trigger I displayed.

I tried changing it 0 before, it still wouldn't work. Not unless I removed the condition that clarifies the ability and its level all together.

Oh, well, the ability is most definitely passive, but with an active spell used as the vessel for the passive ability. I chose the active ability so that I could use it as the switch button for between mana and hitpoint recovery. The 'passive' part of the ability being rather a series of triggers than an actual ability.

I thought it was good to specify, but I will do as you suggest!
Oh, haha. That just came in somewhere when I tried to copy the trigger to this forum, it's in the default 'trigger'-tag.

Thank you so much for your help!

Alright

Level 6
Give me a couple, I'll try and make the ability in question for you.

Level 2
Awesome!

Alright

Level 6
This took me a while, apparently trying a lot of stuff I'm not proud of, turns out I was missing a condition. But it works, although I'm not sure if it's MUI (I have no idea if it's MUI). If you plan to use only one unit in the map with the ability then it should be fine, but if you do use multiple units for this you can probably trying using it anyway, and if it does work, great. If not, another forumgoer will have to cover that. I think it doesn't leak, either (it shouldn't).

I used an Attribute bonus as a dummy ability for you to learn on your hero since it can be hidden in the object editor (if you do recreate another, make sure to set all points it gives (strength, intelligence, agility) to 0 and set hide ability to true), and two abilities based off wind walk, turned off backstab, made duration to 0.01 seconds so it does basically nothing, and renamed them to appropriate abilities (turn on life restoration or mana), and then made it done by triggers.

You can set the mana/life integers in accordance to the dummy ability's level, since that is how it will function. You can add more if/then/else's statements if you do want to add more levels, though for the simplicity's sake I suggest doing an arithmetic that multiples it based on level or something else.

Here's the demo map. I already set the health/mana of the firelord to 50% so you can see it in action.

Attachments

• Enchantedbullets.w3x
20.6 KB · Views: 25

Fheabhas

Level 2
Good lord! That's SO great! I'm forever grateful! It's just so... elegant and perfect! Thank you!!
(Really, thank you!)

Status
Not open for further replies.

Replies
6
Views
478
Replies
5
Views
1K
[Spell] Lifesteal
Replies
2
Views
2K
Replies
1
Views
230
Replies
5
Views
618