Jump to content
The Dark Mod Forums

Addressing lack of AI awareness during and after hostile encounters


MirceaKitsune

Recommended Posts

As someone who tends to alert guards often and occasionally stir trouble when going through a FM, I noticed some major issues when it comes to AI realism and awareness during combat or when guards face difficult situations. Everything's fine when AI go about their usual patrols... once trouble takes place however, the illusion falls apart as guards act like they're less self aware than a toddler. Indeed AI realism can't be improved past a certain point as there's a limit to the effort the team can put into something so complex... yet I do believe a few improvements can make AI behavior much more realistic and exciting. After analyzing this issue for a long time, I decided to put it all it into a few main points... I apologize for their length as I wanted to go in a bit of detail on each one, hope folks have the time and patience to read them.

  1. Biggest issue is AI are unaware of where attacks are coming from. I recently made another thread on how I climbed on a table and blackjacked two guards to death as they sat there doing nothing, something that also happens when shooting them with arrows as guards only explore the nearby area. The issue seems to be that AI don't account for the direction a hit comes from, they only know something hit them but act as if it must be some mystical force of nature: If you're sitting in a parking lot and an asshole neighbor throws a tomato at you from his balcony, you aren't going to cluelessly investigate the road in front of you when the projectile clearly came from behind and hit you in the back of the head, instead you'll storm into the building and start looking for which of the neighbors facing that side of the road may be the culprit.
  2. Despite voice barks existing for this exact scenario, we never see AI running to get help from other AI. NPC's will do one of two things: If armed and with enough health they will attack or search for you nearby, if hurt or unarmed flee to a random location. I've never seen an AI consciously run up to another AI asking for help and bringing them to where they spotted me, even when fleeing the AI seems to go to a random location. They don't share knowledge with each other generally speaking: The only awareness AI spread to other AI is alert level, meaning NPC A becomes alert if it sees or hears that NPC B is alert too... beyond that there's no coherence or actual cooperation, the voices may indicate some form of searching together but friendly NPC's are never seen actually engaging.
  3. Another big issue is voices being played (or not played) in disconnect with what's actually going on. There are AI voices for most important circumstances but they're very rarely activated: It's a miracle to hear a guard say "someone's been hurt" or "there's a body here" when noticing someone who's unconscious or dead. What seems to happen is if AI was already alerted by another peculiarity such as a noise, they're no longer surprised by anything else and won't play the voices designated for that scenario, so they'll only mention a body if that's the first thing to alert them in any way. Furthermore AI don't actively talk with each other while searching together, everyone acts as if they're on their own and not a team.
  4. What happens after a conflict is over. For this discussion I won't focus on better permanent alerts, that has greater difficulty implications and I think I made a separate thread on it a while back. The problem I noticed is once the immediate alert has gone down, AI return to full normality and act abnormally calm: The idle voices change from saying things like "it's a quiet night" to "we've got an intruder" but that's about it. In any realistic scenario even a trained guard would be shocked after being in a fight or finding a body.

Below I'll list the immediate improvements I see to those problems, which without having an understanding the code myself am presuming can be changed without too much effort:

  1. When an enemy hits the AI with any weapon, the AI should be alert to the estimate location of the shooter. If you're standing atop a tower and fire an arrow at a guard, the guard shouldn't draw his sword and look around their nearby vicinity like a fool, but instead run up to the tower where you're standing granted they can pathfind their way to that location. If the player is far away the destination should be fuzzy and a random location nearby, thus the guard won't run to your exact location but will still climb the stairs and enter a room near it.
  2. AI need to learn how to ask for help instead of fleeing to random places when not attacking. If an ally who isn't already alert can be found nearby, the scared AI should explicitly run to their location tell them where you are then have the ally either run to your location (if armed) or go to another ally to get them to your location (if unarmed).
  3. Even if an AI is already alert, finding a body or dropped weapon or broken arrow should result in the AI speaking the voice line for that circumstance, only being engaged in combat should suppress it. I'd go further and support repeating those voice lines: A guard yelling "we have a dead body" several times during the first seconds of discovery would make them appear more shocked. Similarly talking to a nearby guard shouldn't be done just once when the two first meet: When multiple AI are searching for you, they should constantly alternate between single voice lines (eg: "I bet you're right over there in those shadows") and looking at another guard to talk to colleagues (eg: "I know I saw him here keep searching"), this would be a huge improvement since guards currently act like they're completely unaware of each other during a coordinated search.
  4. Making guards permanently affected after an incident is a trickier one but a few tweaks could improve it. The most immediate solution would be changing the idle animations: Instead of stretching or blowing their noses or eating candy, AI should be seen randomly cowering or face-palming or even playing the scout animation to look around carefully. One suggestion I'd absolutely throw here: If the AI found a dead body from an ally, have them cry occasionally... I think that would be an interesting and unexpected detail, that will also get players to think and feel more about the consequences of their actions and how they affect the world.

