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

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:
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
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.
 
Level 2
Joined
Apr 12, 2016
Messages
12
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:
Level 2
Joined
Apr 12, 2016
Messages
12
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>)
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
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.
Top