Planeshift
gem.h
Go to the documentation of this file.
1 /*
2  * gem.h - author Keith Fulton <keith@paqrat.com>
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  * This is the cel access class for PS.
19  *
20  * TODO: This API really needs to be refactored into a set of factories.
21  */
22 
23 #ifndef __GEM_H__
24 #define __GEM_H__
25 //=============================================================================
26 // Crystal Space Includes
27 //=============================================================================
28 #include <iengine/mesh.h>
29 #include <iengine/sector.h>
30 #include <iutil/vfs.h>
31 #include <csutil/csobject.h>
32 #include <csutil/csstring.h>
33 #include <csutil/hash.h>
34 #include <csutil/weakreferenced.h>
35 
36 //=============================================================================
37 // Project Space Includes
38 //=============================================================================
40 #include "bulkobjects/buffable.h"
42 
43 #include "util/gameevent.h"
44 #include "util/consoleout.h"
45 
46 #include "net/npcmessages.h" // required for psNPCCommandsMessage::PerceptionType
47 
48 //=============================================================================
49 // Local Space Includes
50 //=============================================================================
51 #include "msgmanager.h"
52 #include "deathcallback.h"
53 
54 struct iMeshWrapper;
55 
56 class ProximityList;
57 class ServerCharManager;
58 class EntityManager;
59 class gemObject;
60 class PlayerGroup;
61 class psDatabase;
62 class psItem;
63 class csMatrix3;
64 class NPCManager;
65 class psGlyphList;
66 class ProgressionManager;
67 class psNPCDialog;
69 class psActionLocation;
70 class psSpellCastEvent;
71 class MathScript;
72 class gemItem;
73 class gemActor;
74 class gemNPC;
75 class gemPet;
76 class gemActionLocation;
78 class PublishVector;
79 class psLinearMovement;
80 class gemMesh;
81 
86 #define BUFF_INDICATOR "+"
87 #define DEBUFF_INDICATOR "-"
88 
89 #define UNSTICK_TIME 15000
90 
91 
92 //-----------------------------------------------------------------------------
93 
97 class psGemServerMeshAttach : public scfImplementationExt1<psGemServerMeshAttach,
98  csObject,
99  scfFakeInterface<psGemServerMeshAttach> >
100 {
101 public:
103 
110 
115  {
116  return object;
117  }
118 
119 private:
120  gemObject* object;
121 };
122 
126 class GEMSupervisor : public MessageManager<GEMSupervisor>
127 {
128  EntityManager* entityManager;
129  CacheManager* cacheManager;
130 public:
131  iObjectRegistry* object_reg;
134 
143  GEMSupervisor(iObjectRegistry* objreg, psDatabase* db, EntityManager* entitymanager, CacheManager* cachemanager);
144 
150  virtual ~GEMSupervisor();
151 
157  csHash<gemObject*, EID> &GetAllGEMS()
158  {
159  return entities_by_eid;
160  }
161 
164 
171  EID FindItemID(psItem* item);
172 
173  gemObject* FindObject(EID cel_id);
174 
175  gemObject* FindObject(const csString &name);
176 
177  gemActor* FindPlayerEntity(PID player_id);
178 
179  gemNPC* FindNPCEntity(PID npc_id);
180 
181  gemNPC* FindNPCEntity(EID eid);
182 
183  gemItem* FindItemEntity(uint32 item_id);
185 
186  EID CreateEntity(gemObject* obj);
187  void AddEntity(gemObject* obj, EID objEid);
188  void RemoveEntity(gemObject* which);
189  void AddActorEntity(gemActor* actor);
190  void RemoveActorEntity(gemActor* actor);
191  void AddItemEntity(gemItem* item);
192  void RemoveItemEntity(gemItem* item, uint32 uid);
193 
194  void RemovePlayerFromLootables(PID playerID);
195 
196  void UpdateAllDR();
197 
201  void UpdateAllStats();
202 
203  void GetAllEntityPos(csArray<psAllEntityPosMessage> &msgs);
204  int CountManagedNPCs(AccountID superclientID);
205  void FillNPCList(MsgEntry* msg, AccountID superclientID);
206  void SendAllNPCStats(AccountID superclientID);
207  void ActivateNPCs(AccountID superclientID);
208  void StopAllNPCs(AccountID superclientID);
209 
218  void GetPlayerObjects(PID playerID, csArray<gemObject*> &list);
219 
230  void Teleport(gemObject* object, float x, float y, float z, float rot, const char* sectorname);
231 
232  void HandleStatsMessage(MsgEntry* me, Client* client);
233  void HandleDamageMessage(MsgEntry* me, Client* client);
234  void HandleStatDRUpdateMessage(MsgEntry* me, Client* client);
235 
244  void AttachObject(iObject* object, gemObject* gobject);
245 
246 
255  void UnattachObject(iObject* object, gemObject* gobject);
256 
257 
264  gemObject* FindAttachedObject(iObject* object);
265 
266 
278  csArray<gemObject*> FindNearbyEntities(iSector* sector, const csVector3 &pos, InstanceID instance, float radius, bool doInvisible = false);
279 
288  csArray<gemObject*> FindSectorEntities(iSector* sector, bool doInvisible = false);
289 
290 protected:
296  EID GetNextID();
297 
298  csHash<gemObject*, EID> entities_by_eid;
299  csHash<gemItem*, uint32> items_by_uid;
300  csHash<gemActor*, PID> actors_by_pid;
301 
302  uint32 nextEID;
303 
304 
305  csRef<iEngine> engine;
306 };
307 
308 //-----------------------------------------------------------------------------
309 
314 class gemObject : public iDeleteNotificationObject, public CS::Utility::WeakReferenced, public iScriptableVar
315 {
316 
317 public:
318  virtual ~gemObject();
319 
320  EID GetEID()
321  {
322  return eid;
323  }
324 
328  virtual double GetProperty(MathEnvironment* env, const char* ptr);
330  virtual double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
331  virtual const char* ToString()
332  {
333  return name.GetData();
334  }
336 
340  virtual void Disconnect();
341 
342  virtual bool IsValid(void)
343  {
344  return eid.IsValid();
345  }
346 
350  bool IsAlive() const
351  {
352  return is_alive;
353  }
354 
363  void SetAlive(bool flag, bool queue = true);
364 
365  uint32_t GetClientID();
366 
367  virtual const char* GetObjectType()
368  {
369  return "Object";
370  }
371 
372  gemItem* GetItemPtr();
373  gemActor* GetActorPtr();
374  gemNPC* GetNPCPtr();
375  gemPet* GetPetPtr();
376  gemActionLocation* GetALPtr();
377 
378  psItem* GetItem();
380  {
381  return NULL;
382  }
383 
384  virtual Client* GetClient() const
385  {
386  return NULL;
387  }
388 
389  const char* GetName();
390  void SetName(const char* n);
391 
392  void SetInstance(InstanceID newInstance)
393  {
394  worldInstance = newInstance;
395  }
397  {
398  return worldInstance;
399  }
400 
402  {
403  receivers.Push(receiver);
404  }
406  {
407  receivers.Delete(receiver);
408  }
409 
413 
418  iMeshWrapper* GetMeshWrapper();
419 
423  csString GetMesh()
424  {
425  return factname;
426  }
427 
431  void Move(const csVector3 &pos,float rotangle,iSector* room);
432 
436  bool IsNear(gemObject* obj,float radius, bool ignoreY = false);
437 
441  const csVector3 &GetPosition();
442 
446  void GetPosition(csVector3 &pos, float &yrot,iSector* &sector);
447 
451  void GetPosition(csVector3 &pos, iSector* &sector);
452 
459  float GetAngle();
460 
464  iSector* GetSector();
465 
469  virtual float GetVelocity();
470 
474  const char* GetSectorName()
475  {
476  return GetSector() ? GetSector()->QueryObject()->GetName() : "(null)";
477  }
478 
482  csArray<gemObject*>* GetObjectsInRange(float range);
484 
487 
493  {
494  return proxlist;
495  };
496 
500  csArray<PublishDestination> &GetMulticastClients();
501 
509  void UpdateProxList(bool force = false);
510 
514  void RemoveFromAllProx();
515 
519  void SetAlwaysWatching(bool w)
520  {
521  alwaysWatching = w;
522  }
523 
528  {
529  return alwaysWatching;
530  }
532 
533  float RangeTo(gemObject* obj, bool ignoreY = false, bool ignoreInstance = false);
534 
535  virtual bool IsUpdateReq(csVector3 const &pos,csVector3 const &oldPos);
536 
541  virtual float GetBaseAdvertiseRange()
542  {
543  return DEF_PROX_DIST;
544  };
545 
546  virtual void SendBehaviorMessage(const csString &str, gemObject* obj);
547  virtual csString GetDefaultBehavior(const csString &dfltBehaviors);
548 
554  virtual void Dump();
555 
556 
559 
565  virtual void Broadcast(int clientnum, bool control);
566 
575  virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities* allEntities=NULL)
576  {
577  return true;
578  }
579 
585  virtual void SendGroupMessage(MsgEntry* me) { };
587 
590  virtual PID GetPID()
592  {
593  return 0;
594  }
595  virtual int GetGuildID()
596  {
597  return 0;
598  }
600  {
601  return 0;
602  }
603  virtual bool UpdateDR()
604  {
605  return false;
606  }
607  virtual void BroadcastTargetStatDR(ClientConnectionSet* clients) { }
608  virtual void SendTargetStatDR(Client* client) { }
610  {
611  return 0;
612  }
613  virtual void GetLastSuperclientPos(csVector3 &pos, InstanceID &instance, csTicks &last) const { }
614  virtual void SetLastSuperclientPos(const csVector3 &pos, InstanceID instance, const csTicks &now) { }
615  virtual void AddLootablePlayer(PID playerID) { }
616  virtual void RemoveLootablePlayer(PID playerID) { }
617  virtual bool IsLootablePlayer(PID playerID)
618  {
619  return false;
620  }
621  virtual Client* GetRandomLootClient(int range)
622  {
623  return NULL;
624  }
625  virtual AccountID GetSuperclientID()
626  {
627  return 0;
628  }
629  virtual void SetSuperclientID(AccountID id) { }
630 
631  virtual bool GetVisibility()
632  {
633  return true;
634  }
635  virtual bool SeesObject(gemObject* object, float range)
636  {
637  return false;
638  }
639 
640  virtual gemObject* GetOwner()
641  {
642  return NULL;
643  }
644 
653  virtual bool HasKillStealProtection()
654  {
655  return false;
656  }
658 
659 protected:
660  gemObject(GEMSupervisor* gemsupervisor, EntityManager* entitymanager, CacheManager* cachemanager, const char* name, const char* factname, InstanceID myinstance, iSector* room,
661  const csVector3 &pos, float rotangle, int clientnum);
662 
663  bool valid;
664 
667  csString name;
668  static GEMSupervisor* cel;
672  bool is_alive;
673  csString factname;
674  csString matname;
675  EID eid;
676  csRef<iMeshFactoryWrapper> nullfact;
678 
679  csArray<iDeleteObjectCallback*> receivers;
680 
683 
684  bool InitProximityList(float radius,int clientnum);
685 
686  void InitMesh(const char* name, const csVector3 &pos, const float rotangle, iSector* room);
687 };
688 
689 //-----------------------------------------------------------------------------
690 
695 {
696 public:
697  gemActiveObject(GEMSupervisor* gemSupervisor, EntityManager* entitymanager,CacheManager* cachemanager, const char* name,
698  const char* factname,
699  InstanceID myInstance,
700  iSector* room,
701  const csVector3 &pos,
702  float rotangle,
703  int clientnum);
704 
705  virtual const char* GetObjectType()
706  {
707  return "Active object";
708  }
709 
714  virtual void Broadcast(int clientnum, bool control);
715 
724  virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities* allEntities=NULL)
725  {
726  return true;
727  }
728 
729  virtual void SendBehaviorMessage(const csString &str, gemObject* obj);
730  virtual csString GetDefaultBehavior(const csString &dfltBehaviors);
731 
732  virtual bool IsPickupable()
733  {
734  return false;
735  }
736  virtual bool IsPickupableWeak()
737  {
738  return false;
739  }
740  virtual bool IsPickupableStrong()
741  {
742  return false;
743  }
744  virtual bool IsLockable()
745  {
746  return false;
747  }
748  virtual bool IsLocked()
749  {
750  return false;
751  }
752  virtual bool IsConstructible()
753  {
754  return false;
755  }
756  virtual bool IsSecutityLocked()
757  {
758  return false;
759  }
760  virtual bool IsContainer()
761  {
762  return false;
763  }
764 };
765 
766 //-----------------------------------------------------------------------------
767 
768 class gemItem : public gemActiveObject
769 {
770 protected:
772  csString itemType;
773  float xRot;
774  float yRot;
775  float zRot;
776  uint32_t tribeID;
777 
778 public:
779  gemItem(GEMSupervisor* gemsupervisor,
780  CacheManager* cachemanager,
781  EntityManager* entitymanager,
782  psItem* item,
783  const char* factname,
784  InstanceID myInstance,
785  iSector* room,
786  const csVector3 &pos,
787  float xrotangle,
788  float yrotangle,
789  float zrotangle,
790  int clientnum);
791 
792  virtual ~gemItem()
793  {
794  delete itemdata;
795  }
796 
797  void SetTribeID(uint32_t id)
798  {
799  tribeID = id;
800  }
801  uint32_t GetTribeID()
802  {
803  return tribeID;
804  }
805 
806  virtual const char* GetObjectType()
807  {
808  return itemType.GetData();
809  }
811  {
812  return itemdata;
813  }
815  {
816  itemdata = NULL;
817  }
818 
819 
823  virtual double GetProperty(MathEnvironment* env, const char* ptr);
825  virtual double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
827 
828  virtual float GetBaseAdvertiseRange();
829 
834  virtual void Broadcast(int clientnum, bool control);
835 
844  virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities* allEntities=NULL);
845 
856  virtual void SetPosition(const csVector3 &pos,float angle, iSector* sector, InstanceID instance);
857 
865  virtual void SetRotation(float xrotangle, float yrotangle, float zrotangle);
866 
874  virtual void GetRotation(float &xrotangle, float &yrotangle, float &zrotangle);
875 
881  virtual bool IsPickupable();
882 
891  virtual bool IsPickupableWeak();
892 
900  virtual bool IsPickupableStrong();
901 
902  virtual bool IsLockable();
903  virtual bool IsLocked();
904  virtual bool IsConstructible();
905  virtual bool IsSecurityLocked();
906  virtual bool IsContainer();
907  virtual bool IsUsingCD();
908 
909  virtual bool GetCanTransform();
910  virtual bool GetVisibility();
911 
912  virtual void SendBehaviorMessage(const csString &str, gemObject* obj);
913 
914 private:
923  virtual void SendBehaviorMessageTakeAll(const csString &str, gemObject* obj, bool precise);
924 };
925 
926 //-----------------------------------------------------------------------------
927 
935 class gemContainer : public gemItem
936 {
937 protected:
938  csArray<psItem*> itemlist;
939  bool AddToContainer(psItem* item, Client* fromClient,int slot, bool test);
940 
941 public:
942  gemContainer(GEMSupervisor* gemSupervisor, CacheManager* cachemanager,
943  EntityManager* entitymanager,
944  psItem* item,
945  const char* factname,
946  InstanceID myInstance,
947  iSector* room,
948  const csVector3 &pos,
949  float xrotangle,
950  float yrotangle,
951  float zrotangle,
952  int clientnum);
953 
954  ~gemContainer();
955 
961  void CleareWithoutDelete();
962 
966  bool CanAdd(unsigned short amountToAdd, psItem* item, int slot, csString &reason);
967  bool AddToContainer(psItem* item,Client* fromClient, int slot=-1)
968  {
969  return AddToContainer(item, fromClient, slot, false);
970  }
971  bool RemoveFromContainer(psItem* item,Client* fromClient);
972 
981  bool CanTake(Client* client, psItem* item);
982 
994  psItem* RemoveFromContainer(psItem* itemStack, int fromSlot, Client* fromClient, int stackCount);
995 
996  psItem* FindItemInSlot(int slot, int stackCount = -1);
997  int SlotCount()
998  {
999  return GetItemData()->GetContainerMaxSlots();
1000  }
1001  size_t CountItems()
1002  {
1003  return itemlist.GetSize();
1004  }
1006  {
1007  return itemlist[i];
1008  }
1009 
1010  class psContainerIterator;
1011 
1013  {
1014  size_t current;
1015  gemContainer* container;
1016 
1017  public:
1018 
1019  psContainerIterator(gemContainer* containerItem);
1020  bool HasNext();
1021  psItem* Next();
1022  psItem* RemoveCurrent(Client* fromClient);
1023  void UseContainerItem(gemContainer* containerItem);
1024  };
1025 };
1026 
1027 //-----------------------------------------------------------------------------
1028 
1030 {
1031 private:
1032  psActionLocation* action;
1033  bool visible;
1034 
1035 public:
1036  gemActionLocation(GEMSupervisor* gemSupervisor,EntityManager* entitymanager,CacheManager* cachemanager,
1037  psActionLocation* action, iSector* isec, int clientnum);
1038 
1039  virtual const char* GetObjectType()
1040  {
1041  return "ActionLocation";
1042  }
1044  {
1045  return action;
1046  }
1047 
1048  virtual float GetBaseAdvertiseRange();
1049  virtual bool SeesObject(gemObject* object, float range);
1050 
1055  virtual void Broadcast(int clientnum, bool control);
1056 
1065  virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities* allEntities=NULL);
1066 
1067  virtual void SendBehaviorMessage(const csString &str, gemObject* obj);
1068 
1069  virtual bool GetVisibility()
1070  {
1071  return visible;
1072  };
1073  virtual void SetVisibility(bool vis)
1074  {
1075  visible = vis;
1076  };
1077 };
1078 
1079 //-----------------------------------------------------------------------------
1080 
1088 {
1089 public:
1090  virtual ~AttackerHistory() {}
1091 
1093  {
1094  return attacker_ref;
1095  }
1096  csTicks TimeOfAttack() const
1097  {
1098  return timeOfAttack;
1099  }
1100  virtual float Damage() const = 0; // Always positive.
1101 protected:
1102  AttackerHistory(gemActor* attacker) : attacker_ref(attacker)
1103  {
1104  timeOfAttack = csGetTicks();
1105  }
1106 
1107  csWeakRef<gemActor> attacker_ref;
1108  csTicks timeOfAttack;
1109 };
1110 
1115 {
1116 public:
1117  DamageHistory(gemActor* attacker, float dmg) : AttackerHistory(attacker), damage(dmg)
1118  {
1119  CS_ASSERT(damage > 0);
1120  }
1121  virtual ~DamageHistory() {}
1122  virtual float Damage() const
1123  {
1124  return damage;
1125  }
1126 protected:
1127  float damage;
1128 };
1129 
1134 {
1135 public:
1136  DOTHistory(gemActor* attacker, float hpRate, csTicks duration) : AttackerHistory(attacker), hpRate(hpRate), duration(duration)
1137  {
1138  CS_ASSERT(hpRate < 0);
1139  }
1140  virtual ~DOTHistory() {}
1141  virtual float Damage() const
1142  {
1143  csTicks elapsed = csGetTicks() - timeOfAttack;
1144  return -hpRate * csMin(duration, elapsed);
1145  }
1146 protected:
1147  float hpRate;
1148  csTicks duration;
1149 };
1150 
1151 //-----------------------------------------------------------------------------
1153 {
1154 public:
1155  void Initialize(gemActor* actor)
1156  {
1157  this->actor = actor;
1158  }
1159 
1160 protected:
1162  virtual void OnChange();
1163 };
1164 
1165 //-----------------------------------------------------------------------------
1166 
1171 {
1172 protected:
1174  PID pid;
1175  csRef<PlayerGroup> group;
1176 
1178 
1179  csVector3 top, bottom, offset;
1181 
1182  csWeakRef<Client> clientRef;
1183 
1184  uint8_t attack_cnt;
1185 
1186  uint8_t DRcounter;
1187  uint8_t forceDRcounter;
1188  csTicks lastDR;
1189  csVector3 lastV;
1190 
1193 
1197 
1198  csArray<iDeathCallback*> deathReceivers;
1199 
1200  struct DRstate
1201  {
1202  csVector3 pos;
1203  iSector* sector;
1204  float yrot;
1206  } valid_location;
1207 
1211 
1212  // used by /report command.
1213  // for details on current /report implementation
1214  // check PS#2789.
1215 
1218  {
1220  time_t _time;
1221 
1223  csString _line;
1224 
1226  ChatHistoryEntry(const char* szLine, time_t t = 0);
1227 
1233  void GetLogLine(csString &line) const;
1234  };
1235 
1239  unsigned int activeReports;
1240 
1244  csArray<ChatHistoryEntry> chatHistory;
1245 
1248  csRef<iFile> logging_chat_file;
1249 
1254  bool InitLinMove(const csVector3 &pos,float angle, iSector* sector);
1255  bool InitCharData(Client* c);
1256 
1260 
1261  bool isFalling;
1262  csVector3 fallStartPos;
1263  iSector* fallStartSector;
1264  csTicks fallStartTime;
1265 
1266  bool invincible;
1267  bool visible;
1269 
1270  csWeakRef<gemObject> targetObject;
1271 
1272  csPDelArray<AttackerHistory> dmgHistory;
1273  csPDelArray<ProgressionScript> onAttackScripts, onDefenseScripts, onNearlyDeadScripts, onMovementScripts;
1274 
1275  csArray<ActiveSpell*> activeSpells;
1276 
1277  virtual void ApplyStaminaCalculations(const csVector3 &velocity, float times);
1278 
1280  void SetGMDefaults();
1281 
1282  uint8_t movementMode;
1284  bool atRest;
1286 
1289 
1291  psWorkGameEvent* workEvent;
1293 
1298  iSector* forcedSector;
1299 
1300  bool CanSwitchMode(PSCHARACTER_MODE from, PSCHARACTER_MODE to);
1301 
1306 
1307 public:
1309 
1310  gemActor(GEMSupervisor* gemsupervisor,
1311  CacheManager* cachemanager,
1312  EntityManager* entitymanager,
1313  psCharacter* chardata, const char* factname,
1314  InstanceID myInstance,iSector* room,const csVector3 &pos,float rotangle,int clientnum);
1315 
1316  virtual ~gemActor();
1317 
1318  virtual const char* GetObjectType()
1319  {
1320  return "Actor";
1321  }
1323  {
1324  return psChar;
1325  }
1326  virtual Client* GetClient() const;
1327 
1328  virtual PID GetPID()
1329  {
1330  return pid;
1331  }
1332 
1336  virtual double GetProperty(MathEnvironment* env, const char* ptr);
1338  virtual double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
1340 
1341  bool SetupCharData();
1342 
1343  void SetTextureParts(const char* parts);
1344  void SetEquipment(const char* equip);
1345 
1347  {
1348  return mount;
1349  }
1350 
1351  void SetMount(psCharacter* newMount)
1352  {
1353  mount = newMount;
1354  }
1355 
1356  bool IsMounted()
1357  {
1358  return (mount != NULL);
1359  }
1360 
1361 
1363  {
1364  return player_mode;
1365  }
1366  const char* GetModeStr();
1367  void SetMode(PSCHARACTER_MODE newmode, uint32_t extraData = 0);
1369  {
1370  return combat_stance;
1371  }
1372  virtual void SetCombatStance(const Stance &stance);
1374  {
1375  if(attack_cnt < 2)
1376  {
1377  attack_cnt++;
1378  return true;
1379  }
1380  return false;
1381  }
1382  void EndAttack()
1383  {
1384  CS_ASSERT(attack_cnt);
1385  attack_cnt--;
1386  }
1387  virtual void SetDefaultAttackID(unsigned)
1388  {
1389  }
1390  virtual unsigned GetDefaultAttackID()
1391  {
1392  return 1;
1393  }
1394 
1396  {
1397  spellCasting = event;
1398  }
1400  {
1401  return spellCasting != NULL;
1402  }
1404  {
1405  if(spellCasting) spellCasting->Interrupt();
1406  }
1407 
1412  {
1413  workEvent = event;
1414  }
1415 
1420  {
1421  return workEvent;
1422  }
1423 
1425  {
1426  return isAllowedToMove;
1427  }
1428  void SetAllowedToMove(bool newvalue);
1429 
1431  void SetFrozen(bool flag)
1432  {
1433  isFrozen.SetBase(flag ? 1 : 0);
1434  }
1435  bool IsFrozen()
1436  {
1437  return (isFrozen.Current() > 0);
1438  }
1440  {
1441  return isFrozen;
1442  }
1443 
1447  int GetTargetType(gemObject* target);
1448 
1453  bool IsAllowedToAttack(gemObject* target, csString &msg);
1454 
1455 
1459  void Sit();
1460 
1464  void Stand();
1465 
1469  void SetAllowedToDisconnect(bool allowed);
1470 
1471  void SetSecurityLevel(int level);
1472  void SetMasqueradeLevel(int level);
1474  {
1475  return(securityLevel);
1476  }
1478  {
1479  return(masqueradeLevel);
1480  }
1481 
1482  // Last Production Pos is used to require people to move around while /digging
1483  void SetLastProductionPos(csVector3 &pos)
1484  {
1485  last_production_pos = pos;
1486  }
1487  void GetLastProductionPos(csVector3 &pos)
1488  {
1489  pos = last_production_pos;
1490  }
1491 
1497  const csVector3 &GetProductionStartPos(void) const
1498  {
1499  return productionStartPos;
1500  }
1501 
1507  void SetProductionStartPos(const csVector3 &pos)
1508  {
1509  productionStartPos = pos;
1510  }
1511 
1512  // To be used for the /report command.
1513 
1520  bool AddChatReport(gemActor* reporter);
1521 
1528  void RemoveChatReport();
1529 
1533  bool IsLoggingChat() const
1534  {
1535  return activeReports > 0;
1536  }
1537 
1545  bool LogChatMessage(const char* who, const psChatMessage &msg);
1546 
1553  bool LogSystemMessage(const char* szLine);
1554 
1561  bool LogLine(const char* szLine);
1562 
1567  void UpdateStats();
1568  void ProcessStamina();
1569  void ProcessStamina(const csVector3 &velocity, bool force=false);
1570 
1571  void Teleport(const char* sec, const csVector3 &pos, float yrot, InstanceID instance, int32_t loadDelay = 0, csString background = "", csVector2 point1 = 0, csVector2 point2 = 0, csString widget = "");
1572  void Teleport(iSector* sector, const csVector3 &pos, float yrot, InstanceID instance, int32_t loadDelay = 0, csString background = "", csVector2 point1 = 0, csVector2 point2 = 0, csString widget = "");
1573  void Teleport(iSector* sector, const csVector3 &pos, float yrot, int32_t loadDelay = 0, csString background = "", csVector2 point1 = 0, csVector2 point2 = 0, csString widget = "");
1574 
1575  void SetPosition(const csVector3 &pos,float angle, iSector* sector);
1576  void SetInstance(InstanceID worldInstance);
1577 
1578  void UpdateValidLocation(const csVector3 &pos, float yrot, iSector* sector, InstanceID instance, bool force = false);
1579 
1580  bool SetDRData(psDRMessage &drmsg);
1581  void MulticastDRUpdate();
1582  virtual void ForcePositionUpdate(int32_t loadDelay = 0, csString background = "", csVector2 point1 = 0, csVector2 point2 = 0, csString widget = "");
1583 
1587  {
1588  deathReceivers.Push(receiver);
1589  }
1591  {
1592  deathReceivers.Delete(receiver);
1593  }
1594  void HandleDeath();
1595 
1596  float GetRelativeFaction(gemActor* speaker);
1597 
1598  csPtr<PlayerGroup> GetGroup();
1599  void SetGroup(PlayerGroup* group);
1600  bool InGroup() const;
1601  bool IsGroupedWith(gemActor* other, bool IncludePets = false) const;
1602  int GetGroupID();
1603  void RemoveFromGroup();
1604 
1605  bool IsMyPet(gemActor* other) const;
1606 
1607  const char* GetFirstName()
1608  {
1609  return psChar->GetCharName();
1610  }
1611 
1612  const char* GetGuildName();
1614  {
1615  return psChar->GetGuild();
1616  }
1618  {
1619  return psChar->GetGuildLevel();
1620  }
1621 
1628  {
1629  return psChar->GetGuildMembership();
1630  }
1631 
1632  void DoDamage(gemActor* attacker, float damage);
1633  void AddAttackerHistory(gemActor* attacker, float damage); // direct damage version
1634  void AddAttackerHistory(gemActor* attacker, float hpRate, csTicks duration); // DoT version
1635  void RemoveAttackerHistory(gemActor* attacker);
1636  bool CanBeAttackedBy(gemActor* attacker, gemActor* &lastAttacker) const;
1637 
1647  virtual bool HasBeenAttackedBy(gemActor* attacker);
1648 
1649  void Kill(gemActor* attacker)
1650  {
1651  DoDamage(attacker, psChar->GetHP());
1652  }
1653  void Defeat();
1654  void Resurrect();
1655 
1656  virtual bool UpdateDR();
1657  virtual void GetLastSuperclientPos(csVector3 &pos, InstanceID &instance, csTicks &last) const;
1658  virtual void SetLastSuperclientPos(const csVector3 &pos, InstanceID instance, const csTicks &now);
1659 
1660  // Sends statDR to all clients that have this client targeted
1661  virtual void BroadcastTargetStatDR(ClientConnectionSet* clients);
1662 
1663  // Sends this actor statDR to the client specified, who has this actor as a target
1664  virtual void SendTargetStatDR(Client* client);
1665 
1666  // Sends statDR to the client owning this actor, and to all clients that have this client targeted
1667  virtual void SendGroupStats();
1668 
1669  void SetAction(const char* anim,csTicks &timeDelay);
1670 
1671  virtual void Broadcast(int clientnum, bool control);
1672 
1681  virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities* allEntities=NULL);
1682 
1688  virtual void SendGroupMessage(MsgEntry* me);
1689 
1693  gemObject* FindNearbyActorName(const char* name);
1694 
1695  virtual void SendBehaviorMessage(const csString &str, gemObject* obj);
1696  virtual csString GetDefaultBehavior(const csString &dfltBehaviors);
1697 
1704  void FallBegan(const csVector3 &pos, iSector* sector);
1705 
1709  float FallEnded(const csVector3 &pos, iSector* sector);
1710 
1714  bool IsFalling()
1715  {
1716  return isFalling;
1717  }
1718 
1720  {
1721  return fallStartTime;
1722  }
1723 
1724  bool AtRest() const
1725  {
1726  return atRest;
1727  }
1728 
1729  virtual bool GetVisibility()
1730  {
1731  return visible;
1732  }
1733  virtual void SetVisibility(bool visible);
1734  virtual bool SeesObject(gemObject* object, float range);
1735 
1736  virtual bool GetInvincibility()
1737  {
1738  return invincible;
1739  }
1740  virtual void SetInvincibility(bool invincible);
1741 
1746  {
1747  return viewAllObjects;
1748  }
1749  void SetViewAllObjects(bool v);
1750 
1751  void StopMoving(bool worldVel = false);
1752 
1763  bool MoveToSpawnPos(int32_t delay = 0, csString background = "", csVector2 point1 = 0, csVector2 point2 = 0, csString widget = "");
1764 
1776  bool GetSpawnPos(csVector3 &pos, float &yrot, iSector* &sector, bool useRange = false);
1777 
1783  bool MoveToValidPos(bool force = false);
1784 
1785  void GetValidPos(csVector3 &pos, float &yrot, iSector* &sector, InstanceID &instance);
1786 
1790  void GetLastLocation(csVector3 &pos, float &yrot, iSector* &sector, InstanceID &instance);
1791 
1795  void MoveToLastPos();
1796 
1798  void SetPrevTeleportLocation(const csVector3 &pos, float yrot, iSector* sector, InstanceID instance);
1800  void GetPrevTeleportLocation(csVector3 &pos, float &yrot, iSector* &sector, InstanceID &instance);
1801 
1803  {
1804  return dmgHistory.Get(pos);
1805  }
1806  size_t GetDamageHistoryCount() const
1807  {
1808  return dmgHistory.GetSize();
1809  }
1811  {
1812  dmgHistory.Empty();
1813  }
1814 
1815  void AttachScript(ProgressionScript* script, int type);
1816  void DetachScript(ProgressionScript* script, int type);
1817  void InvokeAttackScripts(gemActor* defender, psItem* weapon);
1818  void InvokeDefenseScripts(gemActor* attacker, psItem* weapon);
1819  void InvokeNearlyDeadScripts(gemActor* defender, psItem* weapon);
1820  void InvokeMovementScripts();
1821 
1822  void AddActiveSpell(ActiveSpell* asp);
1823  void SendActiveSpells();
1824  bool RemoveActiveSpell(ActiveSpell* asp);
1825  ActiveSpell* FindActiveSpell(const csString &name, SPELL_TYPE type);
1826  int ActiveSpellCount(const csString &name);
1827  csArray<ActiveSpell*> &GetActiveSpells()
1828  {
1829  return activeSpells;
1830  }
1831  void CancelActiveSpellsForDeath();
1832  void CancelActiveSpellsWhichDamage();
1833  int FindAnimIndex(const char* name);
1834 
1835 
1844  void SetDefaults(bool player);
1845 
1846 
1850 
1852  bool nevertired;
1855  bool safefall;
1858  bool attackable;
1859 
1864  bool SetMesh(const char* meshname);
1865 
1867  {
1868  return GetCharacterData()->Inventory().GetDoRestrictions();
1869  }
1870  void SetFiniteInventory(bool v)
1871  {
1872  GetCharacterData()->Inventory().SetDoRestrictions(v);
1873  }
1874 
1875  // Target information
1877  {
1878  targetObject = object;
1879  }
1881  {
1882  return targetObject;
1883  }
1884 
1888  virtual float GetVelocity();
1889 
1895  virtual bool InsideGuardedArea(gemObject* object);
1896 
1901  {
1902  activeMagic_seq++;
1903  return activeMagic_seq;
1904  }
1905 };
1906 
1907 //-----------------------------------------------------------------------------
1908 class NpcDialogMenu;
1909 
1910 class gemNPC : public gemActor
1911 {
1912 protected:
1914  AccountID superClientID;
1915  csWeakRef<gemObject> target;
1916  csWeakRef<gemObject> owner;
1917 
1921 
1923  csArray<PID> lootablePlayers;
1924 
1926  {
1927  csString said;
1928  csString trigger;
1929  int count;
1930  csTicks when;
1931  static int Compare(DialogCounter* const &first, DialogCounter* const &second)
1932  {
1933  if(first->count != second->count)
1934  return first->count - second->count;
1935  return first->when - second->when;
1936 // if (first.count != second.count)
1937 // return first.count - second.count;
1938 // return first.when - second.when;
1939  }
1940  };
1941 
1942  csPDelArray<DialogCounter> badText;
1943 
1944  unsigned default_attackid;
1945 
1947 
1948  bool busy;
1949 
1950 public:
1951  gemNPC(GEMSupervisor* gemSupervisor,
1952  CacheManager* cachemanager,
1953  EntityManager* entityManager,
1954  psCharacter* chardata, const char* factname,
1955  InstanceID myInstance,iSector* room,const csVector3 &pos,float rotangle,int clientnum);
1956 
1957  virtual ~gemNPC();
1958 
1959  virtual void SetCombatStance(const Stance &stance);
1960  virtual void SetDefaultAttackID(unsigned id)
1961  {
1962  default_attackid = id;
1963  }
1964  virtual unsigned GetDefaultAttackID()
1965  {
1966  return default_attackid;
1967  }
1968 
1969  virtual const char* GetObjectType()
1970  {
1971  return "NPC";
1972  }
1974  {
1975  return npcdialog;
1976  }
1977 
1978  virtual AccountID GetSuperclientID()
1979  {
1980  return superClientID;
1981  }
1982  virtual void SetSuperclientID(AccountID id)
1983  {
1984  superClientID = id;
1985  }
1986 
1987  void SetupDialog(PID npcID, PID masterNpcID, bool force=false);
1988  void ReactToPlayerApproach(psNPCCommandsMessage::PerceptionType type, gemActor* player);
1989 
1990  virtual void ApplyStaminaCalculations(const csVector3 &velocity, float times) { } // NPCs usually have 0 stamina.
1991  // Before this fix, this caused a major long term bug where NPCs would give up attacking after a few hits and expending all stamina.
1992 
1993  virtual void AddLootablePlayer(PID playerID);
1994  virtual void RemoveLootablePlayer(PID playerID);
1995  bool IsLootablePlayer(PID playerID);
1996  const csArray<PID> &GetLootablePlayers() const
1997  {
1998  return lootablePlayers;
1999  }
2000  virtual Client* GetRandomLootClient(int range);
2001 
2013  void Say(const char* sayText, Client* who, bool sayPublic, csTicks &timeDelay);
2014 
2030  void ActionCommand(bool actionMy, bool actionNarrate, const char* actText, Client* who, bool actionPublic, csTicks &timeDelay);
2031 
2032  void AddBadText(const char* playerSaid,const char* trigger);
2033  void GetBadText(size_t first,size_t last, csStringArray &saidArray, csStringArray &trigArray);
2034 
2043  virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities* allEntities=NULL);
2044 
2049  virtual void Broadcast(int clientnum, bool control);
2050 
2051  virtual void SendBehaviorMessage(const csString &str, gemObject* obj);
2052  virtual csString GetDefaultBehavior(const csString &dfltBehaviors);
2053  void ShowPopupMenu(Client* client);
2054 
2055  virtual void SetTarget(gemObject* newTarget)
2056  {
2057  target = newTarget;
2058  }
2060  {
2061  return this->target;
2062  }
2063 
2064  virtual void SetOwner(gemObject* owner);
2065 
2066  virtual gemObject* GetOwner()
2067  {
2068  return this->owner;
2069  }
2070 
2071  virtual void SetPosition(const csVector3 &pos, float angle, iSector* sector);
2072 
2073 
2082  virtual bool HasKillStealProtection()
2083  {
2084  return !GetCharacterData()->IsPet();
2085  }
2086 
2087  virtual void SendGroupStats();
2088  virtual void ForcePositionUpdate();
2089 
2093  void RegisterSpeaker(Client* client);
2094 
2098  void CheckSpeakers();
2099 
2106  void SetBusy(bool busy);
2107 
2114  bool IsBusy() const;
2115 };
2116 
2117 //-----------------------------------------------------------------------------
2118 
2119 class gemPet : public gemNPC
2120 {
2121 public:
2122 
2123  gemPet(GEMSupervisor* gemsupervisor,
2124  CacheManager* cachemanager,
2125  EntityManager* entitymanager,
2126  psCharacter* chardata, const char* factname, InstanceID instance, iSector* room,
2127  const csVector3 &pos,float rotangle,int clientnum,uint32 id) : gemNPC(gemsupervisor, cachemanager, entitymanager, chardata,factname,instance,room,pos,rotangle,clientnum)
2128  {
2129  this->persistanceLevel = "Temporary";
2130  };
2131 
2132  virtual const char* GetObjectType()
2133  {
2134  return "PET";
2135  }
2136 
2137 
2138  void SetPersistanceLevel(const char* level)
2139  {
2140  this->persistanceLevel = level;
2141  };
2142  const char* SetPersistanceLevel(void)
2143  {
2144  return persistanceLevel.GetData();
2145  };
2146  bool IsFamiliar(void)
2147  {
2148  return this->persistanceLevel.CompareNoCase("Permanent");
2149  };
2150 
2151 private:
2152  csString persistanceLevel;
2153 };
2154 
2155 //-----------------------------------------------------------------------------
2156 
2165 {
2166 public:
2167  csWeakRef<gemObject> dependency;
2168 
2169  psGEMEvent(csTicks ticks,int offsetticks,gemObject* depends, const char* newType)
2170  : psGameEvent(ticks,offsetticks,newType)
2171  {
2172  dependency = NULL;
2173 
2174  // Register for disconnect events
2175  if(depends)
2176  {
2177  dependency = depends;
2178  depends->RegisterCallback(this);
2179  }
2180  }
2181 
2182  virtual ~psGEMEvent()
2183  {
2184  // If DeleteObjectCallback() has not been called normal operation
2185  // this object have to unregister to prevent the
2186  // object from calling DeleteObjectCallback() later when destroyed.
2187  if(dependency.IsValid())
2188  {
2189  dependency->UnregisterCallback(this);
2190  dependency = NULL;
2191  }
2192  }
2193 
2195  {
2196  SetValid(false); // Prevent the Trigger from beeing called.
2197 
2198  if(dependency.IsValid())
2199  {
2200  dependency->UnregisterCallback(this);
2201  dependency = NULL;
2202  }
2203  }
2204 };
2205 
2206 //-----------------------------------------------------------------------------
2207 
2208 class psResurrectEvent : public psGameEvent // psGEMEvent
2209 {
2210 protected:
2211  csWeakRef<gemObject> who;
2212 
2213 public:
2214  psResurrectEvent(csTicks ticks,int offsetticks,gemActor* actor)
2215  : psGameEvent(ticks,offsetticks,"psResurrectEvent")
2216  {
2217  who = actor;
2218  }
2219 
2220  void Trigger()
2221  {
2222  if(who.IsValid())
2223  {
2224  gemActor* actor = dynamic_cast<gemActor*>((gemObject*) who);
2225  actor->Resurrect();
2226  }
2227  }
2228 };
2229 
2232 #endif
bool GetViewAllObjects()
Flag to determine of this player can see all objects.
Definition: gem.h:1745
bool nevertired
These flags are for GM/debug abilities.
Definition: gem.h:1852
psLinearMovement * pcmove
Definition: gem.h:1308
uint32_t tribeID
Holds the id of the tribe owning this item (0 if is not tribe-owned)
Definition: gem.h:776
bool atRest
Is this character stationary or moving?
Definition: gem.h:1284
bool questtester
no quest lockouts
Definition: gem.h:1856
uint8_t movementMode
Actor movement mode from DB table movement_modes.
Definition: gem.h:1282
float GetHP()
DRstate newvalid_location
Definition: gem.h:1208
uint8_t attack_cnt
Count of attack events in CS event queue.
Definition: gem.h:1184
uint32 InstanceID
Definition: psconst.h:64
bool GetFiniteInventory()
Definition: gem.h:1866
void SetInstance(InstanceID newInstance)
Definition: gem.h:392
csPDelArray< ProgressionScript > onNearlyDeadScripts
Definition: gem.h:1273
Manages CEL entities on the server.
Definition: entitymanager.h:77
csTicks nextLongRangeAvail
When can npc respond to long range prox trigger again.
Definition: gem.h:1920
csArray< ActiveSpell * > activeSpells
Definition: gem.h:1275
float zRot
Definition: gem.h:775
time_t _time
Info: Time this line was said.
Definition: gem.h:1220
bool IsFrozen()
Definition: gem.h:1435
virtual const char * GetObjectType()
Definition: gem.h:705
bool IsAllowedToMove()
Definition: gem.h:1424
gemActor * Attacker() const
Definition: gem.h:1092
csArray< psItem * > itemlist
Definition: gem.h:938
bool viewAllObjects
can view invisible objects?
Definition: gem.h:1268
ProgressionScript is the imperative script container.
Definition: scripting.h:78
iObjectRegistry * object_reg
The Crystal Space Object Registry.
Definition: gem.h:131
int SlotCount()
Definition: gem.h:997
void Resurrect()
PSCHARACTER_MODE player_mode
Definition: gem.h:1287
gemActor * actor
Definition: gem.h:1161
const char * GetFirstName()
Definition: gem.h:1607
void SetAlwaysWatching(bool w)
Definition: gem.h:519
bool StartAttack()
Definition: gem.h:1373
void GetLastProductionPos(csVector3 &pos)
Definition: gem.h:1487
csTicks nextVeryShortRangeAvail
When can npc respond to very short range prox trigger again.
Definition: gem.h:1918
virtual float Damage() const
Definition: gem.h:1141
#define DEF_PROX_DIST
100m is trial distance here
Definition: psconst.h:47
csArray< iDeleteObjectCallback * > receivers
List of objects which are to be notified when this object is deleted.
Definition: gem.h:679
virtual bool GetInvincibility()
Definition: gem.h:1736
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
psWorkGameEvent * GetTradeWork()
Return trade work event so it can be stopped.
Definition: gem.h:1419
void EndAttack()
Definition: gem.h:1382
A MathScript is a mini-program to run.
Definition: mathscript.h:442
const char * GetSectorName()
Definition: gem.h:474
virtual psActionLocation * GetAction()
Definition: gem.h:1043
PSCHARACTER_MODE
Definition: pscharacter.h:119
bool alwaysWatching
True if this object always watches (proxlists) regardless of owner.
Definition: gem.h:677
psGuildInfo * GetGuild()
Definition: gem.h:1613
float damage
Definition: gem.h:1127
virtual const char * GetObjectType()
Definition: gem.h:367
csVector3 fallStartPos
the position where the fall began
Definition: gem.h:1262
void ClearDamageHistory()
Definition: gem.h:1810
virtual bool IsLootablePlayer(PID playerID)
Definition: gem.h:617
virtual void SetLastSuperclientPos(const csVector3 &pos, InstanceID instance, const csTicks &now)
Definition: gem.h:614
csString GetMesh()
Definition: gem.h:423
uint32 nextEID
The next ID available for an object.
Definition: gem.h:302
const char * GetName(int id)
The message sent from server to superclient every 2.5 seconds.
Definition: npcmessages.h:306
int masqueradeLevel
Definition: gem.h:1259
Holds data for a guild.
Definition: psguildinfo.h:159
virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities *allEntities=NULL)
Send this object to the given client.
Definition: gem.h:575
void SetTradeWork(psWorkGameEvent *event)
Assign trade work event so it can be accessed.
Definition: gem.h:1411
A special form of buffable that is clamped to always return a positive number.
Definition: buffable.h:278
virtual ~psGEMEvent()
Definition: gem.h:2182
float prox_distance_desired
What is the maximum range of proxlist we want.
Definition: gem.h:681
void SetFrozen(bool flag)
Check whether the actor is frozen.
Definition: gem.h:1431
virtual unsigned GetDefaultAttackID()
Definition: gem.h:1390
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
csArray< ActiveSpell * > & GetActiveSpells()
Definition: gem.h:1827
work event class
Definition: workmanager.h:708
AccountID superClientID
Definition: gem.h:1914
CacheManager * cacheManager
Definition: gem.h:670
psCharacter * mount
Definition: gem.h:1177
csRef< iEngine > engine
Stored here to save expensive csQueryRegistry calls.
Definition: gem.h:305
csWeakRef< gemObject > targetObject
Is the current targeted object for this actor.
Definition: gem.h:1270
void Initialize(gemActor *actor)
Definition: gem.h:1155
void SetMount(psCharacter *newMount)
Definition: gem.h:1351
csVector3 top
Definition: gem.h:1179
void ClearItemData()
Definition: gem.h:814
psResurrectEvent(csTicks ticks, int offsetticks, gemActor *actor)
Definition: gem.h:2214
PID pid
Player ID (also known as character ID or PID)
Definition: gem.h:1174
bool AtRest() const
Definition: gem.h:1724
csRef< iFile > logging_chat_file
csRef<iFile> logging_chat_file Info: log file handle.
Definition: gem.h:1248
virtual void SetSuperclientID(AccountID id)
Definition: gem.h:629
csVector3 pos
Definition: gem.h:1202
bool isAllowedToMove
Is a movement lockout in effect?
Definition: gem.h:1283
virtual void RemoveLootablePlayer(PID playerID)
Definition: gem.h:616
Manages character details over the net.
Definition: psserverchar.h:58
EID eid
Entity ID (unique identifier for object)
Definition: gem.h:675
virtual Client * GetClient() const
Definition: gem.h:384
bool IsAlive() const
Returns whether the object is alive.
Definition: gem.h:350
virtual Client * GetRandomLootClient(int range)
Definition: gem.h:621
InstanceID worldInstance
Only objects which match instances can see each other.
Definition: gem.h:671
virtual bool IsContainer()
Definition: gem.h:760
psNPCDialog * npcdialog
Definition: gem.h:1913
virtual psNPCDialog * GetNPCDialogPtr()
Definition: gem.h:1973
PSCHARACTER_MODE GetMode()
Definition: gem.h:1362
const csArray< PID > & GetLootablePlayers() const
Definition: gem.h:1996
Movement related class.
Definition: linmove.h:68
csWeakRef< Client > clientRef
Definition: gem.h:1182
virtual bool GetVisibility()
Definition: gem.h:1069
psDatabase * database
The main PlaneShift database object.
Definition: gem.h:132
Defines a level inside a guild.
Definition: psguildinfo.h:99
ProximityList * GetProxList()
Definition: gem.h:492
virtual unsigned GetDefaultAttackID()
Definition: gem.h:1964
float hpRate
Definition: gem.h:1147
bool invincible
cannot be attacked
Definition: gem.h:1266
bool IsFalling()
Checks if the object is falling.
Definition: gem.h:1714
csWeakRef< gemObject > target
Definition: gem.h:1915
float yrot
Definition: gem.h:1204
gemPet(GEMSupervisor *gemsupervisor, CacheManager *cachemanager, EntityManager *entitymanager, psCharacter *chardata, const char *factname, InstanceID instance, iSector *room, const csVector3 &pos, float rotangle, int clientnum, uint32 id)
Definition: gem.h:2123
Defines a guild member in a guild.
Definition: psguildinfo.h:124
Definition: gem.h:2119
bool IsMounted()
Definition: gem.h:1356
virtual bool IsPickupable()
Definition: gem.h:732
csWeakRef< gemActor > attacker_ref
Definition: gem.h:1107
virtual const char * GetObjectType()
Definition: gem.h:806
void InterruptSpellCasting()
Definition: gem.h:1403
virtual bool IsValid(void)
Definition: gem.h:342
virtual ~AttackerHistory()
Definition: gem.h:1090
csRef< iMeshFactoryWrapper > nullfact
Null factory for our mesh instances.
Definition: gem.h:676
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
csString itemType
Definition: gem.h:772
virtual void AddLootablePlayer(PID playerID)
Definition: gem.h:615
virtual psGuildInfo * GetGuild()
Definition: gem.h:599
static GEMSupervisor * cel
Static ptr back to main collection of all objects.
Definition: gem.h:668
InstanceID instance
Definition: gem.h:1205
iDataConnection * db
Global connection to the Database. Set from the psDatabase class.
uint32_t activeMagic_seq
active magic message seq
Definition: gem.h:1305
size_t GetDamageHistoryCount() const
Definition: gem.h:1806
csTicks nextShortRangeAvail
When can npc respond to short range prox trigger again.
Definition: gem.h:1919
Info: Stores a chat history element.
Definition: gem.h:1217
bool instantcast
cast spells instantly
Definition: gem.h:1854
virtual bool IsPickupableWeak()
Definition: gem.h:736
void RegisterCallback(iDeleteObjectCallback *receiver)
Definition: gem.h:401
virtual bool HasKillStealProtection()
Returns if the npc has killsteal protection.
Definition: gem.h:2082
csString trigger
Definition: gem.h:1928
csString said
Definition: gem.h:1927
unsigned int lastSentSuperclientInstance
Definition: gem.h:1195
bool IsLoggingChat() const
Returns /report file logging status.
Definition: gem.h:1533
gemMesh * pcmesh
link to mesh class
Definition: gem.h:665
void SetSpellCasting(psSpellCastGameEvent *event)
Definition: gem.h:1395
psItem * GetIndexItem(size_t i)
Definition: gem.h:1005
csPDelArray< DialogCounter > badText
Definition: gem.h:1942
gemObject * GetTargetObject() const
Definition: gem.h:1880
This event actually triggers a spell, after the casting wait time.
Definition: psspell.h:202
virtual void GetLastSuperclientPos(csVector3 &pos, InstanceID &instance, csTicks &last) const
Definition: gem.h:613
bool IsFamiliar(void)
Definition: gem.h:2146
gemContainers are the public containers in the world for crafting, like forges or ovens...
Definition: gem.h:935
NPCManager * npcmanager
NPC controller.
Definition: gem.h:133
psGEMEvent(csTicks ticks, int offsetticks, gemObject *depends, const char *newType)
Definition: gem.h:2169
int GetSecurityLevel()
Definition: gem.h:1473
virtual bool IsSecutityLocked()
Definition: gem.h:756
bool AddToContainer(psItem *item, Client *fromClient, int slot=-1)
Definition: gem.h:967
void SetBase(T x)
Definition: buffable.h:172
iSector * sector
Definition: gem.h:1203
static int Compare(DialogCounter *const &first, DialogCounter *const &second)
Definition: gem.h:1931
csWeakRef< gemObject > who
Definition: gem.h:2211
psGuildInfo * GetGuild()
Return the active guild, if any for this character.
Definition: pscharacter.h:739
csTicks fallStartTime
Definition: gem.h:1264
An existing group.
Definition: playergroup.h:36
void SetFiniteInventory(bool v)
Definition: gem.h:1870
virtual void DeleteObjectCallback(iDeleteNotificationObject *object)
Definition: gem.h:2194
virtual ~DOTHistory()
Definition: gem.h:1140
unsigned default_attackid
Default attack type ID.
Definition: gem.h:1944
virtual void SetTarget(gemObject *newTarget)
Definition: gem.h:2055
virtual psCharacter * GetCharacterData()
Definition: gem.h:379
csTicks lastSentSuperclientTick
Definition: gem.h:1196
virtual gemObject * GetOwner()
Definition: gem.h:2066
virtual const char * GetObjectType()
Definition: gem.h:1039
int GetMasqueradeLevel()
Definition: gem.h:1477
This class automatically implements timed events which depend on the existence and validity of a gemO...
Definition: gem.h:2164
void SetTribeID(uint32_t id)
Definition: gem.h:797
virtual void SetVisibility(bool vis)
Definition: gem.h:1073
float xRot
Definition: gem.h:773
InstanceID GetInstance()
Definition: gem.h:396
float yRot
Definition: gem.h:774
csVector3 productionStartPos
Production Start Pos is used to record the place where people started digging.
Definition: gem.h:1192
bool AlwaysWatching()
Definition: gem.h:527
virtual void SendTargetStatDR(Client *client)
Definition: gem.h:608
psGuildMember * GetGuildMembership()
Gets the psguildmember structure refereed to this actor, if in a guild.
Definition: gem.h:1627
virtual void SetSuperclientID(AccountID id)
Definition: gem.h:1982
csVector3 last_production_pos
Definition: gem.h:1180
This class collects data of a netclient.
Definition: client.h:95
Any PS Object with which a player may have interaction (i.e.
Definition: gem.h:694
psGemServerMeshAttach(gemObject *object)
Setup this helper with the object we want to attach with.
void RegisterCallback(iDeathCallback *receiver)
Definition: gem.h:1586
bool givekillexp
give exp if killed
Definition: gem.h:1857
virtual bool Send(int clientnum, bool control, bool to_superclients, psPersistAllEntities *allEntities=NULL)
Send this object to the given client.
Definition: gem.h:724
A record in a gemActor&#39;s attacker history.
Definition: gem.h:1087
void UnregisterCallback(iDeleteObjectCallback *receiver)
Definition: gem.h:405
virtual gemObject * GetTarget()
Definition: gem.h:2059
csString _line
Info: Actual text. (Preformated depending on chat type)
Definition: gem.h:1223
bool busy
Indicator from the NPC client to state the if the NPC is busy.
Definition: gem.h:1948
Definition: gem.h:1910
const char * SetPersistanceLevel(void)
Definition: gem.h:2142
ActiveSpells.
Definition: activespell.h:68
csHash< gemObject *, EID > & GetAllGEMS()
Get a hash of all the current entities on the server.
Definition: gem.h:157
void UnregisterCallback(iDeathCallback *receiver)
Definition: gem.h:1590
csString factname
Name of CS Mesh Factory used to create this object.
Definition: gem.h:673
virtual gemObject * GetOwner()
Definition: gem.h:640
virtual bool IsLocked()
Definition: gem.h:748
virtual psNPCDialog * GetNPCDialogPtr()
Definition: gem.h:609
virtual bool GetVisibility()
Definition: gem.h:1729
gemObject * GetObject()
Get the gemObject that the mesh has attached.
Definition: gem.h:114
const Stance & GetCombatStance()
Definition: gem.h:1368
csHash< gemActor *, PID > actors_by_pid
A list of all the actors stored by PID (player/character ID).
Definition: gem.h:300
bool safefall
no fall damage
Definition: gem.h:1855
void SetLastProductionPos(csVector3 &pos)
Definition: gem.h:1483
virtual float GetBaseAdvertiseRange()
This value indicates the range that this entity would become visible to other entities if no other mo...
Definition: gem.h:541
This class exists per NPC, and holds all dialog triggers, responses and scripts for this particular N...
Definition: psnpcdialog.h:151
csTicks timeOfAttack
Definition: gem.h:1108
virtual const char * GetObjectType()
Definition: gem.h:1969
virtual AccountID GetSuperclientID()
Definition: gem.h:1978
iSector * fallStartSector
the sector where the fall began
Definition: gem.h:1263
virtual bool SeesObject(gemObject *object, float range)
Definition: gem.h:635
virtual float Damage() const
Definition: gem.h:1122
bool is_alive
Flag indicating whether object is alive or not.
Definition: gem.h:672
Holds the trigger menu, if it exists, for a given location in a dialog.
Definition: dictionary.h:325
iSector * forcedSector
Needed to force the effect of a psForcePositionMessage since sectors are tied to instances and force ...
Definition: gem.h:1298
void SetProductionStartPos(const csVector3 &pos)
Sets the place where the player started digging.
Definition: gem.h:1507
virtual void SetDefaultAttackID(unsigned)
Definition: gem.h:1387
unsigned int activeReports
unsigned int activeReports Info: Total /report commands filed against this player that are still acti...
Definition: gem.h:1239
virtual bool IsPickupableStrong()
Definition: gem.h:740
FrozenBuffable & GetBuffableFrozen()
Definition: gem.h:1439
SCF_INTERFACE(psGemServerMeshAttach, 0, 0, 1)
float prox_distance_current
What is the current actual range for proxlists (they adjust when the # of objects gets too high) ...
Definition: gem.h:682
uint32_t GetTribeID()
Definition: gem.h:801
void Kill(gemActor *attacker)
Definition: gem.h:1649
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
csWeakRef< gemObject > dependency
Definition: gem.h:2167
virtual bool GetVisibility()
Definition: gem.h:631
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
int securityLevel
What commands the actor can access. Normally only for a player controlled object. ...
Definition: gem.h:1258
virtual psCharacter * GetCharacterData()
Definition: gem.h:1322
csTicks lastDR
Definition: gem.h:1188
virtual ~DamageHistory()
Definition: gem.h:1121
bool infinitemana
infinite mana
Definition: gem.h:1853
FrozenBuffable isFrozen
Whether the actor is frozen or not.
Definition: gem.h:1285
psGuildLevel * GetGuildLevel()
Return the guild level for this character, if any.
csTicks TimeOfAttack() const
Definition: gem.h:1096
This class holds the refs to the core factories, etc in CEL.
Definition: gem.h:126
This class stores all the properties of an action location Entrance, return location, name, response type, trigger.
csString name
Name of this object, used mostly for debugging.
Definition: gem.h:667
void SetPersistanceLevel(const char *level)
Definition: gem.h:2138
EntityManager * entityManager
Definition: gem.h:669
virtual ~gemItem()
Definition: gem.h:792
Message sent with chat info.
Definition: messages.h:808
SPELL_TYPE
Definition: psconst.h:126
virtual const char * GetObjectType()
Definition: gem.h:1318
Helper class to attach a PlaneShift gem object to a particular mesh.
Definition: gem.h:97
EID GetEID()
Definition: gem.h:320
An AttackerHistory entry for a regular, one-time damaging attack.
Definition: gem.h:1114
void SetTargetObject(gemObject *object)
Definition: gem.h:1876
virtual int GetGuildID()
Definition: gem.h:595
void Trigger()
Abstract event processing function.
Definition: gem.h:2220
csTicks GetFallStartTime()
Definition: gem.h:1719
csVector3 lastSentSuperclientPos
Definition: gem.h:1194
virtual void SendGroupMessage(MsgEntry *me)
Distribute this object to all members of a group.
Definition: gem.h:585
This class is a list of several CLient objects, it&#39;s designed for finding clients very fast based on ...
Definition: clients.h:58
csTicks duration
Definition: gem.h:1148
psGuildLevel * GetGuildLevel()
Definition: gem.h:1617
psCharacter * GetMount() const
Definition: gem.h:1346
virtual void BroadcastTargetStatDR(ClientConnectionSet *clients)
Definition: gem.h:607
uint8_t DRcounter
increments in loop to prevent out of order packet overwrites of better data
Definition: gem.h:1186
bool isFalling
is this object falling down ?
Definition: gem.h:1261
virtual bool IsLockable()
Definition: gem.h:744
psGuildMember * GetGuildMembership()
Return the guild membership for this character, if any.
AttackerHistory(gemActor *attacker)
Definition: gem.h:1102
virtual void ApplyStaminaCalculations(const csVector3 &velocity, float times)
Definition: gem.h:1990
virtual bool HasKillStealProtection()
Returns if the object has killsteal protection.
Definition: gem.h:653
csArray< PID > lootablePlayers
Array of client id&#39;s allowed to loot this char.
Definition: gem.h:1923
DRstate last_location
Definition: gem.h:1209
DOTHistory(gemActor *attacker, float hpRate, csTicks duration)
Definition: gem.h:1136
csString matname
Name of base material used by this object.
Definition: gem.h:674
csVector3 lastV
Definition: gem.h:1189
psItem * itemdata
Definition: gem.h:771
An AttackerHistory entry for a DOT (damage over time) attack.
Definition: gem.h:1133
All scheduled events must inherit from this class.
Definition: gameevent.h:36
virtual const char * ToString()
Definition: gem.h:331
This is a helper class that defines a mesh on the server.
Definition: gemmesh.h:56
const char * GetCharName() const
Definition: pscharacter.h:860
csHash< gemItem *, uint32 > items_by_uid
A list of all the items stored by UID (psItem ID).
Definition: gem.h:299
bool visible
is visible to clients ?
Definition: gem.h:1267
DamageHistory(gemActor *attacker, float dmg)
Definition: gem.h:1117
This class generically allows objects to be notified when a gemObject is removed. ...
ProximityList * proxlist
Proximity List for this object.
Definition: gem.h:666
Definition: gem.h:768
csRef< PlayerGroup > group
Definition: gem.h:1175
int speakers
Definition: gem.h:1946
size_t CountItems()
Definition: gem.h:1001
DRstate prev_teleport_location
Definition: gem.h:1210
csArray< iDeathCallback * > deathReceivers
List of objects which are to be notified when this actor dies.
Definition: gem.h:1198
uint32_t GetActiveMagicSequence()
Get the activeMagic sequence, updating to the next value;.
Definition: gem.h:1900
virtual void SetDefaultAttackID(unsigned id)
Definition: gem.h:1960
csHash< gemObject *, EID > entities_by_eid
A list of all the entities stored by EID (entity/gem ID).
Definition: gem.h:298
Stance combat_stance
Definition: gem.h:1288
AttackerHistory * GetDamageHistory(int pos) const
Definition: gem.h:1802
psCharacter * psChar
Definition: gem.h:1173
bool valid
Is object fully loaded.
Definition: gem.h:663
psItem * GetItemData()
Definition: gem.h:810
virtual const char * GetObjectType()
Definition: gem.h:2132
csArray< ChatHistoryEntry > chatHistory
csArray<ChatHistoryEntry> chatHistory Info: Chat history for this player. A chat line stays in histor...
Definition: gem.h:1244
virtual bool IsConstructible()
Definition: gem.h:752
uint8_t forceDRcounter
sequence number for forced position updates
Definition: gem.h:1187
This class generically allows objects to be notified when a gemActor dies.
Definition: deathcallback.h:42
csWeakRef< gemObject > owner
Definition: gem.h:1916
virtual PID GetPID()
Definition: gem.h:1328
psSpellCastGameEvent * spellCasting
Hold a pointer to the game event < for the spell currently cast.
Definition: gem.h:1290
virtual AccountID GetSuperclientID()
Definition: gem.h:625
const csVector3 & GetProductionStartPos(void) const
Returns the place where the player last started digging.
Definition: gem.h:1497
csPDelArray< AttackerHistory > dmgHistory
Definition: gem.h:1272
virtual bool UpdateDR()
Definition: gem.h:603
bool IsSpellCasting()
Definition: gem.h:1399
This class embodies item instances in the game.
Definition: psitem.h:238
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106