summaryrefslogtreecommitdiffstats
path: root/src/game-server/item.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server/item.h')
-rw-r--r--src/game-server/item.h53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/game-server/item.h b/src/game-server/item.h
index 872e52c..7004a2d 100644
--- a/src/game-server/item.h
+++ b/src/game-server/item.h
@@ -24,6 +24,7 @@
#include <vector>
#include "game-server/actor.h"
+#include "game-server/attack.h"
#include "scripting/script.h"
class Being;
@@ -67,25 +68,15 @@ enum
SET_STATE_NOT_FLOATING
};
-struct ItemAttackInfo
-{
- unsigned int base;
- unsigned int range;
- unsigned int baseSpeed;
- unsigned int skillId;
- /// attribute id -> damage bonus per point
- std::map< unsigned int, double > attrBonus;
-};
-
enum ItemTriggerType
{
ITT_NULL = 0,
- ITT_IN_INVY, // Associated effects apply when the item is in the inventory
- ITT_ACTIVATE, // Associated effects apply when the item is activated
- ITT_EQUIP, // Assosciated effects apply when the item is equipped
+ ITT_IN_INVY, // Associated effects apply when the item is in the inventory
+ ITT_ACTIVATE, // Associated effects apply when the item is activated
+ ITT_EQUIP, // Assosciated effects apply when the item is equipped
ITT_LEAVE_INVY, // Associated effects apply when the item leaves the inventory
- ITT_UNEQUIP, // Associated effects apply when the item is unequipped
- ITT_EQUIPCHG // When the item is still equipped, but in a different way
+ ITT_UNEQUIP, // Associated effects apply when the item is unequipped
+ ITT_EQUIPCHG // When the item is still equipped, but in a different way
};
enum ItemEffectType
@@ -93,13 +84,20 @@ enum ItemEffectType
// Effects that are removed automatically when the trigger ends
// (ie. item no longer exists in invy, unequipped)
IET_ATTR_MOD = 0, // Modify a given attribute with a given value
- IET_ATTACK, // Give the associated being an attack
+ IET_ATTACK, // Give the associated being an attack
// Effects that do not need any automatic removal
- IET_COOLDOWN, // Set a cooldown to this item, preventing activation for n ticks
- IET_G_COOLDOWN, // Set a cooldown to all items of this type for this being
- IET_SCRIPT // Call an associated lua script with given variables
+ IET_COOLDOWN, // Set a cooldown to this item, preventing activation for n ticks
+ IET_G_COOLDOWN, // Set a cooldown to all items of this type for this being
+ IET_SCRIPT // Call an associated lua script with given variables
};
+struct ItemTrigger
+{
+ ItemTriggerType apply;
+ ItemTriggerType dispell;
+};
+
+
class ItemEffectInfo
{
public:
@@ -115,7 +113,8 @@ class ItemEffectAttrMod : public ItemEffectInfo
ItemEffectAttrMod(unsigned int attrId, unsigned int layer, double value,
unsigned int id, unsigned int duration = 0) :
mAttributeId(attrId), mAttributeLayer(layer),
- mMod(value), mDuration(duration), mId(id) {}
+ mMod(value), mDuration(duration), mId(id)
+ {}
bool apply(Being *itemUser);
void dispell(Being *itemUser);
@@ -131,8 +130,14 @@ class ItemEffectAttrMod : public ItemEffectInfo
class ItemEffectAttack : public ItemEffectInfo
{
public:
+ ItemEffectAttack(AttackInfo *attackInfo) :
+ mAttackInfo(attackInfo)
+ {}
+
bool apply(Being *itemUser);
void dispell(Being *itemUser);
+ private:
+ AttackInfo *mAttackInfo;
};
class ItemEffectConsumes : public ItemEffectInfo
@@ -243,6 +248,12 @@ class ItemClass
Script::Ref getEventCallback(const std::string &event) const
{ return mEventCallbacks.value(event); }
+ void addAttack(AttackInfo *attackInfo, ItemTriggerType applyTrigger,
+ ItemTriggerType dispellTrigger);
+
+ std::vector<AttackInfo *> &getAttackInfos()
+ { return mAttackInfos; }
+
private:
/**
* Add an effect to a trigger
@@ -277,6 +288,8 @@ class ItemClass
*/
utils::NameMap<Script::Ref> mEventCallbacks;
+ std::vector<AttackInfo *> mAttackInfos;
+
friend class ItemManager;
};