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

[Trigger] Mana consume detection

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2016
Messages
96
Hi
I need some help with these triggers i made to detect how much mana a spell is consuming

  • Impedido 2
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Set ManaOBJ = (Mana of casting unit)

  • Impedido
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set ManaReal[11] = (ManaOBJ - (Mana of casting unit))
      • Set ManaReal[1] = (ManaReal[1] + ManaReal[11])
      • Floating Text - Create floating text that reads (String(ManaReal[1])) at (Position of casting unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
The current issue is that it keeps returning me 0 damage
 
Level 7
Joined
Mar 10, 2013
Messages
366
The Event you're looking for is:
  • Unit - A unit Finished casting an ability
You just need to be sure that this spell triggers this event (for instance, Mountain King - Avatar doens't fire this event).

Another approach you can take, is to just put a wait timer and use an array to link the variables you're watching wont change if someone else fires this skill at the same time (I suggest you only take this approach if the ability you're using doens't fires the Finished casting event).
 
Level 8
Joined
Jan 28, 2016
Messages
486
You could use a zero-second timer like below but I can't recall if it was MUI. It's a nice example of the basis of catching the manacost of a spell.

  • Mana Detect Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Dark Poison
    • Actions
      • Set Caster = (Triggering unit)
      • Set ManaPrecast = (Mana of Caster)
      • Game - Display to (All players) the text: (Precast Mana: + (String(ManaPrecast)))
      • Countdown Timer - Start Clock as a One-shot timer that will expire in 0.00 seconds
  • Mana Detect Timer
    • Events
      • Time - Clock expires
    • Conditions
    • Actions
      • Set ManaPostcast = (Mana of Caster)
      • Game - Display to (All players) the text: (Postcast Mana: + (String(ManaPostcast)))
      • Set ManaDelta = (ManaPrecast - ManaPostcast)
      • Game - Display to (All players) the text: (Mana spent: + (String(ManaDelta)))
 
After "Starts The Effect" and before "Finishes Casting" there should be the mana consumption, so if you use different triggers, and a variable to keep track of (must be MUI, like maybe using array + unit index), it should work, good.
Dehuna, your method probably won't work correctly when there's some longer "Follow through time" duration.
 
Level 8
Joined
Jan 28, 2016
Messages
486
@IcemanBo Mana is deducted when the "Starts the effect of an ability" event occurs as far as I know, so it'll work no matter how long the cast time is set. Obviously this method won't work on toggle abilities (but does work if it has an initial manacost).
 
Level 8
Joined
Jan 28, 2016
Messages
486
Sorry, my mistake.

I saw this solution somewhere else here on The Hive but couldn't find the thread. They said that the mana is deducted just after the event (or something like that) and that using a timer with zero duration would be the safest way to detect the difference.
 
Status
Not open for further replies.
Top