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

how to keep a created unit on their track?

Status
Not open for further replies.
Level 1
Joined
Aug 8, 2023
Messages
1
Salutations,

So i'm kinda new to this stuffs, editing the map and creating bunch of commands. I have a question regarding creating an issue, so i have created actions which creating some units then giving an order to attack to some certain area and some of the unit are able to cast a spell but after they cast the spell they will return to their first exact position they were created, not resuming their advance to the point i've been created.
So how to keep these units with spells, keep advancing on the targetted area?
Thanks
Capture.PNG
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,869
Hello, here's how you can post your triggers on Hiveworkshop:
It makes everyone's life easier when you do it like this :D

Anyway, this is the lazy but simple method:
  • Events
    • Unit - A unit Stops casting an ability
  • Conditions
    • (Owner of (Triggering unit)) Equal to Player 7 (Green)
  • Actions
    • Unit - Order (Triggering unit) to Attack-Move To (Center of Region 001 <gen>)
This is a step above that since it gives you greater control:
  • Events
    • Unit - A unit Stops casting an ability
  • Conditions
    • ((Triggering unit) is in YourUnitGroupVariable) Equal to True
  • Actions
    • Unit - Order (Triggering unit) to Attack-Move To (Center of Region 001 <gen>)
YourUnitGroupVariable is a Unit Group variable that you would create in the Variable Editor. Then you would Add your created units to it like so:
  • Unit - Create 2 Bloodfiend for Player 7 (Green)...
  • Unit Group - Add (Last created unit group) to YourUnitGroupVariable

A proper method involves more advanced techniques. A Unit Indexer system comes to mind which allows you to store data directly to your units. With that you could always know where your units should be going at all times by storing their "destination" and referencing it whenever the units lose focus.

People also like to use the Periodic Interval event which lets you run Actions once every X seconds. This allows you to periodically order your units to attack towards the Region. Again, you would want to use a Unit Group variable here so you can keep track of the units and reference them in other triggers:
  • Untitled Trigger 001
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in YourUnitGroupVariable and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To (Center of Region 001 <gen>)
Just don't forget that dead units aren't automatically removed from a Unit Group. That job is up to you!
  • Events
    • Unit - A unit dies
  • Conditions
    • (Owner of (Triggering unit)) Equal to Player 7 (Green)
  • Actions
    • Unit Group - Remove (Triggering unit) from YourUnitGroupVariable
This can help prevent bugs and keep your map running smooth! Ordering a dead unit to attack-move somewhere won't break the game but it's not ideal.
 
Last edited:
Status
Not open for further replies.
Top