There are other ones I could get into, but some would be more difficult and likely not worth trying to solve. Most notable and worthy of at least a mention is how AI walk over the bodies of fallen friends as if they're doormats: Obviously there's no way to have them drag bodies to the side, but maybe an avoidance mechanism so they don't look like jackasses trying to profane their dead friends by literally stepping all over them could be a fix for that as well! Let me know what you think of those points and if there are other AI issues you've noticed yourself or better solutions you can think of: I'm not sure if I got everything here but I definitely believe the problems exist and we could make the world more natural and immersive with some simple fixes.

Edited by MirceaKitsune
Link to comment
Share on other sites

I believe that 3. and 4. should be easy to do, by setting some internal triggers for alert sounds and random animations depending on the alert state. I guess that 2. would mean a lot of work for little benefit as I guess if you fought one guard hard enough for him to flee all other guards nearby must be alerted anyway. As for 1. this must be handled very carefully, because while I agree with you on the stupid melee killing from dark corners, I really hate it in games when I fire a ranged weapon like the TDM bow at somebody from behind and they immediately know where I am. This should only happen if the guard is looking exactly into the direction of the player at the moment the bow is released! It's supposed to be dark.

Edited by wesp5
Link to comment
Share on other sites

I believe that 2 can in fact take place from time to time. I've just been playing the revamped 'Sir Talbot's Collateral' where I alerted Sir Talbot in his library. After running around the room trying to get out (another gripe) he was able to escape because the guard that normally patrols the room turned up. A few minutes later another guard arrived who must have been alerted by Sir Talbot.

That doesn't take away from your argument though. Another oddity is that all alerts seem to be treated as 'There's a thief in the area' - I've seen a guard attacked by a spider, run off, and the other guards whip out their swords crying 'You're going to the gallows thief!'.

 

  • Haha 1
Link to comment
Share on other sites

It's easy to imagine how #1 can be solved fairly: When the player or an enemy AI shoot an armed AI, the AI that was hit should be given a random destination near the attacker to run to. The further the player is from the target, the larger the radius around the player in which a random node may be picked; If you're far away the virtual sphere should be large, meaning AI may run to a room or passage near you but still in your general direction . This new behavior should be influenced by AI acuity and difficulty settings though I'm not sure which ones... also toggled by one, for those who prefer the old way and abusing clueless guards as they wonder what force of the universe must be hitting them.

By the way, and I just realized this now: The problem doesn't only affect attacks, but also spotting the player before attacking. Think of the last time a guard standing outside spotted you on a balcony before you hid, enough to draw their swords and start searching but not attack you outright; The guard was alerted by something in a building, yet he draws his sword to search the area near him. If I'm standing outside and think I see a burglar in my house through the window, I'm going to go near my home if I plan to confront the possible intruder, not start looking around the road next to me and say "I know you're here somewhere" which would imply I have a serious problem :P

Main reason I mention #2 is when I helped with transcribing the subtitles for the drunk voice, I noticed there are voice lines for AI returning with an ally. Two in fact: If the player is still there the AI has a voice line for telling the other person "that's the one let's get him", if the player hid there are lines such as "you were too slow now he got away". Those voices in particular are never played, or at least I don't remember ever hearing them in all those years: It occurred to me while I wrote this post that they're likely designed for a mechanic that was never implemented... or was but broke very long ago? Curious what its history is.

Edited by MirceaKitsune
Link to comment
Share on other sites

AI specifically have code to test the attack vector I think, so they should generally know where it came from. They're also supposed to prioritize possible hiding places and investigate them first.

If you're playing with AI acuity turned down, it might cause them to lose you in darkness faster.

 

I have them both on Challenging and they go to alert almost instantly even when I'm just a little lit up. It's very challenging on open maps when you are on a balcony.

I always assumed I'd taste like boot leather.

 

Link to comment
Share on other sites

On 2/4/2024 at 6:58 PM, AluminumHaste said:

AI specifically have code to test the attack vector I think, so they should generally know where it came from. They're also supposed to prioritize possible hiding places and investigate them first.

If you're playing with AI acuity turned down, it might cause them to lose you in darkness faster.

 

I have them both on Challenging and they go to alert almost instantly even when I'm just a little lit up. It's very challenging on open maps when you are on a balcony.

Oh yes: I have both sight and hearing set to Forgiving. I didn't think that would be related: IIRC it only affects the multiplier for how much being seen in light or heard while making noise increases the alert level per event. I should test on a higher alert level too just in case: I tend to be sloppy and impatient thus I used that for years so I wouldn't get caught all the time on more difficult FM's (lots of guards in tight areas with lights you can't turn off).

