diff options
Diffstat (limited to 'src/resources/iteminfo.h')
-rw-r--r-- | src/resources/iteminfo.h | 265 |
1 files changed, 150 insertions, 115 deletions
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index a7c0ddca..24872060 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -22,7 +22,7 @@ #ifndef ITEMINFO_H #define ITEMINFO_H -#include "player.h" +#include "being.h" #include "resources/spritedef.h" @@ -36,38 +36,9 @@ enum EquipmentSoundEvent EQUIP_EVENT_HIT }; -enum EquipmentSlot -{ - // Equipment rules: - // 1 Brest equipment - EQUIP_TORSO_SLOT = 0, - // 1 arms equipment - EQUIP_ARMS_SLOT = 1, - // 1 head equipment - EQUIP_HEAD_SLOT = 2, - // 1 legs equipment - EQUIP_LEGS_SLOT = 3, - // 1 feet equipment - EQUIP_FEET_SLOT = 4, - // 2 rings - EQUIP_RING1_SLOT = 5, - EQUIP_RING2_SLOT = 6, - // 1 necklace - EQUIP_NECKLACE_SLOT = 7, - // Fight: - // 2 one-handed weapons - // or 1 two-handed weapon - // or 1 one-handed weapon + 1 shield. - EQUIP_FIGHT1_SLOT = 8, - EQUIP_FIGHT2_SLOT = 9, - // Projectile: - // this item does not amount to one, it only indicates the chosen projectile. - EQUIP_PROJECTILE_SLOT = 10 -}; - - /** * Enumeration of available Item types. + * TODO: Dynamise this using an xml. */ enum ItemType { @@ -89,134 +60,128 @@ enum ItemType ITEM_SPRITE_HAIR // 15 }; -/** - * Enumeration of available weapon's types. - */ -enum WeaponType -{ - WPNTYPE_NONE = 0, - WPNTYPE_KNIFE, - WPNTYPE_SWORD, - WPNTYPE_POLEARM, - WPNTYPE_STAFF, - WPNTYPE_WHIP, - WPNTYPE_BOW, - WPNTYPE_SHOOTING, - WPNTYPE_MACE, - WPNTYPE_AXE, - WPNTYPE_THROWN -}; +namespace TmwAthena { +class TaItemDB; +} + +namespace ManaServ { +class ManaServItemDB; +} /** - * Defines a class for storing item infos. This includes information used when - * the item is equipped. + * Defines a class for storing generic item infos. + * Specialized version for one or another protocol are defined below. */ class ItemInfo { + friend class ItemDB; + friend void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node); + friend class TmwAthena::TaItemDB; + friend class ManaServ::ManaServItemDB; + public: - /** - * Constructor. - */ ItemInfo(): mType(ITEM_UNUSABLE), mWeight(0), mView(0), mId(0), - mAttackType(ACTION_DEFAULT) + mAttackAction(SpriteAction::INVALID) { } - void setId(int id) - { mId = id; } - int getId() const { return mId; } - void setName(const std::string &name) - { mName = name; } - const std::string &getName() const { return mName; } - void setParticleEffect(const std::string &particleEffect) - { mParticle = particleEffect; } - - std::string getParticleEffect() const { return mParticle; } - - void setImageName(const std::string &imageName) - { mImageName = imageName; } - - const std::string &getImageName() const - { return mImageName; } + std::string getParticleEffect() const + { return mParticle; } - void setDescription(const std::string &description) - { mDescription = description; } + const SpriteDisplay &getDisplay() const + { return mDisplay; } const std::string &getDescription() const { return mDescription; } - void setEffect(const std::string &effect) - { mEffect = effect; } - - const std::string &getEffect() const { return mEffect; } - - void setType(ItemType type) - { mType = type; } - - ItemType getType() const - { return mType; } - - void setWeight(int weight) - { mWeight = weight; } + const std::vector<std::string> &getEffect() const + { return mEffect; } int getWeight() const { return mWeight; } - void setView(int view) - { mView = view; } + const std::string &getSprite(Gender gender) const; - void setSprite(const std::string &animationFile, Gender gender) - { mAnimationFiles[gender] = animationFile; } + // Handlers for seting and getting the string used for particles when attacking + void setMissileParticleFile(const std::string &s) + { mMissileParticleFile = s; } - const std::string &getSprite(Gender gender) const; + const std::string &getMissileParticleFile() const + { return mMissileParticleFile; } - void setWeaponType(int); + void setHitEffectId(int s) + { mHitEffectId = s; } - // Handlers for seting and getting the string used for particles when attacking - void setMissileParticle(std::string s) { mMissileParticle = s; } + int getHitEffectId() const + { return mHitEffectId; } + + void setCriticalHitEffectId(int s) + { mCriticalHitEffectId = s; } - std::string getMissileParticle() const { return mMissileParticle; } + int getCriticalHitEffectId() const + { return mCriticalHitEffectId; } - SpriteAction getAttackType() const - { return mAttackType; } + const std::string &getAttackAction() const + { return mAttackAction; } int getAttackRange() const { return mAttackRange; } - void setAttackRange(int r) - { mAttackRange = r; } + const std::string &getSound(EquipmentSoundEvent event) const; - void addSound(EquipmentSoundEvent event, const std::string &filename); + bool getEquippable() const + { return mEquippable; } - const std::string &getSound(EquipmentSoundEvent event) const; + bool getActivatable() const + { return mActivatable; } + + ItemType getItemType() const + { return mType; } - protected: - std::string mImageName; /**< The filename of the icon image. */ + private: + + void setSprite(const std::string &animationFile, Gender gender) + { mAnimationFiles[gender] = animationFile; } + + void addSound(EquipmentSoundEvent event, const std::string &filename); + + SpriteDisplay mDisplay; /**< Display info (like icon) */ std::string mName; - std::string mDescription; /**< Short description. */ - std::string mEffect; /**< Description of effects. */ - ItemType mType; /**< Item type. */ - std::string mParticle; /**< Particle effect used with this item */ - int mWeight; /**< Weight in grams. */ - int mView; /**< Item ID of how this item looks. */ - int mId; /**< Item ID */ + std::string mDescription; /**< Short description. */ + std::vector<std::string> mEffect; /**< Description of effects. */ + ItemType mType; /**< Item type. */ + std::string mParticle; /**< Particle effect used with this item */ + int mWeight; /**< Weight in grams. */ + int mView; /**< Item ID of how this item looks. */ + int mId; /**< Item ID */ + + bool mEquippable; /**< Whether this item can be equipped. */ + bool mActivatable; /**< Whether this item can be activated. */ + + // Equipment related members. + /** Attack type, in case of weapon. + * See SpriteAction in spritedef.h for more info. + * Attack action sub-types (bow, sword, ...) are defined in items.xml. + */ + std::string mAttackAction; - // Equipment related members - SpriteAction mAttackType; /**< Attack type, in case of weapon. */ - int mAttackRange; /**< Attack range, will be zero if non weapon. */ + /** Attack range, will be equal to ATTACK_RANGE_NOT_SET if no weapon. */ + int mAttackRange; - // Particle to be shown when weapon attacks - std::string mMissileParticle; + /** Effects to be shown when weapon attacks - see also effects.xml */ + std::string mMissileParticleFile; + int mHitEffectId; + int mCriticalHitEffectId; /** Maps gender to sprite filenames. */ std::map<int, std::string> mAnimationFiles; @@ -225,4 +190,74 @@ class ItemInfo std::map< EquipmentSoundEvent, std::vector<std::string> > mSounds; }; -#endif +/* + * TmwAthena specialization of the itemInfo for TmwAthena + */ +namespace TmwAthena { + +enum EquipmentSlot +{ + // Equipment rules: + // 1 Brest equipment + EQUIP_TORSO_SLOT = 0, + // 1 arms equipment + EQUIP_ARMS_SLOT = 1, + // 1 head equipment + EQUIP_HEAD_SLOT = 2, + // 1 legs equipment + EQUIP_LEGS_SLOT = 3, + // 1 feet equipment + EQUIP_FEET_SLOT = 4, + // 2 rings + EQUIP_RING1_SLOT = 5, + EQUIP_RING2_SLOT = 6, + // 1 necklace + EQUIP_NECKLACE_SLOT = 7, + // Fight: + // 2 one-handed weapons + // or 1 two-handed weapon + // or 1 one-handed weapon + 1 shield. + EQUIP_FIGHT1_SLOT = 8, + EQUIP_FIGHT2_SLOT = 9, + // Projectile: + // this item does not amount to one, it only indicates the chosen projectile. + EQUIP_PROJECTILE_SLOT = 10, + EQUIP_VECTOR_END = 11 +}; + +/** + * Defines a class for storing TmwAthena specific item infos. + * Specialized version for one or another protocol are defined below. + */ +class TaItemInfo: public ItemInfo +{ + friend class TaItemDB; + + public: + TaItemInfo() : ItemInfo() + {} + + // Declare TmwAthena Specific item info here +}; + +} // namespace TmwAthena + +namespace ManaServ { + +/** + * Defines a class for storing Manaserv Specific item infos. + * Specialized version for one or another protocol are defined below. + */ +class ManaServItemInfo: public ItemInfo +{ + public: + ManaServItemInfo() : ItemInfo() + {} + + // Declare Manaserv Specific item info here +}; + + +} // namespace ManaServ + +#endif // ITEMINFO_H |