• 🏆 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 Help

Status
Not open for further replies.
Level 2
Joined
Dec 12, 2021
Messages
6
Hi,

I've played a few maps from the creators on Hive, and some have a function (think It's a trigger) which allows you to send all units via attack move. I searched the forums a bit and can't find exactly what I am looking for.

Basically, I'm getting a bit tired of having to assign control groups, select hot keys, etc. I mainly play Custom Games and would love the ability to just mass-attack send my units in a single click rather than all the hot keys. I have seen people do it with JASS by assigning an ability to a building that is castable at any location like the "Attack Move" ability, and it sends all the military-type units to wherever you select... but I am not experienced enough to do it myself. I would be seriously grateful if someone could help me achieve this ability.

I would need this ability to function on Human's "Castle", Undead's "Black Citadel", Night Elves' 'Tree of Eternity" & Orc's Fortress buildings so that I can play any of the 4 original races & be able to make combat-life a little easier by attack-move all units.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
It would have to be a trigger as no such function exists otherwise. This would need to be done on a per map basis, so you'll have to add the trigger and the ability that executes it to each map that you wish to use it in. Luckily, this is a fairly easy thing to setup.

First, find the Channel ability in the Object Editor, copy and paste it, and edit this new copy. This is an ability designed for creating custom spells as it has no actual effects. It needs the following settings:

Follow Through Time: 0.00
Disables Other Abilities: False
Options: Visible
Cast Range: 99999
Mana Cost: 0
Target Type: Point
Hero Ability: False
Levels: 1
Name: Whatever you want to name it, I called it Mass Attack

You can customize the Art as well, either deleting or changing the special effects to something else.

Then you need to go into the Trigger Editor and create a new trigger like this:
  • Mass Attack Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mass Attack
    • Actions
      • Set VariableSet MA_Point = (Target point of ability being cast)
      • Set VariableSet MA_Group = (Units owned by (Triggering player).)
      • Unit Group - Pick every unit in MA_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet MA_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (MA_Unit is A structure) Equal to False
              • (MA_Unit is A peon-type unit) Equal to False
              • (MA_Unit is alive) Equal to True
            • Then - Actions
              • Unit - Order MA_Unit to Attack-Move To MA_Point
            • Else - Actions
      • Custom script: call RemoveLocation(udg_MA_Point)
      • Custom script: call DestroyGroup(udg_MA_Group)
Three variables are being used here, MA_Point, MA_Group, and MA_Unit, which need to be created by you as well. Press (Control + B) to open the Variable Editor where you can create them. Make sure they have the appropriate name and type, MA_Point = Point, MA_Group = Unit Group, MA_Unit = Unit.

Last but not least, make sure to actually Add the Mass Attack ability to your Town Hall structures inside of the Object Editor.

Now any unit with the Mass Attack ability can order it's army to attack any point in the map.

I attached a map with this already setup for you which should makes things easier. You'll want to copy and paste the ability to your other map and then the trigger. It requires the latest patch to open.
 

Attachments

  • Mass Attack 1.w3m
    18.8 KB · Views: 4
Last edited:
Level 2
Joined
Dec 12, 2021
Messages
6
It would have to be a trigger as no such function exists otherwise. This would need to be done on a per map basis, so you'll have to add the trigger(s) to each map that you wish to use it in. Luckily, this is a fairly easy thing to setup.

First, find the Channel ability in the Object Editor, copy and paste it, and edit this new copy. This is an ability designed for creating custom spells as it has no actual effects but gives you many customizable options. It needs the following settings:

Follow Through Time: 0.00
Disables Other Abilities: False
Options: Visible
Cast Range: 99999
Mana Cost: 0
Target Type: Point
Hero Ability: False
Levels: 1
Name: Whatever you want to name it, I called it Mass Attack

You can customize the Art as well, either deleting or changing the special effects to something else.

Then you need to go into the Trigger Editor and create a new trigger like this:
  • Mass Attack Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mass Attack
    • Actions
      • Set VariableSet MA_Point = (Target point of ability being cast)
      • Set VariableSet MA_Group = (Units owned by (Triggering player).)
      • Unit Group - Pick every unit in MA_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet MA_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (MA_Unit is A structure) Equal to False
              • (MA_Unit is A peon-type unit) Equal to False
              • (MA_Unit is alive) Equal to True
            • Then - Actions
              • Unit - Order MA_Unit to Attack-Move To MA_Point
            • Else - Actions
      • Custom script: call RemoveLocation(udg_MA_Point)
      • Custom script: call DestroyGroup(udg_MA_Group)
Three variables are being used here, MA_Point, MA_Group, and MA_Unit, which need to be created by you as well. Press (Control + B) to open the Variable Editor where you can create them. Make sure they have the appropriate name and type, MA_Point = Point, MA_Group = Unit Group, MA_Unit = Unit.

Now any unit with the Mass Attack ability can send orders to it's owners army to attack anywhere. Speaking of which, make sure to actually Add the ability to your Town Hall structures inside of the Object Editor.

