My game uses an entity component framework and uses scripts to define entities (itthis doesn't currentlydirectly define their behaviourbehavior, this is simply for definingI'll talk more about that at the entityend). The scripts define the actual components to be used for creating each entity. It uses a simple scripting language I created. Here is a simplified version of one of my scripts:
This whole thing involves creating a custom parser, some kind of structure to hold the entity definitions (I call mine the Lexicon!) and a factory for taking those entity definitions and generating new entities. For me this system is still in its early stages, but it's turning out really, really well. It's a pretty powerful system for quickly defining entities and allows you to make any entity you want using the components you've created. If you're not comfortable creating your own parser, I think XML will work just fine. I converted mine from a pushback recursive parser I wrote for a little made up programming language.
As you can see this defines the entity. I mentioned that it doesn't directly define behavior. It can, however, easily define such things as hated enemies and how aggressively to react to said enemies. This would be as simple as defining whatever component you use to control such behavior. My entities also have a intelligence component (not shown) that defines things like:
- How they path find (simple line-of-sight movement, simple A*, predictive A*, etc.)
- How aggressive/defensive they are. Entities can have home zones that will be defended, but maybe not aggressive outside those zones.
- Technology awareness (open doors, use gadgets, avoid traps, etc)
- And more...
However yours is defined, it's your system that will drive the data in that component, which in turn affects the behavior of your entites.