On 7/9/06, Andrew Phillips <[EMAIL PROTECTED]> wrote:
As I was looking over the character class definition, I began to wonder how we want to handle assigning unique IDs to each creature, npc, and character, but for the engine, and for the editor. My idea is to assign IDs to the npcs in the order they are created. Determining the next ID in the sequence would be as simple as reading in the last record from a given data file and incrementing that ID.
I thought that for named NPCs, ID and name should be the same. The reason is that they will most likely be referred to by event scripts or dialogues. Using their name for that purpose would be much easier than using a number.
It seems to get a little more complex when dealing with creatures and monsters, as they would be created once in the editor and then possibly instantiated many times over. In order to deal with this one-to-many relationship, I suggest that the template for each creature have a multi-digit ID, where the first one or two digits are the creature's type ID and the last one or two digits can be used to track the number of instances.
My idea for this is quite similar. However, I would combine the name of the creature with a running number (that could be kept with the template and increased each time the template is instanciated). So you'd get Wolf1, Wolf2, and so on ... again, we could then for example have a method to return all creatures with a given name by doing partial string matching on the ID. If we would have to get hold on a particular creature, we can have an event script create it from its template with an ID we supply. (Like WolfForSomeQuest). This should only be necessary in very rare cases, I think. I am not 100% sure yet how the creature template instanciation will really work. Haven't thought about is much yet, but stuff like the ID creation would definitely be done automatically, so the editor does not really have to come up with it, only with a (unique) template/creature name. Seems I should put that on top of my TODO list, as we need to ensure that editor and engine fit together. Right now, I would create a creature template class (quite similar to the character class in that it would keep a copy of each template available in memory) and add a second constructor to the character class that will create a creature from a template (name). In fact, the current constructor could easily be modified to include a special case if character type == CREATURE. If no creature ID is supplied, it will be auto-generated, otherwise a named creature will be created. Makes sense? Kai _______________________________________________ Adonthell-devel mailing list Adonthell-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/adonthell-devel