I attached a map with this already setup for you which should makes things easier. You'll want to copy and paste the ability to your other map and then the trigger. It requires the latest patch to open.
Thank you so much for the help, Uncle. I will give this a shot with the map I use (Raging Stream & Divide and Conquer) and see if I can mimic that. I really appreciate you taking the time to help. It's great to be a part of the community here.
 
Level 2
Joined
Dec 12, 2021
Messages
6
Hi again Uncle,

I mirrored the best I can to match what you suggested, and initially the mass-attack command works, but only if I don't give the specific unit an individual order afterwards.

For example, I had amassed around 80 Footman... casting the ability "Mass Attack" via "Town Hall" initially worked- sent them all to the point, but the game became a bit laggy (usually doesn't happen when I use the group hotkey assignments (C1, C2, C3 per 12-group basis), not sure if that's normal due to the number of units being commanded simultaneously. The issue I'm having is that if I give the units an order (say just highlight a random group of 12 and move them manually to a point without the mass attack ability), then when I cast the Mass Attack Ability, every other unit I didn't give a previous order to (e.g newly created units) will take the command but the ones I gave an order to simply won't respond to the Mass Attack.

TLDR; Basically, newly created units which haven't received any commands will respond to Mass-Attack, and Units that I manually gave an order to before using Mass-Attack will not respond to Mass-Attack command ability. I am not 100% sure why that is.

Edit: Now the ability will not command any units after the first initial mass-attack cast. I sent all of my units the first time around to attack a base, they successfully responded and completed the order, all of them later died---but now any unit I create new or existing, will simply not respond to the Mass-Attack command via Town Hall. Again, I am unsure why the command would do that mid-game. Any Idea?

I'll upload an attachment image of the group of units responding, and then the two Knights that just simply wont respond.
 

Attachments

  • c3fg1.png
    c3fg1.png
    7.3 MB · Views: 10
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
With a lot of units you may notice a performance dip for a split second.

But I'd have to see your trigger to really narrow it down.

There's another issue with Warcraft 3 that occurs when you issue orders to too many units owned by the same player via triggers. This issue is often a common occurrence in TD maps where a lot of units spawn at once, and the solution is often to split the units ownership up so that they're owned by different players. Also, turning off collision size or lowering collision size apparently helps as well, although in your case I don't think either of these is a viable option.

Anyway, I attached a second version of the map that may work better. I split the units up into groups of 12 instead of one massive unit group. Then I used the Unit Group version of the Issue Order Targeting A Point action which will issue an order to up to 12 units at a time. I was hoping that splitting it up like this would help but it might not make a difference.
 

Attachments

  • Mass Attack 2.w3m
    18.3 KB · Views: 1
Last edited:
Level 2
Joined
Dec 12, 2021
Messages
6
  • Mass Attack Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mass Attack
    • Actions
      • Set VariableSet MA_Point = (Target point of ability being cast)
      • Set VariableSet MA_Group = (Units owned by (Triggering player).)
      • Unit Group - Pick every unit in MA_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet MA_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (MA_Unit is A structure) Equal to False
              • (MA_Unit is A peon-type unit) Equal to False
              • (MA_Unit is alive) Equal to True
            • Then - Actions
              • Unit - Order MA_Unit to Attack-Move To MA_Point
            • Else - Actions
              • Custom script: call RemoveLocation(udg_MA_Point)
              • Custom script: call DestroyGroup(udg_MA_Group)
I appreciate your patience; I'm learning as I go here. Thanks for that Trigger-Post tutorial - lol otherwise it would have been a messy post.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
So you made a mistake with your Custom script actions. They're not supposed to be in the Else - Actions section of the If Then Else statement, they're instead supposed to be AFTER the If Then Else statement. Note the difference between our two triggers, it's hard to catch at first.

You can open my example map and literally copy the trigger I made and then open your desired map from the same editor and paste it there. It will automatically create the necessary variables and everything you need. Also, make sure your map has JassHelper enabled inside of the Trigger Editor or else you may get an error. You can do this with other things than just triggers as well.
 
Last edited:
Level 2
Joined
Dec 12, 2021
Messages
6
So you made a mistake with your Custom script actions. They're not supposed to be in the Else - Actions section of the If Then Else statement, they're instead supposed to be AFTER the If Then Else statement. Note the difference between our two triggers, it's hard to catch at first.

You can open my example map and literally copy the trigger I made and then open your desired map from the same editor and paste it there. It will automatically create the necessary variables and everything you need. Also, make sure your map has JassHelper enabled inside of the Trigger Editor or else you may get an error. You can do this with other things than just triggers as well.
I just re-verified the trigger you helped me create and also noticed the mistake- I decided to try to fix it instead of copy-paste because I am trying to learn myself. It's now working as intended and without issue. I didn't realize I placed the scripts in the wrong spot, but the game also does not lag at all either, even with 80+ units. I do appreciate your time and help in making this for me. Thanks again Uncle,
 
Status
Not open for further replies.
Top