Tutorial Spell - Unit Dependant Self-Buff Ability

Ivach

New Member
Reaction score
18
Table of Contents
I.Introduction
II.Spell Concept
III.Making The Spell
IV.Advancing further
V.Conclusion

I.Introduction
Hi, and welcome to my tutorial. In this tutorial, you'll learn how to make an ability, either active or passive, which gives the hero bonus stats, armor, damage and etc depending on how many units are near him. The reason I've created this tutorial is that there aren't many abilities like these, and no other tutorial teaches something of this sort. Hopefully, this tutorial will spark that interest.

And yes, it's in GUI. So upon reading this tutorial, basic knowledge of GUI and the World Editor is highly recommended. But even if you have neither, I have tried to explain the triggers and stuff as in-depth and as understandable as possible.

None of the triggers below are leakless, or MUI for that matter.

II.Spell Concept
The spell is geared towards picking all units around the caster or skill owner and adding a bonus to the hero based on how many units were picked. But it doesn't end there, the possibilities and the customisation could be endless which I will explain later in the tutorial. But first, let's get down to the basic/core of the spell.

III.Making The Spell
Let's take a spell for example:

Code:
Legion Blade - Passive
A blade once used to lead armies to war. Hero gains +2 damage for each nearby unit in a 700 area of effect.

This is the most simplest spell I could think of. No complications and very straightforward. So let's start making the spell!

Firstly, create a new ability based off any aura, and name it Legion Blade or whatever you want. Set the tooltips, levels, icons to whatever fits your liking, and make sure to change any field that could give any effects to your hero that you don't want. Next, create another ability based off Item Damage Bonus, there's probably a dozen of them, but picking any one will do. It can be found under Special>Items.

Now let's get the ability ready for use. Since the effect of the spell has no limit, it's probably better to set the stats to as high as possible. Give the ability about 70-100 levels. Then, right click at the field "Level 1 - Data - Attack Bonus" and select auto fill levels.

tut2dg3.png


Once there, set the base value and constant factor to 2. This will cause the following level of the spells to be multiples of 2's and a constant rate, just perfect for the effect of the spell!

tut3ex8.png


Now onto the triggerwork. Make sure you have these variables.

LB_Skill_Owner = Unit Variable
LB_Timer = Timer Variable
LB_Picked_Units_Group = Unit Group Variable
LB_Picked_Units_No = Integer Variable

Code:
LB Learn
    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Legion Blade
    Actions
        Set LB_Skill_Owner = (Learning Hero)
        Trigger - Turn on LB Add Damage <gen>
        Countdown Timer - Start LB_Timer as a Repeating timer that will expire in 0.20 seconds

Now, basically what this does is that it detects if the hero has learned the ability. If it did, it will proceed with turning on the following trigger, and start a timer that will keep looping every 0.2 seconds.

Code:
LB Add Damage
    Events
        Time - LB_Timer expires
    Conditions
    Actions
        Unit - Remove Item Damage Bonus from LB_Skill_Owner
        Set LB_Picked_Units_Group = (Units within 700.00 of (Position of LB_Skill_Owner) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of FD_Skill_Owner)) Equal to True))))
        Set LB_Picked_Units_No = (Number of units in LB_Picked_Units_Group)

Once this detects that the timer has expired, it will first remove the existing Item Damage Bonus ability from the hero. Why? Because on the account that there are no units near the hero, we wouldn't want it to still have the ability. Next the trigger sets LB_Picked_Units_Group every unit within 700 range of the hero, matching a few conditions. The unit isn't a structure, the unit isn't dead and the unit isn't the hero himself. Then, the integer variable is equivalent to how many units are in the unit group.

Code:
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                LB_Picked_Units_No Greater than 0
            Then - Actions
                Unit - Add Item Damage Bonus to LB_Skill_Owner
            Else - Actions
        Unit - Set level of Item Damage Bonus for LB_Skill_Owner to LB_Picked_Units_No
        Unit Group - Remove all units of LB_Picked_Units_Group from LB_Picked_Units_Group
        Set LB_Picked_Units_No = 0

