[Solved] Prevent units back/stop when they are ordered to Attack-Move

Status
Not open for further replies.

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
189
How can i prevent units losing agro and backing to region where they are ordered to move-attack?
It is not as problematic with units... When it comes to the hero, after he cast a spell, he totally loses mind and stays in place.
  • Red 1
    • Events
      • Time - Elapsed game time is 180.00 seconds
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create DifficultyLevel Toxic Spider for Player 21 (Coal) at (Center of Red Spawner <gen>) facing (Position of (Triggering unit))
      • Wait 2.00 seconds
      • Unit - Create (DifficultyLevel - 6) Toxic Spider for Player 21 (Coal) at (Center of Red Spawner <gen>) facing (Position of (Triggering unit))
      • Unit - Create (DifficultyLevel - 4) Spitting Spider for Player 21 (Coal) at (Center of Red Spawner <gen>) facing (Position of (Triggering unit))
      • Unit - Create 1 Spider Queen for Player 21 (Coal) at (Center of Red Spawner <gen>) facing (Position of (Triggering unit))
  • Actions
    • Unit - Order (Triggering unit) to Attack-Move To (Center of Red <gen>)
 
Level 13
Joined
Feb 5, 2018
Messages
546
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 21 (Coal) at (Center of (Playable map area)) facing Default building facing degrees
      • AI - Ignore (Last created unit)'s guard position
It makes the unit ignore it's guard position so nothing funky happens. :)

Also in the object editor set stats - can flee to FALSE.

Unit - Order (Triggering unit) to Attack-Move To (Center of Red <gen>)

Do you have this action on another trigger? If it's on the creation trigger it should use Last created unit. :)

EDIT: Example trigger to make spawned units attack to next region.
  • Untitled Trigger 002
    • Events
      • Unit - A unit enters Spawn Region <gen>
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 21 (Coal)
    • Actions
      • Unit - Order (Triggering unit) to Attack-Move To (Center of Attack Region <gen>)
 
Last edited:

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
189
  • Blue 16
    • Events
      • Time - Elapsed game time is 2880.00 seconds
    • Conditions
      • (Player 2 (Blue) slot status) Equal to Is playing
    • Actions
      • Unit - Create (DifficultyLevel - 1) Flesh Golem for Player 21 (Coal) at (Center of Blue Spawner <gen>) facing (Position of (Triggering unit))
      • AI - Ignore (Last created unit)'s guard position
      • Wait 2.00 seconds
      • Unit - Create (DifficultyLevel - 1) Darkweaver for Player 21 (Coal) at (Center of Blue Spawner <gen>) facing (Position of (Triggering unit))
      • AI - Ignore (Last created unit)'s guard position
Mover is in separated area but looks like this:
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in Red Spawner <gen>) and do (Actions)
    • Loop - Actions
      • Unit Group - Order (Units in Red Spawner <gen>) to Attack-Move To (Center of Red 2 <gen>)
upload_2020-12-15_18-24-3.png

if I understand correctly and it should look like this, I didn't notice big changes. Units still keep stopping.
 
Level 9
Joined
Jul 30, 2018
Messages
445
Also, it's often very much easier to control NPC units if you have not set an AI player at all to that player slot. I.e. in the map settings you leave Player 21 (Coal) empty, so there's no player there, not even Computer. This way the AI won't order the units around at all. If possible, this is definitely the way to go, if you must have a lot of control over units via triggers. The downside is that the units don't know how to cast any spells (except auto-cast ones, ofc), but they can triggered via triggers as well.
 
Level 7
Joined
Oct 3, 2008
Messages
183
I noticed that in the last trigger you showed you're using "unit group - issue order" instead of issuing it to individual units in the loop, that probably won't help because if I remember correctly that one has a limit of twelve units and also does the group movement behaviour (aka the way units move if you order them in group in game yourself) which could muddle stuff up with the units trying to stay in coherency.

Do you happen to run any ai scripts for player 21? Cause that could be muddling things up as well.

Adding in a fall back is probably a good idea as well, look at say the Uther behaviour in human mission 2. Store their destination somewhere and just occasionally reorder them to attack move to their destination.
 

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
189
Also, it's often very much easier to control NPC units if you have not set an AI player at all to that player slot. I.e. in the map settings you leave Player 21 (Coal) empty, so there's no player there, not even Computer. This way the AI won't order the units around at all. If possible, this is definitely the way to go, if you must have a lot of control over units via triggers. The downside is that the units don't know how to cast any spells (except auto-cast ones, ofc), but they can triggered via triggers as well.

It could be a solution but as you said they don't know how to use spells. There are too many units to trigger it. I mean problem with triggering it will be bigger than topic problem.

