summaryrefslogtreecommitdiff
path: root/src/game-server/item.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-19 15:39:44 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-19 15:39:44 +0000
commit71b183077492e4f9e78bb09d1f1c55d98f60c416 (patch)
tree463115ac59c847d405abd27ee6f216a109df0b3c /src/game-server/item.cpp
parent82498f572e4c6c26f2dc9545d7bc4c06a3c9eb0f (diff)
downloadmanaserv-71b183077492e4f9e78bb09d1f1c55d98f60c416.tar.gz
manaserv-71b183077492e4f9e78bb09d1f1c55d98f60c416.tar.bz2
manaserv-71b183077492e4f9e78bb09d1f1c55d98f60c416.tar.xz
manaserv-71b183077492e4f9e78bb09d1f1c55d98f60c416.zip
Implemented use of items, e.g. food.
Diffstat (limited to 'src/game-server/item.cpp')
-rw-r--r--src/game-server/item.cpp30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp
index 1b32cdfa..23df3b0e 100644
--- a/src/game-server/item.cpp
+++ b/src/game-server/item.cpp
@@ -58,19 +58,16 @@ void ItemModifiers::setAttributeValue(int attr, int value)
void ItemModifiers::applyAttributes(Being *b) const
{
+ /* Note: if someone puts a "lifetime" property on an equipment, strange
+ behavior will occur, as its effect will be canceled twice. While this
+ could be desirable for some "cursed" items, it is probably an error
+ that should be detected somewhere else. */
int lifetime = getValue(MOD_LIFETIME);
for (std::vector< ItemModifier >::const_iterator i = mModifiers.begin(),
i_end = mModifiers.end(); i != i_end; ++i)
{
if (i->type < MOD_ATTRIBUTE) continue;
-
- AttributeModifier am;
- am.attr = i->type - MOD_ATTRIBUTE;
- am.duration = lifetime;
- am.value = i->value;
- // TODO: No spell currently.
- am.level = 0;
- b->addModifier(am);
+ b->applyModifier(i->type - MOD_ATTRIBUTE, i->value, lifetime);
}
}
@@ -80,25 +77,14 @@ void ItemModifiers::cancelAttributes(Being *b) const
i_end = mModifiers.end(); i != i_end; ++i)
{
if (i->type < MOD_ATTRIBUTE) continue;
- b->removeEquipmentModifier(i->type - MOD_ATTRIBUTE, i->value);
+ b->applyModifier(i->type - MOD_ATTRIBUTE, -i->value);
}
}
bool ItemClass::use(Being *itemUser)
{
- bool usedSuccessfully = true;
- // Applying Modifiers for a given lifetime
- // TODO
-
- // Calling a script if scriptName != ""
- if (!mScriptName.empty())
- return (runScript(itemUser) && usedSuccessfully);
+ if (mType != ITEM_USABLE) return false;
- return usedSuccessfully;
-}
-
-bool ItemClass::runScript(Being *itemUser)
-{
- //TODO
+ mModifiers.applyAttributes(itemUser);
return true;
}