• 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.

[Solved] [ creating gui spell ] better with variable or not while its functioning properly

Status
Not open for further replies.
Level 5
Joined
Aug 9, 2012
Messages
119
Hy guys, i really need ur help, ur opinion, and maybe some explanation, what's should i do...

I just want to make a single unit spell, means that its not MUI...
The question is...

I saw many gui spell, jst gui, not mui, but everyone LOVE to use variable,
Since i create my own spell , having the same effect with other people that use
Many variable,mine works just fine... I just want to know...

What's the differences , if i use
(target point of ability being cast)
(Target of ability being cast)
(Level of ability being cast)
(Position of triggering unit)
And so on
All of it in my gui spell, rather than...
Storing ALL of it into variable... Whyy is that? Why should we do that?
Then destroy the location, is it just making the whole pprocess longer?
Even loading the map, slower the loading when u have many variable

Then i think the only useful variable to use is unit group, and destroy it after,
So why other function that ALREADY available , they create variable to store that function?? Whyy? :(
I really want to know the advantage of using that...

Thanks for ur time,
But if using manyy variable is good in such a huge and many trigger,
I know its useful,
But in short yet quite simple spell, why people should store
Casterloc,
Loc,
Ability level,
Point,

Since we can choose it manually from function
I want to know, that without variable and long trigger,
The game loading will be faster...
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Variables are very important to make the spell work correctly, even if it's used by single unit only.
For simple spells, you don't need to use them, that's right - you don't need to use them for simple MUI spells either.

First, variables are faster than unit functions (like Triggering unit; Picked unit, Target unit of ability being cast, etc.)
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Animation - Change (Last created unit)'s size to (40.00%, 40.00%, 40.00%) of its original size
      • Unit - Change color of (Last created unit) to Purple
      • Unit - Set life of (Last created unit) to 50.00%
      • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 0.00%, 80.00%) with 40.00% transparency
      • Animation - Change (Last created unit) flying height to 480.00 at 120.00
      • Unit - Set (Last created unit) movement speed to 150.00
Can you see? Upon casting Animate Dead I create 1 Footman at position of caster and then I have 6 actions refering to that footman as "last created unit". Also the location where I create footman leaks.

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set point = (Position of (Triggering unit))
      • Unit - Create 1 Footman for (Owner of (Triggering unit)) at point facing Default building facing degrees
      • Set Unit1 = (Last created unit)
      • Animation - Change Unit1's size to (40.00%, 40.00%, 40.00%) of its original size
      • Unit - Change color of Unit1 to Purple
      • Unit - Set life of Unit1 to 50.00%
      • Animation - Change Unit1's vertex coloring to (100.00%, 0.00%, 80.00%) with 40.00% transparency
      • Animation - Change Unit1 flying height to 480.00 at 120.00
      • Unit - Set Unit1 movement speed to 150.00
      • Custom script: call RemoveLocation(udg_point)
      • Set Unit1 = No unit
Here is the very same trigger, but now I also save the location, so I can remove it at the end of the trigger (the custom script) to remove memory leak; Variables are faster to load/red than unit functions (such as triggering unit, picked unit, etc.). Because I store Footman in variable Unit1 and then do all these actions for Unit1, the trigger runs faster.
I doubt it will be noticeable by eye though, but if many unit run different spells at similar time, efficiency and speed are needed to prevent bugs.


You also need variables when you have a spell with periodic effect.
  • Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Phase
    • Actions
      • Set Unit1 = (Triggering unit)
      • Set Tick = 0
      • Trigger - Turn on Trigger 002 <gen>
  • Untitled Trigger 002
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set Tick = (Tick + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Tick Equal to 5
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Set p = *somewhere*
      • Unit - Move Unit1 instantly to p
      • Custom script: call RemoveLocation(udg_p)
Here I start the ability "Phase" and from then on, every 2 seconds the caster will be teleported to location "p". This will happen 5 times.
See - here in "Integer" variable called "Tick" I stored how many times the caster has been teleported.
In Unit1 I store who the caster is. The reason for storing him is because in the 2nd trigger there is no "triggering unit", because the trigger is run by "Time - Periodic event" event. Triggering unit refers to most, if not all "Unit" related events. Just like Triggering player refers to most "Player" related events.


You also don't need new variable for each new spell/trigger.
If your spell is instant - that means everything happens in 1 trigger without any "wait" actions used, then you can use what most mapmakers refer to as "temp variables" (or temporal variables). These are same as any other variables, but they are used and removed in many spells - everywhere where you set that variable and in the same trigger you delete it.

From those few triggers I've posted in this post, you could say that those locations I set up called "point" or simply "p" are temp variables - if you look at how they work, I create them and also delete them in the same trigger.
However if you look at the periodic spell I used, then you could say that in that trigger Unit1 is not temp variable, as it has to store a unit for longer period of time.
 
Level 5
Joined
Aug 9, 2012
Messages
119
Oh my, thx all,
For the fast and quick respon...

Thx...
I got it now,

Hmmm so... Variable is faster?
And creating so many variable doesn't make the map taking much time to loading? But what makes mapp usually load slower than the other?


Then, on which kind of type of spell i don't need variable?
Does every spell need variable that consist of triggering unit?
Position of triggering unit? Location? ( That spell need those function )
But should we or must we store tht function into variable?

Thx once again broo...
 
Variables is faster, yes.
Usually it's Abilities at Object Editor which causes Longer Loading.

Almost all triggered spell uses Point Variable.
It's not a must for Triggering unit/others to be stored unless you use multiple trigger for the spell.

Note : Global Variables and Unit-Event Response except triggering unit aren't MUI
 
Level 5
Joined
Aug 9, 2012
Messages
119
Thx, after reading many leaks and learning those stuff,
Now i know...

Sry for the first question, for this topic, tthe answer is simply it will leaks...

The problem is i don't realize it when i use point location function will leaks,
Rather tthan variable then destroy it, adding a few lines is better than one line i guess :D tthx...


Last question,
-will level of ability leaks? Ttriggering unit? And integer value or real?
Should not be problem if i use wihout variable?
The one thts leaks usually is point loc, special effect, sound, floating ttext, unit iff not set generic expire time and unit group right?

-what? So if i have 200 custom ability? Tht makes lag? Or slows the loading time?
Rather than make 100 custom ability, and 100 more is just editting the template , and not making it into custo categories...

Which has biggest size map and effect loading time?

Thank you guys
 
Status
Not open for further replies.
Top