• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to issue orders to a certain type of unit?

Status
Not open for further replies.
Level 4
Joined
Dec 29, 2009
Messages
69
Hey guys just wondering, how do i make a trigger which issues an order to all units of a certain type to attack move to a unit when an enemy unit enters a region ? I tried using the issue order actions but they all require me to specify a unit. Any help would be appreciated. Thanks in advance :D
 
  • Trigger1
  • Events
    • Unit - A unit enters Region 000 <gen>
  • Conditions
    • ((Triggering unit) belongs to an enemy of (Player 1 (Red))) Equal to True
  • Actions
    • Set Temp_Point = (Position of (the unit you want attacked))
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units of type (unit-type here)) and do (Actions)
      • Loop - Actions
        • Unit - Order (Picked unit) to Attack-Move to (Temp_Point)
    • Custom script: call RemoveLocation (udg_Temp_Point)
 
Off topic: What's Custom script: set bj_wantDestroyGroup = true ?

It just makes it so that the group is destroyed after it is created. Basically, it will group the units and allow you to do the functions for those units, and then destroy the group. You can use either the Group - Destroy thing or bj_wantDestroyGroup.

Group - Destroy (or whatever the gui function is) is *technically* faster since bj_wantDestroyGroup leads to calling it anyway, but it doesn't really matter/make a noticeable difference.
 
Level 4
Joined
Dec 29, 2009
Messages
69
Ohh yeahh btw pharaoh how do i set temp_point to the location of the unit i want to be attacked?
 
Level 4
Joined
Dec 29, 2009
Messages
69
So the game will automatically assume this temp point is the position of the unit that's gonig to be attacked?
 
Level 4
Joined
Dec 29, 2009
Messages
69
Ohh okay sweet :D thanks dude and for the issuing order, can i do this
Unit Group - Pick every unit in (Units of type Orc Militia) and do (Unit - Order (Picked unit) to Attack-Move To TempPoint)
Instead of having another action underneath the pick every unit bit?
 
Level 4
Joined
Dec 29, 2009
Messages
69
The spawned units don't seem to understand the trigger, they don't move at all when they spawn xD

  • Orc militia attack
    • Events
      • Unit - A unit enters Attack region 2 <gen>
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units of type Orc Militia) and do (Unit - Order (Picked unit) to Attack-Move To TempPoint)
 
Yes, because you create them at the same time with the spawning trigger, from the other thread of yours. You must create them, add them in a Unit Group and do it like this:
e.g.
  • Trigger0
  • Actions
    • Set Temp_Point = (Random Point in (Region 000 <gen>))
    • For each (IntegerA) from 1 to 5, do (Actions)
      • Loop - Actions
        • Unit - Create 1 Orc Militia at Temp_Point for (Player 2 (Blue)) facing default building degrees
        • Unit Group - Add (Last created unit) to OrcMilitiaGroup
    • Custom script: call RemoveLocation (udg_Temp_Point)
and then, after the creation of all of them,
  • Unit Group - Order (OrcMilitiaGroup) to Attack - Move to (your point)
 
Level 4
Joined
Dec 29, 2009
Messages
69
I don't get this trigger, what was it meant to do? and what do i put for the do actions for the integer bit?
And also, the TempPoint is still set to the position of the triggering unit right? :p
 
Status
Not open for further replies.
Top