- Joined
- May 20, 2015
- Messages
- 25
Hello everyone! I am making a wave system for my survival map and recently I implemented a trigger that when a unit spawns, it checks the closest hero to it and attack moves to its location. At least that's what I want it to do, however since I'm new to all these triggers and whatnot somehow I implemented the trigger wrong and it doesn't do what I want it to.
When a creep spawns, it does check the closest hero (someone helped me with this part, many thanks to him). After checking the closest hero the creep attack moves to its location and so far so good, however if the hero moves its position when the attack move command is issued to the creep or if the creep cant find a target at all in the nearby area it simply walks back to the spawn area and attack moves the hero again.
This results in a constant loop of the creep getting ordered to attack move, doesn't find anything so it moves back and then attack moves again until it gets near the hero, in which case it finally decides to attack it.
Can someone tell me where the problem is and how to solve it please? Here is the trigger:
When a creep spawns, it does check the closest hero (someone helped me with this part, many thanks to him). After checking the closest hero the creep attack moves to its location and so far so good, however if the hero moves its position when the attack move command is issued to the creep or if the creep cant find a target at all in the nearby area it simply walks back to the spawn area and attack moves the hero again.
This results in a constant loop of the creep getting ordered to attack move, doesn't find anything so it moves back and then attack moves again until it gets near the hero, in which case it finally decides to attack it.
Can someone tell me where the problem is and how to solve it please? Here is the trigger:
-
Creep Attack Move
-
Events
-
Unit - A unit enters Creep Spawn <gen>
-
-
Conditions
-
(Owner of (Entering unit)) Equal to Player 11 (Dark Green)
-
-
Actions
-
Set TempPoint = (Position of (Last created unit))
-
Set TempHeroGroup = (Units in (Entire map) matching (((Matching unit) is A Hero) Equal to True))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(TempHeroGroup is empty) Equal to False
-
-
Then - Actions
-
Set ClosestHeroUnit = (Random unit from TempHeroGroup)
-
Set TempPoint2 = (Position of ClosestHeroUnit)
-
Set MinDistance = (Distance between TempPoint and TempPoint2)
-
Custom script: call RemoveLocation(udg_TempPoint2)
-
Unit Group - Pick every unit in TempHeroGroup and do (Actions)
-
Loop - Actions
-
Set TempPoint2 = (Position of (Picked unit))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between TempPoint and TempPoint2) Less than MinDistance
-
-
Then - Actions
-
Set MinDistance = (Distance between TempPoint and TempPoint2)
-
Set ClosestHeroPoint = (Position of (Picked unit))
-
-
Else - Actions
-
-
Custom script: call RemoveLocation(udg_TempPoint2)
-
-
-
-
Else - Actions
-
-
Custom script: call RemoveLocation(udg_TempPoint)
-
Custom script: call DestroyGroup(udg_TempHeroGroup)
-
Unit - Order (Entering unit) to Attack-Move To ClosestHeroPoint
-
-