4
\$\begingroup\$

I'm developing a 2D Zelda game with LibGDX in Java using TileD maps. I am now adding NPCs to the engine and I'm thinking about how to make them so it's going to be easy for me to add/edit their custom dialog/behaviour conditions/interaction/etc in the future,

I don't really know how I should implement it all but I have an idea. I do not want to make subclasses for each NPC or each type of NPCs or whatever. I want to only have one NPC class. My current idea is to write a basic script for each NPC (in Groovy for example) and save it as a file in my resources, and then, to execute this script in Java in the corresponding NPC's "core" game loop code.

I'm not sure about how it's going to work, what should be aware of, or if there are any better solutions... So I'm asking some advice about how should I proceed to implement this. I don't know yet how limited the NPCs will be later but I want to guarantee maximum control over them, still being able to have them all unique if necessary.

\$\endgroup\$

closed as off-topic by Josh Dec 3 '13 at 4:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started" or "what should I learn next" cannot reasonably be answered with anything other than opinion polling and therefore are off topic for the site. For more information on how to ask a better question, see the help center" – Josh
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Have a look at component based entity systems. They're exactly what you are trying to implement. raywenderlich.com/24878/… gamedev.net/topic/… \$\endgroup\$ – Dan Watkins Sep 17 '13 at 3:07
  • \$\begingroup\$ I looked at it. And it seems like a possible solution BUT : I need a way to be able to evaluate custom expressions to trigger events, like reacting in a different way to an item given to the NPC. I can't seem how I'd be able to make this using this system... \$\endgroup\$ – N_Real Sep 17 '13 at 19:57