Next, an if/then/else statement. If the number of picked units is greater than 0, which is also at least 1, the ability will be added to the hero. After that, the level of the damage bonus will be set to equal to the number of units in the unit group. And we're done! The last 2 lines of triggers resets the variables so that they do not stack.

The entire code:

Code:
LB Learn
    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Legion Blade
    Actions
        Set LB_Skill_Owner = (Learning Hero)
        Trigger - Turn on FB Add Damage <gen>
        Countdown Timer - Start LB_Timer as a Repeating timer that will expire in 0.20 seconds

Code:
LB Add Damage
    Events
        Time - LB_Timer expires
    Conditions
    Actions
        Unit - Remove Item Damage Bonus from LB_Skill_Owner
        Set LB_Picked_Units_Group = (Units within 700.00 of (Position of LB_Skill_Owner) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of FD_Skill_Owner)) Equal to True))))
        Set LB_Picked_Units_No = (Number of units in LB_Picked_Units_Group)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                LB_Picked_Units_No Greater than 0
            Then - Actions
                Unit - Add Item Damage Bonus to LB_Skill_Owner
            Else - Actions
        Unit - Set level of Item Damage Bonus for LB_Skill_Owner to LB_Picked_Units_No
        Unit Group - Remove all units of LB_Picked_Units_Group from LB_Picked_Units_Group
        Set LB_Picked_Units_No = 0

IV.Advancing Further
Now that you're familiar with how it works, how about making the spell more complex? The possibilities are endless! To name a few:

-Making it an ability that can be leveled.
-Affect only certain classes of units.
-Doubling/Tripling the bonus gained if unit is under a certain condition.
-Setting a limit to the bonus that can be gained.
-Making it an active ability.

Again, I'll be using an example spell to show you how to implement those features.

Code:
Frigid Damsel - Active
Originally born with a skin as cold as ice itself, her uncanny relation to the cold allows Ayana to absorb the essence from nearby enemy units, giving her a bonus of 1 to her Agility or a bonus of 2 if they are frozen. Lasts 25 seconds. Does not affect the undead. 
Level 1 - Max of 20 Agility
Level 2 - Max of 30 Agility
Level 3 - Max of 40 Agility

Again, you will need 2 abilities. One is the actual ability, which can be based off channel. The mana cost, cooldown and anything is up to you. Another would be the bonuses gained by the heroes. This time, as we want to give bonus agility, we'll use the skill "Attribute Bonus". Give it 40 levels this time. With the agility bonus starting with 1, and ending with 40. Set both the strength and intelligence bonuses to 0. I assume you would already have know how to use the auto-fill levels feature to do this quickly.

Now let's start!

Variables Needed:

FD_Caster = Unit Variable
FD_Agility_Max = Integer Variable
FD_Frozen_Unit_No = Integer Variable
FD_Normal_Unit_No = Integer Variable
FD_Both_Unit_No = Integer Variable
FD_Frozen_Unit_Group = Unit Group Variable
FD_Normal_Unit_Group = Unit Group Variable
FD_Timer = Timer Variable

Code:
FD Init
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Frigid Damsel 
    Actions
        Set FD_Caster= (Triggering unit)
        Trigger - Turn on FD Add Agility <gen>
        Set FD_Agility_Max = (10 + (10 x (Level of Frigid Damsel  for FD_Skill_Owner)))
        Countdown Timer - Start FD_Timer as a Repeating timer that will expire in 0.20 seconds
        Wait 25.00 seconds
        Trigger - Turn off FD Add Agility <gen>
        Unit - Remove Agility Bonus (Frigid Damsel) from FD_Caster
        Countdown Timer - Pause FD_Timer

Pretty much the same as the last one, with a few exceptions. This time it detects whether the unit has casted the spell or not. Also, it sets the maximum amount of agility that the hero can gain. After that, it waits 25 seconds, which is also the duration of the spell, and stops everything. The ability is removed because if it doesn't, the hero will have the buff on him permanently.

Now onto the main part of the triggers.

