Z
Zell
Guest
Various Trigger Systems
Version 1.2
Version 1.2
Foreword:
Firstly, this is a work in progress. Right now I'm just putting in one guide at a time, but have patience. I have a few ideas for some guides, which I will add here at a later date.
Anyways, this is my tutorial. It is, as the title implies, a collection of guides on how to create trigger systems. Most of these aren't all that complicated, and therefore don't really merit their own guide. I will not attach maps with the triggers and objects in them because this is a learning exercise, not a copy and paste one. If you are really having difficulties with it, PM me and we will talk about the matter.
All of the systems are designed to achieve a certain goal. The guides will not, however, give exact directions on which buff to use, the icon to pick, how much damage to deal, or any of the basic aesthetics / balancing. It will merely list the exact steps needed to achieve said goal. Furthermore, some of the triggers will have optional lines that are used to select specific targets only, etc. These lines of code will be marked by ~ (a.k.a. the console button), followed by a number that will be referenced after the trigger for an explanation. All of the systems are written in full GUI (with the exception of the occasional JASS custom script to fix leaks) and are all totally MUI. All of the systems have been designed by myself, and while they might not be 100% unique, they were all built from scratch.
Additionally, there are several references to DotA. If you don't know what it is, DotA (Defense of the Ancients) is one of the all time most played maps in Warcraft. It has some advanced custom skills and a wide variety of heroes and items. To look up anything I mention from DotA, check out www.dota-allstars.com.
Table of Contents:
I. The Basics (tbsc)
II. Custom Passive Skills (cstmps)
III. Custom Auras (cstmar)
IV. Auto-Cast Attack Skills (acats)
V. Version History (vrhst)
The code provided in parenthesis next to the topic is a way to jump to the desired guide. Simply hit Ctrl + F and type in that code.
I. The Basics (tbsc)
This section contains links to guides explaining basic techniques you should already be familiar with before attempting anything cool. While they will not all pertain to my systems, they are definitely required knowledge for almost any good map.
Memory Leaks and Custom Scripts: http://www.thehelper.net/forums/showthread.php?t=27219&highlight=dummy+caster
Abilities Guide: http://www.thehelper.net/forums/showthread.php?t=44234
Icon Coordinate Reference: http://www.thehelper.net/forums/showthread.php?t=38305
Dummy Casters: http://www.thehelper.net/forums/showthread.php?t=26751
Makin’ Spellbooks: http://www.thehelper.net/forums/showthread.php?p=274236#post274236
II. Custom Passive Skills (cstmps)
What is a Custom Passive Skill? Well, it is just what the name says. It is a passive skill, like Bash or Critical Strike, that uses custom triggers to create the effects. This type of skill can range from a defensive skill, like the Faceless Void's Backtrack, to an offensive skill, the Twin-Headed Dragon's Autofire. In essence, a custom passive skill is basically a custom spell that automatically casts on a certain chance.
The first step towards your very own custom passive skill, as with anything, is the idea. What do you want it to do? For this guide, let's make a custom passive skill that causes the attacked unit to be frozen solid, as well as cause AoE damage to slow all nearby enemies. Let's call it "Frigid Strike".
The second step is to create a blank standard passive skill. What do I mean by blank? 'Blank' means a skill that does nothing, all of the values are set to zero and is basically just there to be the icon the user sees. So for our blank passive skill, let's take Bash (because there's only one value to worry about). Create a custom Bash and find and set the "Level n - Data - Chance to Bash: 0", where n is the number of levels this skill will have. Set the icon and the tool tip and everything to your liking.
Step 3: the triggered effects. Our effect has 2 phases. The AoE damage and slow and the freezing. The easiest way to achieve these effects is to utilize the pre-existing spells Frost Nova and Entangling Roots. For Frost Nova, the fields you need to worry about are “Stats – Level” (set it to the same n as Frigid Strike), all of the damage and area fields and the durations. As for Entangling Roots, you need to change the same basic fields; duration and damage, as well as “Stats – Buffs” to the buff you want to show on the unit being hit by Frigid Strike. You will also need to change the “Art – Target” for the buff to something more appropriate, such as “Freezing Breath <Target>”.
Now for the fun part: the trigger. The key to any custom passive skill is that they activate on a certain % chance. To achieve this simulation of a roll, we use “Math – Random Number”. After this, it is basically just making the dummy units for the spells and adding any extra damage or special effects. The event (as always) acts as the switch, the thing the trigger is looking for to go off. With passive skills, there are a few events you could use, the three most common being “A unit is attacked” (any sort of Bash or Critical Strike type skill), “A unit starts the effect of an ability” (for the Ogre Magi’s Multicast) and “A unit dies” (for the Necrolyte’s Sadist). For Frigid Strike, we will use the attack event. The conditions are used to make sure that the attacking unit actually has Frigid Strike, and that the target isn’t an ally you might be trying to deny (1). Then the actions, as explained above, create the actual effect of the skill.
Code:
Frigid Strike
Events
Unit - A unit Is attacked
Conditions
(Level of Frigid Strike for (Attacking unit)) Greater than 0
~ 1 ~((Owner of (Attacking unit)) is an enemy of (Owner of (Attacked unit))) Equal to True
(Random integer number between 1 and 1000) Less than or equal to (((Level of Frigid Strike for (Attacking unit)) x 2) + 100)
Actions
Set Unit_TemporaryPosition = (Position of (Attacking unit))
Unit - Create 1 Dummy for (Owner of (Attacking unit)) at Unit_TemporaryPosition facing Default building facing degrees
Unit - Hide (Last created unit)
Unit - Add Frigid Strike (Nova Effect) to (Last created unit)
Unit - Set level of Frigid Strike (Nova Effect) for (Last created unit) to (Level of Frigid Strike for (Attacking unit))
Unit - Order (Last created unit) to Undead Lich - Frost Nova (Attacked unit)
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
~ 2 ~ ((Attacked unit) has buff Frigid Strike ) Equal to False
Then - Actions
Unit - Create 1 Dummy for (Owner of (Attacking unit)) at Unit_TemporaryPosition facing Default building facing degrees
Unit - Hide (Last created unit)
Unit - Add Frigid Strike (Freeze Effect) to (Last created unit)
Unit - Set level of Frigid Strike (Freeze Effect) for (Last created unit) to (Level of Frigid Strike for (Attacking unit))
Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots (Attacked unit)
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Else - Actions
Custom script: call RemoveLocation (udg_Unit_TemporaryPosition)
1) Explained in the previous paragraph
2) The condition, as well as the entire If/Then/Else basically ensures the unit attacked isn’t still frozen from before. If you don’t want this, put all of the actions under the Frost Nova Effect and delete the If/Then/Else.
III. Custom Auras (cstmar)
Ah! A custom aura you say? Yes. There have been several requests for a method of making a custom aura, and guess what? Here it is. It’s somewhat more complex than most systems, but each step is a logical process (as always).
Custom auras can work for granting any kind of skill; including custom passive and actives (provided they are MUI). Custom auras giving passive skills work on the small “loophole” of spell books in that when they are disabled, they still provide passive effect yet are invisible. As for active skills, well you don’t want that invisible. I will do two examples, one for passive skills (using the Frigid Strike I just made above) and one for active skills. They’re almost identical, but let’s do it anyways!
So what will we need for a passive skill granting custom aura? Well, a spell book, the actual passive you want to give, and a blank aura. We want an aura granting the powerful Frigid Strike, so we’ll call it Frigid Essence. Base Frigid Essence off any old aura with a modified buff, range and art, and remember to set all effect fields to zero (I.E. the bonus mana regeneration if Brilliance Aura was used). We already have the passive skill Frigid Strike, so we need to put that into our custom spell book. The spell book only needs 1 level, whereas Frigid Essence and Frigid Strike should have the same number of levels. There’s one thing to keep in mind here, spell books only take item and unit abilities. So if the passive skill you are granting is a hero ability, you will need a second version of it, as well as a second trigger for the item / unit ability.
We have all of our objects needed; the next thing to do is create the variables. We will need six of them, and they are as follows.
If you’re wondering why I use “Z_” as a prefix, it’s just to keep all of the ability variables together in a row, as opposed to being all over the place. Remember, names of variables never matter, they just help the reader distinguish their use easier.
Now for the trigger. As I said, this one is a bit more complicated, and as such it will be broken down into steps and explained thoroughly. For the event, we will use a periodic one running every 3 seconds. Why so long? Well, if you notice that in-game, even standard auras will actually remain in effect for a brief amount of time after the unit moves outside the range of the aura. You can set the time period smaller, but it will just cause unnecessary strain (as little as it may be; I would suggest staying above 1 second) on the processor. So we have the following so far.
Code:
Events
Time - Every 3.00 seconds of game time
Code:
Actions
Set Z_FrigidEssence_Integer = 0
Set Z_FrigidEssence_UnitGroupSort = (Units in (Playable map area) matching ((Level of Frigid Essence (Brilliance Aura) for (Matching unit)) Greater than 0))
For each (Integer A) from 1 to (Number of units in Z_FrigidEssence_UnitGroupSort), do (Actions)
Loop - Actions
Set Z_FrigidEssence_Hero[(Integer A)] = (Random unit from Z_FrigidEssence_UnitGroupSort)
Set Z_FrigidEssence_HeroPosition[(Integer A)] = (Position of Z_FrigidEssence_Hero[(Integer A)])
Unit Group - Remove Z_FrigidEssence_Hero[(Integer A)] from Z_FrigidEssence_UnitGroupSort
Set Z_FrigidEssence_Integer = (Z_FrigidEssence_Integer + 1)
Custom script: call DestroyGroup(udg_Z_FrigidEssence_UnitGroupSort)
Part two of the trigger will actually grant Frigid Strike to everyone. This will be done in two phases. The first will give the ability to any unit entering the aura. The second phase will adjust the level of the ability, because Frigid Essence will be leveled. You don’t want to have to move every unit out of range (which will be impossible for the unit with the aura) and back in each level, right? The second phase will also increase the level of the granted ability incase a second unit with a better Frigid Essence comes by.
Code:
Actions
For each (Integer A) from 1 to Z_FrigidEssence_Integer, do (Actions)
Loop - Actions
Set Z_FrigidEssence_UnitGroup[(Integer A)] = (Units within 800.00 of Z_FrigidEssence_HeroPosition[(Integer A)])
Unit Group - Pick every unit in Z_FrigidEssence_UnitGroup[(Integer A)] and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) belongs to an ally of (Owner of Z_FrigidEssence_Hero[(Integer A)])) Equal to True
(Level of Frigid Essence’s FS (Spell Book) for (Picked unit)) Equal to 0
Then - Actions
Unit - Add Frigid Essence’s FS (Spell Book) to (Picked unit)
Unit - Set level of Frigid Strike for (Picked unit) to (Level of Frigid Essence (Brilliance Aura) for Z_FrigidEssence_Hero[(Integer A)])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If – Conditions
((Picked unit) belongs to an ally of (Owner of Z_FrigidEssence_Hero[(Integer A)])) Equal to True
(Level of Frigid Essence’s FS (Spell Book) for (Picked unit)) Less than (Level of Frigid Essence (Brilliance Aura) for Z_FrigidEssence_Hero[(Integer A)])
Then - Actions
Unit - Set level of Frigid Strike for (Picked unit) to (Level of Frigid Essence (Brilliance Aura) for Z_FrigidEssence_Hero[(Integer A)])
Else - Actions
Custom script: call RemoveLocation(udg_Z_FrigidEssence_HeroPosition[bj_forLoopAIndex])
If you thought that was it, then you’ve forgotten a key thing. What about the units that come in range and then leave? We need to take care of that. How? Easy. We basically take every unit in the entire map and make sure it isn’t in any of the Z_FrigidEssence_UnitGroup unit groups (I.E. the units that are still in range). Then we simply remove the spell book and clean up the unit groups and we’re done!
Code:
Actions
Set Z_FrigidEssence_Other[(Integer A)] = (Units in (Playable map area))
Unit Group - Pick every unit in Z_FrigidEssence_Other[(Integer A)] and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
And - All (Conditions) are true
Conditions
((Picked unit) belongs to an ally of (Owner of Z_FrigidEssence_Hero[(Integer A)])) Equal to False
((Picked unit) is in Z_FrigidEssence_UnitGroup[(Integer A)]) Equal to True
((Picked unit) is in Z_FrigidEssence_UnitGroup[(Integer A)]) Equal to False
Then - Actions
Unit - Remove Frigid Essence’s FS (Spell Book) from (Picked unit)
Else - Actions
Custom script: call DestroyGroup(udg_Z_FrigidEssence_UnitGroup[bj_forLoopAIndex])
Custom script: call DestroyGroup(udg_Z_FrigidEssence_Other[bj_forLoopAIndex])
Let’s take a look at the finished product, shall we? Ah, looks nice.
What’s that? The units in the aura have a spell book? Sounds like someone didn’t disable the book like I had said. No worries, the trigger is simple.
Code:
Disable Spell Books
Events
Map initialization
Conditions
Actions
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Player - Disable Frigid Essence's FS (Spell Book) for (Player((Integer A)))
IV. Auto-Cast Attack Skills (acats)
This next system is fairly simple, yet it is a common problem that had seemingly no solution. But fear not, I have one (trust me, it’s not that great)! So what’s an auto-cast attack skill? Well, anything that adds an orb effect, like Searing Arrows or Black Arrows, when set to auto-cast. When the skill is used normally, by clicking the icon and selecting the target, the effects will trigger on “A unit starts the effect of an ability” like normal. However, the problem is when you attack and the skill is on auto-cast, the event won’t trip.
Onto the solution. First thing we will need is a trigger-enhanced auto-cast attack skill. Continuing with my randomly chosen theme of ice skills, let’s make a Crystal Arrow skill that causes AoE damage and slow. Take any of the standard auto-cast attack skills and set the effect values to zero (unless you want bonus damage or slow or spawning a minion or etc); I will use Searing Arrows. Our effect will be, like for Frigid Strike, based on Frost Nova. Get the damage and duration just right and we’re off. Then we go into the Trigger Editor and make our standard trigger-enhanced spell for when it is manually cast.
Code:
Crystal Arrow
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Crystal Arrow
Actions
Set Unit_TemporaryPosition = (Position of (Triggering unit))
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Unit_TemporaryPosition facing Default building facing degrees
Unit - Hide (Last created unit)
Unit - Add Crystal Arrow (Nova Effect) to (Last created unit)
Unit - Set level of Crystal Arrow (Nova Effect) for (Last created unit) to (Level of Crystal Arrow for (Triggering unit))
Unit - Order (Last created unit) to Undead Lich - Frost Nova (Target unit of ability being cast)
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation (udg_Unit_TemporaryPosition)
Z_CrystalArrow_UnitGroup / Unit Group / -None-
For our event, we use “Unit - A unit Is issued an order with no target”, since you are merely right clicking the icon. We have no main condition, but we will have two in separate Ifs. The condition is an Order Comparison, and checks that the order given is turning on / off the auto-cast (a.k.a. flamingarrows / unflamingarrows). In the first If, where the auto-cast is being turned on, we add the unit to the Unit Group. The second If is just the opposite, it checks if you are turning off the auto-cast and takes it out of the Unit Group.
Code:
Set Autocast
Events
Unit - A unit Is issued an order with no target
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Issued order) Equal to (Order(flamingarrows))
Then - Actions
Unit Group - Add (Ordered unit) to Z_CrystalArrow_UnitGroup
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Issued order) Equal to (Order(unflamingarrows))
Then - Actions
Unit Group - Remove (Ordered unit) from Z_CrystalArrow_UnitGroup
Else - Actions
There is also one more issue we need to tackle (thanks to Tiber for bringing it up). What if the hero runs low on mana? The trigger will still run, but no mana will be subtracted. For this, we add a second unit group variable; because the skill is still on, so we don’t want to take them out of the original unit group.
Z_CrystalArrow_OutOfMana / Unit Group / -None-
This trigger is very similar to the ‘Set Autocast’ one, only it moves the units from that unit group to our new one based on their current mana. We use a periodic event, set very frequent since the mana pool is very dynamic. The pair of Ifs will move the units back and forth between the unit groups based on their current mana.
Code:
Autocast Out of Mana
Events
Time - Every 0.05 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in Z_CrystalArrow_UnitGroup and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana of (Picked unit)) Less than 8.00
Then - Actions
Unit Group - Add (Picked unit) to Z_CrystalArrow_OutOfMana
Unit Group - Remove (Picked unit) from Z_CrystalArrow_UnitGroup
Else - Actions
Unit Group - Pick every unit in Z_CrystalArrow_OutOfMana and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana of (Picked unit)) Greater than or equal to 8.00
Then - Actions
Unit Group - Add (Picked unit) to Z_CrystalArrow_UnitGroup
Unit Group - Remove (Picked unit) from Z_CrystalArrow_OutOfMana
Else – Actions
Code:
Unit Group - Remove (Ordered unit) from Z_CrystalArrow_OutOfMana
And remember, the ‘Set Autocast’ will work as a general trigger for all of you auto-cast attack skills, just add a pair of opposite Ifs that add / remove the unit to a skill-specific unit group.
V. Version History (vrhst)
Version 1.2
- Edited section IV to cover insufficient mana (thanks to Tiber).
Version 1.1
- Added section IV, Auto-Cast Attack Skills and the Version History.
Version 1.0
- First release. Contained sections I, II and III.