I’m working on an RPG game where I will have a large library of monsters that will have static global constant values (base stats, etc). I want to be able to easily add/remove or edit monsters from a read-only ‘database’ of them as I create more content for the game. I have an enum of monster ‘species’ and want to be able to add one to the enum and then have a place where I can enter all the static data that can be looked up at any time during the game through the enum reference.
What is a good way to do this? Should I just use a text file formatted in a certain way and read from it whenever monster data is needed, or is there a better way?
Why do you want to save these things in a textfile or database? What speaks against having a classic class hierarchie where fields and methods are derived from base types? Like, all Monsters will have health and so on. All Wolfes are Monsters, but may have higher movement speed. By deriving and overriding, the amount of new stats you need to consider should be a lot lower. Very specific data can then either be directly added to the final monster type, or if used in more than one place, through an interface.
I never worked on a game with hundreds of different enemies, and i know the classic approach can cause pretty large files, but i’d imagine the approach you intend to get a bit messy as well.
Not going into the particulars, I found that practical way to do this is using dictionaries, and then use JSON to read/write them. That way you can separate monster creation (write a small app to create the moster definition) and usage (the game that reads the monster definitions). In-between, you can use a text-editor to edit the monster stats after they have been written to file, since JSON usually writes text files.
Database, XML, maybe scriptable objects, Json, or any text frmat is not bad, but if you want edit data in bulk, then it can ecome difficult and tedious.
DB,like SQL /Sqlite, and XML, allows to use tools, for mass searching, filtering and editing multiple entries at once.
Wit XML is easy to implement some algorithms, I.e. Using Excel.
Actually, that’s one hell of a good approach that I keep forgetting. If you have Excel (or open office), you can globally search/replace your data files (assuming you formatted them appropriately) if you can’t (or are a lazy bum like me) grep.