Jump to content
The Dark Mod Forums

AI Entering Combat State


grayman

Recommended Posts

I've been testing a few changes to how AI enter Combat State today.

 

This will hopefully eliminate (or at least reduce) an AI's quirky "I'll fight you w/o drawing my weapon" problem. I don't remember if there's an issue already filed for this.

 

I think this problem happens if he's real close to you and his draw weapon animation gets overridden by his combat animation. He simply starts fighting w/o his weapon.

 

To try to put a stop to this, I'm having him draw his weapon and complete that action before he starts to run at you, and before he starts actual combat.

 

If he's a good distance from you when he spots you, there's enough time for him to run at you and draw his weapon at the same time (as he does today). So separation distance also plays a part.

 

I've also added some randomness in the sequence, so that if two guards spot you in the same frame, they both don't react in the same time, bark at the same time (causing the echo effect), draw their weapons at the same time, and start running at you at the same time. With the randomness, one guard might end up hanging back and drawing his weapon moments later as his buddy charges you w/weapon ready. And their barks won't coincide.

 

This won't affect archers too much, since they only make an attempt to get closer to you if you're out of range. But they'll run the same code.

 

I have a sample map where I saw the "weaponless combat" problem pretty consistently between 2 enemy AI, back when I was testing the "KO AI by dropping things on them" feature. With today's changes, both weapons come out and the problem goes away.

 

If you have comments about this, now's the time.

 

If you have a sample map with AI in it that are enemies, I can test these changes with your map if you make it available. I don't recall any released missions where AI were pitted against each other.

 

-------------------------------

 

On a separate but related note, anyone have any ideas on how to improve the poor archer's melee ability? He has no melee weapon, and just stands there and takes it. Perhaps he should flee to some spot where he can bring his bow to bear?

Link to comment
Share on other sites

The changes sound great!

 

This won't affect archers too much, since they only make an attempt to get closer to you if you're out of range. But they'll run the same code.

 

Are you sure about this? I know I've had archers run at me with nothing in their hand, and they just keep running into me. I remember specifically this happening with the archer at the top of the tower in Business as usual, but it's happened elsewhere as well, including at least one LP I watched. This tends to happen only when the archer is close by when they see you, which made me think the archer's melee code was engaging.

 

On a separate but related note, anyone have any ideas on how to improve the poor archer's melee ability? He has no melee weapon,

 

Archers are supposed to switch to a melee weapon if the player gets too close. But there was some problem with this not working properly so I removed the def_attached melee weapons. I forget now exactly what the problem was (and my tracker entry is decidedly unhelpful).

 

http://bugs.thedarkm...iew.php?id=2527

 

Ah, I had a tracker entry for the first behaviour as well, and they're connected. http://bugs.thedarkm...iew.php?id=2533

 

 

Btw, I've been seeing this problem a lot recently while testing AI vs monster combat: http://bugs.thedarkmod.com/view.php?id=2964 Maybe you can keep your eye out for anything that might be causing this.

Link to comment
Share on other sites

Are you sure about this? I know I've had archers run at me with nothing in their hand, and they just keep running into me. I remember specifically this happening with the archer at the top of the tower in Business as usual, but it's happened elsewhere as well, including at least one LP I watched. This tends to happen only when the archer is close by when they see you, which made me think the archer's melee code was engaging.

 

When I say it won't affect the archer much, I'm talking about it not affecting how he uses his bow. His lack of a melee ability remains a problem, thus the separate question I asked above as to how we should improve that situation.

 

Archers are supposed to switch to a melee weapon if the player gets too close.

 

Is there more than just attaching a melee weapon to him to start debugging why his melee path doesn't work? What weapon is he supposed to carry?

Link to comment
Share on other sites

Things to note (been a while since I played, information might be off):

 

- AI should be able to finish the drawing weapon procedure without being interrupted by pain anims when hit while doing it. This happens now and makes them defenseless targets to a running player rapid firing sword blows. They should still take damage of course, just not have the drawing action stopped and reset when hit.

 

- AI sometimes have a hard time dealing with a fast moving player - before they draw, they often want to be facing the player to be able to do it, resulting in hesitation and resetting positioning (while the player is free to hit him by going in and out of range).

 

