Jump to content

How do Game Devs program NPC attack decisions?


Recommended Posts

Im looking for the direction of knowledge to help advance my own scripts, I assume If/else statements are to slow to respond to character actions but I want to know how things are done with games and other situations like:

  • Dark Souls
  • Threatre of Blood

You can tell most of runescape Npcs just throw 1 move at your character whether it's a magic/range/melee. Obviously a simple Attacking state and then healing states... but even zulrah just changes it's attack styles in a cycle and based on it's HP.

In more advanced games, how do developers get NPCs to defend from attacks? Would most game NPCs simply have 5 different attack moves which then get selected at weighted-random? Then when the HP is lower... Would stronger Attack methods become avaible to the NPC because of critical health booleans becoming true? 


I thought maybe they use Decision Trees, Is this where I should be looking? I never went to university for game Dev so the concept of advanced Decision models is hard for me to study, I know advanced games probably don't use java but I'm sure these things are still achievable within it because Threatre of Blood looks quite complex, or is it...? It's got to be more then if else's...


Thanks for any responses:cate:

Edited by Elixar
Link to comment
Share on other sites

Conditionals are definitely used, and they aren't slow enough to be even close to noticeable.

If i were to guess, I'd say all combat in games is handled on the same thread, so when a player attacks, the developer could call an event and have all other NPC's react accordingly, as there would be quite a few frames between when someone presses a button, and when the effect of that button press happens


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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...