Clone of PhatAC @ https://github.com/floaterxk/PhatAC

PhysicsObj.h 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. #pragma once
  2. #include "Animation.h"
  3. #include "ModelInfo.h"
  4. class CBaseItem;
  5. class CLandBlock;
  6. #define HaltThink() m_pfnThink = NULL;
  7. #define SetThink(x) MakeLive( ); m_pfnThink = static_cast<BOOL (CPhysicsObj::*)(void)>(x);
  8. #define MAX_PLAYER_EQUIPMENT 32
  9. #define MAX_PLAYER_INVENTORY 102
  10. #define MAX_PLAYER_CONTAINERS 7
  11. // Action types
  12. #define ANIM_EMOTE 1
  13. #define ANIM_ATTACK 2
  14. #define ANIM_SPELLCAST 3
  15. #define ANIM_LSRECALL 4
  16. #define ANIM_MPRECALL 5
  17. #define ANIM_DROPITEM 6
  18. #define ANIM_BINDLIFESTONE 1000
  19. // Visual flags
  20. /*
  21. #define VF_JUMPLOCK (VisFlags_t)0x00800000 //no idea, jumping locks you to the north.
  22. #define VF_NOEDGEFALL (VisFlags_t)0x00400000 //falls off edges
  23. #define VF_FROZEN (VisFlags_t)0x00100000
  24. #define VF_DOOR (VisFlags_t)0x00010000
  25. #define VF_BUBBLES (VisFlags_t)0x00004010
  26. #define VF_FREECAMERA (VisFlags_t)0x00001000
  27. #define VF_PLAYER (VisFlags_t)0x00000400
  28. #define VF_ARCS (VisFlags_t)0x00000100 //arcs when airborne (arrows)
  29. #define VF_INVISIBLE (VisFlags_t)0x00000020
  30. #define VF_SIGN (VisFlags_t)0x00000010
  31. #define VF_NORMAL (VisFlags_t)0x00000008
  32. #define VF_HOLLOW (VisFlags_t)0x00000004 //haven't checked
  33. */
  34. #define USEDISTANCE_ANYWHERE -0.1f
  35. // 0x4000 = bubbly?
  36. // 0x1000 = disconnects camera from player, for making videos, sweet!
  37. // 0x0100 = too cool, gives a sort of tumbling effect
  38. // 0x0020 = invisible/cloaked?
  39. // 0x0004 = can pass through objects?
  40. typedef std::vector<CBaseItem *> ItemVector;
  41. /*
  42. enum eOldWeenieType
  43. {
  44. TYPE_MELEE_WEAPON = 0x00000001,
  45. TYPE_ARMOR = 0x00000002,
  46. eShield = 0x00000002, //Shields too?
  47. eClothing = 0x00000004,
  48. eJewelry = 0x00000008,
  49. eMonster = 0x00000010,
  50. eMiscellaneous = 0x00000080,
  51. eCastingTool = 0x00008000
  52. };
  53. */
  54. /*
  55. enum UIEffectColors
  56. {
  57. eHighlightNone = 0x00000000,
  58. eHighlightRed = 0x00000004,
  59. eHighlightBlue = 0x00000008,
  60. eHighlightYellow = 0x00000010,
  61. eHighlightOrange = 0x00000020,
  62. eHighlightPurple = 0x00000040,
  63. eHighlightWhite = 0x00000080,
  64. eHighlightGreen = 0x00000100,
  65. };
  66. */
  67. enum eObjectStat
  68. {
  69. eTotalBurden = 0x05,
  70. eTotalValue = 0x13, //
  71. eTotalPyreal = 0x14,
  72. eTotalXP = 0x15,
  73. eUnassignedXP = 0x16,
  74. eUnassignedSkillPoints = 0x18,
  75. eLevel = 0x19,
  76. eArmorLevel = 0x1C, //
  77. eRank = 0x1E,
  78. eMagicResistance = 0x24, //
  79. eDifficulty = 0x26, //
  80. eFrozen = 0x28,
  81. eDeathCount = 0x2B,
  82. eUnknown2 = 0x2F,
  83. ePortalLevelMin = 0x56, //
  84. ePortalLevelMax = 0x57, //
  85. eBirth = 0x62,
  86. eAge = 0x7D,
  87. eExpTillVitaeRegain = 0x81,
  88. eUnknown4 = 0x8B
  89. };
  90. class CPhysicsObj
  91. {
  92. public:
  93. CPhysicsObj();
  94. virtual ~CPhysicsObj();
  95. //Control handling.
  96. void Attach(CLandBlock* pBlock);
  97. void Detach();
  98. CLandBlock* GetBlock();
  99. BOOL Think(void);
  100. //For overriding.
  101. virtual BOOL DefaultThink(void) { return FALSE; }
  102. void MakeLive(void);
  103. //Generic network messages.
  104. virtual BinaryWriter* CreateMessage(void);
  105. virtual BinaryWriter* UpdateMessage(void);
  106. virtual BinaryWriter* GetModelData(void);
  107. virtual void UpdateModel(void);
  108. virtual void Spawn(void);
  109. virtual void Precache(void) { }
  110. virtual void Save(void) { }
  111. // Events
  112. virtual void MakeAware(CPhysicsObj *) { };
  113. virtual void Use(CPhysicsObj *) { };
  114. virtual void UseEx(CPhysicsObj *, CPhysicsObj *) { };
  115. virtual void Identify(CPhysicsObj *);
  116. virtual void RemoveMe(void) { m_bRemoveMe = TRUE; }
  117. virtual void PostSpawn() { }
  118. // Actions
  119. virtual void ChangeVIS(DWORD);
  120. virtual void RemovePreviousInstance();
  121. virtual void EmitEffect(DWORD dwIndex, float flScale);
  122. virtual void EmitSound(DWORD dwIndex, float fSpeed);
  123. virtual void SpeakLocal(const char* szText, long lColor = 2);
  124. virtual void EmoteLocal(const char* szText);
  125. virtual void ActionLocal(const char* szText);
  126. virtual CPhysicsObj* FindChild(DWORD dwGUID) { return NULL; }
  127. virtual DWORD GetLandcell() { return m_Origin.landcell; }
  128. virtual void SetLocation(DWORD landcell, float x, float y, float z);
  129. virtual void SetAngles(float w, float x, float y, float z);
  130. //should be overridden
  131. virtual BOOL IsItem() { return FALSE; }
  132. BOOL IsWearable() { return m_dwCoverage1 != 0; }
  133. virtual BOOL IsMonster() { return FALSE; }
  134. virtual BOOL IsPlayer() { return FALSE; }
  135. bool IsCorpse() { return !!(m_WeenieBitfield & BF_CORPSE); }
  136. bool IsDoor() { return !!(m_WeenieBitfield & BF_DOOR); }
  137. virtual BOOL IsFoci() { return FALSE; }
  138. bool IsInscribable() { return !!(m_WeenieBitfield & BF_INSCRIBABLE); }
  139. bool IsLifestone() { return !!(m_WeenieBitfield & BF_LIFESTONE); }
  140. bool IsVendor() { return !!(m_WeenieBitfield & BF_VENDOR); }
  141. bool CanPickup() { return !(m_WeenieBitfield & BF_STUCK); }
  142. bool IsPortal() { return !!(m_WeenieBitfield & BF_PORTAL); }
  143. virtual BOOL IsReadable() { return FALSE; }
  144. bool IsAttackable() { return !!(m_WeenieBitfield & BF_ATTACKABLE); }
  145. virtual BOOL IsContained() { return FALSE; }
  146. virtual BOOL IsWielded() { return FALSE; }
  147. virtual BOOL HasOwner();
  148. virtual DWORD GetContainerID() { return 0; }
  149. virtual DWORD GetWielderID() { return 0; }
  150. virtual WORD GetTypeID() { return m_wTypeID; }
  151. virtual WORD GetIcon() { return m_wIcon; }
  152. virtual DWORD GetSoundSet() { return m_dwSoundSet; }
  153. virtual DWORD GetEffectSet() { return m_dwEffectSet; }
  154. virtual const char* GetName() { return m_strName.c_str(); }
  155. virtual float GetApproachDist() { return 0; }
  156. virtual DWORD GetEquipSlot() { return 0; }
  157. virtual DWORD GetEquipType() { return 0; }
  158. const char* GetDescription();
  159. void SetDescription(const char*);
  160. virtual BOOL HasEquipSlot() { return GetEquipSlot() ? TRUE : FALSE; }
  161. virtual BOOL HasEquipType() { return GetEquipType() ? TRUE : FALSE; }
  162. virtual BOOL HasCoverage() { return FALSE; }
  163. virtual BOOL HasBurden() { return FALSE; }
  164. virtual DWORD GetObjectStat(eObjectStat index);
  165. virtual DWORD SetObjectStat(eObjectStat index, DWORD value);
  166. virtual void SendNetMessage(void *_data, DWORD _len, WORD _group, BOOL _event = 0) { }
  167. virtual void SendNetMessage(BinaryWriter *_food, WORD _group, BOOL _event = 0, BOOL del = 1) { }
  168. float DistanceTo(CPhysicsObj *pOther);
  169. void SetAppearanceOverride(ModelInfo *pAppearance);
  170. BOOL m_bRemoveMe;
  171. BOOL(CPhysicsObj::*m_pfnThink)(void);
  172. DWORD m_dwGUID;
  173. std::string m_strName;
  174. std::string m_strDescription;
  175. DWORD m_dwModel;
  176. float m_fScale;
  177. WORD m_wTypeID;
  178. WORD m_wIcon;
  179. ITEM_TYPE m_ItemType;
  180. ITEM_USEABLE m_Usability;
  181. float m_UseDistance;
  182. DWORD m_Value;
  183. WORD m_Burden;
  184. ITEM_TYPE m_TargetType;
  185. AMMO_TYPE m_AmmoType;
  186. RadarEnum m_RadarVis;
  187. int m_BlipColor; // 1=White 5=PK(red) 6=PKL(pink) 10=BrightGreen(fellowship)
  188. WORD m_wNumMovements;
  189. WORD m_wNumAnimInteracts;
  190. WORD m_wNumBubbleModes;
  191. WORD m_wNumJumps;
  192. WORD m_wNumPortals;
  193. WORD m_wAnimCount;
  194. WORD m_wNumOverride;
  195. WORD m_wNumModelChanges;
  196. WORD m_wInstance;
  197. WORD m_wSeagreen10;
  198. WORD m_wNumCombat;
  199. DWORD m_dwEffectSet;
  200. DWORD m_dwSoundSet;
  201. loc_t m_Origin;
  202. heading_t m_Angles;
  203. DWORD m_PhysicsState;
  204. float m_Translucency;
  205. DWORD m_WeenieBitfield;
  206. double m_fNextThink;
  207. DWORD m_dwStats[0x100];
  208. ModelInfo m_miBaseModel;
  209. ModelInfo m_miWornModel;
  210. bool m_bUseModelOverride;
  211. ModelInfo m_miModelOverride;
  212. BYTE *m_AnimOverrideData;
  213. DWORD m_AnimOverrideDataLen;
  214. DWORD m_AutonomousMovement;
  215. #include "container.h"
  216. #include "animate.h"
  217. #include "moves.h"
  218. std::map<DWORD, DWORD> m_dwordProperties;
  219. std::map<DWORD, UINT64> m_qwordProperties;
  220. std::map<DWORD, DWORD> m_boolProperties;
  221. std::map<DWORD, double> m_floatProperties;
  222. std::map<DWORD, std::string> m_stringProperties;
  223. std::map<DWORD, DWORD> m_dataIDProperties;
  224. bool m_bDontClear;
  225. bool m_bLifestoneBound;
  226. placement_t m_LifestonePlacement;
  227. DWORD m_UIEffects;
  228. DWORD m_dwEquipSlot;
  229. DWORD m_dwEquipType;
  230. DWORD m_dwCoverage1;
  231. DWORD m_dwCoverage2;
  232. DWORD m_dwCoverage3;
  233. private:
  234. CLandBlock* m_pBlock;
  235. };