Opened 9 years ago

Closed 15 months ago

#1832 closed defect (fixed)

Entities should abandon chase if their target is in FOW

Reported by: mimo Owned by: Freagarach
Priority: Should Have Milestone: Alpha 25
Component: Simulation Keywords:
Cc: knight.erraunt@… Patch:

Description (last modified by Freagarach)

When you attack an dangerous animal, and then retreat, this animal will always chase you even if you flee to the opposite side of the map, completely out of its vision. There is a comment in the ShouldAbandonChase method saying that CCmpUnitMotion should take care to stop it if the target is lost in FoW, but this does not seem to work with animals. So here is a simple patch which stops the chase if the target is too far from the animal which chase it.

Attachments (1)

abandonchase.diff (847 bytes ) - added by mimo 9 years ago.

Download all attachments as: .zip

Change History (22)

by mimo, 9 years ago

Attachment: abandonchase.diff added

comment:1 by leper, 9 years ago

Keywords: review removed

I took a look at it and the cause of this behaviour is that the "Attacked" handler for animals calls this.Attack() which issues a forced attack order, which shouldn't be used in this case.

I think something similar to Gather() and PerformGather() is the proper solution to this problem.

in reply to:  1 comment:2 by mimo, 9 years ago

Replying to leper:

I took a look at it and the cause of this behaviour is that the "Attacked" handler for animals calls this.Attack() which issues a forced attack order, which shouldn't be used in this case.

I think something similar to Gather() and PerformGather() is the proper solution to this problem.

Yes, I've seen this.Attack() and also thought it was the reason. So I changed the force to false there and tried again, without success. So I thought from it that may-be the notion of FoW would not apply to gaia ?

comment:3 by leper, 9 years ago

I just tested it and it works just fine with force set to false in Attack(), there are some small issues with ranged units though (as the animal vision range isn't huge and the attacker could be to far away).

FoW does apply to gaia, but as there are gaia entities all over the map that isn't really useful. The vision range limitation in ShouldAbandonChase() applies however.

comment:4 by mimo, 9 years ago

Of course, I mixed the problems, sorry. I tested again and you are right. But I was not satisfied with the version without the force because these poor animals would not be allowed to defend themselves against range unit : The typical vision range of animals is 15-20, while we would need something at least 60 to cover all range attacks. And I'm not sure that such a big change would not have other side effect elsewhere.

But I agree my solution could look more as a patch than a proper fix. So let's keep this ticket open, only as a bug report.

comment:5 by mimo, 9 years ago

Keywords: patch removed
Summary: [PATCH] Animals should abandon chase if their target is too farAnimals should abandon chase if their target is too far

comment:6 by leper, 9 years ago

I think having them move to the last known position first would be a sane thing to do. (That way we don't have to increase the vision range, and this behaviour would work for units too (where force should also be false IMO))

comment:7 by Kieran P, 9 years ago

Keywords: patch added; animal removed
Milestone: BacklogAlpha 13

comment:8 by Kieran P, 9 years ago

Milestone: Alpha 13Alpha 14
Summary: Animals should abandon chase if their target is too far[PATCH] Animals should abandon chase if their target is too far

comment:9 by Kieran P, 9 years ago

Milestone: Alpha 14Alpha 15

comment:10 by mimo, 8 years ago

Keywords: patch removed
Milestone: Alpha 15Backlog
Summary: [PATCH] Animals should abandon chase if their target is too farAnimals should abandon chase if their target is too far

comment:11 by elexis, 7 years ago

Sounds similar to #3394

comment:12 by stanislas69, 6 years ago

Summary: Animals should abandon chase if their target is too farEntities should abandon chase if their target is in FOW

comment:13 by erraunt, 6 years ago

Ok, I have investigated and a very simple fix - changing if (!this.GetStance().respondChaseBeyondVision) to

if (!this.GetStance().respondChaseBeyondVision
this.IsAnimal())

in the ShouldAbandonChase? function.

seems to solve the problem for animals - at least it looks like it works. There is no problem with the archers outranging the animals vision sight as the command issued on attacked animals is APPROACHING and not CHASING. Nevertheless I kind of dislike the fact that so many things are solved by hard coded if's for animals, and the amount seems to grow - I recently made a patch (#3444) which is solved in a similar manner. I wonder if it was possible to separate the AI of animals from that of other units? It would probably introduce code duplication, could someone of the architects/experience developers comment on this? As for #3394 - judging from the code it appears that CCmpUnitMotion should take care of it, will try to look at it.

Last edited 6 years ago by erraunt (previous) (diff)

comment:14 by erraunt, 6 years ago

Cc: knight.erraunt@… added
Keywords: rfc patch added
Milestone: BacklogAlpha 21

comment:15 by erraunt, 6 years ago

Keywords: rfc patch removed
Milestone: Alpha 21Backlog

comment:16 by erraunt, 6 years ago

The change mentioned by me above does not solve the problem. As animals are approaching the target in the FOW, and we cannot change that due to the reasons mentioned in the posts above.

comment:17 by Freagarach, 2 years ago

Description: modified (diff)

(See also Phab:D2698.)

Last edited 2 years ago by Freagarach (previous) (diff)

comment:18 by Freagarach, 2 years ago

Component: Core engineSimulation

Would be fixed by #5593, Phab:D2646.

comment:19 by Freagarach, 21 months ago

In 24017:

Do not chase entities in FOW/SOD

Refs #1832 by fixing the non-animal cases.

Differential Revision: D2698
Reviewed by: @bb, @wraitii.
Fixes #3394

comment:20 by Freagarach, 15 months ago

Milestone: BacklogAlpha 25
Owner: set to Freagarach

comment:21 by Freagarach, 15 months ago

Resolution: fixed
Status: newclosed

In 24953:

Unify UnitAI and AnimalAI.

r8995 / rP8995 (#563) introduced an ANIMAL-state from a separate AnimalAI-component (introduced in r7763 / rP7763).
This patch merges that separate state and brings the ROAMING and FEEDING (renamed to LINGERING) under the INDIVIDUAL.IDLE-state.

This enables e.g. city-building mods to have human units that linger and roam or animals that behave like humans.

The specific values for animals might need tweaking after this.

Differential revision: D2646
Fixes: #1832, #5593
Comments by: @Angen, @Langbart, @Nescio, @Stan, @wraitii
Refs.: #3919

Note: See TracTickets for help on using tickets.