summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2006-10-20 14:21:22 +0000
committerYohann Ferreira <bertram@cegetel.net>2006-10-20 14:21:22 +0000
commitd9ba1d35c8076f86283073cd66b25e495641dcae (patch)
tree48ba3d45bffa674092cc3399e14ded2f065e4226 /src
parent80f7db7a84fb73d8266d872f56af108ed49ba2eb (diff)
downloadmanaserv-d9ba1d35c8076f86283073cd66b25e495641dcae.tar.gz
manaserv-d9ba1d35c8076f86283073cd66b25e495641dcae.tar.bz2
manaserv-d9ba1d35c8076f86283073cd66b25e495641dcae.tar.xz
manaserv-d9ba1d35c8076f86283073cd66b25e495641dcae.zip
Added the missing Weapon Type and Max Per Slot item properties.
Diffstat (limited to 'src')
-rw-r--r--src/item.h42
-rw-r--r--src/itemmanager.cpp11
2 files changed, 47 insertions, 6 deletions
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() { }
@@ -138,6 +164,11 @@ class Item
unsigned int getGoldValue() const { return mValue; };
/**
+ * Return max item per slot
+ */
+ unsigned short getMaxPerSlot() const { return mMaxPerSlot; };
+
+ /**
* Return item's modifiers
*/
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
}