9
3

Player.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __EQ2_PLAYER__
  17. #define __EQ2_PLAYER__
  18. #include "Entity.h"
  19. #include "Items/Items.h"
  20. #include "Factions.h"
  21. #include "Skills.h"
  22. #include "Quests.h"
  23. #include "MutexMap.h"
  24. #include "Guilds/Guild.h"
  25. #include "Collections/Collections.h"
  26. #include "Recipes/Recipe.h"
  27. #include "Titles.h"
  28. #include "Languages.h"
  29. #include "Achievements/Achievements.h"
  30. #include "Traits/Traits.h"
  31. #include <algorithm>
  32. #include <set>
  33. #define CF_COMBAT_EXPERIENCE_ENABLED 0
  34. #define CF_ENABLE_CHANGE_LASTNAME 1
  35. #define CF_FOOD_AUTO_CONSUME 2
  36. #define CF_DRINK_AUTO_CONSUME 3
  37. #define CF_AUTO_ATTACK 4
  38. #define CF_RANGED_AUTO_ATTACK 5
  39. #define CF_QUEST_EXPERIENCE_ENABLED 6
  40. #define CF_CHASE_CAMERA_MAYBE 7
  41. #define CF_100 8
  42. #define CF_200 9
  43. #define CF_IS_SITTING 10 /*CAN'T CAST OR ATTACK*/
  44. #define CF_800 11
  45. #define CF_ANONYMOUS 12
  46. #define CF_ROLEPLAYING 13
  47. #define CF_AFK 14
  48. #define CF_LFG 15
  49. #define CF_LFW 16
  50. #define CF_HIDE_HOOD 17
  51. #define CF_HIDE_HELM 18
  52. #define CF_SHOW_ILLUSION 19
  53. #define CF_ALLOW_DUEL_INVITES 20
  54. #define CF_ALLOW_TRADE_INVITES 21
  55. #define CF_ALLOW_GROUP_INVITES 22
  56. #define CF_ALLOW_RAID_INVITES 23
  57. #define CF_ALLOW_GUILD_INVITES 24
  58. #define CF_2000000 25
  59. #define CF_4000000 26
  60. #define CF_DEFENSE_SKILLS_AT_MAX_QUESTIONABLE 27
  61. #define CF_SHOW_GUILD_HERALDRY 28
  62. #define CF_SHOW_CLOAK 29
  63. #define CF_IN_PVP 30
  64. #define CF_IS_HATED 31
  65. #define CF2_1 32
  66. #define CF2_2 33
  67. #define CF2_4 34
  68. #define CF2_ALLOW_LON_INVITES 35
  69. #define CF2_SHOW_RANGED 36
  70. #define CF2_ALLOW_VOICE_INVITES 37
  71. #define CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED 38
  72. #define CF2_80 39
  73. #define CF2_100 40 /* hide achievments*/
  74. #define CF2_200 41
  75. #define CF2_400 42
  76. #define CF2_800 43 /* enable facebook updates*/
  77. #define CF2_1000 44 /* enable twitter updates*/
  78. #define CF2_2000 45 /* enable eq2 player updates */
  79. #define CF2_4000 46 /*eq2 players, link to alt chars */
  80. #define CF2_8000 47
  81. #define CF2_10000 48
  82. #define CF2_20000 49
  83. #define CF2_40000 50
  84. #define CF2_80000 51
  85. #define CF2_100000 52
  86. #define CF2_200000 53
  87. #define CF2_400000 54
  88. #define CF2_800000 55
  89. #define CF2_1000000 56
  90. #define CF2_2000000 57
  91. #define CF2_4000000 58
  92. #define CF2_8000000 59
  93. #define CF2_10000000 60
  94. #define CF2_20000000 61
  95. #define CF2_40000000 62
  96. #define CF2_80000000 63
  97. #define CF_MAXIMUM_FLAG 63
  98. #define CF_HIDE_STATUS 49 /* !!FORTESTING ONLY!! */
  99. #define CF_GM_HIDDEN 50 /* !!FOR TESTING ONLY!! */
  100. #define UPDATE_ACTIVITY_FALLING 0
  101. #define UPDATE_ACTIVITY_RUNNING 128
  102. #define UPDATE_ACTIVITY_RIDING_BOAT 256
  103. #define UPDATE_ACTIVITY_JUMPING 1024
  104. #define UPDATE_ACTIVITY_IN_WATER_ABOVE 6144
  105. #define UPDATE_ACTIVITY_IN_WATER_BELOW 6272
  106. #define UPDATE_ACTIVITY_SITING 6336
  107. #define UPDATE_ACTIVITY_DROWNING 14464
  108. #define UPDATE_ACTIVITY_DROWNING2 14336
  109. #define UPDATE_ACTIVITY_FALLING_AOM 16384
  110. #define UPDATE_ACTIVITY_RIDING_BOAT_AOM 256
  111. #define UPDATE_ACTIVITY_RUNNING_AOM 16512
  112. #define UPDATE_ACTIVITY_JUMPING_AOM 17408
  113. #define UPDATE_ACTIVITY_MOVE_WATER_BELOW_AOM 22528
  114. #define UPDATE_ACTIVITY_MOVE_WATER_ABOVE_AOM 22656
  115. #define UPDATE_ACTIVITY_SITTING_AOM 22720
  116. #define UPDATE_ACTIVITY_DROWNING_AOM 30720
  117. #define UPDATE_ACTIVITY_DROWNING2_AOM 30848
  118. #define NUM_MAINTAINED_EFFECTS 30
  119. #define NUM_SPELL_EFFECTS 45
  120. /* Character History Type Defines */
  121. #define HISTORY_TYPE_NONE 0
  122. #define HISTORY_TYPE_DEATH 1
  123. #define HISTORY_TYPE_DISCOVERY 2
  124. #define HISTORY_TYPE_XP 3
  125. /* Spell Status */
  126. #define SPELL_STATUS_QUEUE 4
  127. #define SPELL_STATUS_LOCK 66
  128. /* Character History Sub Type Defines */
  129. #define HISTORY_SUBTYPE_NONE 0
  130. #define HISTORY_SUBTYPE_ADVENTURE 1
  131. #define HISTORY_SUBTYPE_TRADESKILL 2
  132. #define HISTORY_SUBTYPE_QUEST 3
  133. #define HISTORY_SUBTYPE_AA 4
  134. #define HISTORY_SUBTYPE_ITEM 5
  135. #define HISTORY_SUBTYPE_LOCATION 6
  136. /// <summary>Character history data, should match the `character_history` table in the DB</summary>
  137. struct HistoryData {
  138. int32 Value;
  139. int32 Value2;
  140. char Location[200];
  141. int32 EventID;
  142. int32 EventDate;
  143. bool needs_save;
  144. };
  145. /// <summary>History set through the LUA system</summary>
  146. struct LUAHistory {
  147. int32 Value;
  148. int32 Value2;
  149. bool SaveNeeded;
  150. };
  151. struct SpellBookEntry{
  152. int32 spell_id;
  153. int8 tier;
  154. int32 type;
  155. sint32 slot;
  156. int32 recast_available;
  157. int8 status;
  158. int16 recast;
  159. int32 timer;
  160. bool save_needed;
  161. bool in_use;
  162. bool in_remiss;
  163. Player* player;
  164. bool visible;
  165. };
  166. struct GMTagFilter {
  167. int32 filter_type;
  168. int32 filter_value;
  169. char filter_search_criteria[256];
  170. int16 visual_tag;
  171. };
  172. enum GMTagFilterType {
  173. GMFILTERTYPE_NONE=0,
  174. GMFILTERTYPE_FACTION=1,
  175. GMFILTERTYPE_SPAWNGROUP=2,
  176. GMFILTERTYPE_RACE=3,
  177. GMFILTERTYPE_GROUNDSPAWN=4
  178. };
  179. enum SpawnState{
  180. SPAWN_STATE_NONE=0,
  181. SPAWN_STATE_SENDING=1,
  182. SPAWN_STATE_SENT_WAIT=2,
  183. SPAWN_STATE_SENT=3,
  184. SPAWN_STATE_REMOVING=4,
  185. SPAWN_STATE_REMOVING_SLEEP=5,
  186. SPAWN_STATE_REMOVED=6
  187. };
  188. #define QUICKBAR_NORMAL 1
  189. #define QUICKBAR_INV_SLOT 2
  190. #define QUICKBAR_MACRO 3
  191. #define QUICKBAR_TEXT_CMD 4
  192. #define QUICKBAR_ITEM 6
  193. #define EXP_DISABLED_STATE 0
  194. #define EXP_ENABLED_STATE 1
  195. #define MELEE_COMBAT_STATE 16
  196. #define RANGE_COMBAT_STATE 32
  197. struct QuickBarItem{
  198. bool deleted;
  199. int32 hotbar;
  200. int32 slot;
  201. int32 type;
  202. int16 icon;
  203. int16 icon_type;
  204. int32 id;
  205. int8 tier;
  206. int32 unique_id;
  207. EQ2_16BitString text;
  208. };
  209. struct LoginAppearances {
  210. bool deleted;
  211. int16 equip_type;
  212. int8 red;
  213. int8 green;
  214. int8 blue;
  215. int8 h_red;
  216. int8 h_green;
  217. int8 h_blue;
  218. bool update_needed;
  219. };
  220. struct SpawnQueueState {
  221. Timer spawn_state_timer;
  222. int16 index_id;
  223. };
  224. class PlayerLoginAppearance {
  225. public:
  226. PlayerLoginAppearance() { appearanceList = new map<int8, LoginAppearances>; }
  227. ~PlayerLoginAppearance() { }
  228. void AddEquipmentToUpdate(int8 slot_id, LoginAppearances* equip)
  229. {
  230. //LoginAppearances data;
  231. //data.equip_type = equip->equip_type;
  232. //appearanceList[slot_id] = data;
  233. }
  234. void DeleteEquipmentFromUpdate(int8 slot_id, LoginAppearances* equip)
  235. {
  236. //LoginAppearances data;
  237. //data.deleted = equip->deleted;
  238. //data.update_needed = true;
  239. //appearanceList[slot_id] = data;
  240. }
  241. void RemoveEquipmentUpdates()
  242. {
  243. appearanceList->clear();
  244. safe_delete(appearanceList);
  245. }
  246. private:
  247. map<int8, LoginAppearances>* appearanceList;
  248. };
  249. struct InstanceData{
  250. int32 db_id;
  251. int32 instance_id;
  252. int32 zone_id;
  253. int8 zone_instance_type;
  254. string zone_name;
  255. int32 last_success_timestamp;
  256. int32 last_failure_timestamp;
  257. int32 success_lockout_time;
  258. int32 failure_lockout_time;
  259. };
  260. class CharacterInstances {
  261. public:
  262. CharacterInstances();
  263. ~CharacterInstances();
  264. ///<summary>Adds an instance data to the player with the given data</summary>
  265. ///<param name='db_id'>The unique id for this record in the database</param>
  266. ///<param name='instance_id'>The id of the instance</param>
  267. ///<param name='last_success_timestamp'>The success timestamp</param>
  268. ///<param name='last_failure_timestamp'>The failure timestamp</param>
  269. ///<param name='success_lockout_time'>The lockout time, in secs, for completing the instance</param>
  270. ///<param name='failure_lockout_time'>The lockout time, in secs, for failing the instance</param>
  271. ///<param name='zone_id'>The id of the zone</param>
  272. ///<param name='zone_instancetype'>The type of instance of the zone</param>
  273. ///<param name='zone_name'>The name of the zone</param>
  274. void AddInstance(int32 db_id, int32 instance_id, int32 last_success_timestamp, int32 last_failure_timestamp, int32 success_lockout_time, int32 failure_lockout_time, int32 zone_id, int8 zone_instancetype, string zone_name);
  275. ///<summary>Clears all instance data</summary>
  276. void RemoveInstances();
  277. ///<summary>Removes the instace with the given zone id</summary>
  278. ///<param name='zone_id'>The zone id of the instance to remove</param>
  279. ///<returns>True if the instance was found and removed</returns>
  280. bool RemoveInstanceByZoneID(int32 zone_id);
  281. ///<summary>Removes the instance with the given instance id</summary>
  282. ///<param name='instance_id'>the instance id of the instance to remove</param>
  283. ///<returns>True if instance was found and removed</returns>
  284. bool RemoveInstanceByInstanceID(int32 instance_id);
  285. ///<summary>Gets the instance with the given zone id</summary>
  286. ///<param name='zone_id'>The zone id of the instance to get</param>
  287. ///<returns>InstanceData* of the instance record for the given zone id</returns>
  288. InstanceData* FindInstanceByZoneID(int32 zone_id);
  289. ///<summary>Gets the instance with the given database id</summary>
  290. ///<param name='db_id'>The database id of the instance to get</param>
  291. ///<returns>InstanceData* of the instance record for the given database id</returns>
  292. InstanceData* FindInstanceByDBID(int32 db_id);
  293. ///<summary>Gets the instance with the given instance id</summary>
  294. ///<param name='instance_id'>The instance id of the instance to get</param>
  295. ///<returns>InstanceData* of the instance record for the given instance id</returns>
  296. InstanceData* FindInstanceByInstanceID(int32 instance_id);
  297. ///<summary>Gets a list of all the lockout instances</summary>
  298. vector<InstanceData> GetLockoutInstances();
  299. ///<summary>Gets a list of all the persistent instances</summary>
  300. vector<InstanceData> GetPersistentInstances();
  301. ///<summary>Check the timers for the instances</summary>
  302. ///<param name='player'>player we are checking the timers for</param>
  303. void ProcessInstanceTimers(Player* player);
  304. ///<summary>Gets the total number of instances</summary>
  305. int32 GetInstanceCount();
  306. private:
  307. vector<InstanceData> instanceList;
  308. Mutex m_instanceList;
  309. };
  310. class Player;
  311. struct PlayerGroup;
  312. struct GroupMemberInfo;
  313. struct Statistic;
  314. struct Mail;
  315. class PlayerInfo {
  316. public:
  317. ~PlayerInfo();
  318. PlayerInfo(Player* in_player);
  319. EQ2Packet* serialize(int16 version, int16 modifyPos = 0, int32 modifyValue = 0);
  320. PacketStruct* serialize2(int16 version);
  321. EQ2Packet* serialize3(PacketStruct* packet, int16 version);
  322. EQ2Packet* serializePet(int16 version);
  323. void CalculateXPPercentages();
  324. void CalculateTSXPPercentages();
  325. void SetHouseZone(int32 id);
  326. void SetBindZone(int32 id);
  327. void SetBindX(float x);
  328. void SetBindY(float y);
  329. void SetBindZ(float z);
  330. void SetBindHeading(float heading);
  331. void SetAccountAge(int32 days);
  332. int32 GetHouseZoneID();
  333. int32 GetBindZoneID();
  334. float GetBindZoneX();
  335. float GetBindZoneY();
  336. float GetBindZoneZ();
  337. float GetBindZoneHeading();
  338. float GetBoatX() { return boat_x_offset; }
  339. float GetBoatY() { return boat_y_offset; }
  340. float GetBoatZ() { return boat_z_offset; }
  341. int32 GetBoatSpawn();
  342. void SetBoatX(float x) { boat_x_offset = x; }
  343. void SetBoatY(float y) { boat_y_offset = y; }
  344. void SetBoatZ(float z) { boat_z_offset = z; }
  345. void SetBoatSpawn(Spawn* boat);
  346. void RemoveOldPackets();
  347. private:
  348. int32 house_zone_id;
  349. int32 bind_zone_id;
  350. float bind_x;
  351. float bind_y;
  352. float bind_z;
  353. float bind_heading;
  354. uchar* changes;
  355. uchar* orig_packet;
  356. uchar* pet_changes;
  357. uchar* pet_orig_packet;
  358. InfoStruct* info_struct;
  359. Player* player;
  360. float boat_x_offset;
  361. float boat_y_offset;
  362. float boat_z_offset;
  363. int32 boat_spawn;
  364. };
  365. class PlayerControlFlags{
  366. public:
  367. PlayerControlFlags();
  368. ~PlayerControlFlags();
  369. void SetPlayerControlFlag(int8 param, int8 param_value, bool is_active);
  370. bool ControlFlagsChanged();
  371. void SendControlFlagUpdates(Client* client);
  372. private:
  373. bool flags_changed;
  374. map<int8, map<int8, int8> > flag_changes;
  375. map<int8, map<int8, bool> > current_flags;
  376. Mutex MControlFlags;
  377. Mutex MFlagChanges;
  378. };
  379. class Player : public Entity{
  380. public:
  381. Player();
  382. virtual ~Player();
  383. EQ2Packet* serialize(Player* player, int16 version);
  384. //int8 GetMaxArtLevel(){ return info->GetInfo()->max_art_level; }
  385. //int8 GetArtLevel(){ return info->GetInfo()->art_level; }
  386. Client* GetClient() { return client; }
  387. void SetClient(Client* client) { this->client = client; }
  388. PlayerInfo* GetPlayerInfo();
  389. void SetCharSheetChanged(bool val);
  390. bool GetCharSheetChanged();
  391. void SetRaidSheetChanged(bool val);
  392. bool GetRaidSheetChanged();
  393. void AddFriend(const char* name, bool save);
  394. bool IsFriend(const char* name);
  395. void RemoveFriend(const char* name);
  396. map<string, int8>* GetFriends();
  397. void AddIgnore(const char* name, bool save);
  398. bool IsIgnored(const char* name);
  399. void RemoveIgnore(const char* name);
  400. map<string, int8>* GetIgnoredPlayers();
  401. // JA: POI Discoveries
  402. map<int32, vector<int32> >* GetPlayerDiscoveredPOIs();
  403. void AddPlayerDiscoveredPOI(int32 location_id);
  404. //
  405. EQ2Packet* Move(float x, float y, float z, int16 version, float heading = -1.0f);
  406. /*void SetMaxArtLevel(int8 new_max){
  407. max_art_level = new_max;
  408. }
  409. void SetArtLevel(int8 new_lvl){
  410. art_level = new_lvl;
  411. }*/
  412. bool WasSentSpawn(int32 spawn_id);
  413. bool IsSendingSpawn(int32 spawn_id);
  414. bool IsRemovingSpawn(int32 spawn_id);
  415. bool SetSpawnSentState(Spawn* spawn, SpawnState state);
  416. void CheckSpawnStateQueue();
  417. void SetSideSpeed(float side_speed, bool updateFlags = true) {
  418. SetPos(&appearance.pos.SideSpeed, side_speed, updateFlags);
  419. }
  420. float GetSideSpeed() {
  421. return appearance.pos.SideSpeed;
  422. }
  423. void SetVertSpeed(float vert_speed, bool updateFlags = true) {
  424. SetPos(&appearance.pos.VertSpeed, vert_speed, updateFlags);
  425. }
  426. float GetVertSpeed() {
  427. return appearance.pos.VertSpeed;
  428. }
  429. void SetClientHeading1(float heading, bool updateFlags = true) {
  430. SetPos(&appearance.pos.ClientHeading1, heading, updateFlags);
  431. }
  432. float GetClientHeading1() {
  433. return appearance.pos.ClientHeading1;
  434. }
  435. void SetClientHeading2(float heading, bool updateFlags = true) {
  436. SetPos(&appearance.pos.ClientHeading2, heading, updateFlags);
  437. }
  438. float GetClientHeading2() {
  439. return appearance.pos.ClientHeading2;
  440. }
  441. void SetClientPitch(float pitch, bool updateFlags = true) {
  442. SetPos(&appearance.pos.ClientPitch, pitch, updateFlags);
  443. }
  444. float GetClientPitch() {
  445. return appearance.pos.ClientPitch;
  446. }
  447. int8 GetTutorialStep() {
  448. return tutorial_step;
  449. }
  450. void SetTutorialStep(int8 val) {
  451. tutorial_step = val;
  452. }
  453. void AddMaintainedSpell(LuaSpell* spell);
  454. void AddSpellEffect(LuaSpell* spell, int32 override_expire_time = 0);
  455. void RemoveMaintainedSpell(LuaSpell* spell);
  456. void RemoveSpellEffect(LuaSpell* spell);
  457. void AddQuickbarItem(int32 bar, int32 slot, int32 type, int16 icon, int16 icon_type, int32 id, int8 tier, int32 unique_id, const char* text, bool update = true);
  458. void RemoveQuickbarItem(int32 bar, int32 slot, bool update = true);
  459. void MoveQuickbarItem(int32 id, int32 new_slot);
  460. void ClearQuickbarItems();
  461. PlayerItemList* GetPlayerItemList();
  462. PlayerItemList item_list;
  463. PlayerSkillList skill_list;
  464. Skill* GetSkillByName(const char* name, bool check_update = false);
  465. Skill* GetSkillByID(int32 skill_id, bool check_update = false);
  466. PlayerSkillList* GetSkills();
  467. bool DamageEquippedItems(int8 amount = 10, Client* client = 0);
  468. vector<EQ2Packet*> EquipItem(int16 index, int16 version, int8 appearance_type, int8 slot_id = 255);
  469. bool CanEquipItem(Item* item, int8 slot);
  470. void SetEquippedItemAppearances();
  471. vector<EQ2Packet*> UnequipItem(int16 index, sint32 bag_id, int8 slot, int16 version, int8 appearance_type = 0, bool send_item_updates = true);
  472. int16 ConvertSlotToClient(int8 slot, int16 version);
  473. int16 ConvertSlotFromClient(int8 slot, int16 version);
  474. int16 GetNumSlotsEquip(int16 version);
  475. int8 GetMaxBagSlots(int16 version);
  476. EQ2Packet* SwapEquippedItems(int8 slot1, int8 slot2, int16 version, int16 equiptype);
  477. EQ2Packet* RemoveInventoryItem(int8 bag_slot, int8 slot);
  478. EQ2Packet* SendInventoryUpdate(int16 version);
  479. EQ2Packet* SendBagUpdate(int32 bag_unique_id, int16 version);
  480. void SendQuestRequiredSpawns(int32 quest_id);
  481. void SendHistoryRequiredSpawns(int32 event_id);
  482. map<int32, Item*>* GetItemList();
  483. map<int32, Item*>* GetBankItemList();
  484. vector<Item*>* GetEquippedItemList();
  485. vector<Item*>* GetAppearanceEquippedItemList();
  486. Quest* SetStepComplete(int32 quest_id, int32 step);
  487. Quest* AddStepProgress(int32 quest_id, int32 step, int32 progress);
  488. int32 GetStepProgress(int32 quest_id, int32 step_id);
  489. Quest* GetQuestByPositionID(int32 list_position_id);
  490. bool AddItem(Item* item, AddItemType type = AddItemType::NOT_SET);
  491. bool AddItemToBank(Item* item);
  492. int16 GetSpellSlotMappingCount();
  493. int16 GetSpellPacketCount();
  494. Quest* GetQuest(int32 quest_id);
  495. bool GetQuestStepComplete(int32 quest_id, int32 step_id);
  496. int16 GetQuestStep(int32 quest_id);
  497. int16 GetTaskGroupStep(int32 quest_id);
  498. int8 GetSpellTier(int32 id);
  499. void SetSpellStatus(Spell* spell, int8 status);
  500. void RemoveSpellStatus(Spell* spell, int8 status);
  501. EQ2Packet* GetSpellSlotMappingPacket(int16 version);
  502. EQ2Packet* GetSpellBookUpdatePacket(int16 version);
  503. EQ2Packet* GetRaidUpdatePacket(int16 version);
  504. int32 GetCharacterID();
  505. void SetCharacterID(int32 new_id);
  506. EQ2Packet* GetQuickbarPacket(int16 version);
  507. vector<QuickBarItem*>* GetQuickbar();
  508. bool UpdateQuickbarNeeded();
  509. void ResetQuickbarNeeded();
  510. void set_character_flag(int flag);
  511. void reset_character_flag(int flag);
  512. void toggle_character_flag(int flag);
  513. bool get_character_flag(int flag);
  514. void AddCoins(int64 val);
  515. bool RemoveCoins(int64 val);
  516. /// <summary>Checks to see if the player has the given amount of coins</summary>
  517. /// <param name="val">Amount of coins to check</param>
  518. /// <returns>True if the player has enough coins</returns>
  519. bool HasCoins(int64 val);
  520. void AddSkill(int32 skill_id, int16 current_val, int16 max_val, bool save_needed = false);
  521. void RemovePlayerSkill(int32 skill_id, bool save = false);
  522. void RemoveSkillFromDB(Skill* skill, bool save = false);
  523. void AddSpellBookEntry(int32 spell_id, int8 tier, sint32 slot, int32 type, int32 timer, bool save_needed = false);
  524. SpellBookEntry* GetSpellBookSpell(int32 spell_id);
  525. vector<SpellBookEntry*>* GetSpellsSaveNeeded();
  526. sint32 GetFreeSpellBookSlot(int32 type);
  527. /// <summary>Get a vector of spell ids for all spells in the spell book for the given skill</summary>
  528. /// <param name='skill_id'>The id of the skill to check</param>
  529. /// <returns>A vector of int32's of the spell id's</returns>
  530. vector<int32> GetSpellBookSpellIDBySkill(int32 skill_id);
  531. void UpdateInventory(int32 bag_id);
  532. EQ2Packet* MoveInventoryItem(sint32 to_bag_id, int16 from_index, int8 new_slot, int8 charges, int8 appearance_type, bool* item_deleted, int16 version = 1);
  533. bool IsPlayer(){ return true; }
  534. MaintainedEffects* GetFreeMaintainedSpellSlot();
  535. MaintainedEffects* GetMaintainedSpell(int32 id);
  536. MaintainedEffects* GetMaintainedSpellBySlot(int8 slot);
  537. MaintainedEffects* GetMaintainedSpells();
  538. SpellEffects* GetFreeSpellEffectSlot();
  539. SpellEffects* GetSpellEffects();
  540. int32 GetCoinsCopper();
  541. int32 GetCoinsSilver();
  542. int32 GetCoinsGold();
  543. int32 GetCoinsPlat();
  544. int32 GetBankCoinsCopper();
  545. int32 GetBankCoinsSilver();
  546. int32 GetBankCoinsGold();
  547. int32 GetBankCoinsPlat();
  548. int32 GetStatusPoints();
  549. float GetXPVitality();
  550. float GetTSXPVitality();
  551. bool AdventureXPEnabled();
  552. bool TradeskillXPEnabled();
  553. void SetNeededXP(int32 val);
  554. void SetNeededXP();
  555. void SetXP(int32 val);
  556. void SetNeededTSXP(int32 val);
  557. void SetNeededTSXP();
  558. void SetTSXP(int32 val);
  559. int32 GetNeededXP();
  560. float GetXPDebt();
  561. int32 GetXP();
  562. int32 GetNeededTSXP();
  563. int32 GetTSXP();
  564. bool AddXP(int32 xp_amount);
  565. bool AddTSXP(int32 xp_amount);
  566. bool DoubleXPEnabled();
  567. float CalculateXP(Spawn* victim);
  568. float CalculateTSXP(int8 level);
  569. void CalculateOfflineDebtRecovery(int32 unix_timestamp);
  570. void InCombat(bool val, bool range = false);
  571. void PrepareIncomingMovementPacket(int32 len, uchar* data, int16 version);
  572. uchar* GetMovementPacketData(){
  573. return movement_packet;
  574. }
  575. void AddSpawnInfoPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  576. uchar* GetSpawnInfoPacketForXOR(int32 spawn_id);
  577. void AddSpawnVisPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  578. uchar* GetSpawnVisPacketForXOR(int32 spawn_id);
  579. void AddSpawnPosPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  580. uchar* GetSpawnPosPacketForXOR(int32 spawn_id);
  581. uchar* GetTempInfoPacketForXOR();
  582. uchar* GetTempVisPacketForXOR();
  583. uchar* GetTempPosPacketForXOR();
  584. uchar* SetTempInfoPacketForXOR(int16 size);
  585. uchar* SetTempVisPacketForXOR(int16 size);
  586. uchar* SetTempPosPacketForXOR(int16 size);
  587. int32 GetTempInfoXorSize() { return info_xor_size; }
  588. int32 GetTempVisXorSize() { return vis_xor_size; }
  589. int32 GetTempPosXorSize() { return pos_xor_size; }
  590. bool CheckPlayerInfo();
  591. void CalculateLocation();
  592. void SetSpawnDeleteTime(int32 id, int32 time);
  593. int32 GetSpawnDeleteTime(int32 id);
  594. void ClearRemovalTimers();
  595. void ClearEverything();
  596. bool IsResurrecting();
  597. void SetResurrecting(bool val);
  598. int8 GetTSArrowColor(int8 level);
  599. Spawn* GetSpawnByIndex(int16 index);
  600. int16 GetIndexForSpawn(Spawn* spawn);
  601. bool WasSpawnRemoved(Spawn* spawn);
  602. void RemoveSpawn(Spawn* spawn, bool delete_spawn = true);
  603. bool ShouldSendSpawn(Spawn* spawn);
  604. Client* client = 0;
  605. void SetLevel(int16 level, bool setUpdateFlags = true);
  606. Spawn* GetSpawnWithPlayerID(int32 id){
  607. Spawn* spawn = 0;
  608. index_mutex.readlock(__FUNCTION__, __LINE__);
  609. if (player_spawn_id_map.count(id) > 0)
  610. spawn = player_spawn_id_map[id];
  611. index_mutex.releasereadlock(__FUNCTION__, __LINE__);
  612. return spawn;
  613. }
  614. int32 GetIDWithPlayerSpawn(Spawn* spawn){
  615. int32 id = 0;
  616. index_mutex.readlock(__FUNCTION__, __LINE__);
  617. if (player_spawn_reverse_id_map.count(spawn) > 0)
  618. id = player_spawn_reverse_id_map[spawn];
  619. index_mutex.releasereadlock(__FUNCTION__, __LINE__);
  620. return id;
  621. }
  622. int16 GetNextSpawnIndex(Spawn* spawn, bool set_lock = true);
  623. bool SetSpawnMap(Spawn* spawn);
  624. void SetSpawnMapIndex(Spawn* spawn, int32 index)
  625. {
  626. index_mutex.writelock(__FUNCTION__, __LINE__);
  627. if (player_spawn_id_map.count(index))
  628. player_spawn_id_map[index] = spawn;
  629. else
  630. player_spawn_id_map[index] = spawn;
  631. index_mutex.releasewritelock(__FUNCTION__, __LINE__);
  632. }
  633. int16 SetSpawnMapAndIndex(Spawn* spawn);
  634. PacketStruct* GetQuestJournalPacket(bool all_quests, int16 version, int32 crc, int32 current_quest_id, bool updated = true);
  635. void RemoveQuest(int32 id, bool delete_quest);
  636. vector<Quest*>* CheckQuestsChatUpdate(Spawn* spawn);
  637. vector<Quest*>* CheckQuestsItemUpdate(Item* item);
  638. vector<Quest*>* CheckQuestsLocationUpdate();
  639. vector<Quest*>* CheckQuestsKillUpdate(Spawn* spawn,bool update = true);
  640. bool HasQuestUpdateRequirement(Spawn* spawn);
  641. vector<Quest*>* CheckQuestsSpellUpdate(Spell* spell);
  642. void CheckQuestsCraftUpdate(Item* item, int32 qty);
  643. void CheckQuestsHarvestUpdate(Item* item, int32 qty);
  644. vector<Quest*>* CheckQuestsFailures();
  645. bool CheckQuestRemoveFlag(Spawn* spawn);
  646. int8 CheckQuestFlag(Spawn* spawn);
  647. bool UpdateQuestReward(int32 quest_id, QuestRewardData* qrd);
  648. Quest* PendingQuestAcceptance(int32 quest_id, int32 item_id, bool* quest_exists);
  649. bool AcceptQuestReward(int32 item_id, int32 selectable_item_id);
  650. bool SendQuestStepUpdate(int32 quest_id, int32 quest_step_id, bool display_quest_helper);
  651. void SendQuest(int32 quest_id);
  652. void UpdateQuestCompleteCount(int32 quest_id);
  653. void GetQuestTemporaryRewards(int32 quest_id, std::vector<Item*>* items);
  654. void AddQuestTemporaryReward(int32 quest_id, int32 item_id, int16 item_count);
  655. bool CheckQuestRequired(Spawn* spawn);
  656. void AddQuestRequiredSpawn(Spawn* spawn, int32 quest_id);
  657. void AddHistoryRequiredSpawn(Spawn* spawn, int32 event_id);
  658. int16 spawn_index;
  659. int32 spawn_id;
  660. int8 tutorial_step;
  661. map<int32, vector<int32>*> player_spawn_quests_required;
  662. map<int32, vector<int32>*> player_spawn_history_required;
  663. Mutex m_playerSpawnQuestsRequired;
  664. Mutex m_playerSpawnHistoryRequired;
  665. bool HasQuestBeenCompleted(int32 quest_id);
  666. int32 GetQuestCompletedCount(int32 quest_id);
  667. void AddCompletedQuest(Quest* quest);
  668. bool HasActiveQuest(int32 quest_id);
  669. bool HasAnyQuest(int32 quest_id);
  670. map<int32, Quest*> pending_quests;
  671. map<int32, Quest*> player_quests;
  672. map<int32, Quest*>* GetPlayerQuests();
  673. map<int32, Quest*>* GetCompletedPlayerQuests();
  674. void SetFactionValue(int32 faction_id, sint32 value){
  675. factions.SetFactionValue(faction_id, value);
  676. }
  677. PlayerFaction* GetFactions(){
  678. return &factions;
  679. }
  680. vector<int32> GetQuestIDs();
  681. map<int32, int16> macro_icons;
  682. bool HasPendingLootItems(int32 id);
  683. bool HasPendingLootItem(int32 id, int32 item_id);
  684. vector<Item*>* GetPendingLootItems(int32 id);
  685. void RemovePendingLootItem(int32 id, int32 item_id);
  686. void RemovePendingLootItems(int32 id);
  687. void AddPendingLootItems(int32 id, vector<Item*>* items);
  688. int16 GetTierUp(int16 tier);
  689. bool HasSpell(int32 spell_id, int8 tier = 255, bool include_higher_tiers = false, bool include_possible_scribe = false);
  690. bool HasRecipeBook(int32 recipe_id);
  691. void AddPlayerStatistic(int32 stat_id, sint32 stat_value, int32 stat_date);
  692. void UpdatePlayerStatistic(int32 stat_id, sint32 stat_value, bool overwrite = false);
  693. sint64 GetPlayerStatisticValue(int32 stat_id);
  694. void WritePlayerStatistics();
  695. //PlayerGroup* GetGroup();
  696. void SetGroup(PlayerGroup* group);
  697. bool IsGroupMember(Entity* player);
  698. void SetGroupInformation(PacketStruct* packet);
  699. void ResetSavedSpawns();
  700. bool IsReturningFromLD();
  701. void SetReturningFromLD(bool val);
  702. bool CheckLevelStatus(int16 new_level);
  703. int16 GetLastMovementActivity();
  704. void DestroyQuests();
  705. string GetAwayMessage() const { return away_message; }
  706. void SetAwayMessage(string val) { away_message = val; }
  707. void SetRangeAttack(bool val);
  708. bool GetRangeAttack();
  709. bool AddMail(Mail* mail);
  710. MutexMap<int32, Mail*>* GetMail();
  711. Mail* GetMail(int32 mail_id);
  712. void DeleteMail(bool from_database = false);
  713. void DeleteMail(int32 mail_id, bool from_database = false);
  714. CharacterInstances* GetCharacterInstances() { return &character_instances; }
  715. void SetIsTracking(bool val) { is_tracking = val; }
  716. bool GetIsTracking() const { return is_tracking; }
  717. void SetBiography(string new_biography) { biography = new_biography; }
  718. string GetBiography() const { return biography; }
  719. void SetPlayerAdventureClass(int8 new_class);
  720. void SetGuild(Guild* new_guild) { guild = new_guild; }
  721. Guild* GetGuild() { return guild; }
  722. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  723. SkillBonus* GetSkillBonus(int32 spell_id);
  724. virtual void RemoveSkillBonus(int32 spell_id);
  725. virtual bool CanSeeInvis(Entity* target);
  726. bool CheckChangeInvisHistory(Entity* target);
  727. void UpdateTargetInvisHistory(int32 targetID, bool canSeeStatus);
  728. void RemoveTargetInvisHistory(int32 targetID);
  729. bool HasFreeBankSlot();
  730. int8 FindFreeBankSlot();
  731. PlayerCollectionList * GetCollectionList() { return &collection_list; }
  732. PlayerRecipeList * GetRecipeList() { return &recipe_list; }
  733. PlayerRecipeBookList * GetRecipeBookList() { return &recipebook_list; }
  734. PlayerAchievementList * GetAchievementList() { return &achievement_list; }
  735. PlayerAchievementUpdateList * GetAchievementUpdateList() { return &achievement_update_list; }
  736. void SetPendingCollectionReward(Collection *collection) { pending_collection_reward = collection; }
  737. Collection * GetPendingCollectionReward() { return pending_collection_reward; }
  738. void AddPendingSelectableItemReward(int32 source_id, Item* item) {
  739. if (pending_selectable_item_rewards.count(source_id) == 0)
  740. pending_selectable_item_rewards[source_id] = vector<Item*>();
  741. pending_selectable_item_rewards[source_id].push_back(item);
  742. }
  743. void AddPendingItemReward(Item* item) {
  744. pending_item_rewards.push_back(item);
  745. }
  746. bool HasPendingItemRewards() { return (pending_item_rewards.size() > 0 || pending_selectable_item_rewards.size() > 0); }
  747. vector<Item*> GetPendingItemRewards() { return pending_item_rewards; }
  748. map<int32, Item*> GetPendingSelectableItemReward(int32 item_id) { //since the client sends the selected item id, we need to have the associated source and remove all of them. Yes, there is an edge case if multiple sources have the same Item in them, but limited on what the client sends (just a single item id)
  749. map<int32, Item*> ret;
  750. if (pending_selectable_item_rewards.size() > 0) {
  751. map<int32, vector<Item*>>::iterator map_itr;
  752. for (map_itr = pending_selectable_item_rewards.begin(); map_itr != pending_selectable_item_rewards.end(); map_itr++) {
  753. vector<Item*>::iterator itr;
  754. for (itr = map_itr->second.begin(); itr != map_itr->second.end(); itr++) {
  755. if ((*itr)->details.item_id == item_id) {
  756. ret[map_itr->first] = *itr;
  757. break;
  758. }
  759. }
  760. if (ret.size() > 0)
  761. break;
  762. }
  763. }
  764. return map<int32, Item*>();
  765. }
  766. void ClearPendingSelectableItemRewards(int32 source_id, bool all = false) {
  767. if (pending_selectable_item_rewards.size() > 0) {
  768. map<int32, vector<Item*>>::iterator map_itr;
  769. if (all) {
  770. for (map_itr = pending_selectable_item_rewards.begin(); map_itr != pending_selectable_item_rewards.end(); map_itr++) {
  771. vector<Item*>::iterator itr;
  772. for (itr = map_itr->second.begin(); itr != map_itr->second.end(); itr++) {
  773. safe_delete(*itr);
  774. }
  775. }
  776. pending_selectable_item_rewards.clear();
  777. }
  778. else {
  779. if (pending_selectable_item_rewards.count(source_id) > 0) {
  780. vector<Item*>::iterator itr;
  781. for (itr = pending_selectable_item_rewards[source_id].begin(); itr != pending_selectable_item_rewards[source_id].end(); itr++) {
  782. safe_delete(*itr);
  783. }
  784. pending_selectable_item_rewards.erase(source_id);
  785. }
  786. }
  787. }
  788. }
  789. void ClearPendingItemRewards() { //the client doesn't send any reference to where the pending rewards came from, so if they collect one, we should just them all of them at once
  790. if (pending_item_rewards.size() > 0) {
  791. vector<Item*>::iterator itr;
  792. for (itr = pending_item_rewards.begin(); itr != pending_item_rewards.end(); itr++) {
  793. safe_delete(*itr);
  794. }
  795. pending_item_rewards.clear();
  796. }
  797. }
  798. enum DELETE_BOOK_TYPE {
  799. DELETE_TRADESKILLS = 1,
  800. DELETE_SPELLS = 2,
  801. DELETE_COMBAT_ART = 4,
  802. DELETE_ABILITY = 8,
  803. DELETE_NOT_SHOWN = 16
  804. };
  805. void DeleteSpellBook(int8 type_selection = 0);
  806. void RemoveSpellBookEntry(int32 spell_id, bool remove_passives_from_list = true);
  807. void ResortSpellBook(int32 sort_by, int32 order, int32 pattern, int32 maxlvl_only, int32 book_type);
  808. void GetSpellBookSlotSort(int32 pattern, int32* i, int8* page_book_count, int32* last_start_point);
  809. static bool SortSpellEntryByName(SpellBookEntry* s1, SpellBookEntry* s2);
  810. static bool SortSpellEntryByCategory(SpellBookEntry* s1, SpellBookEntry* s2);
  811. static bool SortSpellEntryByLevel(SpellBookEntry* s1, SpellBookEntry* s2);
  812. static bool SortSpellEntryByNameReverse(SpellBookEntry* s1, SpellBookEntry* s2);
  813. static bool SortSpellEntryByCategoryReverse(SpellBookEntry* s1, SpellBookEntry* s2);
  814. static bool SortSpellEntryByLevelReverse(SpellBookEntry* s1, SpellBookEntry* s2);
  815. int8 GetSpellSlot(int32 spell_id);
  816. void AddTitle(sint32 title_id, const char *name, int8 prefix, bool save_needed = false);
  817. void AddAAEntry(int16 template_id, int8 tab_id, int32 aa_id, int16 order, int8 treeid);
  818. PlayerTitlesList* GetPlayerTitles() { return &player_titles_list; }
  819. void AddLanguage(int32 id, const char *name, bool save_needed = false);
  820. PlayerLanguagesList* GetPlayerLanguages() { return &player_languages_list; }
  821. bool HasLanguage(int32 id);
  822. bool HasLanguage(const char* name);
  823. bool CanReceiveQuest(int32 quest_id, int8* ret = 0);
  824. float GetBoatX() { if (info) return info->GetBoatX(); return 0; }
  825. float GetBoatY() { if (info) return info->GetBoatY(); return 0; }
  826. float GetBoatZ() { if (info) return info->GetBoatZ(); return 0; }
  827. int32 GetBoatSpawn() { if (info) return info->GetBoatSpawn(); return 0; }
  828. void SetBoatX(float x) { if (info) info->SetBoatX(x); }
  829. void SetBoatY(float y) { if (info) info->SetBoatY(y); }
  830. void SetBoatZ(float z) { if (info) info->SetBoatZ(z); }
  831. void SetBoatSpawn(Spawn* boat) { if (info) info->SetBoatSpawn(boat); }
  832. Mutex* GetGroupBuffMutex();
  833. void SetPendingDeletion(bool val) { pending_deletion = val; }
  834. bool GetPendingDeletion() { return pending_deletion; }
  835. float GetPosPacketSpeed() { return pos_packet_speed; }
  836. bool ControlFlagsChanged();
  837. void SetPlayerControlFlag(int8 param, int8 param_value, bool is_active);
  838. void SendControlFlagUpdates(Client* client);
  839. /// <summary>Casts all the passive spells for the player, only call after zoning is complete.</summary>
  840. void ApplyPassiveSpells();
  841. /// <summary>Removes all passive spell effects from the player and clears the passive list</summary>
  842. void RemoveAllPassives();
  843. /// <summary>Gets the current recipie ID</summary>
  844. int32 GetCurrentRecipe() { return current_recipe; }
  845. /// <summary>Sets the current recipie ID</summary>
  846. /// <param name="val">Id of the new recipe</param>
  847. void SetCurrentRecipe(int32 val) { current_recipe = val; }
  848. /// <summary>Reset the pet window info</summary>
  849. void ResetPetInfo();
  850. void ProcessCombat();
  851. /* Character history stuff */
  852. /// <summary>Adds a new history event to the player</summary>
  853. /// <param name="type">The history type</param>
  854. /// <param name="subtype">The history sub type</param>
  855. /// <param name="value">The first history value</param>
  856. /// <param name="value2">The second history value</param>
  857. void UpdatePlayerHistory(int8 type, int8 subtype, int32 value, int32 value2 = 0);
  858. /// <summary>Checks to see if the player has discovered the location</summary>
  859. /// <param name="locationID">The ID of the location to check</param>
  860. /// <returns>True if the player has discovered the location</returns>
  861. bool DiscoveredLocation(int32 locationID);
  862. /// <summary>Load the players history from the database</summary>
  863. /// <param name="type">The history type</param>
  864. /// <param name="subtype">The history sub type</param>
  865. /// <param name="hd">The history data</param>
  866. void LoadPlayerHistory(int8 type, int8 subtype, HistoryData* hd);
  867. /// <summary>Save the player's history to the database</summary>
  868. void SaveHistory();
  869. /* New functions for spell locking and unlocking*/
  870. /// <summary>Lock all Spells, Combat arts, and Abilities (not trade skill spells)</summary>
  871. void LockAllSpells();
  872. /// <summary>Unlocks all Spells, Combat arts, and Abilities (not trade skill spells)</summary>
  873. void UnlockAllSpells(bool modify_recast = false, Spell* exception = 0);
  874. /// <summary>Locks the given spell as well as all spells with a shared timer</summary>
  875. void LockSpell(Spell* spell, int16 recast);
  876. /// <summary>Unlocks the given spell as well as all spells with shared timers</summary>
  877. void UnlockSpell(Spell* spell);
  878. /// <summary>Locks all ts spells and unlocks all normal spells</summary>
  879. void LockTSSpells();
  880. /// <summary>Unlocks all ts spells and locks all normal spells</summary>
  881. void UnlockTSSpells();
  882. /// <summary>Queue the given spell</summary>
  883. void QueueSpell(Spell* spell);
  884. /// <summary>Unqueue the given spell</summary>
  885. void UnQueueSpell(Spell* spell);
  886. ///<summary>Get all the spells the player has with the given id</summary>
  887. vector<Spell*> GetSpellBookSpellsByTimer(Spell* spell, int32 timerID);
  888. PacketStruct* GetQuestJournalPacket(Quest* quest, int16 version, int32 crc, bool updated = true);
  889. void SetSpawnInfoStruct(PacketStruct* packet) { safe_delete(spawn_info_struct); spawn_info_struct = packet; }
  890. void SetSpawnVisStruct(PacketStruct* packet) { safe_delete(spawn_vis_struct); spawn_vis_struct = packet; }
  891. void SetSpawnPosStruct(PacketStruct* packet) { safe_delete(spawn_pos_struct); spawn_pos_struct = packet; }
  892. void SetSpawnHeaderStruct(PacketStruct* packet) { safe_delete(spawn_header_struct); spawn_header_struct = packet; }
  893. void SetSpawnFooterStruct(PacketStruct* packet) { safe_delete(spawn_footer_struct); spawn_footer_struct = packet; }
  894. void SetSignFooterStruct(PacketStruct* packet) { safe_delete(sign_footer_struct); sign_footer_struct = packet; }
  895. void SetWidgetFooterStruct(PacketStruct* packet) { safe_delete(widget_footer_struct); widget_footer_struct = packet; }
  896. PacketStruct* GetSpawnInfoStruct() { return spawn_info_struct; }
  897. PacketStruct* GetSpawnVisStruct() { return spawn_vis_struct; }
  898. PacketStruct* GetSpawnPosStruct() { return spawn_pos_struct; }
  899. PacketStruct* GetSpawnHeaderStruct() { return spawn_header_struct; }
  900. PacketStruct* GetSpawnFooterStruct() { return spawn_footer_struct; }
  901. PacketStruct* GetSignFooterStruct() { return sign_footer_struct; }
  902. PacketStruct* GetWidgetFooterStruct() { return widget_footer_struct; }
  903. Mutex info_mutex;
  904. Mutex pos_mutex;
  905. Mutex vis_mutex;
  906. Mutex index_mutex;
  907. Mutex spawn_mutex;
  908. mutable std::shared_mutex spawn_aggro_range_mutex;
  909. void SetTempMount(int32 id) { tmp_mount_model = id; }
  910. int32 GetTempMount() { return tmp_mount_model; }
  911. void SetTempMountColor(EQ2_Color* color) { tmp_mount_color = *color; }
  912. EQ2_Color GetTempMountColor() { return tmp_mount_color; }
  913. void SetTempMountSaddleColor(EQ2_Color* color) { tmp_mount_saddle_color = *color; }
  914. EQ2_Color GetTempMountSaddleColor() { return tmp_mount_saddle_color; }
  915. void LoadLUAHistory(int32 event_id, LUAHistory* history);
  916. void SaveLUAHistory();
  917. void UpdateLUAHistory(int32 event_id, int32 value, int32 value2);
  918. LUAHistory* GetLUAHistory(int32 event_id);
  919. bool HasGMVision() { return gm_vision; }
  920. void SetGMVision(bool val) { gm_vision = val; }
  921. void StopCombat(int8 type=0) {
  922. switch(type)
  923. {
  924. case 2:
  925. SetRangeAttack(false);
  926. InCombat(false, true);
  927. break;
  928. default:
  929. InCombat(false);
  930. InCombat(false, true);
  931. SetRangeAttack(false);
  932. break;
  933. }
  934. }
  935. NPC* InstantiateSpiritShard(float origX, float origY, float origZ, float origHeading, int32 origGridID, ZoneServer* origZone);
  936. void DismissAllPets();
  937. void SaveSpellEffects();
  938. void SetSaveSpellEffects(bool val) { stop_save_spell_effects = val; }
  939. AppearanceData SavedApp;
  940. CharFeatures SavedFeatures;
  941. bool custNPC;
  942. Entity* custNPCTarget;
  943. // bot index, spawn id
  944. map<int32, int32> SpawnedBots;
  945. bool StopSaveSpellEffects() { return stop_save_spell_effects; }
  946. void MentorTarget();
  947. void SetMentorStats(int32 effective_level, int32 target_char_id = 0, bool update_stats = true);
  948. bool ResetMentorship() {
  949. bool mentorship_status = reset_mentorship;
  950. if(mentorship_status)
  951. {
  952. SetMentorStats(GetLevel());
  953. }
  954. reset_mentorship = false;
  955. return mentorship_status;
  956. }
  957. void EnableResetMentorship() {
  958. reset_mentorship = true;
  959. }
  960. bool SerializeItemPackets(EquipmentItemList* equipList, vector<EQ2Packet*>* packets, Item* item, int16 version, Item* to_item = 0);
  961. void AddGMVisualFilter(int32 filter_type, int32 filter_value, char* filter_search_str, int16 visual_tag);
  962. int16 MatchGMVisualFilter(int32 filter_type, int32 filter_value, char* filter_search_str, bool in_vismutex_lock = false);
  963. void ClearGMVisualFilters();
  964. int GetPVPAlignment();
  965. int32 GetCurrentLanguage() { return current_language_id; }
  966. void SetCurrentLanguage(int32 language_id) { current_language_id = language_id; }
  967. void SetActiveReward(bool val) { active_reward = val; }
  968. bool IsActiveReward() { return active_reward; }
  969. bool IsSpawnInRangeList(int32 spawn_id);
  970. void SetSpawnInRangeList(int32 spawn_id, bool in_range);
  971. void ProcessSpawnRangeUpdates();
  972. void CalculatePlayerHPPower(int16 new_level = 0);
  973. bool IsAllowedCombatEquip(int8 slot = 255, bool send_message = false);
  974. void SetActiveFoodUniqueID(int32 unique_id, bool update_db = true);
  975. void SetActiveDrinkUniqueID(int32 unique_id, bool update_db = true);
  976. int32 GetActiveFoodUniqueID() { return active_food_unique_id; }
  977. int32 GetActiveDrinkUniqueID() { return active_drink_unique_id; }
  978. Mutex MPlayerQuests;
  979. float pos_packet_speed;
  980. map <int8, map <int8, vector<TraitData*> > >* SortedTraitList;
  981. map <int8, vector<TraitData*> >* ClassTraining;
  982. map <int8, vector<TraitData*> >* RaceTraits;
  983. map <int8, vector<TraitData*> >* InnateRaceTraits;
  984. map <int8, vector<TraitData*> >* FocusEffects;
  985. mutable std::shared_mutex trait_mutex;
  986. std::atomic<bool> need_trait_update;
  987. void InitXPTable();
  988. map<int8, int32> m_levelXPReq;
  989. mutable std::shared_mutex spell_packet_update_mutex;
  990. mutable std::shared_mutex raid_update_mutex;
  991. private:
  992. bool reset_mentorship;
  993. bool range_attack;
  994. int16 last_movement_activity;
  995. bool returning_from_ld;
  996. PlayerGroup* group;
  997. float test_x;
  998. float test_y;
  999. float test_z;
  1000. int32 test_time;
  1001. map<int32, map<int32, bool> > pending_loot_items;
  1002. Mutex MSpellsBook;
  1003. Mutex MRecipeBook;
  1004. map<Spawn*, bool> current_quest_flagged;
  1005. PlayerFaction factions;
  1006. map<int32, Quest*> completed_quests;
  1007. std::atomic<bool> charsheet_changed;
  1008. std::atomic<bool> raidsheet_changed;
  1009. std::atomic<bool> hassent_raid;
  1010. map<int32, string> spawn_vis_packet_list;
  1011. map<int32, string> spawn_info_packet_list;
  1012. map<int32, string> spawn_pos_packet_list;
  1013. map<int32, int8> spawn_packet_sent;
  1014. map<int32, SpawnQueueState*> spawn_state_list;
  1015. uchar* movement_packet;
  1016. uchar* old_movement_packet;
  1017. uchar* spell_orig_packet;
  1018. uchar* spell_xor_packet;
  1019. int16 spell_count;
  1020. uchar* raid_orig_packet;
  1021. uchar* raid_xor_packet;
  1022. //float speed;
  1023. int16 target_id;
  1024. Spawn* combat_target;
  1025. int32 char_id;
  1026. bool quickbar_updated;
  1027. bool resurrecting;
  1028. PlayerInfo* info;
  1029. vector<SpellBookEntry*> spells;
  1030. vector<QuickBarItem*> quickbar_items;
  1031. map<int32, Statistic*> statistics;
  1032. void RemovePlayerStatistics();
  1033. map<string, int8> friend_list;
  1034. map<string, int8> ignore_list;
  1035. bool pending_deletion;
  1036. PlayerControlFlags control_flags;
  1037. map<int32, bool> target_invis_history;
  1038. // JA: POI Discoveries
  1039. map<int32, vector<int32> > players_poi_list;
  1040. // Jabantiz: Passive spell list, just stores spell id's
  1041. vector<int32> passive_spells;
  1042. /// <summary>Adds a new passive spell to the list</summary>
  1043. /// <param name='id'>Spell id to add</param>
  1044. /// <param name='tier'>Tier of spell to add</param>
  1045. void AddPassiveSpell(int32 id, int8 tier);
  1046. /// <summary>Removes a passive spell from the list</summary>
  1047. /// <param name='id'>Spell id to remove</param>
  1048. /// <param name='tier'>Tier of spell to remove</param>
  1049. /// <param name='remove_from_list'>Remove the spell from this players passive list, default true</param>
  1050. void RemovePassive(int32 id, int8 tier, bool remove_from_list = true);
  1051. CharacterInstances character_instances;
  1052. string away_message;
  1053. string biography;
  1054. MutexMap<int32, Mail*> mail_list;
  1055. bool is_tracking;
  1056. Guild* guild;
  1057. PlayerCollectionList collection_list;
  1058. Collection * pending_collection_reward;
  1059. vector<Item*> pending_item_rewards;
  1060. map<int32, vector<Item*>> pending_selectable_item_rewards;
  1061. PlayerTitlesList player_titles_list;
  1062. PlayerRecipeList recipe_list;
  1063. PlayerLanguagesList player_languages_list;
  1064. PlayerRecipeBookList recipebook_list;
  1065. PlayerAchievementList achievement_list;
  1066. PlayerAchievementUpdateList achievement_update_list;
  1067. // Need to keep track of the recipe the player is crafting as not all crafting packets have this info
  1068. int32 current_recipe;
  1069. void HandleHistoryNone(int8 subtype, int32 value, int32 value2);
  1070. void HandleHistoryDeath(int8 subtype, int32 value, int32 value2);
  1071. void HandleHistoryDiscovery(int8 subtype, int32 value, int32 value2);
  1072. void HandleHistoryXP(int8 subtype, int32 value, int32 value2);
  1073. /// <summary></summary>
  1074. void ModifySpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  1075. void AddSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  1076. void RemoveSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  1077. void SetSpellEntryRecast(SpellBookEntry* spell, bool modify_recast, int16 recast);
  1078. // void InitXPTable();
  1079. // map<int8, int32> m_levelXPReq;
  1080. //The following variables are for serializing spawn packets
  1081. PacketStruct* spawn_pos_struct;
  1082. PacketStruct* spawn_info_struct;
  1083. PacketStruct* spawn_vis_struct;
  1084. PacketStruct* spawn_header_struct;
  1085. PacketStruct* spawn_footer_struct;
  1086. PacketStruct* sign_footer_struct;
  1087. PacketStruct* widget_footer_struct;
  1088. uchar* spawn_tmp_vis_xor_packet;
  1089. uchar* spawn_tmp_pos_xor_packet;
  1090. uchar* spawn_tmp_info_xor_packet;
  1091. int32 vis_xor_size;
  1092. int32 pos_xor_size;
  1093. int32 info_xor_size;
  1094. // Character history, map<type, map<subtype, vector<data> > >
  1095. map<int8, map<int8, vector<HistoryData*> > > m_characterHistory;
  1096. map<int32, LUAHistory*> m_charLuaHistory;
  1097. Mutex mLUAHistory;
  1098. int32 tmp_mount_model;
  1099. EQ2_Color tmp_mount_color;
  1100. EQ2_Color tmp_mount_saddle_color;
  1101. bool gm_vision;
  1102. bool stop_save_spell_effects;
  1103. map<int32, Spawn*> player_spawn_id_map;
  1104. map<Spawn*, int32> player_spawn_reverse_id_map;
  1105. map<int32, bool> player_aggro_range_spawns;
  1106. bool all_spells_locked;
  1107. Timer lift_cooldown;
  1108. vector<GMTagFilter> gm_visual_filters;
  1109. int32 current_language_id;
  1110. bool active_reward;
  1111. Quest* GetAnyQuest(int32 quest_id);
  1112. Quest* GetCompletedQuest(int32 quest_id);
  1113. std::atomic<int32> active_food_unique_id;
  1114. std::atomic<int32> active_drink_unique_id;
  1115. };
  1116. #pragma pack()
  1117. #endif