I'm developing an RPG and I'm at the point where I need to start building an enemy database. There's a couple challenges associated with this and a few solutions I've been considering.
Here's what I need to do in my enemy database:
I have two primary enemy classes I need to represent data about:
A base enemy class that includes the follow:
Base Stats
Status Resistance Table
Elemental Resistance Table
Steal Table
Drop Table
Level
Unique ID
Base XP
AI Hook
Name
Display Name
And a derived class that adds the ability to add equipment, adding the following fields:
Main Weapon
Secondary Weapon/Equipment
Armor
Accessories
I may add additional fields or additional classes in the future if it makes sense. I've considered two possible formats to database enemies.
XML Files
I'd basically do it like this:
<?xml version="1.0" encoding="utf-8"?>
<Enemies>
<Enemy name="Red Dragon" type="BaseEnemy" level="56" displayname="Red Dragon">
<Stats HP="55000" MP="2500" SP="2500" Strength="212" Vitality="125" Magic="200" Spirit="162" Skill="111" Speed="109" Evasion="100" MgEvasion="100" Accuracy="100" Luck="55"/>
<StatusResistances>
<Resistance name="Sleep" value="100" />
<Resistance name="Stop" value="100" />
</StatusResistances>
<ElementResistances>
<Resistance name="Fire" value="75" />
</ElementResistances>
<LootTable>
<Item name="Elixir" rate="0.03" count="1"/>
</LootTable>
<DropTable>
<Item name="Elixir" rate="0.03" count="1"/>
</DropTable>
<AIScript value="BasicBehaviour.py" />
<BaseXP value="4800"/>
</Enemy>
<Enemy name="Gaverick 1" type="HumanoidEnemy" level="33" displayname="Gaverick">
<!--Same Stuff as above here-->
<Equipment>
<Weapon name="Dark Eclipse"/>
<Armor name="Terra Defense"/>
<Accessory name="Ribbon"/>
</Equipment>
</Enemy>
</Enemies>
Advantages:
- Easy to extend if I need to add/rearrange parameters
- easy to assign default values
- I already have an XML parser (pugixml) included for config files, tiled maps and resource description loading
Disadvantages:
- potentially slow (my database will likely hit several hundred enemies)
- can't query for arbitrary enemies, so will likely need to keep all enemies in memory.
- This would mean I need to restart the game to load changed enemy data as well
SQLite
For this, I'd basically make a table with columns representing all the data I'd need and leave the unnecessary fields empty
Advantages
- Arbitrary querying can keep unnecessary enemy data out of memory
- Feels more structured
- Smaller file size
Disadvantages
- More difficult to extend/rearrange parameter orders
- Unnecessary overhead to to unused fields
- Will need to write a database interface wrapper for sqlite
With this in mind I was curious on getting some outside experience on what other people have done. I may be thinking about this totally wrong, and if so, please suggest an alternative to the two possibilities I have here.
Additionally, any suggestions on how to improve either of these possibilities would be appreciated. Really, I just want to know if I'm on the right track.
I'm open to using any free library and am already incorporating boost