• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Making units spawn and attack-move script

Status
Not open for further replies.
Level 2
Joined
Apr 12, 2016
Messages
12
Hi. I'm trying to make a custom map and I'm currently struggling with scripting. I'm very new to using the editor and I've been trying to make a group of units Attack-Move to a certain location. I was able to make the units spawn when entering the region, but they won't move-attack at all unless my units get within their range.
Here's my script
  • Unit spawn 2
    • Events
      • Unidad - A unit enters HeroArrives <gen>
    • Conditions
      • ((Triggering unit) is Un héroe) Igual a True
    • Acciones
      • Detonador - Turn off (This trigger)
      • Unidad - Order (Last created unit) to Atacar-mover a (Center of HeroArrives <gen>)
      • Unidad - Create 2 Myrmidon naga for Jugador 2 (azul) at (Center of Naga Spawn <gen>) facing (Position of (Triggering unit))
Any help is welcome :peasant-victory:
 
There is no "last created unit" here. That variable (yes it is an internal variable) is only set when using the Unit - Create action. Use Triggering Unit. I don't think you should be turning off the trigger either, but it's not clear what exactly you are trying to do.
 
There is no "last created unit" here. That variable (yes it is an internal variable) is only set when using the Unit - Create action. Use Triggering Unit. I don't think you should be turning off the trigger either, but it's not clear what exactly you are trying to do.
I want them to spawn only once and then Attack-Move an area.
 
Last edited:
UPDATE: I figured it out. I used Triggering Unit with the enemy units and they finally attacked.
  • Undead spawn
    • Events
      • Unit - A unit enters UndeadTrigger <gen>
    • Conditions
      • (Owner of (Triggering unit)) Igual a Jugador 1 (rojo)
      • ((Triggering unit) is Un héroe) Igual a True
    • Actions
      • Unit - Create 11 Zombi for Player 4 (purple) at (Center of UndeadSpawn <gen>) facing (Position of (Triggering unit))
      • Trigger - Turn off (This trigger)
  • Undead movement
    • Events
      • Unit - A unit enters UndeadSpawn <gen>
    • Conditions
      • ((Triggering unit) is Muerto viviente) Igual a True
    • Actions
      • Unit - Order (Triggering unit) to Atacar-mover a (Center of UndeadTrigger <gen>)
 
My reply was incorrect because I didn't understand which unit you wanted to move. You can create the units and then immediately order them to move using "last created unit group" which will contain all of the units when multiple are made simultaneously (all 11 zombies). You won't need two triggers, only the first one.
  • Unit - Create 11 Zombi for Player 4 (purple) at (Center of UndeadSpawn <gen>) facing (Position of (Triggering unit))
  • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked Unit) to Attack-Move to (Center of UndeadTrigger <gen>)
This leaks a unit group as well as a bunch of points. You probably have many triggers that leak objects, so instead of trying to fix this one I'll just link a good tutorial and a good reference:
 
Status
Not open for further replies.
Back
Top