• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] Group Unit Trigger

Status
Not open for further replies.
Level 2
Joined
Apr 2, 2011
Messages
17
I'm working on a skill that will pick every unit in a group and do actions, but it's not working as it was writen for. There is a good time I don't play with triggers, but it feels so strange, so I would like some help. So, if you can spare some time I will be grateful.

The trigger is the following:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Frost Nova
  • Actions
    • Sound - Play Mage_FrostNova_Cast_1 <gen> at 100.00% volume, attached to (Casting unit)
    • Unit Group - Add all units of (Units within 500.00 of (Position of (Casting unit)) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is dead) Equal to False) and (((Matching unit) belongs to an enemy to FrostNova
    • Unit Group - Pick every unit in FrostNova and do (Actions)
      • Loop - Actions
        • Unit - Create 1 Dummy for (Owner of (Casting unit)) at (Position of (Picked unit)) facing Default building facing degrees
        • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        • Unit - Add FrostNovaDummy to (Last created unit)
        • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
        • Unit - Cause (Casting unit) to damage (Picked unit), dealing ((((Real((Strength of (Casting unit) (Include bonuses)))) + (Real((Agility of (Casting unit) (Include bonuses))))) x 1.00) + ((Real((Intelligence of (Casting unit) (Include bonuses)))) x 2.00)) damage of attack type Spells and damage type Cold
    • Unit Group - Remove all units from FrostNova
My problem is: when it should create 1 specified unit for each unit in the group and do the actions for each unit, it is creating only one for the whole group. What am I missing?
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
There are a lot of other issues that need to be fixed such as leaks and redundancy, but to stay on topic, let's start with your problem.

My initial guess as to why this won't work is because something is wrong with the filters. Unfortunately, you chose the horrendous (Matching unit) function to filter out units, which cuts off at a certain point in trigger tags as you can see in your post. That is actually one of three reasons as to why I prefer to filter units like this, rather than that. I suggest you take a read through it and try to implement it here.

To get back to the problem, the filter that stands out to me unfortunately is cut off, but I would like to know what variable is here: (Matching unit) belongs to an enemy to FrostNova... I ask because I don't see you storing variables anywhere, which would be a problem. To help out, you should also print out a message that displays how many units are in the FrostNova group.
 
Level 2
Joined
Apr 2, 2011
Messages
17
There are a lot of other issues that need to be fixed such as leaks and redundancy, but to stay on topic, let's start with your problem.

My initial guess as to why this won't work is because something is wrong with the filters. Unfortunately, you chose the horrendous (Matching unit) function to filter out units, which cuts off at a certain point in trigger tags as you can see in your post. That is actually one of three reasons as to why I prefer to filter units like this, rather than that. I suggest you take a read through it and try to implement it here.

To get back to the problem, the filter that stands out to me unfortunately is cut off, but I would like to know what variable is here: (Matching unit) belongs to an enemy to FrostNova... I ask because I don't see you storing variables anywhere, which would be a problem. To help out, you should also print out a message that displays how many units are in the FrostNova group.

Thank you both for the answers.

After some tries, I found out that "Casting Unit" in the group loop should be "Triggering Unit". I have checked the group orders with a game - chat command and it was displaying the correctly number of units, though not casting spells on all of them.

The result is:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Frost Nova [W]
  • Actions
    • Set Damage = ((((Real((Strength of (Casting unit) (Include bonuses)))) x 1.00) + ((Real((Agility of (Casting unit) (Include bonuses)))) x 1.00)) + ((Real((Intelligence of (Casting unit) (Include bonuses)))) x 2.00))
    • Sound - Play Mage_FrostNova_Cast_1 <gen> at 100.00% volume, attached to (Casting unit)
    • Set FrostNova = (Units within 375.00 of (Position of (Casting unit)) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is dead) Equal to False) and (((Matching unit) belongs to an enemy
    • Unit Group - Pick every unit in FrostNova and do (Actions)
      • Loop - Actions
        • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Picked unit)) facing Default building facing degrees
        • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        • Unit - Add FreezingDummy to (Last created unit)
        • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
        • Unit - Cause (Triggering unit) to damage (Picked unit), dealing Damage damage of attack type Spells and damage type Cold
    • Custom script: call DestroyGroup(udg_FrostNova)
About leaks, I don't have a good idea of this, as I never really worried about it before, but it was always a issue in my maps. For now I'm following this thread: Things That Leak
But it's nice to get advices directly, so feel free to comment any leak-reduction tip if you can.

Unfortunately, you chose the horrendous (Matching unit) function to filter out units, which cuts off at a certain point in trigger tags as you can see in your post. That is actually one of three reasons as to why I prefer to filter units like this, rather than that.

God! I made it like you did at the first time, but I thought it would be the reason for the malfunction. That's really better for many conditions.
 
We still can not see the whole code:

To get back to the problem, the filter that stands out to me unfortunately is cut off, but I would like to know what variable is here: (Matching unit) belongs to an enemy to FrostNova... I ask because I don't see you storing variables anywhere, which would be a problem. To help out, you should also print out a message that displays how many units are in the FrostNova group.
 
Status
Not open for further replies.
Top