Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Scet

How do A_Chase and P_DoNewChaseDir work?

Recommended Posts

OK this should be my last question for a while. Basically I'm onto the AI component of my game. I was thinking of using the A* algorithm with either sub-sectors or the blockmap, but after looking at Dooms code this seems to be too much.

So I'm wondering if anyone can explain how A_Chase and P_DoNewChaseDir work? I already know about tolerance and not targetting itself/other monsters like it. I just need to know how monsters walk toward the player and somehow manage to avoid obstacles. Is it just kind of a guess? Like if the player is east, head east? If the monster hits a wall, find a new direction? If the player is visible just face them? I don't see anything really complex in these functions, yet I can't believe it would be that easy.

If anyone could explain how these functions work it would be appreciated.

Share this post


Link to post

Although I don't know much at the code level, as a player I can tell you that the Doom AI is pretty simple and straightforward. Monsters wake up and generally head for the players direction, but if there are obstacles or walls in the way, they will generally make a left or right turn. Sometimes, especially apparent with Demons, they will hit a wall and go the opposite direction of the player until they hit a wall. I'm not sure why they do this, but it can sometimes be useful if a monster needs to go all the way around a level structure to actually get to the player.

A good way to observe monster movement behavior is to make a sort of maze-like map with monsters (I tested with demons and archviles) and put it on Nightmare with iddt x2 and just sit back and watch the automap. Sometimes it's amazing how well the monsters can navigate around the level without any complex AI scripting or anything...

Share this post


Link to post
Scet said:

Like if the player is east, head east? If the monster hits a wall, find a new direction? If the player is visible just face them? I don't see anything really complex in these functions, yet I can't believe it would be that easy.

It really is that simple.

P_Move() tries to directly move the monster in the current direction, and fails if it can't move (monster hit something), in which case a new direction is set. A new direction is also set when the 'threshold' timer counts down.

Share this post


Link to post
Ajapted said:

It really is that simple.


Well that sure makes my job easier. Thanks guys, I'll give the maze map a try too.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×