Opened 3 years ago

Closed 3 years ago

#5945 closed defect (fixed)

Hero "aggressive" state not working

Reported by: snelius Owned by: wraitii
Priority: Release Blocker Milestone: Alpha 24
Component: Simulation Keywords: regression
Cc: Patch: Phab:D3442, Phab:D3504

Description

When hero is sent under enemy CC and there are enemy women working around him (actually other units too) he tries to overtake the nearest building instead of attack nearby units. Tested on revisions 24725 & 24660.

Attachments (6)

2021-01-20_5945 hero aggresive state.zip (19.8 KB ) - added by snelius 3 years ago.
Replay showing hero dying under CC instead of killing nearby enemy units.
2021-01-20_5945 hero behaviour.zip (53.2 KB ) - added by snelius 3 years ago.
Another, more complex, example of insane hero behaviour with aggressive state.
2021-01-21_5945 hero in a23.zip (32.9 KB ) - added by snelius 3 years ago.
Hero in a23
2021-01-22_5945 hero in a24.zip (33.8 KB ) - added by snelius 3 years ago.
hero in a24
2021-01-30_5945 hero captures CC.zip (49.2 KB ) - added by snelius 3 years ago.
hero captures CC (rev. 24810)
2021-02-01_0000 hero ignores arrows (correct) a23.zip (167.5 KB ) - added by snelius 3 years ago.
Live example from a23 how hero should work

Download all attachments as: .zip

Change History (27)

comment:1 by Stan, 3 years ago

Can you upload replays?

comment:2 by Freagarach, 3 years ago

Component: Core engineSimulation
Keywords: hero aggresive state removed
Milestone: Alpha 24
Resolution: invalid
Status: newclosed

Capturing takes precedence, also an aggressive entity will sometimes disobey user-given orders when attacked.

by snelius, 3 years ago

Replay showing hero dying under CC instead of killing nearby enemy units.

by snelius, 3 years ago

Another, more complex, example of insane hero behaviour with aggressive state.

comment:3 by snelius, 3 years ago

Cc: snelius removed
Milestone: Alpha 24
Resolution: invalid
Status: closedreopened

Freagarach, I definitely disagree with you. Please see another replay (2021-01-20_5945 hero behaviour.zip) showing insane hero behaviour, like attacking fields instead of women in that field.

This functionality worked perfectly in a23 and this is why it males 0ad much more interesting and playable. If this will be changed in a24 it may be a huge drawback.

Besides, what is the logic of capturing CC full of units (= more arrows) while it's impossible to capture it anyway, instead of slowing opponents economy by eliminating nearby women?

"capturing takes precedence" argument doesn't convince me. Now hero's behavior is simply irrational (contrary to a23 which is all good).

comment:4 by Freagarach, 3 years ago

snelius, thanks for your persistance, I may have closed too eagerly.
I'll investigate, thanks for the report.

comment:5 by Silier, 3 years ago

Owner: set to Freagarach
Status: reopenednew

comment:6 by Freagarach, 3 years ago

I guess you are mostly talking about around turn 1381 (~11:30) of your last upload, where the hero attacks the field instead of nearby units. For it seems AttackEntitiesByPreference works for all other cases.

comment:7 by wraitii, 3 years ago

Keywords: regression added
Owner: changed from Freagarach to wraitii
Patch: Phab:D3442
Priority: Must HaveRelease Blocker

comment:8 by wraitii, 3 years ago

Resolution: fixed
Status: newclosed

Fixed in Phab:rP24751 / 24751

comment:9 by snelius, 3 years ago

I guess I'm a bit late with more detailed explanation, but I will write it anyway.

I have prepared 2 replays which I believe clearly show discrepancies between a23 and a24 hero behaviour.

