• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Question about variables

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2014
Messages
152
If you have a point variable for a certain spell(triggered), let's say it's variable name is CasterPoint. Can I use the variable "CasterPoint" for another triggered spell? or will that cause bugs?
 
You can use same variables if the spell or action is instant without bugging up.
I usually call variables for instant actions or triggers "TempInt" or "TempPoint" or "TempUnitGRoup" or "TempReal" if you understand.
But for spells, I myself, create a variable that'll be used just for that spell.
 
You should not because you do not know how the implementation will blow up. Even if it is "instant", there may be interrupts. You should avoid global variables when possible anyway because then your code will be less instanceable, less recursion-capable. It's also better for debugging to separate it.
 
You should not because you do not know how the implementation will blow up. Even if it is "instant", there may be interrupts. You should avoid global variables when possible anyway because then your code will be less instanceable, less recursion-capable. It's also better for debugging to separate it.

If I use different variables for every spell, would that increase the map size? Because I plan to make a lot of spells for my map and I'm trying to save up space
 
@Rheiko: Are you talking about arrays? sorry I'm new to the WE. anyway the variables I'm having trouble with are the points (Position of casting unit to be exact). I have a lot of spells that will be referencing to the pos. of the casting unit.
 
Of course each new declaration increases the map size. But that's marginal in comparison to other assets of the map like imports.

Since you asked for it, I just looked up how much the globals block in my current project weights.

1.483mb for 25689 variables with a compression ratio of 15% -> 222.45kb -> 8.6 bytes per variable on average

and that's before wc3optimizer (you can only play maps with up to ~25k variables anyway) and includes initial values like string paths (which it can obv compress worse).
 
@WaterKnight: That solves my problem. I thought that variables would be about 30-80kb each hahaha. I really appreciate the effort. and wow! that's a lot of variables
 
Status
Not open for further replies.
Back
Top