Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
2  
This is a pretty broad question, do you have a specific issue you're dealing with? –  Byte56 Sep 23 '12 at 23:09
    
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. –  joon Sep 23 '12 at 23:17
3  
1  
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 –  junkdog Sep 24 '12 at 12:35

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.