Code:
FD Add Agility
    Events
        Time - FD_Timer expires
    Conditions
    Actions
        Unit - Remove Agility Bonus (Frigid Damsel) from FD_Caster
        Unit Group - Pick every unit in (Units within 800.00 of (Position of FD_Caster) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of FD_Caster)) Equal to True) and (((Matching unit) is Undead) Equal to False) and do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Picked unit) has buff Frozen ) Equal to True
            Then - Actions
                Unit Group - Add (Picked unit) to FD_Frozen_Units_Group
            Else - Actions
                Unit Group - Add (Picked unit) to FD_Normal_Unit_Group
        Set FD_Frozen_Unit_No = ((Number of units in FD_Frozen_Units_Group) x 2)
        Set FD_Normal_Unit_No = (Number of units in FD_Normal_Unit_Group)
        Set FD_Both_No = (FD_Frozen_Unit_No + FD_Normal_Unit_No)

Again, it is sort of similiar to the code before, First it removes the bonus ability, for reasons which I have stated earlier. Then it picks every unit within 800 range from the hero matching conditions. This time there are 2 extra conditions. One is that it only picks enemies of the hero, and another is that if that unit isn't an undead. Those 2 are not compulsary to have. It really depends on who you want your spell to affect. Thus, reading the spells description, this is exactly what I want.

Once it does that, it goes through another condition. Of whether or not the unit has the buff "Frozen" or not. If it does, the unit is added to "FD_Frozen_Unit_Group". If it doesn't, it is added to "FD_Normal_Unit_Group". The next 3 actions are pretty much the same. The first 2 counts the number of units in the unit group and stores them to the integer variable. Note that the first one is multiplied by 2. Remember the spell effect? Frozen units give twice the bonus. After that's done, the 2 integers are totaled up as "FD_Both_No".


Code:
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                FD_Both_No Greater than 0
            Then - Actions
                Unit - Add Agility Bonus (Frigid Damsel) to FD_Caster
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                FD_Both_No Greater than FD_Agility_Max
            Then - Actions
                Unit - Set level of Agility Bonus (Frigid Damsel) for FD_Skill_Owner to FD_Agility_Max
            Else - Actions
                Unit - Set level of Agility Bonus (Frigid Damsel) for FD_Skill_Owner to FD_Both_No
        Unit Group - Remove all units of FD_Frozen_Units_Group from FD_Frozen_Units_Group
        Unit Group - Remove all units of FD_Normal_Unit_Group from FD_Normal_Unit_Group
        Set FD_Frozen_Unit_No = 0
        Set FD_Normal_Unit_No = 0
        Set FD_Both_No = 0

Pretty much the same old thing. It detects if both of the integers are greater than 0, then adds the ability "Attribute bonus" which I have renamed to "Agility Bonus (Frigid Damsel). The next part is important. It detects if the total is greater than the maximum bonus of agility. If it is, then the level of ability will be set equal to the integer variable "FD_Agility_Max". If it isn't, well you get the idea..

The rest of the trigger basically just removes everything and resets the variables.

Once that's done, you have your ability! Here's the full code:

Code:
FD Init
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Frigid Damsel 
    Actions
        Set FD_Caster= (Triggering unit)
        Trigger - Turn on FD Add Agility <gen>
        Set FD_Agility_Max = (10 + (10 x (Level of Frigid Damsel  for FD_Skill_Owner)))
        Countdown Timer - Start FD_Timer as a Repeating timer that will expire in 0.20 seconds
        Wait 25.00 seconds
        Trigger - Turn off FD Add Agility <gen>
        Countdown Timer - Pause FD_Timer


