Planeshift
psitem.h
Go to the documentation of this file.
1 /*
2  * psitem.h
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef __PSITEM_H__
21 #define __PSITEM_H__
22 //=============================================================================
23 // Crystal Space Includes
24 //=============================================================================
25 #include <csutil/array.h>
26 #include <csgeom/vector3.h>
27 #include <csutil/weakreferenced.h>
28 
29 //=============================================================================
30 // Project Includes
31 //=============================================================================
32 #include "util/psconst.h"
33 #include "util/scriptvar.h"
34 #include "util/gameevent.h"
35 #include "util/slots.h"
36 
37 #include <idal.h>
38 
39 #include "util/poolallocator.h"
40 
41 #include "net/messages.h"
42 
43 //=============================================================================
44 // Local Includes
45 //=============================================================================
46 #include "psskills.h"
47 #include "psitemstats.h"
48 #include "deleteobjcallback.h"
49 #include "psactionlocationinfo.h"
50 #include "lootrandomizer.h"
51 
52 
53 class Client;
54 class gemActor;
55 
60 // Note: The following 2 options require a clean rebuild when changed.
61 
63 #define SAVE_DEBUG 0
64 
66 #define SAVE_TRACER 0
67 
68 
70 #define REMOVAL_INTERVAL_RANGE 300
71 #define REMOVAL_INTERVAL_MINIMUM 2419200
72 
74 #define ID_DONT_SAVE_ITEM 0xffffffff
75 
77 #define PSITEM_FLAG_CRAFTER_ID_IS_VALID 0x00000001
78 #define PSITEM_FLAG_GUILD_ID_IS_VALID 0x00000002
80 #define PSITEM_FLAG_UNIQUE_ITEM 0x00000004
82 
91 #define PSITEM_FLAG_USES_BASIC_ITEM 0x00000008
92 #define PSITEM_FLAG_PURIFIED 0x00000010
94 #define PSITEM_FLAG_PURIFYING 0x00000020
95 
97 #define PSITEM_FLAG_LOCKED 0x00000040
98 
100 #define PSITEM_FLAG_LOCKABLE 0x00000080
101 
103 #define PSITEM_FLAG_NOPICKUP 0x00000100
104 
106 #define PSITEM_FLAG_KEY 0x00000200
107 
109 #define PSITEM_FLAG_TRANSIENT 0x00000400
110 
112 #define PSITEM_FLAG_UNPICKABLE 0x00000800
113 
115 #define PSITEM_FLAG_SECURITYLOCK 0x00001000
116 
118 #define PSITEM_FLAG_NPCOWNED 0x00002000
119 
121 #define PSITEM_FLAG_MASTERKEY 0x00004000
122 
124 #define PSITEM_FLAG_USE_CD 0x00008000
125 
127 #define PSITEM_FLAG_ACTIVE 0x00010000
128 
130 #define PSITEM_FLAG_UNSTACKABLE 0x00020000
131 
133 #define PSITEM_FLAG_STACKABLE 0x00040000
134 
136 #define PSITEM_FLAG_SETTINGITEM 0x00080000
137 
139 #define PSITEM_FLAG_NOPICKUPWEAK 0x00100000
140 
142 #define PSITEM_FLAG_IDENTIFIABLE 0x00200000
143 
144 #define KEY_SKELETON ((unsigned int)-2)
145 
146 #define MAX_STACK_COUNT 65 // This is the most items a player can have in a stack
147 
148 typedef unsigned int PSITEM_FLAGS;
149 
151 #define PSITEM_MAX_MODIFIERS 10
152 
153 class ActiveSpell;
154 class psItem;
155 class psCharacter;
156 class gemItem;
157 class psSectorInfo;
158 struct psItemCategory;
159 class psScheduledItem;
160 class psWorkGameEvent;
161 
172 {
173 public:
176  bool active;
177  csString name;
178  float weight;
179  float latency;
183  csArray<ItemRequirement> reqs;
184  csString mesh;
185  csString icon;
186 };
187 
239 {
240 public:
241 
247  psItem();
248 
251  virtual ~psItem();
252 
255  virtual const char* GetItemType()
256  {
257  return "Item";
258  }
259 
261  {
262  return gItem;
263  }
264  void SetGemObject(gemItem* object);
265 
267  {
268  return transformationEvent;
269  }
271  {
272  transformationEvent = t;
273  }
274 
276  virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
277 
279  void UpdateView(Client* fromClient, EID eid, bool clear);
280 
281  bool SendItemDescription(Client* client);
282 
283  bool SendContainerContents(Client* client, int containerID = CONTAINER_INVENTORY_BULK);
284 
291  void ViewItem(Client* client, int containerID, INVENTORY_SLOT_NUMBER slotID);
292 
293  bool SendActionContents(Client* client, psActionLocation* action);
294 
295 private:
296 
297 
302  void FillContainerMsg(Client* client, psViewContainerDescription &outgoing);
303 
304  void SendCraftTransInfo(Client* client);
305 
306  void GetComboInfoString(psCharacter* character, uint32 designID, csString &comboString);
307 
308  void GetTransInfoString(psCharacter* character, uint32 designID, csString &transString);
309 
310  bool SendBookText(Client* client, int containerID, int slotID);
311 
312  void SendSketchDefinition(Client* client);
313 
314  void SendMusicalSheet(Client* client);
315 
317  uint32 uid;
318 
320  bool item_in_use;
321 
323  psWorkGameEvent* transformationEvent;
324 
326  struct
327  {
329  float loc_x,loc_y,loc_z;
330  float loc_xrot,loc_yrot,loc_zrot;
332  } location;
333 
335  float decay_resistance; // percent 3.2
336 
337 
338  float item_quality;
339  float crafted_quality;
340 
341 
343  float item_quality_original;
344 
346  unsigned short stack_count;
347 
349  int charges;
350 
352  bool useNat;
353 
354 
355 protected:
363 private:
367  PID crafter_id;
374  unsigned int guild_id;
375 
376  /* Container Hierarchy Data
377  *
378  * The following field allows objects-within-objects (containers) to be described.
379  *
380  */
382  InstanceID parent_item_InstanceID;
383 
384 
388  INVENTORY_SLOT_NUMBER loc_in_parent;
389 
390 
396  psCharacter* owning_character;
397 
401  PID owningCharacterID;
402  PID guardingCharacterID;
403 
408  psItemStats* base_stats;
414  psItemStats* current_stats;
420  psItemStats* modifiers[PSITEM_MAX_MODIFIERS];
421 
422  // Lock stuff
423  unsigned int lockStrength;
424  PSSKILL lockpickSkill;
425 
426  // A key can open multiple locks
427  csArray<unsigned int> openableLocks;
428 
429  psScheduledItem* schedule;
430 
436  void Commit(bool children = false);
437 
444  void UpdateItemQuality(uint32 id, float qual);
445 
447  friend class psDelaySave;
448 
452  csString item_name;
453 
457  csString item_description;
458 
460  ActiveSpell* equipActiveSpell;
461 
463  psItemCreativeStats creativeStats;
464 
466  RandomizedOverlay* itemModifiers;
467 
469  csArray<uint32_t> modifierIds;
470 
471 public:
476  virtual bool Load(iResultRow &row);
477 
482  void Save(bool children);
483 
485  void ForceSaveIfNew();
486 
491  void SetLoaded()
492  {
493  loaded = true;
494  }
495 
498  bool CheckRequirements(psCharacter* character, csString &resp);
499 
504  uint32 GetUID()
505  {
506  return uid;
507  }
508 
512  void SetUID(uint32 v);
513 
515  bool GetIsCrafterIDValid();
517  void SetIsCrafterIDValid(bool v);
518 
520  bool GetIsGuildIDValid();
522  void SetIsGuildIDValid(bool v);
524 
525  PID GetCrafterID() const
526  {
527  return crafter_id;
528  }
530  void SetCrafterID(PID v);
531 
533  unsigned int GetGuildID() const
534  {
535  return guild_id;
536  }
538  void SetGuildID(unsigned int v);
539 
541  float GetMaxItemQuality() const;
543  void SetMaxItemQuality(float v);
544 
546  float GetItemQuality() const;
548  void SetItemQuality(float v);
550  const char* GetQualityString();
551 
553  PSITEM_FLAGS ParseItemFlags(csString flagstr);
554 
556  int GetRequiredRepairTool();
558  bool GetRequiredRepairToolConsumed();
559 
561  int GetIdentifySkill();
563  int GetIdentifyMinSkill();
564 
566  void SetDecayResistance(float v);
568  void SetItemDecayRate(float v);
571  {
572  return base_stats->GetDecayRate();
573  }
575  float AddDecay(float severityFactor);
576 
577  bool IsInUse()
578  {
579  return item_in_use;
580  }
581  void SetInUse(bool flag)
582  {
583  item_in_use = flag;
584  }
585 
590  bool GetIsUnique() const;
591 
599  bool HasModifier(psItemStats* modifier);
600 
606  bool AddModifier(psItemStats* modifier);
607 
611  psItemStats* GetModifier(int index);
612 
614  virtual psItem* CreateNew()
615  {
616  return new psItem();
617  }
618 
625  virtual psItem* Copy(unsigned short newstackcount);
626 
629  virtual void Copy(psItem* target);
630 
637  psItem* SplitStack(unsigned short newstackcount);
638 
639 
642  void CombineStack(psItem* &stackme);
643 
644 
648  int GetAttackAnimID(psCharacter* pschar);
649 
651  float GetDecay();
653  void SetDecay(float v);
654 
656  unsigned short GetStackCount() const
657  {
658  return stack_count;
659  }
664  void SetStackCount(unsigned short v);
665 
666 
673  {
674  return owning_character;
675  }
680  {
681  return owningCharacterID;
682  }
683 
685  virtual void SetOwningCharacter(psCharacter* owner);
686 
690  {
691  return guardingCharacterID;
692  }
693  void SetGuardingCharacterID(PID guardian)
694  {
695  guardingCharacterID = guardian;
696  }
697 
699  uint32 GetContainerID() const
700  {
701  return parent_item_InstanceID;
702  }
703  void SetContainerID(uint32 parentId)
704  {
705  parent_item_InstanceID = parentId;
706  }
707 
708 
713  INVENTORY_SLOT_NUMBER GetLocInParent(bool adjustSlot=false);
714 
716  void SetLocInParent(INVENTORY_SLOT_NUMBER location);
717 
721  void SetUniqueStats(psItemStats* statptr);
722 
727  void SetBaseStats(psItemStats* statptr);
728 
733  {
734  return base_stats;
735  }
736 
741  void SetCurrentStats(psItemStats* statptr);
742 
747  {
748  return current_stats;
749  }
750 
754  void RecalcCurrentStats();
755 
757  {
758  return flags;
759  }
760 
761  void SetFlags(int f)
762  {
763  flags = f;
764  }
765 
766  virtual int GetPurifyStatus() const
767  {
768  return 0;
769  }
770 
771  // Interface to itemstats
772 
773  /* The following functions mostly call into the current stats to return the requested values.
774  * In the future additional logic about value modification may be added to these functions.
775  * For this reason these functions should ALWAYS be used rather than calling GetCurrentStats()->Get*()
776  * unless you REALLY know what you're doing and REALLY mean to bypass the intended value of the item instance.
777  */
778 
779  bool GetIsMeleeWeapon();
780  bool GetIsBothHandsWeapon();
781  bool GetIsRangeWeapon();
782  bool GetIsAmmo();
783  bool GetIsArmor();
784  bool GetIsShield();
785  bool GetIsContainer();
786  bool GetIsAutoTransformContainer();
787  bool GetIsTrap();
788  bool GetIsConstructible();
789  bool GetCanTransform();
790  bool GetUsesAmmo();
791  bool GetIsStackable() const;
792  bool GetIsEquipStackable() const;
793  PSITEMSTATS_CREATIVETYPE GetCreative();
795  bool SetCreation(PSITEMSTATS_CREATIVETYPE, const csString &, csString);
800  PID GetCreator(PSITEMSTATS_CREATORSTATUS &creatorStatus);
802  void SetCreator(PID, PSITEMSTATS_CREATORSTATUS);
803 
809  bool IsThisTheCreator(PID pid);
810  bool GetBuyPersonalise();
811  const char* GetName() const;
816  const char* GetDescription() const;
817  void SetName(const char* newName);
818  void SetDescription(const char* newDescription);
819  const char* GetStandardName();
820  const char* GetStandardDescription();
821 
830  void AddLootModifier(uint32_t id, int pos = -1);
831 
833  void UpdateModifiers();
834 
835  float GetRange() const
836  {
837  return current_stats->GetRange();
838  }
839  bool UsesAmmoType(uint32_t id) const
840  {
841  return current_stats->UsesAmmoType(id);
842  }
843 
844  psWeaponType *GetWeaponType();
845  PSSKILL GetWeaponSkill(PSITEMSTATS_WEAPONSKILL_INDEX index);
846  float GetLatency();
847  float GetDamage(PSITEMSTATS_DAMAGETYPE dmgtype);
848  PSITEMSTATS_AMMOTYPE GetAmmoType();
849 
850  float GetPenetration();
851  float GetUntargetedBlockValue();
852  float GetTargetedBlockValue();
853  float GetCounterBlockValue();
854  PSITEMSTATS_ARMORTYPE GetArmorType();
855  float GetDamageProtection(PSITEMSTATS_DAMAGETYPE dmgtype);
856  float GetHardness();
857  float GetWeaponAttributeBonus(PSITEMSTATS_STAT stat);
858  PSITEMSTATS_STAT GetWeaponAttributeBonusType(int index);
859  float GetWeaponAttributeBonusMax(int index);
860 
861  float GetWeight();
862  float GetItemSize();
865  {
866  return GetItemSize()*stack_count;
867  }
868 
869  unsigned short GetContainerMaxSize();
870 
877  int GetContainerMaxSlots();
878  PSITEMSTATS_SLOTLIST GetValidSlots();
879  bool FitsInSlots(PSITEMSTATS_SLOTLIST slotmask);
880  bool FitsInSlot(INVENTORY_SLOT_NUMBER slot);
881 
888  csString GetSlotRemovedMesh(int slot, csString meshName = "")
889  {
890  return GetBaseStats()->GetSlotRemovedMesh(slot, meshName);
891  }
892  float GetDecayResistance();
893  psMoney GetPrice();
894  psMoney GetSellPrice();
895  psItemCategory* GetCategory();
896 
897 
898  float GetVisibleDistance();
899 
900  void GetLocationInWorld(InstanceID &instance,psSectorInfo** sectorinfo,float &loc_x,float &loc_y,float &loc_z,float &loc_yrot) const;
901  void SetLocationInWorld(InstanceID instance,psSectorInfo* sectorinfo,float loc_x,float loc_y,float loc_z,float loc_yrot);
902 
907  void GetXZRotationInWorld(float &loc_xrot, float &loc_zrot);
908 
913  void SetXZRotationInWorld(float loc_xrot, float loc_zrot);
914 
920  void GetRotationInWorld(float &loc_xrot, float &loc_yrot, float &loc_zrot);
921 
927  void SetRotationInWorld(float loc_xrot, float loc_yrot, float loc_zrot);
928 
930  {
931  return location.loc_sectorinfo;
932  }
933 
938  const char* GetMeshName();
939 
944  const char* GetTextureName();
945 
951  const char* GetPartName();
952 
958  const char* GetPartMeshName();
959 
965  const char* GetImageName();
966 
967  csString GetQuantityName(); // returns the quantity and plural name in a string
968  static csString GetQuantityName(const char* namePtr, int stack_count, PSITEMSTATS_CREATIVETYPE creativeType, bool giveDetail = false);
969 
970  // For future use, see notes for mesh_index variables, etc.
971  /*
972  unsigned int GetMeshIndex();
973  unsigned int GetTextureIndex();
974  unsigned int GetTexturePartIndex();
975  unsigned int GetImageIndex();
976  */
977 
978  void UpdateInventoryStatus(psCharacter* owner,uint32 parent_id, INVENTORY_SLOT_NUMBER slot);
979 
980  bool IsEquipped() const;
981  // an item can be equipped, but not active. This happens when its equip requirements
982  // fail to be met while the item is still equipped.
983  // IsActive = true means the progression script for this item is active
984  // IsActive = false means the progression script for this item is inactive
985  bool IsActive() const;
986  void SetActive(bool state);
987 
988  void RunEquipScript(gemActor* actor);
989  void CancelEquipScript();
990 
995  const char* GetModifiersDescription();
996 
1005  bool CheckStackableWith(const psItem* otheritem, bool precise, bool checkStackCount = true, bool checkWorld = true) const;
1006 
1007  const char* GetSound();
1008 
1010  double GetProperty(MathEnvironment* env, const char* ptr);
1011  double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
1012  const char* ToString()
1013  {
1014  return item_name.GetDataSafe();
1015  }
1016 
1018  {
1019  return ((flags & PSITEM_FLAG_LOCKED)? true : false);
1020  }
1021  void SetIsLocked(bool v);
1022 
1024  {
1025  return ((flags & PSITEM_FLAG_LOCKABLE)? true : false);
1026  }
1027  void SetIsLockable(bool v);
1028 
1030  {
1031  return ((flags & PSITEM_FLAG_SECURITYLOCK)? true : false);
1032  }
1033  void SetIsSecurityLocked(bool v);
1034 
1036  {
1037  return ((flags & PSITEM_FLAG_UNPICKABLE)? true : false);
1038  }
1039  void SetIsUnpickable(bool v);
1040 
1045  {
1046  return (GetIsNoPickupStrong() || GetIsNoPickupWeak());
1047  }
1048 
1053  {
1054  return ((flags & PSITEM_FLAG_NOPICKUP)? true : false);
1055  }
1056 
1061  {
1062  return ((flags & PSITEM_FLAG_NOPICKUPWEAK)? true : false);
1063  }
1064 
1065  bool GetIsCD() const
1066  {
1067  return ((flags & PSITEM_FLAG_USE_CD)? true : false);
1068  }
1069  void SetIsCD(bool v);
1070 
1071  bool GetIsNpcOwned() const
1072  {
1073  return (flags & PSITEM_FLAG_NPCOWNED) != 0;
1074  }
1075  void SetIsNpcOwned(bool v);
1076 
1077  bool GetIsKey() const
1078  {
1079  return ((flags & PSITEM_FLAG_KEY)? true : false);
1080  }
1081  void SetIsKey(bool v);
1082 
1083  bool GetIsMasterKey() const
1084  {
1085  return ((flags & PSITEM_FLAG_MASTERKEY)? true : false);
1086  }
1087  void SetIsMasterKey(bool v);
1088 
1090  {
1091  return ((flags & PSITEM_FLAG_TRANSIENT) ? true : false);
1092  }
1093  void SetIsTransient(bool v);
1094 
1098  void SetIsPickupable(bool v);
1099 
1103  void SetIsPickupableWeak(bool v);
1104 
1105  void SetIsItemStackable(bool v);
1106  void ResetItemStackable();
1107 
1108  bool GetIsSettingItem() const
1109  {
1110  return ((flags & PSITEM_FLAG_SETTINGITEM)? true : false);
1111  }
1112  void SetIsSettingItem(bool v);
1113 
1115  {
1116  return lockpickSkill;
1117  }
1118  void SetLockpickSkill(PSSKILL v);
1119 
1120  unsigned int GetLockStrength()
1121  {
1122  return lockStrength;
1123  }
1124  void SetLockStrength(unsigned int v);
1125 
1126  bool CompareOpenableLocks(const psItem* key) const;
1127  bool CanOpenLock(uint32 id, bool includeSkel) const;
1128  void AddOpenableLock(uint32 v);
1129  void RemoveOpenableLock(uint32 v);
1130  void ClearOpenableLocks();
1131  void CopyOpenableLock(psItem* origKey);
1132  void MakeSkeleton(bool b);
1133  bool GetIsSkeleton();
1134  csString GetOpenableLockNames();
1135 
1137  {
1138  return schedule;
1139  }
1141  {
1142  schedule = item;
1143  }
1144  void ScheduleRespawn();
1145 
1147  float GetArmorVSWeaponResistance(psItemStats* armor);
1148 
1150  csString GetBookText()
1151  {
1152  return GetLiteratureText();
1153  }
1155  bool SetBookText(const csString &newText);
1157  bool SetSketch(const csString &newSketchData);
1159  bool SetMusicalSheet(const csString &newMusicalSheet);
1160 
1161  bool HasCharges() const;
1162  bool IsRechargeable() const;
1163  void SetCharges(int charges);
1164  int GetCharges() const;
1165  int GetMaxCharges() const;
1166 
1168  csString GetItemCommand()
1169  {
1170  return GetBaseStats()->GetItemCommand();
1171  }
1172 
1182  bool Destroy();
1183 
1188  void ScheduleRemoval();
1189 
1190  bool DeleteFromDatabase();
1191 
1192  /* Objects of this class utilize a pool allocator. The pool allocator can be found in poolallocator.h in the psutil library.
1193  * The pool allocator allows us to avoid allocating memory from and releasing memory to the heap over and over for things that are
1194  * constantly shifting in the number of allocations (such as items in the game). It also reduces memory usage overhead slightly.
1195  *
1196  * It should be possible to debug memory leaks from a specific pool easier as well since you can analyze allocations solely from that pool
1197  * without getting flooded with allocations from everywhere else.
1198  */
1199 
1201  void* operator new(size_t);
1203  void operator delete(void*);
1204 
1208  bool GetIsWriteable();
1212  bool GetIsReadable();
1213 
1215  const csString &GetSketch(void)
1216  {
1217  return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetSketch() : creativeStats.content;
1218  }
1220  const csString &GetMusicalSheet(void)
1221  {
1222  return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetSketch() : creativeStats.content;
1223  }
1225  const csString &GetLiteratureText(void)
1226  {
1227  return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetSketch() : creativeStats.content;
1228  }
1230  const csString &GetCreativeBackgroundImg()
1231  {
1232  return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetCreativeBackgroundImg() : creativeStats.backgroundImg;
1233  }
1234 
1235  void PrepareCreativeItemInstance();
1236 
1238  float GetRarity();
1239 
1241  csString GetRarityName();
1242 
1245  {
1246  return ((flags & PSITEM_FLAG_IDENTIFIABLE)? true : false);
1247  }
1249  void SetIsIdentifiable(bool v);
1250 
1251 
1252 private:
1254  static PoolAllocator<psItem> itempool;
1255 
1256  gemItem* gItem;
1257 
1258  bool pendingsave;
1259 
1260  float rarity;
1261 
1264  float CalculateItemRarity();
1265 
1266 protected:
1267  bool loaded;
1268 
1269 #if SAVE_TRACER
1270 private:
1271  csString last_save_queued_from;
1272 #endif
1273 
1274 };
1275 
1276 
1278 {
1279 public:
1280  psScheduledItem(int spawnID,uint32 itemID,csVector3 &position, psSectorInfo* sector,InstanceID instance, int interval,int maxrnd,
1281  float range, int lock_str = 0, int lock_skill = -1, csString flags = "");
1282 
1283  psItem* CreateItem();
1284  uint32 GetItemID()
1285  {
1286  return itemID;
1287  }
1288 
1290  {
1291  return sector;
1292  }
1293  csVector3 &GetPosition()
1294  {
1295  return pos;
1296  }
1297  int MakeInterval();
1299  {
1300  return interval;
1301  }
1303  {
1304  return maxrnd;
1305  }
1306 
1309  {
1310  return lock_str;
1311  }
1312 
1315  {
1316  return lock_skill;
1317  }
1318 
1320  csString GetFlags()
1321  {
1322  return flags;
1323  }
1324 
1325  void UpdatePosition(csVector3 &positon, const char* sector);
1326  void ChangeIntervals(int newint, int newrand);
1327  void ChangeRange(float newRange);
1328  void ChangeAmount(int newAmount);
1329  void Remove();
1330 
1331  bool WantToDie()
1332  {
1333  return wantToDie;
1334  }
1335 
1336 private:
1337  bool wantToDie;
1338  int spawnID;
1339  uint32 itemID;
1340  csVector3 pos;
1341  psSectorInfo* sector;
1342  InstanceID worldInstance;
1343  int interval;
1344  int maxrnd;
1345  float range;
1346  int lock_str;
1347  int lock_skill;
1348  csString flags;
1349 };
1350 
1353 #endif
#define PSITEM_FLAG_LOCKED
Flags for locked status (as in a locked container). If locked it can be opened only with lockpick or ...
Definition: psitem.h:97
uint32 InstanceID
Definition: psconst.h:64
uint32 GetUID()
Returns the UID of this item instance.
Definition: psitem.h:504
#define PSITEM_FLAG_SECURITYLOCK
Flag to indicate that lock is a security lock that stays locked.
Definition: psitem.h:115
csArray< ItemRequirement > reqs
Array of all the stat prerequisites needed to equip this item.
Definition: psitem.h:183
#define PSITEM_FLAG_SETTINGITEM
Flag defines if item is done by setting (unused by the server, it&#39;s more for ordering in the db) ...
Definition: psitem.h:136
PSITEMSTATS_WEAPONSKILL_INDEX
Definition: psitemstats.h:52
bool UsesAmmoType(uint32_t id) const
Definition: psitemstats.h:667
unsigned int PSITEMSTATS_SLOTLIST
Definition: psitemstats.h:159
float loc_zrot
Definition: psitem.h:330
bool GetIsSettingItem() const
Definition: psitem.h:1108
void SetContainerID(uint32 parentId)
Definition: psitem.h:703
psMoney price
Price calculated from the loot modifiers rules which overlays the basic one.
Definition: psitem.h:182
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
PSITEM_FLAGS flags
Flags for this item instance.
Definition: psitem.h:362
void SetLoaded()
Flags that this item has been fully loaded, and is allowed to be saved on changes.
Definition: psitem.h:491
unsigned int GetLockStrength()
Definition: psitem.h:1120
PID GetCrafterID() const
Returns the UID for the crafter of this item. Be sure to check GetIsCrafterIDValid()! ...
Definition: psitem.h:525
int GetLockSkill()
Gets the lock skill which will be associated to this item.
Definition: psitem.h:1314
unsigned short GetStackCount() const
Returns the stack count. Be sure to call GetIsStackable() first!
Definition: psitem.h:656
#define PSITEM_FLAG_UNPICKABLE
Flag to indicate that lock is unpickable.
Definition: psitem.h:112
bool UsesAmmoType(uint32_t id) const
Definition: psitem.h:839
const char * GetName(int id)
INVENTORY_SLOT_NUMBER
Holds a list of the possible socket identifiers that items can be attached to.
Definition: slots.h:32
unsigned int PSITEM_FLAGS
Definition: psitem.h:148
void SetScheduledItem(psScheduledItem *item)
Definition: psitem.h:1140
PSSKILL GetLockpickSkill()
Definition: psitem.h:1114
work event class
Definition: workmanager.h:708
PSITEMSTATS_CREATIVETYPE
Definition: psitemstats.h:115
bool GetIsNoPickupWeak()
Checks if the item has a weak no pickup flag set.
Definition: psitem.h:1060
PSITEMSTATS_AMMOTYPE
Definition: psitemstats.h:106
const csString & GetLiteratureText(void)
return creative contents of books.
Definition: psitem.h:1225
#define PSITEM_FLAG_NOPICKUPWEAK
Flag for an un-pickupable item (remains fixed) - weak variant.
Definition: psitem.h:139
PSITEMSTATS_DAMAGETYPE
Definition: psitemstats.h:89
void SetFlags(int f)
Definition: psitem.h:761
csString GetBookText()
Gets the book text, should only be used if this is a book.
Definition: psitem.h:1150
csString GetItemCommand()
returns the special command assigned to this item
Definition: psitem.h:1168
float GetDecayRate()
unsigned int GetGuildID() const
Returns the UID for the guild who has certified this item. Be sure to check GetIsGuildIDValid()! ...
Definition: psitem.h:533
float GetItemDecayRate()
Get the item decay factor.
Definition: psitem.h:570
uint32 GetContainerID() const
Returns the item that contains this item, or NULL if it&#39;s not contained by another item...
Definition: psitem.h:699
General Message for sending information about an containter to a client.
Definition: messages.h:4339
bool active
Notifies if this overlay is active and should be applied.
Definition: psitem.h:176
PSITEMSTATS_STAT
Definition: psitemstats.h:69
void SetInUse(bool flag)
Definition: psitem.h:581
ApplicativeScript * equip_script
Equip script for this item overriding the main one from loot modifiers rules.
Definition: psitem.h:181
bool GetIsLockable()
Definition: psitem.h:1023
psCharacter * GetOwningCharacter()
Returns a pointer to the character who is holding this item directly or indirectly (including contain...
Definition: psitem.h:672
psWorkGameEvent * GetTransformationEvent()
Definition: psitem.h:266
csString mesh
Overriden mesh of this item from the basic one.
Definition: psitem.h:184
bool GetIsKey() const
Definition: psitem.h:1077
float latency
Latency of the weapon changed by the loot modifiers rules.
Definition: psitem.h:179
psItemStats * GetBaseStats() const
Returns the base stats for this item instance.
Definition: psitem.h:732
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
#define PSITEM_FLAG_MASTERKEY
Flag defines any item as a key to a locked object that can be used to make a copy of the key...
Definition: psitem.h:121
const csString & GetMusicalSheet(void)
return creative contents of musical sheets.
Definition: psitem.h:1220
bool loaded
Definition: psitem.h:1267
psSectorInfo * loc_sectorinfo
Definition: psitem.h:328
int GetLockStrength()
Gets the lock strength which will be associated to this item.
Definition: psitem.h:1308
psItemStats * GetCurrentStats() const
Gets a pointer to the current stats.
Definition: psitem.h:746
csString name
The name which should be replaced for this randomized item.
Definition: psitem.h:177
float GetRange() const
Definition: psitem.h:835
csString GetFlags()
Gets the flags which will be associated to this item.
Definition: psitem.h:1320
float weight
Weigth of the item changed by the loot modifier rules.
Definition: psitem.h:178
bool GetIsUnpickable()
Definition: psitem.h:1035
const csString & GetCreativeBackgroundImg()
return the background image used in this creative.
Definition: psitem.h:1230
PSSKILL
Definition: psskills.h:44
#define PSITEM_FLAG_TRANSIENT
Transient items are removed from the world approx 3hrs after creation, if not picked up by someone...
Definition: psitem.h:109
#define PSITEM_FLAG_LOCKABLE
Flag to allow locking/unlocking of the item. It will add the "lock/unlock" icon in the context menu o...
Definition: psitem.h:100
#define PSITEM_FLAG_KEY
Flag defines any item as a key to a locked object.
Definition: psitem.h:106
float GetTotalStackSize()
Gets the total size of the items in the stack.
Definition: psitem.h:864
const csString & GetSketch(void)
return creative contents of sketches.
Definition: psitem.h:1215
psSectorInfo * GetSector()
Definition: psitem.h:1289
bool IsInUse()
Definition: psitem.h:577
const char * ToString()
Definition: psitem.h:1012
bool GetIsMasterKey() const
Definition: psitem.h:1083
virtual int GetPurifyStatus() const
Definition: psitem.h:766
int GetInterval()
Definition: psitem.h:1298
This class collects data of a netclient.
Definition: client.h:95
gemItem * GetGemObject()
Definition: psitem.h:260
csString icon
Overriden icon of this item from the basic one.
Definition: psitem.h:185
float loc_z
Definition: psitem.h:329
~RandomizedOverlay()
Destructor.
csString GetSlotRemovedMesh(int slot, csString meshName="")
Proxies the same function in psitemstats which gets the list of mesh to remove when this item is equi...
Definition: psitem.h:888
ActiveSpells.
Definition: activespell.h:68
#define PSITEM_FLAG_NPCOWNED
Flag to indicate that players shouldn&#39;t be able to put items into this container. ...
Definition: psitem.h:118
int GetMaxModifier()
Definition: psitem.h:1302
PID GetGuardingCharacterID() const
Item guardians: items dropped in the world or placed in a public container are not owned...
Definition: psitem.h:689
RandomizedOverlay()
Constructor.
ApplicativeScript is the applied script container.
Definition: scripting.h:143
This class holds info about Creative items such as books, etc.
Definition: psitemstats.h:351
PSITEMSTATS_ARMORTYPE
Definition: psitemstats.h:60
bool GetIsIdentifiable()
Get the identifiable status of the item.
Definition: psitem.h:1244
void SetGuardingCharacterID(PID guardian)
Definition: psitem.h:693
This huge class stores all the properties of any object a player can have in the game.
Definition: psitemstats.h:463
PSITEMSTATS_CREATORSTATUS
Definition: psitemstats.h:123
bool IsTransient()
Definition: psitem.h:1089
virtual psItem * CreateNew()
Creates a new blank instance of it&#39;s class (i.e.
Definition: psitem.h:614
virtual const char * GetItemType()
Return a string identifying this object as an Item.
Definition: psitem.h:255
bool GetIsLocked()
Definition: psitem.h:1017
This class stores all the properties of an action location Entrance, return location, name, response type, trigger.
#define PSITEM_FLAG_IDENTIFIABLE
Flag for identifiable item (not yet identified)
Definition: psitem.h:142
float GetRange() const
csVector3 & GetPosition()
Definition: psitem.h:1293
#define PSITEM_FLAG_NOPICKUP
Flag for an un-pickupable item (remains fixed)
Definition: psitem.h:103
bool GetIsNpcOwned() const
Definition: psitem.h:1071
Stores the randomized stats from the loot randomizer, it could be used to apply any global special ef...
Definition: psitem.h:171
float damageStats[PSITEMSTATS_DAMAGETYPE_COUNT]
Damage/protection stats changed by the loot modifiers rules.
Definition: psitem.h:180
Contains information about sectors from the server perspective.
Definition: pssectorinfo.h:46
bool GetIsNoPickup()
Gets if the item has a no pickup flag set.
Definition: psitem.h:1044
PID GetOwningCharacterID() const
Get the ID of the owning character.
Definition: psitem.h:679
bool GetIsNoPickupStrong()
Checks if the item has a strong no pickup flag set.
Definition: psitem.h:1052
psScheduledItem * GetScheduledItem()
Definition: psitem.h:1136
#define PSITEM_MAX_MODIFIERS
The maximum number of modifiers that can be applied to a single instance of an item on top of the bas...
Definition: psitem.h:151
This class generically allows objects to be notified when a gemObject is removed. ...
Definition: gem.h:768
#define PSITEM_FLAG_USE_CD
Flag defines if CD should be used on this item.
Definition: psitem.h:124
PSITEM_FLAGS GetFlags()
Definition: psitem.h:756
psSectorInfo * GetSector() const
Definition: psitem.h:929
uint32 GetItemID()
Definition: psitem.h:1284
bool GetIsSecurityLocked()
Definition: psitem.h:1029
bool WantToDie()
Definition: psitem.h:1331
bool GetIsCD() const
Definition: psitem.h:1065
InstanceID worldInstance
Definition: psitem.h:331
void SetTransformationEvent(psWorkGameEvent *t)
Definition: psitem.h:270
This class embodies item instances in the game.
Definition: psitem.h:238