I have noticed an aspect that does work well: If you're making noise by running even in darkness, alert AI will head toward your direction while searching, they won't go around randomly but actually care where the impulse came from. The problem is that this doesn't seem to scale over larger distances: If they briefly see you in broad light at a distance enough to draw weapons, AI won't head toward your general direction but begin searching their own vicinity... and at least on Forgiving the same happens if you shoot a broadhead arrow at a guard's helmet: I still think the guard should actively run toward your location instead, not exactly where you are but they should go to that road or barge into the same building.

Link to comment
Share on other sites

So you set the AI to be blind and deaf and are surprised when they act the way they do.

EDIT: Also makes sense that when a guard sees you far away, and shouts, then you duck back into cover, that he would start searching his general vicinity as he's already "lost" you.

 

  • Like 2

I always assumed I'd taste like boot leather.

 

Link to comment
Share on other sites

2 hours ago, AluminumHaste said:

So you set the AI to be blind and deaf and are surprised when they act the way they do.

EDIT: Also makes sense that when a guard sees you far away, and shouts, then you duck back into cover, that he would start searching his general vicinity as he's already "lost" you.

Wasn't sure what blind and deaf actually mean to the code: I thought they only offset the alert level increase rate, not what AI does afterward. You're right that it's kind of silly I didn't think to check on higher difficulty settings as they didn't come to mind as a possible factor. I'll do that as well and see which of those points it improves: #1 might be offset by that... I think the others aren't difficulty related and just not implemented, I'll actually check before presuming though.

Link to comment
Share on other sites

Okay: I replayed a few missions with difficulty set to Hardcore which is the maximum setting. Nothing obvious changes: All of the same issues persist, including the ability to beat up a guard with no reaction by climbing on a table in total darkness. All that changes is guards running to your location a bit more accurately when seeing you from a distance, attacks however don't count as sight. I decided to record a video for this thread to show my point, Crucible of Omens: Behind Closed Doors.

What's happening here: While standing on a ledge that should be reachable by a stair, I shoot the guard in the back as he's walking away. His first reaction is to run down the stairs in the completely opposite direction. A few seconds later he comes running back up, only to go in a crevice at the other opposite end of where I was located. By sheer chance he heads somewhat toward my initial position, after which he runs down the stairs again. He finishes his alert state far away, looking for me far at the bottom of the stairs where I clearly wouldn't have been located.

How this could have been better: The guard was shot in the back, it doesn't take a genius to tell that's where the arrow came from. He should have picked random positions in a cone originating from his view and facing toward me at the moment of the shot: He shouldn't come running to my exact location which would be both difficult and unrealistic, but should have searched in my general direction such as the wooden door to my right.

Edited by MirceaKitsune
Link to comment
Share on other sites

IMO it's better to create test maps for such cases, who knows how AAS and monsterclip layout looks like in this mission.

Also, it might be a subjective question of how picky you are. I wouldn't mind that guard going in a general direction of where the damage came from; it kinda looks like he assumed the attacker has already changed his position, which is not a bad idea itself :D

Link to comment
Share on other sites

4 hours ago, peter_spy said:

IMO it's better to create test maps for such cases, who knows how AAS and monsterclip layout looks like in this mission.

Also, it might be a subjective question of how picky you are. I wouldn't mind that guard going in a general direction of where the damage came from; it kinda looks like he assumed the attacker has already changed his position, which is not a bad idea itself :D

Technically a good way to justify it is him suspecting the attacker may have changed position, though that should happen slowly over time. A solution then might be to widen the search radius with each iteration: First he'll run to a location close to the player, next time it may be one further away, etc.

It's not too bad the way things work now, just think there's room for some improvement: In my example which is easy to test on any map, you can tell the pattern is completely random and the guard looks silly with his search. He clearly picks random spots within a radius of himself run to, which don't have any intelligent decision making behind them.

Link to comment
Share on other sites

@MirceaKitsune - have you raised a bug report for this particular problem (searching in the wrong place if shot by an arrow)? I think I have found the cause of it and can write it up in the bug tracker.

