#3405 closed defect (fixed)
[PATCH] Animals do not flee anymore when wounded
Reported by: | mimo | Owned by: | mimo |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | Core engine | Keywords: | pathfinding patch |
Cc: | Itms | Patch: |
Description
This seems to be due to the pathFinder changes, and this could be the true cause of #3372. Attached is a simple commands.txt which reproduces the problem.
Attachments (6)
Change History (23)
by , 9 years ago
Attachment: | commands.txt added |
---|
comment:1 by , 9 years ago
Cc: | added |
---|---|
Keywords: | pathfinding added |
comment:2 by , 9 years ago
comment:4 by , 9 years ago
Milestone: | Backlog → Alpha 19 |
---|
Please note that in your replay file, the deer now flees in the wrong direction because it is close to the edge of the map, so the long-range pathfinder detects that and makes it flee to the closest reachable out-of-attacker-range point.
Thanks for reporting and for finding out in which part of the code I had to take a look :)
comment:5 by , 9 years ago
Thanks for the fix, but I suspect there is something wrong in the computation of the closest point as, if d is the distance between the hunter and the animal and f its flee distance, the animal is ordered to go to the nearest point on a circle centered on the hunter and with radius d+f by a MoveToPointRange(hunter, d+f). And, even if this circle is truncated because of the edge of the map in the commands.txt, there are clearly better possibility than going towards the hunter. But to make it clearer, I've tried hunting another deer in the middle of the map, and here is a commands.txt with the deer still going towards the hunter. And in my attempts, it seems than even when the deer flees in the right direction, it flees by much less than its flee distance.
by , 9 years ago
Attachment: | commands.2.txt added |
---|
comment:6 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
There is a problem, Roman cavalry spear would still not go chasing a deer, he remained in place to repeat the attacks and then to chase deer. Deer had run away at this time.
comment:8 by , 9 years ago
@stanislas69: yes,my friend.
@Itms: Roman cavalry spear can't hunt deer. Roman cavalry spear while hunting deer, deer cannot be pursued in a timely manner to, when the deer ran away after he began a slow attack. He should follow, and then to attack the deer, but he doesn't have to follow the deer. Seems to be related to how attacks and damage is calculated, and because of the slow attack speed of spearcav.
by , 9 years ago
Attachment: | commands.3.txt added |
---|
All deer near the north edge of the map fleeing to the right. (r17078)
by , 9 years ago
Attachment: | commands.4.txt added |
---|
comment:9 by , 9 years ago
Notice the deer flees the right direction after being hit once and then being chased by the cavalry without attacking it again.
comment:10 by , 9 years ago
Owner: | removed |
---|---|
Status: | reopened → new |
I don't consider this a release blocker, and I probably won't have time at all for that, so if nobody works on it it should be pushed.
comment:11 by , 9 years ago
After the changes during the last 3 weeks, the animals now flee but quite often not in the direction we could expect. Looking at CCmpUnitMotion code, it seems the origin of the problem is that, when going away from an entity, MoveToTargetRange always uses an INVERTED_SQUARE and the directions of the square are fixed u=(1,0) and v=(0,1). I think we should approximate this INVERTED_SQUARE to an INVERTED_CIRCLE when units are involved (as is done when going towards an entity where the SQUARE is replaced by a CIRCLE). Another way to improve the global flee direction would be to take as u the direction between the attacker and the fleeing entity (in principle the direction the attacker is facing at).
by , 9 years ago
Attachment: | ticket3405-fix.diff added |
---|
by , 9 years ago
Attachment: | ticket3405-improv.diff added |
---|
comment:12 by , 9 years ago
The problem was in fact in some goal dependent computations in the case of inverted (going to bigger distance) movement. This is fixed in the first patch attached. But still the flee direction keeps track of the square shape and is thus not exactly the one expected. The second patch adds the circle approximation.
comment:13 by , 9 years ago
Ah awesome catch! Sorry for the big mistake.
Be careful of spaces/tabs in this patch, as you can see in the Trac display there is a problem. Lines 49 or 84 of PathGoal.cpp are a good example of how to deal with that. :)
comment:14 by , 9 years ago
Keywords: | patch review added |
---|---|
Summary: | Animals do not flee anymore when wounded → [PATCH] Animals do not flee anymore when wounded |
comment:17 by , 9 years ago
Keywords: | review removed |
---|
Thanks Itms for the quick review. And if nobody disagree, i will revert r16973 after a19 is out as animals fleeing foundations was visually better than seeing them walk quietly as we have now.
As the Flee order seems to work for female, but not for animals, and the main difference (code-wise !) is the FleeDistance, I varied the one for animals. The nominal one is 24, decreasing it to 18 makes the Flee works for animals, while 20 fails.
Adding some printouts in CCmpUnitMotion, the reason is that up to 18, only a short path is done, while at 20, a long path is computed.
One possibility is that the long pathFinder, when you want to go at a given distance from the target while you start at a smaller distance, has some flaws ?