- AI reaction time between alert-fully alert-aware of the player-drawing for combat is often too slow; the player is able to cover a lot of distance when running before the ai will recognize him as a threat and defend himself (this might or might not be accurate, Im talking about a typical situation where you come from a dark shadow area and ambush some ai in a lit area). If you have his back then the situqtion should be hopeless for them, but if they are facing you while your running towards them they should be able to react a bit faster.

 

Ps: These are NOT meant to start a discussion on melee again, these are only small adjustments Im talking about to refine an already functioning setup.

Edited by RPGista
Link to comment
Share on other sites

"guards forget to draw their sword"

-- a big thanks for addressing this.

 

On the rare occasion, a guard will also forget to stand up when he goes to attack the player. He'll just sit there, look at you and spin around to face you. I'll bet this is the same thing as forgetting to draw the sword? It happens when you're close to him when he goes to attack.

 

As for the last part, I'm not sure. Perhaps he could just beat the player over the head with his bow? You can always take the easy way out and just give him a short dagger for melee. Easy because you can re-use animations, hard because of more coding necessary.

Edited by lost_soul

--- War does not decide who is right, war decides who is left.

Link to comment
Share on other sites

On the rare occasion, a guard will also forget to stand up when he goes to attack the player. He'll just sit there, look at you and spin around to face you. I'll bet this is the same thing as forgetting to draw the sword? It happens when you're close to him when he goes to attack.

 

This is a completely separate issue that occurs when AI can't stand up (due to the player blocking their path). It looks like they only try once, and if that fails, they stay seated. It's tracked somewhere.

 

Is there more than just attaching a melee weapon to him to start debugging why his melee path doesn't work? What weapon is he supposed to carry?

 

Originally I was going to attach a dagger. However, the problem of him running straight into the player when he's in melee range happened regardless of whether he has a weapon attached or not. This was a couple years back, so I can't remember if there is a spawnarg that needs to be set to allow him to attack with the melee weapon or whether it's default behaviour. My hunch is the latter.

Link to comment
Share on other sites

On a separate but related note, anyone have any ideas on how to improve the poor archer's melee ability? He has no melee weapon, and just stands there and takes it. Perhaps he should flee to some spot where he can bring his bow to bear?

 

The most rational choice for me would be giving him a melee weapon, like a dagger or even a blackjack. What could be different would be his behaviour while using this weapon. Instead of being offensive, he could simply try using it to keep distance from you, while trying to run away towards a safer place to shoot his bow or alert his comrades.

Edited by zergrush
Link to comment
Share on other sites

I've given my test archer a dagger and he still won't use it.

 

I don't see anything in the code that says to put away the bow and draw the dagger (or vice versa). Perhaps it's hidden somewhere in the scripts.

 

I'm also a bit worried about the replace animations. They might not automatically work when two weapons are attached. If you remember, I had all sorts of problems with the replace anim design, in that it didn't allow for various combinations of attachments, really only being designed to handle one.

 

--------------------------------

 

The bit about the AI not standing up before going into combat mode might have something to do with combat aborting the standing up animation. I'll have to investigate that. The code doesn't wait until the standing up anim is done before executing the draw weapon or run toward player code. That's probably okay when the player is at a distance, because there's time for the stand up + draw weapon + run anims to play out before closing w/in melee range. But when the player is close by, I suspect that he enters melee combat before any of the other anims have finished, possibly aborting them and leaving the AI in a bad state.

Link to comment
Share on other sites

The most rational choice for me would be giving him a melee weapon, like a dagger or even a blackjack. What could be different would be his behaviour while using this weapon. Instead of being offensive, he could simply try using it to keep distance from you, while trying to run away towards a safer place to shoot his bow or alert his comrades.

 

I doubt if there's anything in the melee design that is strictly defensive. Once he enters melee combat, he's going to try to stab the enemy.

 

Having him flee after drawing the weapon is a possibility, though. Don't let him enter melee combat, and change the existing flee code to allow for "falling back to a better position". If he were to do that, then he wouldn't need a melee weapon, because he'd never have a need for it.

Link to comment
Share on other sites

- AI should be able to finish the drawing weapon procedure without being interrupted by pain anims when hit while doing it. This happens now and makes them defenseless targets to a running player rapid firing sword blows. They should still take damage of course, just not have the drawing action stopped and reset when hit.

 

I'll look into that.

 

