Jump to content
The Dark Mod Forums

Enemy AI


Stardog

Recommended Posts

I'm remaking Dishonored for programming practice, and I'm wondering how your enemy AI works. I decided to go with a Behaviour Tree after getting into a mess with a state machines (multiple communicating using Events).

 

My alert system works with timers. If you are in view for X seconds (depends on position/distance), it will increment the alert level.

  • Alert 1 - (LOOK) Stop patrolling. Turn to look in direction of object noticed (last known position). Timer countdown if player is still visible.
  • Alert 2 - (SEARCH) Move towards last known position. Timer countdown if player is still visible. If not visible, search nearby for 20 seconds.
  • Alert 3 - (CHASE/ATTACK) If player is still in view, start chasing. If he runs more than 20 units away, go back to level 2.

Also, does your AI have peripheral vision? I split my view cone into 27 points which decide how fast the countdown timer is. So 75 degrees X, 50 degrees Y and 50 distance means the timer will take a long time before Alert Level 1 happens. If you are 0 degrees X, 0 degrees Y, 5 distance, then you're standing right infront of the guard, and the countdown timer will cycle through alert levels faster.

 

If you did a behaviour tree, it would be interesting to see it, because I only started learning them 2 days ago and I can't find many decent examples of guards.

Edited by Stardog
Link to comment
Share on other sites

I'm not familiar with behavior trees, so I'll just give you a simple overview.

 

Our AI rise and fall through 6 alert states, governed by an alert number that is added to by fixed amounts when certain events occur around the AI (finding a dead body, noting that some important loot is missing, etc.).

 

They're given tasks (walk to point B, open a door, use an elevator, investigate a location, etc.). Some tasks can be interrupted and resumed later, other tasks are mutually exclusive to each other.

 

Each AI has a FOV depending on their physical makeup. Eye patches, helmet visors, etc. can reduce the FOV horizontally or vertically. I haven't examined this code enough to know if vision is more poor on the periphery of the FOV than it is in the center.

 

The AI's ability to spot the player is governed by the player's visibility (how much light is on him at any given time), the AI's visual acuity, the LOS to the player, and how long the player is in view.

 

If you want to look at the code, you can obtain a copy of the 1.08 source from this page.

Link to comment
Share on other sites

There is also an alert level float behind those stages. If it raises above a certain level, the alert stage is increased. Some events can cause the alert level (and therefore the stage) to jump on a certain value.

 

If for example the ai identifies an enemy (for example the player), it immediatelly goes up to alert stage 5.

 

The searching behaviour also aims for searching on the last known position (or a position that caught the attention of the ai last if it can't see the enemy, for example a sound) and takes the lighting into consideration IIRC. This means the prefer to search dark areas (as the ai could see the enemy if it would stand in bright light). I'm not sure if other aspects are taken into consideration as well.

 

I don't think that the angle inside the fov of the ai plays a role in identifying it, at least not in a way that it is noticeable, but I don't really know.

 

There are other thinks that can cause the alert level to grow, for example unlocked or opened doors, missing items and turned out lights. It can also be manipulated via script.

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

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

    • 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
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...