Thursday, October 28, 2010

Items, Templates, and tables. Oh my.

So, after sitting down I worked through all the things I want to see in loot tables, item generation, templates, and vendors. With this I believe I have covered everything I want in the game.

Classes:
Item
Weapon : Item
Armor : Item
Consumable : Item
ItemTemplate
WeaponTemplate : ItemTemplate
ArmorTemplate : ItemTemplate
ConsumableTemplate : ItemTemplate

class Item
{
   ID
   Name
   Description
   Value
   Quality
   Condition
   Durability
   IsUsable //denotes if there are spells or other effects on this item
   Weight
   Volume
   IsStackable
   IsEquippable
}


class ItemTemplate
{
   ID
   Name
   DisplayName // denotes a difference in name for multiple items with the same name but different templates
   Description
   low_Value
   high_Value
   low_Quality
   high_Quality
   low_Condition
   high_Condition
   low_Durability
   high_Durability
   IsUsable //denotes if there are spells or other effects on this item //
   low_Weight
   high_Weight
   low_Volume
   high_volume
   IsStackable
   IsEquippable
   low_NumEffects // the total number of effects that can be applied to this item during creation
   high_NumEffects
}

These 2 classes form the base from which all other items are listed. Due to the nature of the API I am using, I can use concrete inheritance for the templates, but the items have to use a composite inheritance, otherwise functions just don't work right. 

With these 2 classes in place, we can code a couple of functions such as Item.generateItemFromTemplate(ItemTemplate);

This will take the template, determine any effects the item will have, quality, condition, durability, and any other stats and generate an item. So already this gives us a the setup we need for a few things: Loot Tables, Crafting Tables, and Vendor tables.

This is a quick and easy way to have all of our items defined and generated at any time. The only tables left out are Effect, ItemEffect, and ItemTemplateEffect. These define what effects are available, what effects an item has, and what effects an item could have.

Falling back to posts last year, we have an effective way to give players unique loot with stats that can vary but won't provide a piece of loot that everyone will want no matter what.

No comments: