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

Following/attack?

Status
Not open for further replies.
Level 12
Joined
Mar 30, 2013
Messages
664
Greetings!

Im making a samurai map where a player gonna be a hero.
The hero gonna have normaly units following him.
The one thing im wonderring about is that.
When the player moves and enemies commes close to the player and starts to attack, can the units that is following the player starts to attack the enemies and when the enemies are killed can they still keep following the player :vw_wtf:
Hope some one can respond! :thumbs_up:
 
Level 7
Joined
Mar 6, 2006
Messages
282
You should check out Locust Swarm. It does exactly what you're asking. You set the unit type, the number of units, the follow range (I believe it's Area of Effect). Could set the duration to 99999

Edit: Actually, ordering the unit to Patrol the other unit does what you want better. Note though, that if they aren't in follow range, they'll move to the target, and won't stay to fight. I think the default follow range is really small, so they basically won't stay to fight unless they're right next to the target. You can change follow range in the Gameplay Constants.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Order them to patrol onto the unit. Unless something interrupts their order they will forever follow the targeted unit and attack any enemies nearby it and then return to following. Stun and other order cancelling processes would cause them to stop patrolling on the unit and so no longer follow it. You can get around this by a periodic trigger that checks distance between the unit and the unit being followed for it becoming large (unit being left behind or no longer following) and then ordering it to patrol onto it again (it will abandon any current attack target and move to the unit).

This task has a reasonable deadline in the order of seconds so you could get away with a loop every 5-10 seconds for this (so the unit eventually follows if it stops). Anything higher is a waste of processor resources. If using GUI you will need to clean up the locations used to get the distance to prevent leaks. You can have several followers very easily by having a group. Several units could be followed by different followers by making a sort of structure for each unit being followed along with a group of units that follows it.
 
Status
Not open for further replies.
Top