00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef RPG_ITEM_H
00018 #define RPG_ITEM_H
00019
00020 #include <map>
00021 #include <string>
00022 #include <vector>
00023 #include "../constants.h"
00024 #include "character.h"
00025 #include "../persist.h"
00026
00027 using namespace std;
00028
00029
00030
00031
00032
00033
00034
00035
00036 class Monster;
00037 class Dice;
00038 class MagicSchool;
00039 class Spell;
00040 class RpgItem;
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 class RpgItem {
00090 private:
00091
00092 int index;
00093 char *name, *desc, *shortDesc;
00094 int level;
00095 int rareness;
00096 int type;
00097 float weight;
00098 int price, quality;
00099 int action;
00100 int speed;
00101 int shape_index;
00102 int twohanded;
00103 int distance;
00104 int equip;
00105 int skill;
00106 int minDepth;
00107 int maxCharges;
00108 int potionSkill;
00109 int potionTime;
00110 GLuint acl;
00111 bool isWeaponItem;
00112 int iconTileX, iconTileY;
00113
00114 static map<int, map<int, vector<const RpgItem*>*>*> typesMap;
00115 static map<string, const RpgItem *> itemsByName;
00116 static vector<RpgItem*> containers;
00117 static vector<RpgItem*> containersNS;
00118
00119 public:
00120
00121 enum itemTypes {
00122 SWORD=0,
00123 AXE,
00124 BOW,
00125 MACE,
00126 CONTAINER,
00127 ARMOR,
00128 FOOD,
00129 DRINK,
00130 POTION,
00131 OTHER,
00132 MISSION,
00133 SCROLL,
00134
00135
00136 ITEM_TYPE_COUNT
00137 };
00138 static char itemTypeStr[ITEM_TYPE_COUNT][40];
00139
00140 enum twoHandedType {
00141 NOT_TWO_HANDED=0,
00142 ONLY_TWO_HANDED,
00143 OPTIONAL_TWO_HANDED
00144 };
00145
00146 static RpgItem *items[1000];
00147 static int itemCount;
00148
00149 static int enchantableTypes[];
00150 static int enchantableTypeCount;
00151
00152 RpgItem(int index, char *name, int level, int rareness, int type, float weight, int price, int quality,
00153 int action, int speed, char *desc, char *shortDesc, int equip, int shape_index,
00154 int twohanded=NOT_TWO_HANDED, int distance=1, int skill=-1, int minDepth=0, int maxCharges=0,
00155 int potionSkill=-1, int potionTime=0, int iconTileX=0, int iconTileY=0);
00156 ~RpgItem();
00157
00158
00159
00160 inline int getLevelRpg() { return level; }
00161 inline float getWeightRpg() { return weight; }
00162 inline int getPriceRpg() { return price; }
00163 inline int getActionRpg() { return action; }
00164 inline int getSpeedRpg() { return speed; }
00165 inline int getDistanceRpg() { return distance; }
00166 inline int getMaxChargesRpg() { return maxCharges; }
00167 inline int getDurationRpg() { return potionTime; }
00168 inline int getQualityRpg() { return quality; }
00169
00170 inline int getIndex() { return index; }
00171 inline char *getName() { return name; }
00172 inline int getRareness() { return rareness; }
00173 inline int getShapeIndex() { return shape_index; }
00174 inline char *getShortDesc() { return shortDesc; }
00175 inline char *getLongDesc() { return desc; }
00176 inline int getEquip() { return equip; }
00177 inline int getSkill() { return skill; }
00178 inline int getMinDepth() { return minDepth; }
00179 inline int getType() { return type; }
00180 inline int getPotionSkill() { return potionSkill; }
00181 inline bool getAcl(int index) { return (acl & (1 << index) ? true : false); }
00182 inline void setAcl(int index, bool value) { if(value) acl |= (1 << index); else acl &= ((GLuint)0xffff - (GLuint)(1 << index)); }
00183 inline void setAllAcl(bool value) { if(value) acl = (GLuint)0xffff; else acl = (GLuint)0; }
00184 inline GLuint getAllAcl() { return acl; }
00185 inline bool isWeapon() { return this->isWeaponItem; }
00186 inline int getIconTileX() { return this->iconTileX; }
00187 inline int getIconTileY() { return this->iconTileY; }
00188
00189
00190
00191 inline bool isRangedWeapon() { return type == BOW; }
00192
00193 bool isEnchantable();
00194
00195 static RpgItem *getRandomItem(int depth);
00196 static RpgItem *getRandomContainer();
00197 static RpgItem *getRandomContainerNS();
00198 inline static RpgItem *getItem(int index) { return items[index]; }
00199
00200 static int getTypeByName(char *name);
00201 static void addItem(RpgItem *item, int width, int depth, int height);
00202 static RpgItem *getItemByName(char *name);
00203
00204 protected:
00205 static RpgItem *getRandomItemFromTypes(int level, int types[], int typeCount);
00206 };
00207
00208 #endif