- AI sometimes have a hard time dealing with a fast moving player - before they draw, they often want to be facing the player to be able to do it, resulting in hesitation and resetting positioning (while the player is free to hit him by going in and out of range).

 

There's nothing in the code about having to face the player before drawing the weapon. I'll look into what might be causing the reset behavior, though.

 

- AI reaction time between alert-fully alert-aware of the player-drawing for combat is often too slow; the player is able to cover a lot of distance when running before the ai will recognize him as a threat and defend himself (this might or might not be accurate, Im talking about a typical situation where you come from a dark shadow area and ambush some ai in a lit area). If you have his back then the situqtion should be hopeless for them, but if they are facing you while your running towards them they should be able to react a bit faster.

 

So it sounds like the fixes we made to keep AI from seeing you instantly have mucked with this particular situation. Others will need to chime in on this, because we don't want to make it impossible for the player to surprise an AI from the front.

Link to comment
Share on other sites

I doubt if there's anything in the melee design that is strictly defensive. Once he enters melee combat, he's going to try to stab the enemy.

 

Having him flee after drawing the weapon is a possibility, though. Don't let him enter melee combat, and change the existing flee code to allow for "falling back to a better position". If he were to do that, then he wouldn't need a melee weapon, because he'd never have a need for it.

 

Actually he would. Plain intimidation. If your enemy draws a blade, and you're close to him, you would instinctively draw your own as well and halt, giving him a chance to run away, for instance. Just a thought, though.

Link to comment
Share on other sites

I've created issue #3331 to cover the situations I'm looking at, and to reference existing issues, in case they get fixed in the process.

 

If there are any other new or existing issues you know of that are related to entering Combat, post them here so I can reference them from the new issue.

Link to comment
Share on other sites

 

Actually he would. Plain intimidation. If your enemy draws a blade, and you're close to him, you would instinctively draw your own as well and halt, giving him a chance to run away, for instance. Just a thought, though.

 

True. We only have "run away when my health gets low" behavior, though. We don't have "run away when his weapon is bigger than mine" behavior. I don't know if that was discussed by the original team years ago.

Link to comment
Share on other sites

Regarding ranged AI switching to melee weapon. I noticed weird behaviour with this, too. I did some testing with a city watch archer. The archer has attached a dagger by default. There is a spawnarg "melee_range" that seem to handle at which distance the ai should go to melee mode. The funny thing is, that it doesn't. It just keeps running at you.

 

You can test this by increasing the melee range. So it seems that the ability of switching weapons is partly implemented, but the switch never takes place. I took a look in the code myself but must admit that I didn't find anything related to this either. :unsure:

 

I hope anybody else has more luck as this "pushing you into the next corner" behaviour of ranged AI is a bit nerving.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I couldn't find anything in the code that would cause the archer to sheathe his bow and draw his dagger. Or vice versa. The code appears to be written for creatures like the imp (or AI like the mage) that can do both melee and ranged combat, but do not actually have a weapon that needs drawing and sheathing.

Link to comment
Share on other sites

But there must be code to tell the AI to draw his weapon (and which weapon) and to put it away again. (And some code telling the archer to run into me to defeat me :smile:)

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

There's code to draw a weapon when Combat state starts. And to sheathe it when it ends.

 

While Combat state is running, it checks distance to the enemy each time the AI thinks, and decides whether to switch between ranged and melee. In that code, there's nothing about sheathing or drawing weapons.

Link to comment
Share on other sites

Question: You've said it checks the distance during the combat. Does it check the distance before the combat (to decide with which weapon to attack)?

 