First one, named "2021-01-21_5945 hero in a23.zip" and refering to a23, shows how hero works now in alpha 23 This is an example of very correct method of picking "next to kill units/objects". Moment worth to focus on:

  1. turn 3565 to turn 3742 (min 11:52 to 12:28) Hero manually directed under enemy CC is picking enemy units one by one in a correct order until he's manually retreaded back to the temple to heal

  1. turn 4208 (min 14:00) Hero manually placed among fields with women working in them. After killing enemy cav unit he pick as a target nearby woman, and then next cavalry unit to fight, which is all good, and this is how hero should work in a24 (imho). Then he moves towards 2 archers shooting at him, istead of trying to destory fields as it does in a24.

  1. turn 4390 to turn 4582 (min 14:38 to 15:16) Hero attacks many units around CC, including neutral units like traders. Hero is not focused neither on capturing CC nor on destoying fields around enemy CC.

Second, named "2021-01-22_5945 hero in a24.zip" and refering to a24, should mostly be focused on moments:

  1. turn 2450 (min 08:10) [OK] Hero on its own start to move toward enemy cav approaching. At the moment hero moved, enemy cav was in quite a far distance, which proves it can react on enemy in a far distance.
  1. turn 2739 (min 09:08) [OK] This is a situation similar to case no. 1. This time the distance to enemy is also long enough to admit hero's reaction is correct.
  1. turn 3135 to turn 3159 (min 10:26 to 10:32) [BUG] Despite having 1 more archer to kill (who is the nearest enemy unit) hero moves towards another archer located far away. Both archers were shooting into hero. I guess it might have something connected to the "latest unit attacked you" function determining which units should be attacked as the next one.

  1. turn 3166 (min 10:34) [BUG] This is a moment when hero turns back towards the archer (currently only one enemy unit attacking him) he left alone at moment no. 3. Please consider if it's not a bug. In a23 hero would have attacked the neares unit, which is a woman building a tower nearby, and then he would go to the archer. In a24 hero attacks "nearest attacking unit" not simply "nearest unit" as would suggest the description under the "aggresive state" of the hero. Besides this situation shows how easily hero can be tricked. Let's say hero is among many women working in fields and only one unit (cav archer) is shooting at him from a far distance. Instead of fighting women to destoy enemy economy, hero would chase that one cavalry unit which would be a waste of time. This is why, in my opinion, this case also should be considered as a bug.
  1. turn 3210 (min 10:42) [BUG] After killing the archer hero turns to spearmen who is coming from far away. The nearest unit is priest, and he should be attacked as the next one, or eventually women in woods or woman building a tower. There were 4 "neutral" units around, all in a much shorter distance than spearmen coming towards hero. None of them were attacked. This is a next example how vulnerable hero in a24 is. Instead of attacking units who are much lower threat to him, he chooses to attack spearman who has x3 bonus fighting the cavalry. In short words this is a "suicide yourself asap" logic. Considering fact, that in a24 hero can be made only once, this is worst possible method of picking units to fight.
  1. turn 4170 (min 13:54) [BUG] Hero manually placed under opponent's CC. Instead of picking women working in fields, hero starts to capture the building, which is obviously impossible to do.

turn 4200 (min 14:00) [BUG] Hero manually moved to the corner of the building. Same reaction - capture higher priority than nearby enemy units.

  1. turn 4250 (min 14:10) [BUG] Field has higher priority than enemy units nearby. After killing women in fields under enemy CC, hero start to destroy field, instead of picking next woman mining stone nearby. He does that only after moving him manually between metal and stone at turn 4320 (min 14:24).
  1. turn 4888 (min 16:17) [BUG] Field has higher priority than enemy nearby units. After eliminating spearman hero destroys fields instead of other nearby units. Same situations several times until min 17:00 when hero is manually retreated to heal.
  1. turn 5455 (min 18:10) [OK] After all enemy soldiers went inside CC hero attacks nearby women at stone ...

10.turn 5475 (min 18:15) [BUG]

... and then destroys closest field instead of enemy units at metal mine nearby.

11.turn 5500 (min 18:20) [BUG]

After manually placed next to mining woman, hero tries to capture enemy building (CC), which is another example of "suicide yourself asap" way of hero works now in a24. He repeats that again after next try at turn 5530.

by snelius, 3 years ago

Hero in a23

by snelius, 3 years ago

hero in a24

in reply to:  9 comment:10 by wraitii, 3 years ago

Thanks for this very detailed report. All cases of attacking buildings first are now fixed.

I can confirm a few issues, however, and they relate to Cheering.

Replying to snelius:

  1. turn 3135 to turn 3159 (min 10:26 to 10:32) [BUG] Despite having 1 more archer to kill (who is the nearest enemy unit) hero moves towards another archer located far away. Both archers were shooting into hero. I guess it might have something connected to the "latest unit attacked you" function determining which units should be attacked as the next one.

The Hero has an order to cheer, so it does, in doing that, it gets attacked, and reacts to his attackers which is as you guessed the faraway archer. The cheer came from almost 200 turns back though, so that seems wrong, and explains the A23 difference (the unit wouldn't cheer).

  1. turn 3166 (min 10:34) [BUG] This is a moment when hero turns back towards the archer (currently only one enemy unit attacking him) he left alone at moment no. 3. Please consider if it's not a bug. In a23 hero would have attacked the neares unit, which is a woman building a tower nearby, and then he would go to the archer.

This is actually the same as above: the hero cheers, then it gets attacked, so it reacts to its attacker. In A23, it would have picked a new target directly.

In a24 hero attacks "nearest attacking unit" not simply "nearest unit" as would suggest the description under the "aggresive state" of the hero.

Not actually what's happening, thankfully.

  1. turn 3210 (min 10:42) [BUG] After killing the archer hero turns to spearmen who is coming from far away. The nearest unit is priest, and he should be attacked as the next one, or eventually women in woods or woman building a tower. There were 4 "neutral" units around, all in a much shorter distance than spearmen coming towards hero. None of them were attacked.

Yup, that's also a bug in Cheering, but another one: the spearman just enters his line of sight, and so it's the only unit considered for attack.

This is a next example how vulnerable hero in a24 is. Instead of attacking units who are much lower threat to him, he chooses to attack spearman who has x3 bonus fighting the cavalry.

There is however no such logic in A23 or A24.

Last edited 3 years ago by wraitii (previous) (diff)

comment:11 by wraitii, 3 years ago

I've opened #5966

comment:12 by snelius, 3 years ago

Resolution: fixed
Status: closedreopened

Reopening again:

Sorry for being as stubborn as a mule with this hero "aggressive state", but I think not every case of attacking or capturing nearby buildings has been covered with last bug fixes. Please see attached "2021-01-30_5945 hero captures CC.zip" replay which shows:

1) at min 6:17 (turn 755) hero receives order to go to the point "P" (between 3 fields) which he reaches at min 6:33 (turn 786),but instead of being interested with women in fields he tries to capture CC from now on (until he's manually retreated to point P again).

2) at min 6:51 (turn 823) hero reaches point P (also manual order like in case no. 1) and turns back to capture CC (similarly to situation described above)

3) at min 7:08 (turn 857) hero for the third time reaches point P and this time his behaviour is correct - he starts to attack units

4) at min 13:36 (turn 1633) same problem as in cases 1 & 2 with a difference that this time hero killed 1 enemy unit who attacked him on his way to CC

All these cases have been tested on revision no. 24810

