0
\$\begingroup\$

I'm making a game in Flixel and I need to program an NPC. It's rapidly turning more complex than I expected. I was wondering if there are any best practices, tutorials or examples that you can refer me to, to see how this is done.

I can probably hack it together, which is what I always do, but it would be nice if I can make it maintanable and can add stuff later on.

Here's screenshot to give you an idea: The butler will be an NPC that will follow you, or guide you, and talk to you the whole time.

enter image description here

EDIT: More specifically: What I have now is a long list of IF statements in the update loop of the butler (about 8 different cases), and all I have covered is his walking behavior. I want him to comment on things and sometimes switch his main behavior to be more aggresive or distant,... Is there any way to keep track of this, or is complex code with many many nested if statements the way to go?

\$\endgroup\$
4
  • 2
    \$\begingroup\$ This is a pretty broad question, do you have a specific issue you're dealing with? \$\endgroup\$
    – House
    Sep 23, 2012 at 23:09
  • \$\begingroup\$ You are right, I tried again to be a bit more specific, but feel free to flag the question if you think it is inappropriate. \$\endgroup\$
    – joon
    Sep 23, 2012 at 23:17
  • 3
    \$\begingroup\$ New to creating AI - where to start? \$\endgroup\$
    – House
    Sep 23, 2012 at 23:20
  • 1
    \$\begingroup\$ Don't have time to post a proper answer, but check out the slides from the GDC talk "AI-driven Dynamic Dialog through Fuzzy Pattern Matching", it's both simple and elegant: gdcvault.com/play/1015317/AI-driven-Dynamic-Dialog-through \$\endgroup\$
    – junkdog
    Sep 24, 2012 at 12:35

1 Answer 1

2
\$\begingroup\$

From your description it sounds like you need some kind of state machine, maybe switchable for different rooms/zones to keep things maintainable. Take a look also at Behavior Trees: http://twvideo01.ubm-us.net/o1/vault/gdc10/slides/ChampandardDaweHernandezCerpa_BehaviorTrees.pdf

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .