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

[Trigger] Level ability of unit

Status
Not open for further replies.
Level 5
Joined
Jan 5, 2012
Messages
116
I'm making a Land Mine spell based off Goblin land mine and I have given levels to "AOE damage upon death (Goblin Mine)" unit ability which the Land mine summoned unit uses. So I want the unit ability to level up when the hero ability land mine levels up. I know I can make different land mine units with different leveled abilities but I wanted to try this with triggers.

  • Land Mine
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Land Mine
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Land Mine for (Triggering unit)) Equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in (Units of type Land Mine) and do (Unit - Set level of AOE damage upon death (Goblin Mine) for (Picked unit) to 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Land Mine for (Triggering unit)) Equal to 2
            • Then - Actions
              • Unit Group - Pick every unit in (Units of type Land Mine) and do (Unit - Set level of AOE damage upon death (Goblin Mine) for (Picked unit) to 2)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Land Mine for (Triggering unit)) Equal to 3
                • Then - Actions
                  • Unit Group - Pick every unit in (Units of type Land Mine) and do (Unit - Set level of AOE damage upon death (Goblin Mine) for (Picked unit) to 3)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Land Mine for (Triggering unit)) Equal to 4
                    • Then - Actions
                      • Unit Group - Pick every unit in (Units of type Land Mine) and do (Unit - Set level of AOE damage upon death (Goblin Mine) for (Picked unit) to 4)
                    • Else - Actions
                      • Do nothing
Does this trigger apply to the land mine as it is summoned by the ability? Or will they still have the level 1 ability?
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Unfortunately, no. The event you're using obviously neglects your wanted mechanics and it may only work in cases where the hero selects this ability to learn and only level up the abilities of the current summoned units in the map for this instance only.

You also leak unit groups and filtering is bad here. Always ensure you're not picking units that are dead and pick caster owned units, both boolean conditions. To remove such unit group leaks here I suggest using this;

  • Custom Script: set bj_wantDestroyGroup = true
Make sure you always put this line at the top or before of each 'Pick every unit action' if the group is not referencing such variable (if it does, you may use the DestroyGroup function instead after on each 'Pick every unit action' line and properly destroy the referenced group)

For filtering units, you may use 'Pick every unit and do multiple actions' and put the boolean conditions inside for a much cleaner way.

As I've stated before, you must use an appropriate event for this so we can ensure it will work properly. Fortunately, we have this kind of resource to handle the event for you; GUI Unit Event v2.5.2.0 make sure to properly read its documentation part.

If you're avoiding the easy way then I can provide you some workarounds here;

#1
(Untested)
Use unit starts the effect or finish the effect of an ability event, set the ability being cast equal to your Land Mine ability condition then enumerate units using a unit group and set the certain levels you wishes to. To prevent picking units that are summoned before and gain such level again then you may store the units into another unit group that acts as a container and remove if a unit belongs to that group dies.

#2
(Should work but not MUI)
If the event doesn't work for catching the summoned units at the appropriate unit creation time (unless you use waits which are not recommended but if you intended to do so then it may work) use a periodic timer event instead with an interval of 1. Of course you won't need an ability cast condition for this and jump instantly into the enumeration part. The downside of this if you were using a multiple casters to cast the same spell. It may only pick one of the casters to check the ability level and set the level for all the existing summoned units of your desired type even they're not the summoners of these units. In other words, not MUI.

#3
(Should work perfectly and safe)
Code the whole spell and guarantee it's MUI.
This works as a replacement for the editor's summoning ability so that you can manipulate the summoner and the summoned units completely in any part of the spell.
 
Level 5
Joined
Jan 5, 2012
Messages
116
Thanks for the great suggestions. The GUI Unit event tool seems interesting I'll look into it. I was looking for a way other than coding the whole spell, I'm not that good with spell-making. I'll probably go the object editor way since it seems easier to me to just create new units with the leveled ability.
 
Status
Not open for further replies.
Top