the black hole 
it all ends here. 
bhC login
 the black hole's front page. all the latest vb rpg development and vbgaming news, as well as this week's feature rpg project!
rpg theory (7)
directx in vb (3)
vb rpg programming (4)
miscellaneous (4)
rpg / tile engine source (23)
full vb games w/ source (5)
'helper' libraries and utilities (13)
effect samples (5)
miscellaneous (10)
rpg projects
 vb rpg projects under development by members of the bhC. show them your support, and check out their games!
message board
 a forum to interact with your fellow vb rpg programmers. you do *not* have to be a bhC member to post!
vb rpg programming (5)
vb gaming (14)
general game programming (6)
vb sites (6)
miscellaneous (2)
general rpg programming (2)
 you want to contact the guy behind the black hole? here's where to do it!


Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\sites2\\blackhole\include\ on line 40
<< Back to Category List

Developing advanced NPCs - page 1

pages: prev | 1 | next
Developing advanced NPCs
By Kiko

(1) Finite State Machine - An abstract machine which changes from state to state based on its current state and the input that it receives.

Overview This document will discuss ways to better develop your NPCs into intricate real life characters and not just lifeless puppets. It is in no way a technical tutorial with source or anything of the sort.

Main In most any RPG ever made, the NPCs were simply characters which stood in the same position for most of the game and were only there to tell the main character an important piece of information, at the most. But what if you could develop more realistic NPCs, some which actually led lives? Well you can, using what we already use every day! Our human feelings of moods. Yup, it's that simple. If you've ever gotten the chance to play the game, The Sims, then you've already got the gist of where I'm going with this. Simply by giving variables to each NPC, and creating a (1)finite state machine, you can create an NPC capable of living a realistic life.
First of all, the variables. What kind of variables will we need to realistically mirror a person's life? Well, the basic variables that can cause us to change what we are doing would be: hunger, tiredness, social needs, physical needs, and emotional needs. To break this down further, here would be the specific needs of a person: food, sleep, fun, friends, lovers, money, and hygiene. So we would just assign variables to each of the needs. From there the finite state machine will take over. The finite state machine for us will become the ultimate make or break point. It will take all the variables into account, then according to what the character needs most, and what time of day it is, it will change the state of the NPC. The reason we need to take into account what time it is, is because we need to make sure they don't try to go buy groceries some time around 4 or 5 in the morning. Basically, as time goes on, each variable will move down. Like for bladder needs, you can't go more than a day before you have to use the restroom, so the bladder variable will move quicker than some of the others. As soon as the variable is down low enough, the FMS will take into account other variables which are getting low and will decide which is more important at that time and will change the state accordingly(i.e., sleep variable is low, NPC goes to sleep). Then, as soon as the character has performed the needed action (i.e. sleep, eat, socialize, etc.) then the variable will go back up so that other needs can be assessed.
Quick note: The money variable should be used less as a variable and be used more as a control. Depending on if they have enough money or not, they can buy more/less food or maybe even take a day off of work. The reason for this is that the NPC should, as in real life, go to work at set times, not just whenever they need money.

Another thing that we can include to make better NPCs are sub-moods. A sub-mood to friends would be how each NPC likes/dislikes another NPC. They could grow to like or dislike one another depending on what they decide to say to each other and act towards each other(All done randomly). For example, if a guy and a girl act nice to each other for a while, their variable for liking each other might go through the roof, at which point they might arrange a marriage or go, well ya know. Or on the other hand, two guys might consecutively say bad things about one another and eventually break out into a brawl. Going further, depending on certain relationships, a friend of somebody that dislikes a person, will also learn to dislike them.

In pseudocode:
player1.relationship with (player2) = -10 ' bad relationship
player1.relationship with (player3) = 10 ' good relationship
'player 1 and 2 met first and disliked each other, but player 1 and 3 like each other, now see what happens 'when players 2 and 3 meet!
player2.relationships with (player3) = -10 ' bad relationship

Through these small groups of people, what will eventually evolve will be cliques, possies, or even gangs. What intelligence! Another idea would be to include overrationing. In other words, buying more than you need for the time being. So instead of just buying groceries for a day, buy them for a whole week if the money is available. That way later in the week, the NPC would have more time for other things. Though this idea can be used on things for buying food, it obviously couldn't be used on such things as cleanliness and bladder needs.

This tutorial was a compilation of readings from PCgamer, Windows programming for dummies (finite state machine), and mostly of just my general ideas and everyday ramblings of the sort. Though these concepts wouldn't be of much use to an RPG where you spend little time in each town, it would be good in such a game where the basis revolves around a town or two.
I hope these random ideas can help and spur your own ideas for everybody out there.


pages: prev | 1 | next