In short, I believe the intended behaviour is that the victim is supposed to search halfway between him and the shooter (presumably chosen because he shouldn't really know where the shooter really is) but the code that sets this point gets overridden shortly afterwards by code that sets the search point to his current location.

It's quite instructive (if you like that sort of thing) to read up the various bugs reports on AI behaviour that have been raised down the years. In particular, bug 3331 contains a number of fixes to problems similar to those reported in this thread.

Link to comment
Share on other sites

4 hours ago, boissiere said:

@MirceaKitsune - have you raised a bug report for this particular problem (searching in the wrong place if shot by an arrow)? I think I have found the cause of it and can write it up in the bug tracker.

In short, I believe the intended behaviour is that the victim is supposed to search halfway between him and the shooter (presumably chosen because he shouldn't really know where the shooter really is) but the code that sets this point gets overridden shortly afterwards by code that sets the search point to his current location.

It's quite instructive (if you like that sort of thing) to read up the various bugs reports on AI behaviour that have been raised down the years. In particular, bug 3331 contains a number of fixes to problems similar to those reported in this thread.

Thanks for mentioning this: I did not know that and it explains some things, though I didn't imagine a +10 year old bug that got forgotten would be involved. I did mention it in my report about being able to beat up clueless guards by standing in total darkness, not as a primary focus though so this should probably be reported separately.

https://bugs.thedarkmod.com/view.php?id=6436

The functionality you describe would be even simpler: Have a virtual box between you and the attacked guard and pick positions only from there. That would be hardwired to a 90* angle on every axis though: The best solution I can think of is using an AI awareness setting to trace a cone from the AI to the player and pick positions within that virtual cone, the smaller the cone the more accurate the guard's prediction so give it enough space to be fuzzy but accurate enough.

Link to comment
Share on other sites

I have added some notes to 6436 relating to the 'shot from afar' problem.

For your main point (1 in your original report) I think that the main aspect of it is that you are (code-wise) literally invisible to the guards. It's as though if there was a real-life invisible man who whacks you on the shoulder from behind, you'd whirl round and there would be no-one there. What would you do?

 

  • Thanks 1
Link to comment
Share on other sites

I would guess you would take a random swing and maybe something like this could be implemented. Like if the player hits the guard with his sword, sooner or later the guard should just hit back even if he can't see the player. I don't think we need to do anything about hitting guards from far away in the back. How should they know where the arrow came from?

Edited by wesp5
Link to comment
Share on other sites

22 hours ago, wesp5 said:

How should they know where the arrow came from?

Obviously they should know the general direction it came from, the AI would feel where the arrow hit and how it pushed them: If an arrow struck them in the back, it's clear that arrow wouldn't have come from the front... if it hits them in the right arm, obviously it didn't come from the left. TDM disables arrow sticking for living AI, probably since it would look too silly as guards don't have a wounded state with custom animations to match that up... realistically though you'd look and be able to tell from the angle of the arrow where it hit you, it's not like bullets where you can't be expected to analyze a bullet wound in real time and feel which direction such a tiny and fast projectile hit from.

Link to comment
Share on other sites

Basically correct, but most of the TDM missions are not on an open field, but in narrow town environments. As has been said before, the bowman could have moved or hid himself. I see that a lesser problem than them not reacting to melee attacks which must come from nearby!

Link to comment
Share on other sites

24 minutes ago, wesp5 said:

Basically correct, but most of the TDM missions are not on an open field, but in narrow town environments. As has been said before, the bowman could have moved or hid himself. I see that a lesser problem than them not reacting to melee attacks which must come from nearby!

That is true, which is why slowly widening the search area over time would be even more realistic, just don't think instantly picking random locations everywhere feels right. As my video shows though, the guard was hit directly in the back and immediately went searching down the stairs right in front of him: That's like someone who got his foot stuck in the floor looking up thinking something is hitting them over the head.

Link to comment
Share on other sites

24 minutes ago, MirceaKitsune said:

As my video shows though, the guard was hit directly in the back and immediately went searching down the stairs right in front of him...

I agree, they should at least turn into the direction they were hit from, that should be easy enough to implement. They could then start their usual search pattern.

Edited by wesp5
Link to comment
Share on other sites

3 minutes ago, JackFarmer said:

I've encountered this problem every now and then:

https://streamable.com/gm74g1

In that case they seem to go in the right direction and attack accordingly. What you could have expected to see for instance: If you only activated the lantern for a few seconds as to make the AI lose you, it's possible the guard may have instantly went searching in the opposite direction as if having no recollection of what (or rather where) caused it to become alert.

Link to comment
Share on other sites

8 minutes ago, JackFarmer said:

I've encountered this problem every now and then:

https://streamable.com/gm74g1

That looks stupid. Isn't there a setting to make guards alerted if they hear combat sounds or other guards nearby are alerted? Even Bloodlines has the first option as standard that can be set for any AI and can do the other using stats!

Edited by wesp5
Link to comment
Share on other sites

15 minutes ago, AluminumHaste said:

Yes AI in combat or search alert other AI.

Are these AI on the same "team"?

No, you are right, that was my mistake. Thank you for asking that, cause this would have caused me problems during beta testing as every AI must be on the same team in this mission.

Anyway, this happens when both are on the same time (tested three times, each time the same result):

https://streamable.com/0n3yqg


This is much better...but far from perfect. During the second try the other guy returned, but did not assist his friend. :)

Link to comment
Share on other sites

I noticed he has a bow but no melee weapon.

He's probably trying to run away to get space to fire arrows, but that might be around the corner and out of range. So he comes back then runs away again.

I always assumed I'd taste like boot leather.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...