Thank you wraitii for your explanations to previous replay and opening a "Cheering problems" bug (https://trac.wildfiregames.com/ticket/5966).

by snelius, 3 years ago

hero captures CC (rev. 24810)

comment:13 by Silier, 3 years ago

The first one comes from L1481, where is handled attacked message of individual, where basicly hero reacts to being attacked by cc. As he has no other orders since he finished the last one, he reacts to attacks. I think all others cases follow the same pattern. The line is there since Dec 2017 One possible issue might be, that checks in idle were moved into the timer, and IDLE does not rewrite Attacked message. Now question here is, would it be ok for unit to not react that turn and ignore attacker and then run FindNewTargets inside the timer, or is that time while not reacting worse than current behaviour?

in reply to:  13 comment:14 by wraitii, 3 years ago

Replying to Angen:

Now question here is, would it be ok for unit to not react that turn and ignore attacker and then run FindNewTargets inside the timer, or is that time while not reacting worse than current behaviour?

IMO not reacting before the timer is run is a better call, given the described behaviour. I'm not sure units should react to structures attacks at all anyways, but that probably has edge cases.

comment:15 by Silier, 3 years ago

Patch: Phab:D3442Phab:D3442, Phab:D3504

in reply to:  13 comment:16 by snelius, 3 years ago

Replying to Angen:

Now question here is, would it be ok for unit to not react that turn and ignore attacker and then run FindNewTargets inside the timer, or is that time while not reacting worse than current behaviour?

I agree with wraitii: It's better not to react till the timer is run.

Replying to wraitii:

I'm not sure units should react to structures attacks at all anyways, but that probably has edge cases.

And that would be the best solution, i.e. to not react to any structures attacks.
Maybe we should make a separate topic and discuss this problem on a forum?

In practice many units (like heroes, elephants, or any kind of soldiers) die under towers/CCs/forts/walls if not managed properly "by hand". They are simply vulnerable to being lured by arrows hitting them from enemy buildings. This is why players have to pay an attention not to let them suicide under enemy buildings. It would be better if they ignored attacks from structures and attacked:

  1. first nearest units,
  2. then structures (if no enemy units left around).

Order in which structures should be attacked, could be the same like if all of enemy structures were empty or, being more precisely, without giving any higher priority other than because of the distance (cause for example empty towers also can shoot arrows).

by snelius, 3 years ago

Live example from a23 how hero should work

comment:17 by snelius, 3 years ago

Please see attached "live example" from a23 (file 2021-02-01_0000 hero ignores arrows (correct) a23.zip​). It shows exactly what I've described above.

Please rewind to min. 34:34 when hero (no units around) ignores tower and CC shooting at him, and starts to destroy fields one by one, until he's manually retreated.

comment:18 by Silier, 3 years ago

snelius, do you know how to apply patch? if you do, you could test this changes: https://code.wildfiregames.com/D3504

comment:19 by snelius, 3 years ago

Actually haven't applied any so far. Should I update to the latest revision or do sth more ? If it's not complicated you could write me on my 0ad forum account.

comment:20 by Stan, 3 years ago

Here is what you need to do:

  1. Update to latest.
  2. Open binaries/data/mods/public/simulation/components/UnitAI.js
  3. Go to line 1580
  4. Add
"Attacked": function(msg) {
    if (this.isIdle && (this.GetStance().targetAttackersAlways || !this.order || !this.order.data || !this.order.data.force))
        this.RespondToTargetedEntities([msg.data.attacker]);
},
  1. Save the file.
  2. Run the game and notice the behavior.

NB: Make sure to remove those lines if you want to play with someone.

comment:21 by Silier, 3 years ago

Resolution: fixed
Status: reopenedclosed

In 24818:

React to Attacked message in IDLE when really idle

Issue described in #5945.
Unit finishing the order such as walking, will reach destination and if attacked, imediately reacts to the attacker.
Hovewer, more desireble is for unit to look around since entering idle state and pick the target if any using preference and then react to attacker.
This issue rised up after finding of new targets have been moved from enter to timer to avoid infinite loops after alwaysenterstate logic removal.

Only downside here is unit will receive few hits before reacting as we are waiting to the timer first. This happens only if unit goes idle.

Differential revision: D3504
Reviewed by: Freagarach
Comments by: wraitii
Fixes: #5945

Note: See TracTickets for help on using tickets.