Code:
FD Add Agility
    Events
        Time - FD_Timer expires
    Conditions
    Actions
        Unit - Remove Agility Bonus (Frigid Damsel) from FD_Caster
        Unit Group - Pick every unit in (Units within 800.00 of (Position of FD_Caster) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of FD_Caster)) Equal to True) and (((Matching unit) is Undead) Equal to False) and do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Picked unit) has buff Frozen ) Equal to True
            Then - Actions
                Unit Group - Add (Picked unit) to FD_Frozen_Units_Group
            Else - Actions
                Unit Group - Add (Picked unit) to FD_Normal_Unit_Group
        Set FD_Frozen_Unit_No = ((Number of units in FD_Frozen_Units_Group) x 2)
        Set FD_Normal_Unit_No = (Number of units in FD_Normal_Unit_Group)
        Set FD_Both_No = (FD_Frozen_Unit_No + FD_Normal_Unit_No)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                FD_Both_No Greater than 0
            Then - Actions
                Unit - Add Agility Bonus (Frigid Damsel) to FD_Caster
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                FD_Both_No Greater than FD_Agility_Max
            Then - Actions
                Unit - Set level of Agility Bonus (Frigid Damsel) for FD_Skill_Owner to FD_Agility_Max
            Else - Actions
                Unit - Set level of Agility Bonus (Frigid Damsel) for FD_Skill_Owner to FD_Both_No
        Unit Group - Remove all units of FD_Frozen_Units_Group from FD_Frozen_Units_Group
        Unit Group - Remove all units of FD_Normal_Unit_Group from FD_Normal_Unit_Group
        Set FD_Frozen_Unit_No = 0
        Set FD_Normal_Unit_No = 0
        Set FD_Both_No = 0

V.Conclusion
And that's the end of my tutorial. I hope this tutorial was helpful to you in some way. Furthermore, don't be afraid to experiment and create a spell with complex effects. The sky is the limit!

Here's the demo map.
 

Attachments

  • Demo Map - Ivach's Tutorial.w3x
    13.4 KB · Views: 186

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
Code:
LB Add Damage
    Events
        Time - LB_Timer expires
    Conditions
    Actions
        Unit - Remove Item Damage Bonus from LB_Skill_Owner
        [B]Unit Group - Pick every unit in (Units within 700.00 of (Position of LB_Skill_Owner) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of FD_Skill_Owner)) Equal to True)))) and do (Actions)[/B]
            Loop - Actions
                    Unit Group - Add (Picked unit) to LB_Picked_Units_Group
        Set LB_Picked_Units_No = (Number of units in LB_Picked_Units_Group)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                LB_Picked_Units_No Greater than 0
            Then - Actions
                Unit - Add Item Damage Bonus to LB_Skill_Owner
            Else - Actions
        Unit - Set level of Item Damage Bonus for LB_Skill_Owner to LB_Picked_Units_No
        Unit Group - Remove all units of LB_Picked_Units_Group from LB_Picked_Units_Group
        Set LB_Picked_Units_No = 0

The bolded part above leaks.
The code above can be shortened, see below :

Code:
LB Add Damage
    Events
        Time - LB_Timer expires
    Conditions
    Actions
        Unit - Remove Item Damage Bonus from LB_Skill_Owner
        [B]Set LB_Picked_Units_Group = (Units within 700.00 of (Position of LB_Skill_Owner) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of FD_Skill_Owner)) Equal to True))))[/B]
        Set LB_Picked_Units_No = (Number of units in LB_Picked_Units_Group)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                LB_Picked_Units_No Greater than 0
            Then - Actions
                Unit - Add Item Damage Bonus to LB_Skill_Owner
            Else - Actions
        Unit - Set level of Item Damage Bonus for LB_Skill_Owner to LB_Picked_Units_No
        Unit Group - Remove all units of LB_Picked_Units_Group from LB_Picked_Units_Group
        Set LB_Picked_Units_No = 0
 

garion992

TH.net Regular
Reaction score
17
A very nice and original idear, it works well, a bit laggy, but you said that already.
Very nice if the units unfreeze your agility halves and if a unit dies it get's -1, if frozen unit dies -2.
Very nice +rep
 

Ivach

New Member
Reaction score
18
The bolded part above leaks.
The code above can be shortened, see below :

Thank you. Edited.
A very nice and original idear, it works well, a bit laggy, but you said that already.
Very nice if the units unfreeze your agility halves and if a unit dies it get's -1, if frozen unit dies -2.
Very nice +rep

Thank you. Glad you liked it. I don't quite get what you are trying to say though. What do you mean by:
Very nice if the units unfreeze your agility halves and if a unit dies it get's -1, if frozen unit dies -2.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top