Jump to content

How do Game Devs program NPC attack decisions?


Recommended Posts

Posted (edited)

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
Posted

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

 

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
  • Recently Browsing   0 members

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