I noticed that in the last trigger you showed you're using "unit group - issue order" instead of issuing it to individual units in the loop, that probably won't help because if I remember correctly that one has a limit of twelve units and also does the group movement behaviour (aka the way units move if you order them in group in game yourself) which could muddle stuff up with the units trying to stay in coherency.

Do you happen to run any ai scripts for player 21? Cause that could be muddling things up as well.

Adding in a fall back is probably a good idea as well, look at say the Uther behaviour in human mission 2. Store their destination somewhere and just occasionally reorder them to attack move to their destination.

1. It seems that I didn't know about that loop method. It will be much better when units are ordered separately. Can you present me how to do this?

2. Do you mean
  • Melee Game - Run melee AI scripts (for computer players)
or something else?
Anyway I don't use either of them.

3. I have a solution that prevents reverse.
  • Anti Reverse Red
    • Events
      • Unit - A unit enters Red Spawner <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 21 (Coal)
    • Actions
      • Unit - Order (Triggering unit) to Attack-Move To (Center of Red 2 <gen>)
When unit decided to back to its spawner region. It gets the same order so finaly it will do it.

About your solution:
Well I have a 6 spawners and 6 separated destination for them.
The best solution will be to:

pick every unit owned by player 21
order them to move to specified region

Lets create array of regions to keep destination in it.
Then I can set custom value of unit, when spawning them.
So leater I can extract that information.

But solution like evey 180 sec of the game it not good.
I don't know if I can use event -> when unit stops but it will be the best.
 
Level 13
Joined
Feb 5, 2018
Messages
546
The best solution is to use the example trigger I gave you earlier. And add regions in between, depending on the distance on the final destination.

Usually the unit movement in hero def/survival and/or td maps contain multiple regions and multiple re-issues for the unit's to continue their attack-move.

With one trigger and 2 regions it just simply won't work as intented.

What you want to do is add more regions and for each region create this:
  • Events - A unit enters region 0
  • actions
  • Unit issue order (triggering unit) to attack-move to Region1
  • Events - A unit enters region 1
  • actions
  • Unit issue order (triggering unit) to attack-move to Region2
And so on.
 
  • Like
Reactions: KPC
Level 13
Joined
Feb 5, 2018
Messages
546
I would leave some distance between the regions :D, other than that it looks like you got the idea!
 

Attachments

  • WC3ScrnShot_121720_155044_001.png
    WC3ScrnShot_121720_155044_001.png
    3.2 MB · Views: 21

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
189
Ofcourse more distance. I think you found solution for my problem. The distance betwen my regions was huge. No wonder the units were losing their destination.
Really thanks for this reply and your other helps.

Now the problem will be that units can be lured to the region designed for other group. Then one player will get 2 waves and other nothing. Any idea how to prevent this?
 
Last edited:
Level 13
Joined
Feb 5, 2018
Messages
546
Well you need some wave managment. You can store the units for designed for players into groups. When you create the units desired for player 1 red, add the units to Player1UnitGroup.

And then for region triggers add

Unit enters region blueXXX
if all condtions are true
or (any conditions are true)
Unit is in unit group Player1UnitGroup equal to true
Unit is in unit group Player3UnitGroup equal to true
Unit is in unit group Player4UnitGroup equal to true
do what you need here
else
do what you need here

The idea is to filter out the units you don't want to continue to attack in the wrong direction. You could issue them to attack back to their own regions
OR
To prevent abuse, you could also instantly move the units back to the desired region.

Whatever seems to be the best solution for your map.
 
  • Like
Reactions: KPC

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
189
Is this proper way to do this?
I have 6 Players so I will Make Player_Unit_Group array:

Variable:
upload_2021-1-9_21-11-39.png


And once I create Units for the Player I storem them in specific Group.
Trigger:
  • Red 1
    • Events
      • Time - Elapsed game time is 180.00 seconds
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create DifficultyLevel Toxic Spider for Player 21 (Coal) at (Center of Red Spawner <gen>) facing (Position of (Triggering unit))
      • Unit Group - Add (Last created unit) to Player_Unit_Group[1]
Also move unit:
  • Main Mover
    • Events
      • Time - Every 180.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Red Spawner <gen>) and do (Actions)
        • Loop - Actions
          • Unit Group - Order (Units in Red Spawner <gen>) to Attack-Move To (Center of Red 1 <gen>)
When Unit enter Region:
  • Next Move
    • Events
      • Unit - A unit enters Red 1 <gen>
    • Conditions
      • ((Entering unit) is in Player_Unit_Group[1].) Equal to True
    • Actions
      • Unit - Order (Triggering unit) to Attack-Move To (Center of Red 2 <gen>)
 
Last edited:
Status
Not open for further replies.
Top