From d9ba1d35c8076f86283073cd66b25e495641dcae Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 20 Oct 2006 14:21:22 +0000 Subject: Added the missing Weapon Type and Max Per Slot item properties. --- data/items.xml | 236 ++++++++++++++++++++++++++-------------------------- data/items.xsd | 2 + src/item.h | 42 ++++++++-- src/itemmanager.cpp | 11 ++- 4 files changed, 167 insertions(+), 124 deletions(-) diff --git a/data/items.xml b/data/items.xml index a41e9bba..942247ab 100644 --- a/data/items.xml +++ b/data/items.xml @@ -7,122 +7,122 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/items.xsd b/data/items.xsd index 020a9837..2517bbf0 100644 --- a/data/items.xsd +++ b/data/items.xsd @@ -16,6 +16,7 @@ + @@ -39,6 +40,7 @@ + diff --git a/src/item.h b/src/item.h index 2f568a9e..492e97c8 100644 --- a/src/item.h +++ b/src/item.h @@ -29,7 +29,7 @@ /** * Enumeration of available Item types. */ -typedef enum { +typedef enum ItemType { ITEM_UNUSABLE = 0, ITEM_USABLE, // 1 ITEM_EQUIPMENT_ONE_HAND_WEAPON, // 2 @@ -42,7 +42,30 @@ typedef enum { ITEM_EQUIPMENT_RING, // 9 ITEM_EQUIPMENT_NECKLACE, // 10 ITEM_EQUIPMENT_FEET // 11 -} ItemType; +}; + +/** + * Enumeration of available weapon's types. + */ +typedef enum WeaponType { + WPNTYPE_NONE = 0, + WPNTYPE_KNIFE, // 1 + WPNTYPE_SWORD, // 2 + WPNTYPE_SPEAR, // 3 + WPNTYPE_JAVELIN, // 4 + WPNTYPE_ROD, // 5 + WPNTYPE_STAFF, // 6 + WPNTYPE_WIPE, // 7 + WPNTYPE_PROJECTILE, // 8 + WPNTYPE_BOOMERANG, // 9 + WPNTYPE_BOW, // 10 + WPNTYPE_SICKLE, // 11 + WPNTYPE_CROSSBOW, // 12 + WPNTYPE_STICK, // 13 + WPNTYPE_HAMMER, // 14 + WPNTYPE_AXE, // 15 + WPNTYPE_HAND_PROECTILE // 16 +}; /** * States attribute effects to beings, and actors. @@ -90,8 +113,9 @@ struct Modifiers int hp; /**< HP modifier */ int mp; /**< MP Modifier */ - // Equipment + // Weapon unsigned short range; /**< Weapon Item Range */ + WeaponType weaponType; /**< Weapon Type enum */ }; @@ -107,12 +131,14 @@ class Item unsigned short itemType = 0, unsigned int weight = 0, unsigned int value = 0, - std::string scriptName = ""): + std::string scriptName = "", + unsigned short maxPerSlot = 0): mModifiers(modifiers), mItemType(itemType), mWeight(weight), mValue(value), - mScriptName(scriptName) {} + mScriptName(scriptName), + mMaxPerSlot(maxPerSlot) {} virtual ~Item() throw() { } @@ -137,6 +163,11 @@ class Item */ unsigned int getGoldValue() const { return mValue; }; + /** + * Return max item per slot + */ + unsigned short getMaxPerSlot() const { return mMaxPerSlot; }; + /** * Return item's modifiers */ @@ -155,6 +186,7 @@ class Item unsigned int mWeight; /**< Weight of the item */ unsigned int mValue; /**< Gold value of the item */ std::string mScriptName; /**< item's script. None if =="" */ + unsigned short mMaxPerSlot; /**< Max item amount per slot in inventory */ Modifiers mModifiers; /**< Item's Modifiers */ }; diff --git a/src/itemmanager.cpp b/src/itemmanager.cpp index d30fd276..ae3351ca 100644 --- a/src/itemmanager.cpp +++ b/src/itemmanager.cpp @@ -73,6 +73,7 @@ ItemManager::ItemManager(const std::string &itemReferenceFile) unsigned short itemType = 0; unsigned int weight = 0; unsigned int value = 0; + unsigned short maxPerSlot = 0; std::string scriptName = ""; Modifiers modifiers; @@ -86,6 +87,7 @@ ItemManager::ItemManager(const std::string &itemReferenceFile) READ_PROP(node, prop, "type", itemType, atoi); READ_PROP(node, prop, "weight", weight, atoi); READ_PROP(node, prop, "value", value, atoi); + READ_PROP(node, prop, "max_per_slot", maxPerSlot, atoi); READ_PROP(node, prop, "script_name", scriptName, ); // --- Modifiers @@ -124,6 +126,8 @@ ItemManager::ItemManager(const std::string &itemReferenceFile) READ_PROP(node, prop, "mp", modifiers.mp, atoi); // Equipment READ_PROP(node, prop, "range", modifiers.range, atoi); + READ_PROP(node, prop, "weapon_type", modifiers.weaponType, + (WeaponType)atoi); // Status effect READ_PROP(node, prop, "status_effect", modifiers.beingStateEffect, (BeingStateEffect)atoi); @@ -142,6 +146,11 @@ ItemManager::ItemManager(const std::string &itemReferenceFile) LOG_WARN("Item Manager: An (ignored) item has no ID in " << itemReferenceFile << "!", 0); } + if (maxPerSlot == 0) + { + LOG_WARN("Item Manager: Missing max per slot properties for item: " + << id << " in " << itemReferenceFile << ".", 0); + } if (weight == 0) { LOG_WARN("Item Manager: Missing weight for item: " @@ -150,7 +159,7 @@ ItemManager::ItemManager(const std::string &itemReferenceFile) LOG_INFO("Item: ID: " << id << ", itemType: " << itemType << ", weight: " << weight << ", value: " << value << - ", scriptName: " << scriptName << ".", 3); + ", scriptName: " << scriptName << ", maxPerSlot: " << maxPerSlot << ".", 3); //TODO: Log level 5 with everything } -- cgit v1.2.3-70-g09d2