00001
00002
00003
00004
00005
00006
00007
00008
00009
00014 #ifndef __ITEMS_H
00015 #define __ITEMS_H
00016
00017 #include "amx/amxcback.h"
00018 #include "object.h"
00019 #include "magic.h"
00020 #include "item.h"
00021 #include "globals.h"
00022
00027 enum AmxItemEvents {
00028 EVENT_IONSTART = 0,
00029 EVENT_IONDAMAGE,
00030 EVENT_IONEQUIP,
00031 EVENT_IONUNEQUIP,
00032 EVENT_IONCLICK,
00033 EVENT_IONDBLCLICK,
00034 EVENT_IPUTINBACKPACK,
00035 EVENT_IDROPINLAND,
00036 EVENT_IDROPONCHAR,
00037 EVENT_IONCHECKCANUSE,
00038 EVENT_IONTRANSFER,
00039 EVENT_IONSTOLEN,
00040 EVENT_IONPOISONED,
00041 EVENT_IONDECAY,
00042 EVENT_IONREMOVETRAP,
00043 EVENT_IONLOCKPICK,
00044 EVENT_IONWALKOVER,
00045 EVENT_IONPUTITEM,
00046 EVENT_ITAKEFROMCONTAINER,
00047 ALLITEMEVENTS
00048 };
00049
00051 enum DelType
00052 {
00053 DELTYPE_UNKNOWN,
00054 DELTYPE_DECAY,
00055 DELTYPE_GMREMOVE
00056 };
00057
00061 class cItem : public cObject
00062 {
00063 public:
00069 cItem& operator=(cItem& b);
00070
00071 static void archive();
00072 static void safeoldsave();
00073
00074 public:
00075 cItem(SERIAL serial);
00076 ~cItem();
00077
00078
00080
00083 AmxEvent *amxevents[ALLITEMEVENTS];
00084
00085 SI32 hp;
00086 SI32 maxhp;
00087
00088 void Refresh();
00089 SI32 getName(char* itemname);
00090 const char* getRealItemName();
00092
00094
00097 inline SI16 animid()
00098 { return ( animid1 && animid2 ) ? (SI16)((animid1<<8)|animid2) : getId(); }
00099 SI08 isFieldSpellItem();
00100
00101 LOGICAL IsCorpse();
00102 LOGICAL IsSpellScroll();
00103 LOGICAL IsSpellScroll72();
00104 LOGICAL IsTree();
00105 LOGICAL IsTree2();
00106 LOGICAL IsInstrument();
00107
00108 LOGICAL IsAxe();
00109 LOGICAL IsSword();
00110 LOGICAL IsSwordType();
00111 LOGICAL IsMace1H();
00112 LOGICAL IsMace2H();
00113 LOGICAL IsMaceType();
00114 LOGICAL IsFencing1H();
00115 LOGICAL IsFencing2H();
00116 LOGICAL IsFencingType();
00117 LOGICAL IsBow();
00118 LOGICAL IsCrossbow();
00119 LOGICAL IsHeavyCrossbow();
00120 LOGICAL IsBowType();
00121 LOGICAL IsArrow();
00122 LOGICAL IsBolt();
00123 LOGICAL IsStave();
00124 LOGICAL IsSpecialMace();
00125 LOGICAL IsChaosOrOrderShield();
00126 LOGICAL IsShield();
00127
00128 LOGICAL IsLog();
00129 LOGICAL IsShaft();
00130 LOGICAL IsBoard();
00131 LOGICAL IsFeather();
00132 LOGICAL IsCutLeather();
00133 LOGICAL IsHide();
00134 LOGICAL IsBoltOfCloth();
00135 LOGICAL IsCutCloth();
00136 LOGICAL IsCloth();
00137 LOGICAL IsChest();
00138
00139 LOGICAL IsForge();
00140 LOGICAL IsAnvil();
00141 LOGICAL IsCookingPlace();
00142 LOGICAL IsDagger();
00143
00144 LOGICAL IsFish();
00145 LOGICAL IsFishWater();
00146
00147 LOGICAL IsSign();
00148 LOGICAL IsBrassSign();
00149 LOGICAL IsWoodenSign();
00150 LOGICAL IsGuildSign();
00151 LOGICAL IsTradeSign();
00152 LOGICAL IsBankSign();
00153 LOGICAL IsTheatreSign();
00154 LOGICAL IsHouse();
00155 LOGICAL isSpawner();
00156
00157 UI08 animid1;
00158 UI08 animid2;
00159 void animSetId(SI16 id);
00160 LOGICAL useAnimId;
00161 SI08 layer;
00162 SI08 oldlayer;
00163 SI08 scriptlayer;
00164
00165 SI08 magic;
00166 SI08 visible;
00167 SI16 dir;
00169
00171
00174 private:
00175 Serial contserial;
00176 Serial oldcontserial;
00177
00178 public:
00179 SI32 getContSerial(LOGICAL old= 0) const;
00180 BYTE getContSerialByte(UI32 nByte, LOGICAL old= false) const;
00181 const cObject* getContainer() const;
00182
00183 inline void setCont(P_OBJECT obj)
00184 { setContSerial(obj->getSerial32()); }
00185
00186 void setContSerial(SI32 serial, LOGICAL old= false, LOGICAL update= true);
00187 void setContSerialByte(UI32 nByte, BYTE value, LOGICAL old= false);
00188
00190 inline const LOGICAL isContainer() const
00191 { return type==1 || type==12 || type==63 || type==8 || type==13 || type==64; }
00192
00193 inline const LOGICAL isSecureContainer() const
00194 { return type==8 || type==13 || type==64; }
00195
00196
00197 void SetRandPosInCont(P_ITEM pCont);
00198 bool ContainerPileItem( P_ITEM pItem );
00199 SI32 secureIt;
00200 LOGICAL AddItem(P_ITEM pItem, short xx=-1, short yy=-1);
00201 SI32 DeleteAmountByID(int amount, unsigned int scriptID);
00202 SI16 getContGump();
00203 void putInto( P_ITEM pi );
00205
00206
00207
00208
00209 UI08 more1;
00210 UI08 more2;
00211 UI08 more3;
00212 UI08 more4;
00213 SI08 moreb1;
00214 SI08 moreb2;
00215 SI08 moreb3;
00216 SI08 moreb4;
00217 UI32 morex;
00218 UI32 morey;
00219 UI32 morez;
00220
00222
00225 UI16 amount;
00226 UI16 amount2;
00227 SI32 ReduceAmount(const SI16 amount);
00228 SI32 IncreaseAmount(const SI16 amount);
00229
00231 inline void setAmount(const UI16 amt)
00232 { amount= amt; Refresh(); }
00233
00234 SI32 DeleteAmount(int amount, short id, short color=-1);
00235 inline const SI32 CountItems(short ID=-1, short col= -1,LOGICAL bAddAmounts = true) const
00236 { return pointers::containerCountItems(getSerial32(), ID, col, bAddAmounts); }
00237
00238 inline const SI32 CountItemsByID(unsigned int scriptID, LOGICAL bAddAmounts) const
00239 { return pointers::containerCountItemsByID(getSerial32(), scriptID, bAddAmounts); }
00240 inline const SI32 CountItemsByType(unsigned int type, LOGICAL bAddAmounts) const
00241 { return pointers::containerCountItemsByType(getSerial32(), type, bAddAmounts); }
00243
00245
00248 UI32 weight;
00249 R32 getWeight();
00250
00251 inline const R32 getWeightActual()
00252 { return (amount>1)? getWeight()*amount : getWeight(); }
00254
00256
00259 inline const LOGICAL isInWorld() const
00260 { return contserial.serial32==INVALID; }
00261
00262 void MoveTo(Location newloc);
00263
00264 inline void MoveTo(SI32 x, SI32 y, SI32 z)
00265 { MoveTo( Loc(x, y, z) ); }
00267
00269
00274 Skill getCombatSkill();
00275 UI32 att;
00276 UI32 def;
00277 Skill fightskill;
00278 SI32 reqskill[2];
00279 DamageType damagetype;
00280 DamageType auxdamagetype;
00281 SI32 auxdamage;
00282 SI32 lodamage;
00283 SI32 hidamage;
00284 SI32 wpsk;
00285 SI32 spd;
00286 SI32 itmhand;
00287 SI32 resists[MAX_RESISTANCE_INDEX];
00288 SI32 st;
00289 SI32 st2;
00290 SI32 dx;
00291 SI32 dx2;
00292 SI32 in;
00293 SI32 in2;
00294 PoisonType poisoned;
00295 UI32 ammo;
00296 UI32 ammoFx;
00297
00298
00300
00303 SI32 countSpellsInSpellBook();
00304 LOGICAL containsSpell(magic::SpellId spellnumber);
00305 UI32 gatetime;
00306 SI32 gatenumber;
00307 SI08 offspell;
00309
00311
00314 LOGICAL corpse;
00315 string murderer;
00316 SI32 murdertime;
00317
00318
00320
00324 SI32 smelt;
00325
00335 SI32 rank;
00336
00337
00338 std::string creator;
00339 SI32 good;
00340 SI32 rndvaluerate;
00341
00359 SI32 madewith;
00360
00361 std::string vendorDescription;
00363
00365
00368 void SetMultiSerial(SI32 mulser);
00370
00372
00375 SI32 value;
00376 SI32 restock;
00377
00378
00380
00383 SI32 trigger;
00384 SI32 trigtype;
00385 SI32 tuses;
00386
00387
00389
00392 UI32 type;
00393 UI32 type2;
00394 SI32 carve;
00395 LOGICAL incognito;
00396 SI32 wipe;
00397 UI32 time_unused;
00398 UI32 timeused_last;
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408 SI08 doordir;
00409 LOGICAL dooropen;
00410 SI32 itemSoundEffect;
00411 void explode(NXWSOCKET s);
00412
00413
00414 LOGICAL dye;
00415
00416 SI08 priv;
00417
00418 private:
00419 TIMERVAL decaytime;
00420
00421 public:
00422 inline const SI32 getSound() const
00423 { return itemSoundEffect; }
00424 inline void setSound(UI16 newSound)
00425 { itemSoundEffect = newSound; }
00426
00427 inline UI32 getType()
00428 { return type; };
00429
00430 inline void setType(UI32 newType)
00431 { type=newType; };
00432
00433 LOGICAL doDecay();
00434
00435 inline const LOGICAL canDecay() const
00436 { return priv&0x01; }
00437
00438 void setDecay( const LOGICAL on = true );
00439
00440 inline const void setDecayTime( const TIMERVAL delay = uiCurrentTime+(SrvParms->decaytimer*MY_CLOCKS_PER_SEC) )
00441 { decaytime = delay; }
00442
00443 inline const TIMERVAL getDecayTime() const
00444 { return decaytime; }
00445
00446 inline const LOGICAL isNewbie() const
00447 { return priv&0x02; }
00448
00449 void setNewbie( const LOGICAL on = true );
00450
00451 inline const LOGICAL isDispellable() const
00452 { return priv&0x04; }
00453
00454 void setDispellable( const LOGICAL on = true );
00455
00456 LOGICAL pileable;
00457 bool PileItem( P_ITEM pItem );
00458
00459 P_ITEM getOutMostCont( short rec=50 );
00460 P_CHAR getPackOwner();
00461
00462 UI32 distFrom( P_CHAR pc );
00463 UI32 distFrom( P_ITEM pi );
00464
00465 public:
00466 virtual void Delete();
00467
00468
00469
00470
00471 } PACK_NEEDED;
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 class cContainerItem : public cItem
00483 {
00484 private:
00485 vector<SI32> ItemList;
00486
00487 SI16 getGumpType();
00488 LOGICAL pileItem(P_ITEM pItem);
00489 void setRandPos(P_ITEM pItem);
00490
00491 public:
00492 cContainerItem(LOGICAL ser= true);
00493 UI32 removeItems(UI32 scriptID, UI32 amount);
00494 void dropItem(P_ITEM pi);
00495 UI32 countItems(UI32 scriptID, LOGICAL bAddAmounts= false);
00496 UI32 countItemsByType(short type, LOGICAL bAddAmounts=false);
00497
00498 } PACK_NEEDED;
00499
00500 class cWeapon : public cItem
00501 {
00502 public:
00503 cWeapon(SERIAL serial);
00504 } PACK_NEEDED;
00505
00506 extern LOGICAL LoadItemEventsFromScript (P_ITEM pi, char *script1, char *script2);
00507
00508
00509 #define MAKE_ITEM_REF(i) pointers::findItemBySerial(i)
00510
00511 #define DEREF_P_ITEM(pi) ( ( ISVALIDPI(pi) ) ? pi->getSerial32() : INVALID )
00512
00513 #define ISVALIDPI(pi) ( ( pi!=NULL && sizeof(*pi) == sizeof(cItem) ) ? (pi->getSerial32() > 0) : false )
00514
00515 #define VALIDATEPI(pi) if (!ISVALIDPI(pi)) { LogWarning("Warning: a non-valid P_ITEM pointer was used in %s:%d", basename(__FILE__), __LINE__); return; }
00516 #define VALIDATEPIR(pi, r) if (!ISVALIDPI(pi)) { LogWarning("Warning: a non-valid P_ITEM pointer was used in %s:%d", basename(__FILE__), __LINE__); return r; }
00517
00518
00519
00520 #endif