If not I would suggest the following:

  • put a distance check at the beginning so the AI can decide which weapon to attack with (If not already there)
  • while combat, if the distance changed in a way making it necessary to change the weapon, just end the weapon state (I guess this causes the AI to put away it's weapon and as still alerted to draw the appropiate weapon afterwards)
  • maybe include some sort of timeout variable, so the ai does not switch the weapons on and on if the player repetively closes up and take distance (maybe favor melee weapon once the player was close enough and is still reachable for a certain amount of time)

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

http://www.youtube.com/watch?feature=player_embedded&v=fxU7zQxa9o8#!

 

Some references to issues being discussed:

 

0;50 - Issue of AI being often deaf to the death cries of comrades.

 

1:53 - Archer fighting (the bow stops blows while he fires arrows, the player has to strafe in order to get a clean shot).

 

2:41 - "Treadmilling on player's chest" issue.

 

3:19 - Running all the way to AI and killing him, frontal view, he only gets slightly alerted before the end.

 

3:56 - Running all the way to AI and killing them, they cant hear the running untill too close, nor the death cries and sword hits (not even the steambot alerts them fully).

 

4:09 - Running all the way to AI and killing him, rapid fire keeps him from drawing weapon, strafing makes him hesitate (one or the other).

 

Didnt see an instance where AI is prevented from drawing weapon by being hit, though I was quite sure I saw that happening more than once...

Edited by RPGista
Link to comment
Share on other sites

There is no check for distance when the AI first draws his weapon, because it's not needed in the current design, which assumes each AI only has one weapon. (We're talking about hammers, daggers, swords, etc., not the weapons that mages use.)

 

As to whether the AI reaches behind his back for a hammer, or draws his sword from his hip, that is defined by the weapon attachment via what's called replacement animations. An AI starts life with the default weapon-draw animation, which is a "draw sword" animation. When, at spawn time, he gets a hammer attached to his back, it sets the weapon-draw animation to a "draw hammer" replacement animation, so that when it comes time to draw that hammer, the correct animation gets played.

 

As I noted, switching from melee to ranged appears to have "weapon-less" AI in mind, such as imps or mages. In their cases, there's no drawing or sheathing animation, so the code doesn't bother with that.

 

In order to give an archer a dagger, and have him be able to switch back and forth between melee and ranged combat, I need to make a bunch of changes that disrupt the assumptions made when the code was first written. That will, indeed, need to know at combat start, which weapon to draw, and when melee vs. ranged distance checking happens while fighting, drawing and sheathing needs to be added there. As a prerequisite for playing the correct weapon-drawing animation, that needs to be set on the fly depending on which weapon is being drawn. Rather than rely entirely on the replacement animation code, I'll need to interrogate the weapon I'm about to call for, and ask it what drawing animation it wants me to use, then I'll have to apply that via the replacement code.

 

So there's a bit of work to do.

 

I don't know if ending the combat state and restarting it with a different weapon would work. There's a lot of baggage going in and out of this state, so the odds of it looking awkward are high. If I can get the code to switch weapons on the fly, that'd be smoother.

  • Like 1
Link to comment
Share on other sites

Some references to issues being discussed:

 

I won't be looking at the bark issues as part of entering the combat state. They're a sound propagation issue.

 

Running at the AI and surprising him can probably be mitigated by small changes in the code that AIs use to spot the player. Since the 1.08 changes I made to keep AI from seeing you instantly from afar were tweaked thoroughly, and well-tested, futzing with them will require thorough re-testing.

Link to comment
Share on other sites

In order to give an archer a dagger, and have him be able to switch back and forth between melee and ranged combat, I need to make a bunch of changes that disrupt the assumptions made when the code was first written.

 

I had been lead to believe that the code was already working, but perhaps there was some confusion and they were talking about unarmed combat.

 

The list of changes sounds like a lot of work. Would it be easier/better to just have archers run away when the player gets within a certain range?

Link to comment
Share on other sites

I had been lead to believe that the code was already working, but perhaps there was some confusion and they were talking about unarmed combat.

 

I don't see how it could have been working, since attaching the bow to the archer replaces his "draw" anim with "drawBow". If he then needed to draw his dagger, the code would have to put the draw animation back to "draw", which it currently doesn't do. Ditto when replacing "sheath" with "sheathBow".

 

They probably were referring to unarmed combat, which can switch back and forth between melee and ranged combat easily, since no weapons are involved.

 

The list of changes sounds like a lot of work. Would it be easier/better to just have archers run away when the player gets within a certain range?

 

Certainly. I'll continue with the attempt to switch between the dagger and the bow, though, to see if something comes of it.

Link to comment
Share on other sites

@Spring,

 

Tell me again how "search", "search1", "search2", and "search3" are supposed to work, or be chosen, when searching.

 

If the mage uses "search3" and the forger uses "search1", and the code tells them to use the "search" anim, are we just using whatever "search[N]" has been registered for that AI?

 

I can't find where the code does that.

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

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • 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 )
      · 3 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
       
      · 7 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...