Opened 5 years ago

Closed 4 years ago

#5443 closed defect (fixed)

Units in formation change run to walk after some time when chasing fleeing unit

Reported by: Silier Owned by: wraitii
Priority: Should Have Milestone: Alpha 24
Component: Simulation Keywords:
Cc: Patch: Phab:D2763

Description

When you order individual units to attack some unit and the unit flees, they chase the target with running speed.

If you do the same scenario with units in formation, after some time they change their speed back to walking speed. It is the most noticeable when you send them to hunt some skittish or passive animals.

Units chasing in formation should keep their running speed as it is with individual chasing. This would be helpful if one decide to enable back skittish behaviour on los update disabled based on #2092.

Attachments (1)

commands.txt (6.7 KB ) - added by wraitii 4 years ago.
minimal reproduce

Download all attachments as: .zip

Change History (6)

comment:1 by Silier, 5 years ago

Summary: Units in formation changes run to walk after some time when chasing fleeing unitUnits in formation change run to walk after some time when chasing fleeing unit

comment:2 by Freagarach, 4 years ago

What I observe when hunting with a formation is that there are some entities which go into their CHASING state (and keep running in that), but after a while their distance to their formation controller has become too large and they will return to that. When arrived, the formation controller will then go into APPROACHING state again to follow the target.

by wraitii, 4 years ago

Attachment: commands.txt added

minimal reproduce

comment:3 by wraitii, 4 years ago

The above reproduces what Freagarach says, not necessarily what Angen describes above - I'm not certain it's the same issue, but Angen reported this pre-UM rewrite which fixed a lot of formation issues.

As for the bug above, here's what happens:

  • Formation is ordered to gather. Order.Gather notices the target must be killed, and Pushed OrderAttack
  • Order.Attack notices it's not in range, and since combat-as-formation is deactivated, dispatches members to attack and goes in "MEMBER".
  • units do what they do -> Combat.Approaching, Combat.attacking, then Chasing once they notice the unit flees. Not all units notice the unit flees (we only switch to CHASING in attacking proper... This is kinda wonky, but it's unrelated).
  • At some point, all members have called "FinishOrder" at least once.
  • the formation member picks up, and now goes back to Order.Gather, and since it's so far away all units actually go back then start again.

Now in the above replay, you will notice that this isn't what happens -> the entities never finished their order. The call is actually from "ShapeUpdate", which is called every second, and which computes the distance between the controller and its target. Obviously, since the controller hasn't moved, this distance increases, and it crosses the threshold into "Line" column. So units go back, and things pick up again. That's bug #1.

But as usual with unitAI, it's not fun if there's just one bug. So if you fix that, you might run into D2702. Bug #2. We can also fix the fact that entities go back to where the formation was originally: it seems "MEMBER" should put the formation controller in a "virtual", out-of-the-world state, and we should just recompute our position when all members have finished. Bug #3.

Finally, this still won't be perfect, because units will kill the target but not start gathering from it, as there is a pending formation order. So they will go back to formationIdle anyways. We _could_ special-case this, but it seems more worthwhile to call the formation controller and ask for what to do. Bug #4.

I'll try and create some diffs to fix those issues, which all sounds fairly easy. Thanks for reporting anyways, this might single-handedly by the one ticket that leads to the most fixes :P .

comment:4 by wraitii, 4 years ago

Milestone: BacklogAlpha 24
Patch: Phab:D2763

Fixed by Phab:D2763

comment:5 by wraitii, 4 years ago

Owner: set to wraitii
Resolution: fixed
Status: newclosed

In 23806:

Fix formations reshaping incorrectly & related issues.

Formation were reshaping in cases where they should not (such as when the controller is waiting on members).
This made them look very odd for some orders.

This also cleans up held positions for formations somewhat.

Also:

  • rP23346 fixed units not facing correctly after a formation-walk. The fix is correct, but we can actually make it slightly more self-contained by moving everything in leave. Also clarify comments.
  • This fixes some very broken code in rP22447 in FORMATIONMEMBER.WALKING.MovementUpdate. It never errored because formation controllers weren't moved out of the world before.

Reviewed By: Angen

Fixes #5443

Differential Revision: https://code.wildfiregames.com/D2763

Note: See TracTickets for help on using tickets.