Do Nothing:
Often used in league with If / Then / Else functions. This, if it isn't obvious enough, does nothing. It may seem pointless, but later in this class you will learn why it's useful, as we move onto the other functions.
Comment:
Comments are used for many reasons. The most common uses are for separation and pointing things out to other people. For example, in my maps, I place comments strategically so that people with little knowledge can figure out what the functions are for.
I also sometimes use comments to visually separate different parts of a trigger. In long initialization triggers, it helps to have dividers.
Custom Script:
Possibly the most useful function in GUI. This can be used to place Jass functions within GUI Script. Common uses include Cleaning up memory leaks and calling functions not included in the GUI menu.
Terms related to Custom Script-
Memory Leak: the leakage of handle objects, or in other words, basically whenever you create something or reference something that isn't an integer, the game loses it’s location, thus causing a leaked piece of memory. Now granted these are cleaned at the end of the game, but if enough pile up during play without being removed, it can cause serious lag to the players, ranging from a little here and there, to complete un-playability, neither of which is wanted.
Jass: the scripting language used for scripting Maps and AI files in Blizzard Entertainment's Warcraft III game. Most people make triggers in GUI format, the premade template triggers that are in the World Editor. However, the actual language of these is that of JASS, which can give you almost free reign over every aspect of the game.
Custom Script: this is an action in the World Editor Trigger Editor which allows you to type one line of JASS script as opposed to using a template GUI script. This is what we will be using to clean up most of our memory leaks, since Blizzard put in the ability to remove these leaks, but neglected to add them to basic GUI.
Memory Leaks
What not to do:
How to do it:
The purpose of destroying that group variable is so that there is not stray memory floating around, not being used. Once you're finished with it, clean it up.
What not to do:
How to do it:
Essentially what that does is creates a point at the said position, which is lost and cannot later be referenced, so it just floats around as a tempfile, lagging the game.
How not to do it:
How to do it:
Another way to do it:
The purpose of the second 'correct' way is so that you can use waits, without losing the special effect.
How not to do it:
How to do it:
The line in blue is if you're using this unit as a "dummy caster" to help with triggered spells. It is not necessary otherwise.
Credit goes to emjlr3 and his Custom Script and Memory Leaks Tutorial for the information.
If you have problems with Custom Script, reference this tutorial as you work:
http://www.thehelper.net/forums/showthread.php?t=27219
It's fairly comprehensive and easy to understand.
Your assignment:
Give me a trigger that changes the color of a random unit from all units to blue, then moves the unit to the center of a region. Use Custom Script to clean up leaks, and Comments to explain what you're doing with the functions.
I understand that some people may not consider this thread as very explanatory. However, I consider the best form of teaching as revision of work that one has done, rather than presenting work that one is unfamiliar with.
Please post completed work in this thread by copying your trigger as text and posting it in
Often used in league with If / Then / Else functions. This, if it isn't obvious enough, does nothing. It may seem pointless, but later in this class you will learn why it's useful, as we move onto the other functions.
Comment:
Comments are used for many reasons. The most common uses are for separation and pointing things out to other people. For example, in my maps, I place comments strategically so that people with little knowledge can figure out what the functions are for.
I also sometimes use comments to visually separate different parts of a trigger. In long initialization triggers, it helps to have dividers.
Custom Script:
Possibly the most useful function in GUI. This can be used to place Jass functions within GUI Script. Common uses include Cleaning up memory leaks and calling functions not included in the GUI menu.
Terms related to Custom Script-
Memory Leak: the leakage of handle objects, or in other words, basically whenever you create something or reference something that isn't an integer, the game loses it’s location, thus causing a leaked piece of memory. Now granted these are cleaned at the end of the game, but if enough pile up during play without being removed, it can cause serious lag to the players, ranging from a little here and there, to complete un-playability, neither of which is wanted.
Jass: the scripting language used for scripting Maps and AI files in Blizzard Entertainment's Warcraft III game. Most people make triggers in GUI format, the premade template triggers that are in the World Editor. However, the actual language of these is that of JASS, which can give you almost free reign over every aspect of the game.
Custom Script: this is an action in the World Editor Trigger Editor which allows you to type one line of JASS script as opposed to using a template GUI script. This is what we will be using to clean up most of our memory leaks, since Blizzard put in the ability to remove these leaks, but neglected to add them to basic GUI.
Memory Leaks
- - - Unit Group Leaks - - -
What not to do:
Code:
Trigger
Events
Conditions
Actions
Unit Group - Pick every unit in [COLOR="Red"](Units in (Playable map area))[/COLOR] and do (Actions)
Loop - Actions
Unit - Kill (Picked unit)
How to do it:
Code:
Trigger
Events
Conditions
Actions
Set Temp_Group = (Units in (Playable map area))
Unit Group - Pick every unit in Temp_Group and do (Actions)
Loop - Actions
Unit - Kill (Picked unit)
Custom script: call DestroyGroup (udg_Temp_Group)
The purpose of destroying that group variable is so that there is not stray memory floating around, not being used. Once you're finished with it, clean it up.
- - - Point Leaks - - -
What not to do:
Code:
Trigger
Events
Conditions
Actions
Unit - Create 1 Footman for Player 1 (Red) at [COLOR="Red"](Center of (Playable map area))[/COLOR] facing Default building facing degrees
How to do it:
Code:
Trigger
Events
Conditions
Actions
Set Temp_Point = (Center of (Playable map area))
Unit - Create 1 Footman for Player 1 (Red) at Temp_Point facing Default building facing degrees
Custom script: call RemoveLocation (udg_Temp_Point)
Essentially what that does is creates a point at the said position, which is lost and cannot later be referenced, so it just floats around as a tempfile, lagging the game.
- - - SFX Leaks - - -
How not to do it:
Code:
Trigger
Events
Conditions
Actions
Special Effect - Create a special effect at [COLOR="Red"](Center of (Playable map area))[/COLOR] using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
How to do it:
Code:
Trigger
Events
Conditions
Actions
Set Temp_Point = (Center of (Playable map area))
Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation (udg_Temp_Point)
Another way to do it:
Code:
Trigger
Events
Conditions
Actions
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Set Temp_Point = (Center of (Playable map area))
Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Undead\UnholyAura\UnholyAura.mdl
Set Temp_SFX[(Integer A)] = (Last created special effect)
Custom script: call RemoveLocation (udg_Temp_Point)
Wait 2.00 seconds
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Special Effect - Destroy Temp_SFX[(Integer A)]
The purpose of the second 'correct' way is so that you can use waits, without losing the special effect.
- - - Unit Leaks - - -
How not to do it:
Code:
Trigger
Events
Conditions
Actions
Unit - Create 1 Dummy Caster for Player 1 (Red) at [B](Center of (Playable map area))[/B] facing Default building facing degrees
How to do it:
Code:
Trigger
Events
Conditions
Actions
Set Temp_Point = (Center of (Playable map area))
Unit - Create 1 Dummy Caster for Player 1 (Red) at Temp_Point facing Default building facing degrees
Custom script: call RemoveLocation (udg_Temp_Point)
[COLOR="Blue"]Unit - Add a 2.00 second Generic expiration timer to (Last created unit)[/COLOR]
The line in blue is if you're using this unit as a "dummy caster" to help with triggered spells. It is not necessary otherwise.
Credit goes to emjlr3 and his Custom Script and Memory Leaks Tutorial for the information.
If you have problems with Custom Script, reference this tutorial as you work:
http://www.thehelper.net/forums/showthread.php?t=27219
It's fairly comprehensive and easy to understand.
Your assignment:
Give me a trigger that changes the color of a random unit from all units to blue, then moves the unit to the center of a region. Use Custom Script to clean up leaks, and Comments to explain what you're doing with the functions.
I understand that some people may not consider this thread as very explanatory. However, I consider the best form of teaching as revision of work that one has done, rather than presenting work that one is unfamiliar with.
Please post completed work in this thread by copying your trigger as text and posting it in
Code:
Tags.[/COLOR]