MObjectItem.h
00001 #ifndef MOBJECTITEM_H 00002 #define MOBJECTITEM_H 00003 00004 #include "MXml.h" 00005 #include "MObject.h" 00006 #include "MObjectTypes.h" 00007 #include <list> 00008 using namespace std; 00009 00010 #define FILENAME_ITEM_DESC "item.xml" 00011 00013 enum MSlotType 00014 { 00015 MET_INVENTORY = 0, 00016 MET_HEAD, 00017 MET_CHEST, 00018 MET_SHOULDER, 00019 MET_HANDS, 00020 MET_WAIST, 00021 MET_LEGS, 00022 MET_FEET, 00023 MET_FINGER, 00024 MET_NECK, 00025 MET_BACK, 00026 MET_PRIMARY, 00027 MET_SECONDARY, 00028 MET_AMMO, 00029 MET_KEY, 00030 MET_CONTAINER 00031 }; 00032 typedef unsigned long int MSlotTypes; 00033 #define SetSlotType(v, f) (v |= (1 << f)) 00034 #define DelSlotType(v, f) (v &= -(1 << f)) 00035 #define CheckSlotType(v, f) (v & (1 << f)) 00036 00037 struct MItemDesc 00038 { 00039 // 식별 00040 unsigned long int nID; 00041 unsigned long int nSerial; 00042 char szName[64]; 00043 unsigned char nCreator; 00044 00045 // 분류 00046 unsigned char nMagic; 00047 unsigned char nUnique; 00048 unsigned char nTradable; 00049 00050 // 슬롯 00051 MSlotTypes SlotTypes; 00052 00053 // 공격 00054 unsigned char nAtkDmg; // 공격 00055 unsigned char nAtkDelay; 00056 unsigned char nAtkBonus; 00057 unsigned char nAtkTarget; 00058 unsigned char nAtkRangeMin; 00059 unsigned char nAtkRangeMax; 00060 unsigned char nAtkEffective; 00061 unsigned char nAtkType; 00062 00063 // 방어 00064 unsigned char nAC; 00065 00066 // STAT 보정치 00067 char nSTR; 00068 char nCON; 00069 char nDEX; 00070 char nAGI; 00071 char nINT; 00072 char nCHA; 00073 char nHP; 00074 char nEN; 00075 char nFR; 00076 char nCR; 00077 char nPR; 00078 char nLR; 00079 char nMR; 00080 00081 // 이펙트 00082 unsigned long int nEffect; 00083 unsigned char nEffectType; 00084 char nRandomRate; 00085 char nCharges; 00086 00087 // 적재 00088 unsigned int nWeight; 00089 bool bStackable; 00090 unsigned char nStackCount; 00091 00092 // 요구사항 00093 MCharacterClasses nClasses; 00094 MCharacterRaces nRaces; 00095 unsigned char nMinLevel; 00096 unsigned char nMinSTR; 00097 unsigned char nMinCON; 00098 unsigned char nMinDEX; 00099 unsigned char nMinAGI; 00100 unsigned char nMinINT; 00101 unsigned char nMinCHA; 00102 00103 // 시각, 음향 00104 unsigned char nIcon; 00105 bool bHasLook; 00106 unsigned char nLookType; 00107 unsigned char nLookTexture; 00108 unsigned char nDropLook; 00109 unsigned int nBlendColor; 00110 unsigned char nParticle; 00111 unsigned char nSound; 00112 00113 // 포커스 00114 char nMcritical; 00115 char nRCritical; 00116 char nMAspd; 00117 char nRAspd; 00118 char nMAccu; 00119 char nRAccu; 00120 char nMFlee; 00121 char nRFlee; 00122 char nSFlee; 00123 char nHPRegen; 00124 char nENRegen; 00125 char nDSight; 00126 char nNSight; 00127 char nSpd; 00128 char nOCS; 00129 char nDCS; 00130 char nRCS; 00131 char nECS; 00132 char nOMS; 00133 char nDMS; 00134 char nEMS; 00135 }; 00136 00137 class MItemCatalog : public map<int, MItemDesc*> 00138 { 00139 private: 00140 protected: 00141 public: 00142 MItemCatalog(); 00143 virtual ~MItemCatalog(); 00144 bool Read(const char* szFileName); 00145 void Clear(); 00146 MItemDesc* Find(int nDescID); 00147 }; 00148 00150 class MObjectItem : public MObject { 00151 protected: 00152 MObject* m_pOwner; 00153 MObjectItem* m_pParent; 00154 MItemDesc* m_pItemDesc; 00155 long m_nQuantity; 00156 rvector m_Pos; 00157 public: 00158 MObjectItem(); 00159 MObjectItem(MUID& uid, MMap* pMap, rvector& Pos); 00160 MObjectItem(MUID& uid, int nDescID, MMap* pMap, rvector& Pos); 00161 virtual ~MObjectItem(void){} 00162 const rvector& GetPos() { return m_Pos; } 00163 void SetPos(const rvector& Pos) { m_Pos = Pos; } 00164 00165 00166 void SetDescID(int nDescID); 00167 void SetDesc(MItemDesc* pItemDesc) { m_pItemDesc = pItemDesc; } 00168 int GetDescID() { return m_pItemDesc->nID; } 00169 MItemDesc* GetDesc() { return m_pItemDesc; } 00170 void SetOwner(MObject* pOwner) { m_pOwner = pOwner; } 00171 MObject* GetOwner() { return m_pOwner; } 00172 00173 DECLARE_RTTI() 00174 }; 00175 00176 class MObjectItemVector : public vector<MObjectItem*> {}; 00177 class MObjectItemList : public list<MObjectItem*> {}; 00178 class MObjectItemMap : public map<MUID, MObjectItem*> { }; 00179 00180 00182 enum MEquipmentSlot 00183 { 00184 MES_HEAD = 0, 00185 MES_CHEST, 00186 MES_SHOULDER, 00187 MES_HANDS, 00188 MES_WAIST, 00189 MES_LEGS, 00190 MES_FEET, 00191 MES_LFINGER, 00192 MES_RFINGER, 00193 MES_NECK, 00194 MES_BACK, 00195 MES_PRIMARY, 00196 MES_SECONDARY, 00197 MES_AMMO, 00198 MES_PRIMARY2, 00199 MES_SECONDARY2, 00200 MES_AMMO2, 00201 MES_END // enum 요소의 갯수를 알기 위함 00202 }; 00203 00204 00205 class MEquipContainer 00206 { 00207 private: 00208 protected: 00209 00210 public: 00211 MEquipContainer(); 00212 virtual ~MEquipContainer(); 00213 MObjectItemVector m_EquipItemVector; 00214 }; 00215 00216 00218 class MItemContainer : public MObjectItem 00219 { 00220 private: 00221 protected: 00222 int m_nMaxSpace; 00223 public: 00224 MObjectItemVector m_ObjectItemVector; 00225 00226 MItemContainer(MUID& uid, MMap* pMap, rvector& Pos); 00227 MItemContainer(); 00228 virtual ~MItemContainer(); 00229 00230 bool Create(int nMaxSpace); 00231 void Destroy(); 00232 void Clear(); 00233 00234 bool Push(int nIndex, MObjectItem* pObjectItem); 00235 void ForcePush(int nIndex, MObjectItem* pObjectItem, MObjectItem* pOutObjectItem); 00236 MObjectItem* Pop(int nIndex); 00237 MObjectItem* GetItem(int nIndex); 00238 00239 DECLARE_RTTI() 00240 }; 00241 00242 00243 extern MItemCatalog g_ItemCatalog; 00244 00245 // TAG 00246 #define MICTOK_ITEM "ITEM" 00247 #define MICTOK_IDENT "IDENT" 00248 #define MICTOK_CLASS "CLASS" 00249 #define MICTOK_slot "SLOT" 00250 #define MICTOK_ATTACK "ATTACK" 00251 #define MICTOK_DEFENSE "DEFENSE" 00252 #define MICTOK_STAT "STAT" 00253 #define MICTOK_EFFECT "EFFECT" 00254 #define MICTOK_VISUAL "VISUAL" 00255 #define MICTOK_FOCUS "FOCUS" 00256 00257 // Attribute 00258 #define MICTOK_ID "id" 00259 #define MICTOK_NAME "name" 00260 #define MICTOK_SLOTTYPE "type" 00261 00262 #endif
MAIET entertainment