00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef ITEM_H
00019 #define ITEM_H
00020
00021 #include "constants.h"
00022 #include "persist.h"
00023 #include "glshape.h"
00024 #include "shapepalette.h"
00025 #include "rpg/rpgitem.h"
00026 #include "rpg/spell.h"
00027 #include <vector>
00028
00029 class Scourge;
00030 class Session;
00031
00040 class Item {
00041 private:
00042 RpgItem *rpgItem;
00043 int shapeIndex;
00044 Color *color;
00045 GLShape *shape;
00046 bool blocking;
00047 Item *containedItems[MAX_CONTAINED_ITEMS];
00048 int containedItemCount;
00049 int currentCharges;
00050 Spell *spell;
00051 char itemName[255];
00052 bool containsMagicItem;
00053 bool showCursed;
00054
00055
00056
00057
00058 int level;
00059 float weight;
00060 int price;
00061 int action;
00062 int speed;
00063 int distance;
00064 int maxCharges;
00065 int duration;
00066 int quality;
00067
00068
00069 int magicLevel;
00070 int bonus;
00071 int damageMultiplier;
00072 char *monsterType;
00073 MagicSchool *school;
00074 Dice *magicDamage;
00075 bool cursed;
00076 int stateMod[Constants::STATE_MOD_COUNT];
00077 bool stateModSet;
00078 map<int, int> skillBonus;
00079 Session *session;
00080
00081 public:
00082 Item(Session *session, RpgItem *rpgItem, int level=1, bool loading=false);
00083 ~Item();
00084
00085 ItemInfo *save();
00086
00087 static Item *load(Session *session, ItemInfo *info);
00088
00089 static map<int, vector<string> *> soundMap;
00090
00091 inline Color *getColor() { return color; }
00092 inline void setColor(Color *c) { color = c; }
00093 inline void setShape(GLShape *s) { shape = s; }
00094 inline GLShape *getShape() { return shape; }
00095 inline RpgItem *getRpgItem() { return rpgItem; }
00096 inline bool isBlocking() { return blocking; }
00097 inline void setBlocking(bool b) { blocking = b; }
00098 inline int getCurrentCharges() { return currentCharges; }
00099 inline void setCurrentCharges(int n) { if(n < 0)n=0; if(n>rpgItem->getMaxChargesRpg())n=rpgItem->getMaxChargesRpg(); currentCharges = n; }
00100 inline void setWeight(float f) { if(f < 0.0f)f=0.1f; weight=f; }
00101 inline void setSpell(Spell *spell) { this->spell = spell; sprintf(this->itemName, "Scroll of %s", spell->getName()); }
00102 inline Spell *getSpell() { return spell; }
00103
00104 inline void setShowCursed( bool b ) { showCursed = b; }
00105 inline bool getShowCursed() { return showCursed; }
00106
00107 void getDetailedDescription(char *s, bool precise=true);
00108 inline char *getItemName() { return itemName; }
00109
00110 inline int getContainedItemCount() { return containedItemCount; }
00111
00112 bool addContainedItem(Item *item, bool force=false);
00113
00114 Item *removeContainedItem(int index);
00115 Item *getContainedItem(int index);
00116 bool isContainedItem(Item *item);
00117 inline bool getContainsMagicItem() { return containsMagicItem; }
00118
00119
00120
00121 bool decrementCharges();
00122
00123 const char *getRandomSound();
00124
00125 static void initItems(ShapePalette *shapePal);
00126
00127 void enchant(int level);
00128
00129
00130
00131 inline int getLevel() { return level; }
00132 inline float getWeight() { return weight; }
00133 inline int getPrice() { return price; }
00134 inline int getAction() { return action; }
00135 inline int getSpeed() { return speed; }
00136 inline int getDistance() { return distance; }
00137 inline int getMaxCharges() { return maxCharges; }
00138 inline int getDuration() { return duration; }
00139 inline int getQuality() { return quality; }
00140
00141 inline bool isMagicItem() { return ( magicLevel > -1 ); }
00142 inline map<int,int> *getSkillBonusMap() { return &skillBonus; }
00143 inline int getSkillBonus(int skill) { return (skillBonus.find(skill) == skillBonus.end() ? 0 : skillBonus[skill]); }
00144 inline int getMagicLevel() { return magicLevel; }
00145 inline int getBonus() { return bonus; }
00146 inline int getDamageMultiplier() { return damageMultiplier; }
00147 inline char *getMonsterType() { return monsterType; }
00148 inline MagicSchool *getSchool() { return school; }
00149 int rollMagicDamage();
00150 inline int getMagicResistance() { return (7 * (getLevel() + getMagicLevel())); }
00151 char *describeMagicDamage();
00152 inline bool isCursed() { return cursed; }
00153 inline bool isStateModSet(int mod) { return(stateMod[mod] == 1); }
00154 inline bool isStateModProtected(int mod) { return(stateMod[mod] == 2); }
00155
00156 void debugMagic(char *s);
00157
00158 protected:
00159 void commonInit( bool loading=false );
00160 float getRandomSum( float base, int count );
00161 void describeMagic(char *s, char *itemName);
00162 };
00163
00164 #endif