• 🏆 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] Pls help me...

Status
Not open for further replies.
Level 5
Joined
Mar 13, 2008
Messages
126
i wanted to make a trigger that would "toss" a mana cost of ability being cast over the casting unit. it works but sometimes gives something like manacost-1 or negative values...i have tested it with 3 different spells that are insta-cast and i have rapidly fired them...
  • Mana Cost Show
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: local unit udg_Caster
      • Set Caster = (Triggering unit)
      • Set Mana_Cost_Before = (Mana of Caster)
      • Wait 0.00 seconds
      • Set Mana_Cost_After = (Mana of Caster)
      • Set Mana_Cost = ((Integer(Mana_Cost_Before)) - (Integer(Mana_Cost_After)))
      • Floating Text - Create floating text that reads (String(Mana_Cost)) above Caster with Z offset 7.00, using font size 10.00, color (0.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Set Caster = No unit
TNX in advance!
 
Level 5
Joined
Mar 13, 2008
Messages
126
because WE is retarted and it recognizes everything at once, and if u tell him to wait 0,he can recognize before and after that wait...i know that it sounds stupid and weird but it must be in order to work!

i've read them but they don't help...i also tried with o timeout timers as well!
 
Level 4
Joined
Jul 11, 2007
Messages
82
You are detecting the amount of mana of the caster when the effect starts, so the mana is already used. Then you detect again, but its the same number, so they subtract and get zero. It's possible for you to get -1 because the unit might have actually gained mana (because of its mana regen) in that short time. You can't detect the amount of mana a unit has before the Event happened.

I would suggest that you set your Mana_Cost variable based upon the ability being cast. So something like this:

if
ability being cast = firebolt
then
set Mana_Cost = 50

if
ability being cast = icebolt
then
set Mana_Cost = 60

if
ability being cast = shockwave
then
set Mana_Cost = 100

You can then display the Mana_Cost in your floating text. I don't know how many spells you have, but this is pretty simple to do for each spell.

If you know JASS, you could do it using an "elseif" condition for each spell.
 
Status
Not open for further replies.
Top