View Issue Details

IDProjectCategoryView StatusLast Update
0006436The Dark ModAIpublic12.02.2024 15:06
ReporterMirceaKitsune Assigned To 
PrioritynormalSeveritynormalReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSManjaroOS VersionStable
Product VersionTDM 2.11 
Summary0006436: Climbing on tall objects allows beating AI to death with the blackjack without the AI ever noticing the player's presence
Descriptionhttps://youtube.com/watch?v=hffjLds2FM0
https://youtube.com/watch?v=m15Vm9tIWaw

Though I partly captured those sequences for fun, I wanted to use them for a report as this seems to indicate an underlying issue with the AI. No cheats were used and targeting is enabled: I alerted a couple of guards during my normal run then wanted to hit them to annoy and distract them, which is when I noticed this is a thing that can occur.

What happens and steps to reproduce: If you climb on a table or any tall object located in a dark spot, guards are unable to see you even if you attack them at close range. This leads to the hilarious situation where you're able to beat a guard to death with the blackjack, all while the guard just sits there and does nothing but scream in pain, not even moving out of the way unless he happens to go searching in a random direction. The guard never becomes aware of you even if you're right there and actively hitting him in the face... if you get too close and touch him which does trigger combat awareness, the AI forgets your presence in one second after attempting to attack.
Additional InformationWhat seems to happen, from what I can tell as a player with limited knowledge of the AI code, is a cumulus of three requirements simultaneously coming into play:

1: The player is located in total darkness at minimum lightgem level.
2: The player is not touching the guard directly and doesn't bump into them.
3: The player is in a location that's not reachable to the guard through pathfinding.

If all of those factors are met, the AI instantly forgets the player and goes from attacking to searching. You can easily achieve all 3 by climbing on any tall object in a dark spot and leaning forward to be in attack range while not bumping into the guard, given pathfinding does not produce a valid route to the top of a table or piece of furniture so guards can't get there. This allows you to literally hit an officer standing next to you repeatedly until he dies, without him or any of his nearby colleagues having any reaction other than saying "ouch" and cluelessly looking around with swords drawn wondering what could be happening.

While far less noticeable across long distances, a similar behavior occurs if you fire at a guard from afar: When your arrow hits the AI he realizes he's been attacked and will start searching the area, but will never turn his attention toward the location the arrow came from and think of running there to check. It's like throwing an egg from your balcony at someone standing in a parking lot, then the person who was hit starts looking under the cars or the base of the opposite building to see if someone is there, even if it's obvious roughly which direction the projectile came from and he should be running into your building knocking on your neighbors doors to find the culprit. While the TDM AI will likely never be highly realistic, I hope a solution can be found for those cases to make guards not be quite this comically clueless in combat situations.
Tagspathfinding, psychology, realism

Activities

boissiere

boissiere

11.02.2024 14:50

reporter   ~0016509

When an AI is initially hit by a projectile, it is handled in method OnProjectileHit in State.cpp. This calls SetUpSearchData which, for a projectile hit, sets the alertPos in memory to a position halfway between the AI and the shooter. Presumably this half distance represents the AI knowing roughly where the shot came from and so would start going towards the shooter to follow up.
This code is generic for all states. Unfortunately the shot then causes the AI to switch to the Pain state which, in its Init method, then sets the alertPos to the AI's current position, overriding the previously set value. Therefore the subsequent search starts in the wrong place.
I think that the easiest fix would be for the Pain::Init code to check if the cause of the pain (which it does know) was a projectile and not override the alertPos in this case.
boissiere

boissiere

11.02.2024 14:54

reporter   ~0016510

Just to say that the previous note is for the 'firing an arrow from afar' part of the bug report.
MirceaKitsune

MirceaKitsune

12.02.2024 15:06

reporter   ~0016512

Thanks for that information! I didn't realize a better algorithm for shot direction detection was once implemented, but a bug that's likely been around for over a decade is overriding it. Simply picking a location between the victim and attacker should be accurate enough: I was thinking the AI could trace a cone toward the player and pick points inside that cone to go to, but if the override problem can be solved it probably doesn't need to be that complex. The current behavior is definitely wrong though, I made a video which showcases how a guard goes searching in every incorrect place when I hit them from behind.

https://www.youtube.com/watch?v=Bi-8CezzNqE

Fixing this should improve players being able to attack AI with blackjack / sword without them realizing someone is hitting them if the player's light gem is dark, which technically is caused by the issue you described. What's going wrong is when you hit the AI it simply goes in a search state without attacking, which would work but they go searching in a random direction: If they picked the right set of positions, they would head toward the player and bump into them instead which would trigger an attack... since they only go around randomly they appear completely clueless instead.

Issue History

Date Modified Username Field Change
11.01.2024 22:15 MirceaKitsune New Issue
11.02.2024 05:04 Fiver Tag Attached: pathfinding
11.02.2024 05:04 Fiver Tag Attached: realism
11.02.2024 05:04 Fiver Tag Attached: psychology
11.02.2024 14:50 boissiere Note Added: 0016509
11.02.2024 14:54 boissiere Note Added: 0016510
12.02.2024 15:06 MirceaKitsune Note Added: 0016512