• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Mana Burn

Status
Not open for further replies.
Level 2
Joined
May 2, 2011
Messages
15
I really need a spell that burns a percentage of the target's mana like 25% mana shall be burned the problem is how can I create this in GUI
 
Level 9
Joined
Apr 23, 2011
Messages
460
  • Mana Burn
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your_Ability
    • Actions
      • Set Target = Target unit of ability being cast
      • Unit - Set mana of Target to (Mana of Target) x 0.75)
      • Custom script: set udg_Target = null
This is a bare minimum trigger, should work, didn't test, GUI isn't really what I do xD
 
Level 9
Joined
Apr 23, 2011
Messages
460
For the sake of GUI functioning, so that the entire script wasn't in Custom script, using a global variable that will act like a local in this case is also possible. Otherwise it might as well have been in Jass or vJass. But then again, I don't do GUI so I wouldn't know the proper method.
Edit: And it's just good practice to null a variable like this in this situation, had a local been used and that wasn't implicated, then it would have leaked. But all is well. I see your point ; )
 
Level 4
Joined
Oct 20, 2011
Messages
129
  • Mana Burn
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your_Ability
    • Actions
      • Set Target = Target unit of ability being cast
      • Unit - Set mana of Target to (Mana of Target) x 0.75)
      • Custom script: set udg_Target = null
This is a bare minimum trigger, should work, didn't test, GUI isn't really what I do xD

I think you don't need to set a variable for this, unless you want more effect.
  • Unit - Set mana of (Target unit of ability being cast) to (Mana of (Target unit of ability being cast)) x 0.75)
This isn't leak in GUI, or you want to waste one variable slot? :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Because you can use a Temporal Unit Variable to prevent calling over and over the same unit. In this trigger is just one aditional action... but still, if it can be improved, why not?

a temp variable slot isn't wasted, since you use it over and over and over to make all the triggers more effective.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
JASS:
// 2 Lines // 1 GetUnit()
Set Target = Target unit of ability being cast
Unit - Set mana of Target to (Mana of Target) x 0.75)

JASS:
// 1 Line // 2 GetUnit()
Unit - Set mana of (Target unit of ability being cast) to (Mana of (Target unit of ability being cast)) x 0.75)

In this case where the (Target Unit of Ability Being Cast) is just being used twice, it doesn't matter. But if you have more functions involving the same unit, using the variable is waaaaaayyy better.
 
Level 9
Joined
Apr 23, 2011
Messages
460
JASS:
// 2 Lines // 1 GetUnit()
Set Target = Target unit of ability being cast
Unit - Set mana of Target to (Mana of Target) x 0.75)

JASS:
// 1 Line // 2 GetUnit()
Unit - Set mana of (Target unit of ability being cast) to (Mana of (Target unit of ability being cast)) x 0.75)

In this case where the (Target Unit of Ability Being Cast) is just being used twice, it doesn't matter. But if you have more functions involving the same unit, using the variable is waaaaaayyy better.

Let me again clarify, the storage of the unit into a variable will cause only 1 GetUnit call. It's not only more efficient its a good coding practice. Since the global variable "udg_Target" is a temporal variable, you actually don't even need to null it, it will be recycling in the end after all.
 
Level 9
Joined
Apr 23, 2011
Messages
460
I was kinda referring to everyone xD. There's a method to my madness. Most of it is proper coding practice but W/E. GUI has its own little qwerks, but the concept is the same. I hope it helps some people understand more optimum coding, I myself am personally always learning better and more efficient ways to code things. We are always learning as coders!
 
Status
Not open for further replies.
Top