• 🏆 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!

Gain mana on attack trigger

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi

I am making a spell that curses an enemy. When my units attacks it, it is supposed to restore mana to them.

It is only supposed to be for a duration. So how do I delete the variable set for the unit, without leaking other targets.

It is available to be 2 of the same hero, which means another Hero can cast it as well. How do I make sure that when the first curse runs out, that the other curse variable is not removed as well? And if a unit has the curse and the other Hero curses another unit, will it overlap the other variable, removing it from the first 1?

Here are my triggers so far:

Trigger 1:
  • Unholy Shackles 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Monk Unholy Shackles
    • Actions
      • Set UnholyShackledUnit = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • Set UnholyShackledUnit = No unit
Trigger 2:
  • Unholy Shackles 2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacked unit) Equal to UnholyShackledUnit
    • Actions
      • Unit - Set mana of (Attacking unit) to ((Percentage mana of (Attacking unit)) + 1.00)

Leaks:
If you curse the enemy, select to attack and spam press Stop, it will generate mana very fast, without him hitting. How do you prevent that?
 
Use a Damage Detection system that detects physical damage, like Damage Engine (http://www.hiveworkshop.com/forums/spells-569/gui-damage-engine-v3-3-0-0-a-201016/).

  • Unholy Shackles 2
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to UnholyShackledUnit
      • IsDamageSpell Equal to false
    • Actions
      • Unit - Set mana of DamageEventSource to ((Percentage mana of DamageEventSource) + 1.00)
 
Level 8
Joined
Jun 13, 2010
Messages
344
Use a Damage Detection system that detects physical damage, like Damage Engine (http://www.hiveworkshop.com/forums/spells-569/gui-damage-engine-v3-3-0-0-a-201016/).

  • Unholy Shackles 2
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to UnholyShackledUnit
      • IsDamageSpell Equal to false
    • Actions
      • Unit - Set mana of DamageEventSource to ((Percentage mana of DamageEventSource) + 1.00)

I'm sorry but I would need a bit more details. I am not that good at using variables. :)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
First of all you want a unique classification on any unit in your map.
So when they are attacked, you can check if they succeed on that classification and if so, you let them regain mana.

First of all you need the classification.
This can be done by applying a buff on the unit (which is one of the most used methods for spells cause they make you aware that you will regain mana).
Another way to do it (how you did it) is setting the unit to a variable or setting a variable stored on the unit to something else than the default.

To make this MUI, you will have to download a Unit Indexer.
You can use Bribes (which I use as well).
You can find it in the spell section or click on the link in his signature.
What that system basically does is create a unique integer between 1 and 8190 for each unit on the map.

Because of that feature, we can store data to units separately.
So we have a variable for each unit.
Create a real array variable and name it something like "UnholyShackles_ManaGain".
Now when a unit casts an ability, you
  • Set UnholyShackles_ManaGain[(Custom value of (Triggering Unit))] = 1.00
(Real Comparison)

Now you get the DDS.
When your unit takes damage and the damage taken is physical damage, you do this check:
  • UnholyShackles_ManaGain[(Custom value of (Triggering unit))] Greater than 0.00
If that is true, your unit is affected by Unholy Shackles (because his value is set to 1 in the other trigger).
So then you can add "UnholyShackles_ManaGain[(Custom value of (Triggering unit))]" to the current mana of the unit like this:
  • Unit - Set mana of DamageEventSource to ((mana of DamageEventTarget) + UnholyShackles_ManaGain[(Custom value of DamageEventTarget)])
(With this method, you can see that you can calculate the exact amount of mana to be regained for every individual unit separetely when they cast the ability.)

Now there is only one problem left.
Set UnholyShackles_ManaGain[(Custom value of (Triggering Unit))] back to 0.
You can do this like you did with your wait, but that wait action is extremely inaccurate.
The Wait ... seconds of gametime is a bit more accurate than that one but that one leaks a timer handle and in multiplayer this one is also extremely inaccurate and laggs the game (your wait does that too).
So I am forced to recommend you to use a timer.
However... a timer is hard to use in GUI.
Maybe someone else can have a nice method to do this or maybe you can be satisfied with the Wait ... seconds of gametime.
A buff (as mentioned before) would fix this problem cause you do not have to set the value back to 0 and just add another check to the second trigger that checks if the target has the buff.
 
Status
Not open for further replies.
Top