9
3

Player.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  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 <algorithm>
  31. #include <set>
  32. #define CF_COMBAT_EXPERIENCE_ENABLED 0
  33. #define CF_ENABLE_CHANGE_LASTNAME 1
  34. #define CF_FOOD_AUTO_CONSUME 2
  35. #define CF_DRINK_AUTO_CONSUME 3
  36. #define CF_AUTO_ATTACK 4
  37. #define CF_RANGED_AUTO_ATTACK 5
  38. #define CF_QUEST_EXPERIENCE_ENABLED 6
  39. #define CF_CHASE_CAMERA_MAYBE 7
  40. #define CF_100 8
  41. #define CF_200 9
  42. #define CF_IS_SITTING 10 /*CAN'T CAST OR ATTACK*/
  43. #define CF_800 11
  44. #define CF_ANONYMOUS 12
  45. #define CF_ROLEPLAYING 13
  46. #define CF_AFK 14
  47. #define CF_LFG 15
  48. #define CF_LFW 16
  49. #define CF_HIDE_HOOD 17
  50. #define CF_HIDE_HELM 18
  51. #define CF_SHOW_ILLUSION 19
  52. #define CF_ALLOW_DUEL_INVITES 20
  53. #define CF_ALLOW_TRADE_INVITES 21
  54. #define CF_ALLOW_GROUP_INVITES 22
  55. #define CF_ALLOW_RAID_INVITES 23
  56. #define CF_ALLOW_GUILD_INVITES 24
  57. #define CF_2000000 25
  58. #define CF_4000000 26
  59. #define CF_DEFENSE_SKILLS_AT_MAX_QUESTIONABLE 27
  60. #define CF_SHOW_GUILD_HERALDRY 28
  61. #define CF_SHOW_CLOAK 29
  62. #define CF_IN_PVP 30
  63. #define CF_IS_HATED 31
  64. #define CF2_1 32
  65. #define CF2_2 33
  66. #define CF2_4 34
  67. #define CF2_ALLOW_LON_INVITES 35
  68. #define CF2_SHOW_RANGED 36
  69. #define CF2_ALLOW_VOICE_INVITES 37
  70. #define CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED 38
  71. #define CF2_80 39
  72. #define CF2_100 40 /* hide achievments*/
  73. #define CF2_200 41
  74. #define CF2_400 42
  75. #define CF2_800 43 /* enable facebook updates*/
  76. #define CF2_1000 44 /* enable twitter updates*/
  77. #define CF2_2000 45 /* enable eq2 player updates */
  78. #define CF2_4000 46 /*eq2 players, link to alt chars */
  79. #define CF2_8000 47
  80. #define CF2_10000 48
  81. #define CF2_20000 49
  82. #define CF2_40000 50
  83. #define CF2_80000 51
  84. #define CF2_100000 52
  85. #define CF2_200000 53
  86. #define CF2_400000 54
  87. #define CF2_800000 55
  88. #define CF2_1000000 56
  89. #define CF2_2000000 57
  90. #define CF2_4000000 58
  91. #define CF2_8000000 59
  92. #define CF2_10000000 60
  93. #define CF2_20000000 61
  94. #define CF2_40000000 62
  95. #define CF2_80000000 63
  96. #define CF_MAXIMUM_FLAG 63
  97. #define CF_HIDE_STATUS 49 /* !!FORTESTING ONLY!! */
  98. #define CF_GM_HIDDEN 50 /* !!FOR TESTING ONLY!! */
  99. #define UPDATE_ACTIVITY_FALLING 0
  100. #define UPDATE_ACTIVITY_RUNNING 128
  101. #define UPDATE_ACTIVITY_RIDING_BOAT 256
  102. #define UPDATE_ACTIVITY_JUMPING 1024
  103. #define UPDATE_ACTIVITY_IN_WATER_ABOVE 6144
  104. #define UPDATE_ACTIVITY_IN_WATER_BELOW 6272
  105. #define UPDATE_ACTIVITY_SITING 6336
  106. #define UPDATE_ACTIVITY_DROWNING 14464
  107. #define UPDATE_ACTIVITY_DROWNING2 14336
  108. #define UPDATE_ACTIVITY_FALLING_AOM 16384
  109. #define UPDATE_ACTIVITY_RIDING_BOAT_AOM 256
  110. #define UPDATE_ACTIVITY_RUNNING_AOM 16512
  111. #define UPDATE_ACTIVITY_JUMPING_AOM 17408
  112. #define UPDATE_ACTIVITY_MOVE_WATER_BELOW_AOM 22528
  113. #define UPDATE_ACTIVITY_MOVE_WATER_ABOVE_AOM 22656
  114. #define UPDATE_ACTIVITY_SITTING_AOM 22720
  115. #define UPDATE_ACTIVITY_DROWNING_AOM 30720
  116. #define UPDATE_ACTIVITY_DROWNING2_AOM 30848
  117. #define NUM_MAINTAINED_EFFECTS 30
  118. #define NUM_SPELL_EFFECTS 45
  119. /* Character History Type Defines */
  120. #define HISTORY_TYPE_NONE 0
  121. #define HISTORY_TYPE_DEATH 1
  122. #define HISTORY_TYPE_DISCOVERY 2
  123. #define HISTORY_TYPE_XP 3
  124. /* Spell Status */
  125. #define SPELL_STATUS_QUEUE 4
  126. #define SPELL_STATUS_LOCK 66
  127. /* Character History Sub Type Defines */
  128. #define HISTORY_SUBTYPE_NONE 0
  129. #define HISTORY_SUBTYPE_ADVENTURE 1
  130. #define HISTORY_SUBTYPE_TRADESKILL 2
  131. #define HISTORY_SUBTYPE_QUEST 3
  132. #define HISTORY_SUBTYPE_AA 4
  133. #define HISTORY_SUBTYPE_ITEM 5
  134. #define HISTORY_SUBTYPE_LOCATION 6
  135. /// <summary>Character history data, should match the `character_history` table in the DB</summary>
  136. struct HistoryData {
  137. int32 Value;
  138. int32 Value2;
  139. char Location[200];
  140. int32 EventID;
  141. int32 EventDate;
  142. bool needs_save;
  143. };
  144. /// <summary>History set through the LUA system</summary>
  145. struct LUAHistory {
  146. int32 Value;
  147. int32 Value2;
  148. bool SaveNeeded;
  149. };
  150. struct SpellBookEntry{
  151. int32 spell_id;
  152. int8 tier;
  153. int32 type;
  154. sint32 slot;
  155. int32 recast_available;
  156. int8 status;
  157. int16 recast;
  158. int32 timer;
  159. bool save_needed;
  160. bool in_use;
  161. bool in_remiss;
  162. Player* player;
  163. bool visible;
  164. };
  165. struct GMTagFilter {
  166. int32 filter_type;
  167. int32 filter_value;
  168. char filter_search_criteria[256];
  169. int16 visual_tag;
  170. };
  171. enum GMTagFilterType {
  172. GMFILTERTYPE_NONE=0,
  173. GMFILTERTYPE_FACTION=1,
  174. GMFILTERTYPE_SPAWNGROUP=2,
  175. GMFILTERTYPE_RACE=3,
  176. GMFILTERTYPE_GROUNDSPAWN=4
  177. };
  178. enum SpawnState{
  179. SPAWN_STATE_NONE=0,
  180. SPAWN_STATE_SENDING=1,
  181. SPAWN_STATE_SENT_WAIT=2,
  182. SPAWN_STATE_SENT=3,
  183. SPAWN_STATE_REMOVING=4,
  184. SPAWN_STATE_REMOVING_SLEEP=5,
  185. SPAWN_STATE_REMOVED=6
  186. };
  187. #define QUICKBAR_NORMAL 1
  188. #define QUICKBAR_INV_SLOT 2
  189. #define QUICKBAR_MACRO 3
  190. #define QUICKBAR_TEXT_CMD 4
  191. #define QUICKBAR_ITEM 6
  192. #define EXP_DISABLED_STATE 0
  193. #define EXP_ENABLED_STATE 1
  194. #define MELEE_COMBAT_STATE 16
  195. #define RANGE_COMBAT_STATE 32
  196. struct QuickBarItem{
  197. bool deleted;
  198. int32 hotbar;
  199. int32 slot;
  200. int32 type;
  201. int16 icon;
  202. int16 icon_type;
  203. int32 id;
  204. int8 tier;
  205. int32 unique_id;
  206. EQ2_16BitString text;
  207. };
  208. struct LoginAppearances {
  209. bool deleted;
  210. int16 equip_type;
  211. int8 red;
  212. int8 green;
  213. int8 blue;
  214. int8 h_red;
  215. int8 h_green;
  216. int8 h_blue;
  217. bool update_needed;
  218. };
  219. struct SpawnQueueState {
  220. Timer spawn_state_timer;
  221. int16 index_id;
  222. };
  223. struct QuestRewardData {
  224. int32 quest_id;
  225. bool is_temporary;
  226. std::string description;
  227. bool is_collection;
  228. bool has_displayed;
  229. int64 tmp_coin;
  230. int32 tmp_status;
  231. bool db_saved;
  232. int32 db_index;
  233. };
  234. class PlayerLoginAppearance {
  235. public:
  236. PlayerLoginAppearance() { appearanceList = new map<int8, LoginAppearances>; }
  237. ~PlayerLoginAppearance() { }
  238. void AddEquipmentToUpdate(int8 slot_id, LoginAppearances* equip)
  239. {
  240. //LoginAppearances data;
  241. //data.equip_type = equip->equip_type;
  242. //appearanceList[slot_id] = data;
  243. }
  244. void DeleteEquipmentFromUpdate(int8 slot_id, LoginAppearances* equip)
  245. {
  246. //LoginAppearances data;
  247. //data.deleted = equip->deleted;
  248. //data.update_needed = true;
  249. //appearanceList[slot_id] = data;
  250. }
  251. void RemoveEquipmentUpdates()
  252. {
  253. appearanceList->clear();
  254. safe_delete(appearanceList);
  255. }
  256. private:
  257. map<int8, LoginAppearances>* appearanceList;
  258. };
  259. struct InstanceData{
  260. int32 db_id;
  261. int32 instance_id;
  262. int32 zone_id;
  263. int8 zone_instance_type;
  264. string zone_name;
  265. int32 last_success_timestamp;
  266. int32 last_failure_timestamp;
  267. int32 success_lockout_time;
  268. int32 failure_lockout_time;
  269. };
  270. class CharacterInstances {
  271. public:
  272. CharacterInstances();
  273. ~CharacterInstances();
  274. ///<summary>Adds an instance data to the player with the given data</summary>
  275. ///<param name='db_id'>The unique id for this record in the database</param>
  276. ///<param name='instance_id'>The id of the instance</param>
  277. ///<param name='last_success_timestamp'>The success timestamp</param>
  278. ///<param name='last_failure_timestamp'>The failure timestamp</param>
  279. ///<param name='success_lockout_time'>The lockout time, in secs, for completing the instance</param>
  280. ///<param name='failure_lockout_time'>The lockout time, in secs, for failing the instance</param>
  281. ///<param name='zone_id'>The id of the zone</param>
  282. ///<param name='zone_instancetype'>The type of instance of the zone</param>
  283. ///<param name='zone_name'>The name of the zone</param>
  284. 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);
  285. ///<summary>Clears all instance data</summary>
  286. void RemoveInstances();
  287. ///<summary>Removes the instace with the given zone id</summary>
  288. ///<param name='zone_id'>The zone id of the instance to remove</param>
  289. ///<returns>True if the instance was found and removed</returns>
  290. bool RemoveInstanceByZoneID(int32 zone_id);
  291. ///<summary>Removes the instance with the given instance id</summary>
  292. ///<param name='instance_id'>the instance id of the instance to remove</param>
  293. ///<returns>True if instance was found and removed</returns>
  294. bool RemoveInstanceByInstanceID(int32 instance_id);
  295. ///<summary>Gets the instance with the given zone id</summary>
  296. ///<param name='zone_id'>The zone id of the instance to get</param>
  297. ///<returns>InstanceData* of the instance record for the given zone id</returns>
  298. InstanceData* FindInstanceByZoneID(int32 zone_id);
  299. ///<summary>Gets the instance with the given database id</summary>
  300. ///<param name='db_id'>The database id of the instance to get</param>
  301. ///<returns>InstanceData* of the instance record for the given database id</returns>
  302. InstanceData* FindInstanceByDBID(int32 db_id);
  303. ///<summary>Gets the instance with the given instance id</summary>
  304. ///<param name='instance_id'>The instance id of the instance to get</param>
  305. ///<returns>InstanceData* of the instance record for the given instance id</returns>
  306. InstanceData* FindInstanceByInstanceID(int32 instance_id);
  307. ///<summary>Gets a list of all the lockout instances</summary>
  308. vector<InstanceData> GetLockoutInstances();
  309. ///<summary>Gets a list of all the persistent instances</summary>
  310. vector<InstanceData> GetPersistentInstances();
  311. ///<summary>Check the timers for the instances</summary>
  312. ///<param name='player'>player we are checking the timers for</param>
  313. void ProcessInstanceTimers(Player* player);
  314. ///<summary>Gets the total number of instances</summary>
  315. int32 GetInstanceCount();
  316. private:
  317. vector<InstanceData> instanceList;
  318. Mutex m_instanceList;
  319. };
  320. class Player;
  321. struct PlayerGroup;
  322. struct GroupMemberInfo;
  323. struct Statistic;
  324. struct Mail;
  325. class PlayerInfo {
  326. public:
  327. ~PlayerInfo();
  328. PlayerInfo(Player* in_player);
  329. EQ2Packet* serialize(int16 version, int16 modifyPos = 0, int32 modifyValue = 0);
  330. PacketStruct* serialize2(int16 version);
  331. EQ2Packet* serialize3(PacketStruct* packet, int16 version);
  332. EQ2Packet* serializePet(int16 version);
  333. void CalculateXPPercentages();
  334. void CalculateTSXPPercentages();
  335. void SetHouseZone(int32 id);
  336. void SetBindZone(int32 id);
  337. void SetBindX(float x);
  338. void SetBindY(float y);
  339. void SetBindZ(float z);
  340. void SetBindHeading(float heading);
  341. void SetAccountAge(int32 days);
  342. int32 GetHouseZoneID();
  343. int32 GetBindZoneID();
  344. float GetBindZoneX();
  345. float GetBindZoneY();
  346. float GetBindZoneZ();
  347. float GetBindZoneHeading();
  348. float GetBoatX() { return boat_x_offset; }
  349. float GetBoatY() { return boat_y_offset; }
  350. float GetBoatZ() { return boat_z_offset; }
  351. int32 GetBoatSpawn();
  352. void SetBoatX(float x) { boat_x_offset = x; }
  353. void SetBoatY(float y) { boat_y_offset = y; }
  354. void SetBoatZ(float z) { boat_z_offset = z; }
  355. void SetBoatSpawn(Spawn* boat);
  356. void RemoveOldPackets();
  357. private:
  358. int32 house_zone_id;
  359. int32 bind_zone_id;
  360. float bind_x;
  361. float bind_y;
  362. float bind_z;
  363. float bind_heading;
  364. uchar* changes;
  365. uchar* orig_packet;
  366. uchar* pet_changes;
  367. uchar* pet_orig_packet;
  368. InfoStruct* info_struct;
  369. Player* player;
  370. float boat_x_offset;
  371. float boat_y_offset;
  372. float boat_z_offset;
  373. int32 boat_spawn;
  374. };
  375. class PlayerControlFlags{
  376. public:
  377. PlayerControlFlags();
  378. ~PlayerControlFlags();
  379. void SetPlayerControlFlag(int8 param, int8 param_value, bool is_active);
  380. bool ControlFlagsChanged();
  381. void SendControlFlagUpdates(Client* client);
  382. private:
  383. bool flags_changed;
  384. map<int8, map<int8, int8> > flag_changes;
  385. map<int8, map<int8, bool> > current_flags;
  386. Mutex MControlFlags;
  387. Mutex MFlagChanges;
  388. };
  389. enum AddItemType {
  390. NOT_SET = 0,
  391. BUY_FROM_BROKER = 1,
  392. GM_COMMAND = 2
  393. };
  394. class Player : public Entity{
  395. public:
  396. Player();
  397. virtual ~Player();
  398. EQ2Packet* serialize(Player* player, int16 version);
  399. //int8 GetMaxArtLevel(){ return info->GetInfo()->max_art_level; }
  400. //int8 GetArtLevel(){ return info->GetInfo()->art_level; }
  401. Client* GetClient() { return client; }
  402. void SetClient(Client* client) { this->client = client; }
  403. PlayerInfo* GetPlayerInfo();
  404. void SetCharSheetChanged(bool val);
  405. bool GetCharSheetChanged();
  406. void AddFriend(const char* name, bool save);
  407. bool IsFriend(const char* name);
  408. void RemoveFriend(const char* name);
  409. map<string, int8>* GetFriends();
  410. void AddIgnore(const char* name, bool save);
  411. bool IsIgnored(const char* name);
  412. void RemoveIgnore(const char* name);
  413. map<string, int8>* GetIgnoredPlayers();
  414. // JA: POI Discoveries
  415. map<int32, vector<int32> >* GetPlayerDiscoveredPOIs();
  416. void AddPlayerDiscoveredPOI(int32 location_id);
  417. //
  418. EQ2Packet* Move(float x, float y, float z, int16 version, float heading = -1.0f);
  419. /*void SetMaxArtLevel(int8 new_max){
  420. max_art_level = new_max;
  421. }
  422. void SetArtLevel(int8 new_lvl){
  423. art_level = new_lvl;
  424. }*/
  425. bool WasSentSpawn(int32 spawn_id);
  426. bool IsSendingSpawn(int32 spawn_id);
  427. bool IsRemovingSpawn(int32 spawn_id);
  428. bool SetSpawnSentState(Spawn* spawn, SpawnState state);
  429. void CheckSpawnStateQueue();
  430. void SetSideSpeed(float side_speed, bool updateFlags = true) {
  431. SetPos(&appearance.pos.SideSpeed, side_speed, updateFlags);
  432. }
  433. float GetSideSpeed() {
  434. return appearance.pos.SideSpeed;
  435. }
  436. int8 GetTutorialStep() {
  437. return tutorial_step;
  438. }
  439. void SetTutorialStep(int8 val) {
  440. tutorial_step = val;
  441. }
  442. void AddMaintainedSpell(LuaSpell* spell);
  443. void AddSpellEffect(LuaSpell* spell, int32 override_expire_time = 0);
  444. void RemoveMaintainedSpell(LuaSpell* spell);
  445. void RemoveSpellEffect(LuaSpell* spell);
  446. 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);
  447. void RemoveQuickbarItem(int32 bar, int32 slot, bool update = true);
  448. void MoveQuickbarItem(int32 id, int32 new_slot);
  449. void ClearQuickbarItems();
  450. PlayerItemList* GetPlayerItemList();
  451. PlayerItemList item_list;
  452. PlayerSkillList skill_list;
  453. Skill* GetSkillByName(const char* name, bool check_update = false);
  454. Skill* GetSkillByID(int32 skill_id, bool check_update = false);
  455. PlayerSkillList* GetSkills();
  456. bool DamageEquippedItems(int8 amount = 10, Client* client = 0);
  457. vector<EQ2Packet*> EquipItem(int16 index, int16 version, int8 appearance_type, int8 slot_id = 255);
  458. bool CanEquipItem(Item* item, int8 slot);
  459. void SetEquippedItemAppearances();
  460. vector<EQ2Packet*> UnequipItem(int16 index, sint32 bag_id, int8 slot, int16 version, int8 appearance_type = 0, bool send_item_updates = true);
  461. int16 ConvertSlotToClient(int8 slot, int16 version);
  462. int16 ConvertSlotFromClient(int8 slot, int16 version);
  463. int16 GetNumSlotsEquip(int16 version);
  464. int8 GetMaxBagSlots(int16 version);
  465. EQ2Packet* SwapEquippedItems(int8 slot1, int8 slot2, int16 version, int16 equiptype);
  466. EQ2Packet* RemoveInventoryItem(int8 bag_slot, int8 slot);
  467. EQ2Packet* SendInventoryUpdate(int16 version);
  468. EQ2Packet* SendBagUpdate(int32 bag_unique_id, int16 version);
  469. void SendQuestRequiredSpawns(int32 quest_id);
  470. void SendHistoryRequiredSpawns(int32 event_id);
  471. map<int32, Item*>* GetItemList();
  472. map<int32, Item*>* GetBankItemList();
  473. vector<Item*>* GetEquippedItemList();
  474. vector<Item*>* GetAppearanceEquippedItemList();
  475. Quest* SetStepComplete(int32 quest_id, int32 step);
  476. Quest* AddStepProgress(int32 quest_id, int32 step, int32 progress);
  477. int32 GetStepProgress(int32 quest_id, int32 step_id);
  478. Quest* GetQuestByPositionID(int32 list_position_id);
  479. bool AddItem(Item* item, AddItemType type = AddItemType::NOT_SET);
  480. bool AddItemToBank(Item* item);
  481. int16 GetSpellSlotMappingCount();
  482. int16 GetSpellPacketCount();
  483. Quest* GetQuest(int32 quest_id);
  484. bool GetQuestStepComplete(int32 quest_id, int32 step_id);
  485. int16 GetQuestStep(int32 quest_id);
  486. int16 GetTaskGroupStep(int32 quest_id);
  487. int8 GetSpellTier(int32 id);
  488. void SetSpellStatus(Spell* spell, int8 status);
  489. void RemoveSpellStatus(Spell* spell, int8 status);
  490. EQ2Packet* GetSpellBookUpdatePacket(int16 version);
  491. EQ2Packet* GetSpellSlotMappingPacket(int16 version);
  492. int32 GetCharacterID();
  493. void SetCharacterID(int32 new_id);
  494. EQ2Packet* GetQuickbarPacket(int16 version);
  495. vector<QuickBarItem*>* GetQuickbar();
  496. bool UpdateQuickbarNeeded();
  497. void ResetQuickbarNeeded();
  498. void set_character_flag(int flag);
  499. void reset_character_flag(int flag);
  500. void toggle_character_flag(int flag);
  501. bool get_character_flag(int flag);
  502. void AddCoins(int64 val);
  503. bool RemoveCoins(int64 val);
  504. /// <summary>Checks to see if the player has the given amount of coins</summary>
  505. /// <param name="val">Amount of coins to check</param>
  506. /// <returns>True if the player has enough coins</returns>
  507. bool HasCoins(int64 val);
  508. void AddSkill(int32 skill_id, int16 current_val, int16 max_val, bool save_needed = false);
  509. void RemovePlayerSkill(int32 skill_id, bool save = false);
  510. void RemoveSkillFromDB(Skill* skill, bool save = false);
  511. void AddSpellBookEntry(int32 spell_id, int8 tier, sint32 slot, int32 type, int32 timer, bool save_needed = false);
  512. SpellBookEntry* GetSpellBookSpell(int32 spell_id);
  513. vector<SpellBookEntry*>* GetSpellsSaveNeeded();
  514. sint32 GetFreeSpellBookSlot(int32 type);
  515. /// <summary>Get a vector of spell ids for all spells in the spell book for the given skill</summary>
  516. /// <param name='skill_id'>The id of the skill to check</param>
  517. /// <returns>A vector of int32's of the spell id's</returns>
  518. vector<int32> GetSpellBookSpellIDBySkill(int32 skill_id);
  519. void UpdateInventory(int32 bag_id);
  520. EQ2Packet* MoveInventoryItem(sint32 to_bag_id, int16 from_index, int8 new_slot, int8 charges, int8 appearance_type, bool* item_deleted, int16 version = 1);
  521. bool IsPlayer(){ return true; }
  522. MaintainedEffects* GetFreeMaintainedSpellSlot();
  523. MaintainedEffects* GetMaintainedSpell(int32 id);
  524. MaintainedEffects* GetMaintainedSpellBySlot(int8 slot);
  525. MaintainedEffects* GetMaintainedSpells();
  526. SpellEffects* GetFreeSpellEffectSlot();
  527. SpellEffects* GetSpellEffects();
  528. int32 GetCoinsCopper();
  529. int32 GetCoinsSilver();
  530. int32 GetCoinsGold();
  531. int32 GetCoinsPlat();
  532. int32 GetBankCoinsCopper();
  533. int32 GetBankCoinsSilver();
  534. int32 GetBankCoinsGold();
  535. int32 GetBankCoinsPlat();
  536. int32 GetStatusPoints();
  537. float GetXPVitality();
  538. float GetTSXPVitality();
  539. bool AdventureXPEnabled();
  540. bool TradeskillXPEnabled();
  541. void SetNeededXP(int32 val);
  542. void SetNeededXP();
  543. void SetXP(int32 val);
  544. void SetNeededTSXP(int32 val);
  545. void SetNeededTSXP();
  546. void SetTSXP(int32 val);
  547. int32 GetNeededXP();
  548. float GetXPDebt();
  549. int32 GetXP();
  550. int32 GetNeededTSXP();
  551. int32 GetTSXP();
  552. bool AddXP(int32 xp_amount);
  553. bool AddTSXP(int32 xp_amount);
  554. bool DoubleXPEnabled();
  555. float CalculateXP(Spawn* victim);
  556. float CalculateTSXP(int8 level);
  557. void CalculateOfflineDebtRecovery(int32 unix_timestamp);
  558. void InCombat(bool val, bool range = false);
  559. void PrepareIncomingMovementPacket(int32 len, uchar* data, int16 version);
  560. uchar* GetMovementPacketData(){
  561. return movement_packet;
  562. }
  563. void AddSpawnInfoPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  564. uchar* GetSpawnInfoPacketForXOR(int32 spawn_id);
  565. void AddSpawnVisPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  566. uchar* GetSpawnVisPacketForXOR(int32 spawn_id);
  567. void AddSpawnPosPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  568. uchar* GetSpawnPosPacketForXOR(int32 spawn_id);
  569. uchar* GetTempInfoPacketForXOR();
  570. uchar* GetTempVisPacketForXOR();
  571. uchar* GetTempPosPacketForXOR();
  572. uchar* SetTempInfoPacketForXOR(int16 size);
  573. uchar* SetTempVisPacketForXOR(int16 size);
  574. uchar* SetTempPosPacketForXOR(int16 size);
  575. int32 GetTempInfoXorSize() { return info_xor_size; }
  576. int32 GetTempVisXorSize() { return vis_xor_size; }
  577. int32 GetTempPosXorSize() { return pos_xor_size; }
  578. bool CheckPlayerInfo();
  579. void CalculateLocation();
  580. void SetSpawnDeleteTime(int32 id, int32 time);
  581. int32 GetSpawnDeleteTime(int32 id);
  582. void ClearRemovalTimers();
  583. void ClearEverything();
  584. bool IsResurrecting();
  585. void SetResurrecting(bool val);
  586. int8 GetTSArrowColor(int8 level);
  587. Spawn* GetSpawnByIndex(int16 index);
  588. int16 GetIndexForSpawn(Spawn* spawn);
  589. bool WasSpawnRemoved(Spawn* spawn);
  590. void RemoveSpawn(Spawn* spawn, bool delete_spawn = true);
  591. bool ShouldSendSpawn(Spawn* spawn);
  592. Client* client = 0;
  593. void SetLevel(int16 level, bool setUpdateFlags = true);
  594. Spawn* GetSpawnWithPlayerID(int32 id){
  595. Spawn* spawn = 0;
  596. index_mutex.readlock(__FUNCTION__, __LINE__);
  597. if (player_spawn_id_map.count(id) > 0)
  598. spawn = player_spawn_id_map[id];
  599. index_mutex.releasereadlock(__FUNCTION__, __LINE__);
  600. return spawn;
  601. }
  602. int32 GetIDWithPlayerSpawn(Spawn* spawn){
  603. int32 id = 0;
  604. index_mutex.readlock(__FUNCTION__, __LINE__);
  605. if (player_spawn_reverse_id_map.count(spawn) > 0)
  606. id = player_spawn_reverse_id_map[spawn];
  607. index_mutex.releasereadlock(__FUNCTION__, __LINE__);
  608. return id;
  609. }
  610. bool SetSpawnMap(Spawn* spawn);
  611. void SetSpawnMapIndex(Spawn* spawn, int32 index)
  612. {
  613. index_mutex.writelock(__FUNCTION__, __LINE__);
  614. if (player_spawn_id_map.count(index))
  615. player_spawn_id_map[index] = spawn;
  616. else
  617. player_spawn_id_map[index] = spawn;
  618. index_mutex.releasewritelock(__FUNCTION__, __LINE__);
  619. }
  620. int16 SetSpawnMapAndIndex(Spawn* spawn)
  621. {
  622. int16 new_index = 0;
  623. index_mutex.writelock(__FUNCTION__, __LINE__);
  624. spawn_index += 1;
  625. if (spawn_index == 255)
  626. spawn_index += 1; //just so we dont have to worry about overloading
  627. new_index = spawn_index;
  628. player_spawn_id_map[new_index] = spawn;
  629. player_spawn_reverse_id_map[spawn] = new_index;
  630. index_mutex.releasewritelock(__FUNCTION__, __LINE__);
  631. return new_index;
  632. }
  633. PacketStruct* GetQuestJournalPacket(bool all_quests, int16 version, int32 crc, int32 current_quest_id, bool updated = true);
  634. void RemoveQuest(int32 id, bool delete_quest);
  635. vector<Quest*>* CheckQuestsChatUpdate(Spawn* spawn);
  636. vector<Quest*>* CheckQuestsItemUpdate(Item* item);
  637. vector<Quest*>* CheckQuestsLocationUpdate();
  638. vector<Quest*>* CheckQuestsKillUpdate(Spawn* spawn,bool update = true);
  639. bool HasQuestUpdateRequirement(Spawn* spawn);
  640. vector<Quest*>* CheckQuestsSpellUpdate(Spell* spell);
  641. void CheckQuestsCraftUpdate(Item* item, int32 qty);
  642. void CheckQuestsHarvestUpdate(Item* item, int32 qty);
  643. vector<Quest*>* CheckQuestsFailures();
  644. bool CheckQuestRemoveFlag(Spawn* spawn);
  645. int8 CheckQuestFlag(Spawn* spawn);
  646. bool UpdateQuestReward(int32 quest_id, QuestRewardData* qrd);
  647. Quest* PendingQuestAcceptance(int32 quest_id, int32 item_id, bool* quest_exists);
  648. bool AcceptQuestReward(int32 item_id, int32 selectable_item_id);
  649. bool SendQuestStepUpdate(int32 quest_id, int32 quest_step_id, bool display_quest_helper);
  650. void SendQuest(int32 quest_id);
  651. void UpdateQuestCompleteCount(int32 quest_id);
  652. void GetQuestTemporaryRewards(int32 quest_id, std::vector<Item*>* items);
  653. void AddQuestTemporaryReward(int32 quest_id, int32 item_id, int16 item_count);
  654. bool CheckQuestRequired(Spawn* spawn);
  655. void AddQuestRequiredSpawn(Spawn* spawn, int32 quest_id);
  656. void AddHistoryRequiredSpawn(Spawn* spawn, int32 event_id);
  657. int16 spawn_index;
  658. int32 spawn_id;
  659. int8 tutorial_step;
  660. map<int32, vector<int32>*> player_spawn_quests_required;
  661. map<int32, vector<int32>*> player_spawn_history_required;
  662. Mutex m_playerSpawnQuestsRequired;
  663. Mutex m_playerSpawnHistoryRequired;
  664. bool HasQuestBeenCompleted(int32 quest_id);
  665. int32 GetQuestCompletedCount(int32 quest_id);
  666. void AddCompletedQuest(Quest* quest);
  667. bool HasActiveQuest(int32 quest_id);
  668. bool HasAnyQuest(int32 quest_id);
  669. map<int32, Quest*> pending_quests;
  670. map<int32, Quest*> player_quests;
  671. map<int32, Quest*>* GetPlayerQuests();
  672. map<int32, Quest*>* GetCompletedPlayerQuests();
  673. void SetFactionValue(int32 faction_id, sint32 value){
  674. factions.SetFactionValue(faction_id, value);
  675. }
  676. PlayerFaction* GetFactions(){
  677. return &factions;
  678. }
  679. vector<int32> GetQuestIDs();
  680. map<int32, int16> macro_icons;
  681. bool HasPendingLootItems(int32 id);
  682. bool HasPendingLootItem(int32 id, int32 item_id);
  683. vector<Item*>* GetPendingLootItems(int32 id);
  684. void RemovePendingLootItem(int32 id, int32 item_id);
  685. void RemovePendingLootItems(int32 id);
  686. void AddPendingLootItems(int32 id, vector<Item*>* items);
  687. int16 GetTierUp(int16 tier);
  688. bool HasSpell(int32 spell_id, int8 tier = 255, bool include_higher_tiers = false, bool include_possible_scribe = false);
  689. bool HasRecipeBook(int32 recipe_id);
  690. void AddPlayerStatistic(int32 stat_id, sint32 stat_value, int32 stat_date);
  691. void UpdatePlayerStatistic(int32 stat_id, sint32 stat_value, bool overwrite = false);
  692. sint64 GetPlayerStatisticValue(int32 stat_id);
  693. void WritePlayerStatistics();
  694. //PlayerGroup* GetGroup();
  695. void SetGroup(PlayerGroup* group);
  696. bool IsGroupMember(Entity* player);
  697. void SetGroupInformation(PacketStruct* packet);
  698. void ResetSavedSpawns();
  699. bool IsReturningFromLD();
  700. void SetReturningFromLD(bool val);
  701. bool CheckLevelStatus(int16 new_level);
  702. int16 GetLastMovementActivity();
  703. void DestroyQuests();
  704. string GetAwayMessage() const { return away_message; }
  705. void SetAwayMessage(string val) { away_message = val; }
  706. void SetRangeAttack(bool val);
  707. bool GetRangeAttack();
  708. ZoneServer* GetGroupMemberInZone(int32 zone_id);
  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. Mutex MPlayerQuests;
  973. float pos_packet_speed;
  974. private:
  975. bool reset_mentorship;
  976. bool range_attack;
  977. int16 last_movement_activity;
  978. bool returning_from_ld;
  979. PlayerGroup* group;
  980. float test_x;
  981. float test_y;
  982. float test_z;
  983. int32 test_time;
  984. map<int32, map<int32, bool> > pending_loot_items;
  985. Mutex MSpellsBook;
  986. Mutex MRecipeBook;
  987. map<Spawn*, bool> current_quest_flagged;
  988. PlayerFaction factions;
  989. map<int32, Quest*> completed_quests;
  990. bool charsheet_changed;
  991. map<int32, string> spawn_vis_packet_list;
  992. map<int32, string> spawn_info_packet_list;
  993. map<int32, string> spawn_pos_packet_list;
  994. map<int32, int8> spawn_packet_sent;
  995. map<int32, SpawnQueueState*> spawn_state_list;
  996. uchar* movement_packet;
  997. uchar* old_movement_packet;
  998. uchar* spell_orig_packet;
  999. uchar* spell_xor_packet;
  1000. int16 spell_count;
  1001. //float speed;
  1002. int16 target_id;
  1003. Spawn* combat_target;
  1004. int32 char_id;
  1005. bool quickbar_updated;
  1006. bool resurrecting;
  1007. PlayerInfo* info;
  1008. vector<SpellBookEntry*> spells;
  1009. vector<QuickBarItem*> quickbar_items;
  1010. map<int32, Statistic*> statistics;
  1011. void RemovePlayerStatistics();
  1012. map<string, int8> friend_list;
  1013. map<string, int8> ignore_list;
  1014. bool pending_deletion;
  1015. PlayerControlFlags control_flags;
  1016. map<int32, bool> target_invis_history;
  1017. // JA: POI Discoveries
  1018. map<int32, vector<int32> > players_poi_list;
  1019. // Jabantiz: Passive spell list, just stores spell id's
  1020. vector<int32> passive_spells;
  1021. /// <summary>Adds a new passive spell to the list</summary>
  1022. /// <param name='id'>Spell id to add</param>
  1023. /// <param name='tier'>Tier of spell to add</param>
  1024. void AddPassiveSpell(int32 id, int8 tier);
  1025. /// <summary>Removes a passive spell from the list</summary>
  1026. /// <param name='id'>Spell id to remove</param>
  1027. /// <param name='tier'>Tier of spell to remove</param>
  1028. /// <param name='remove_from_list'>Remove the spell from this players passive list, default true</param>
  1029. void RemovePassive(int32 id, int8 tier, bool remove_from_list = true);
  1030. CharacterInstances character_instances;
  1031. string away_message;
  1032. string biography;
  1033. MutexMap<int32, Mail*> mail_list;
  1034. bool is_tracking;
  1035. Guild* guild;
  1036. PlayerCollectionList collection_list;
  1037. Collection * pending_collection_reward;
  1038. vector<Item*> pending_item_rewards;
  1039. map<int32, vector<Item*>> pending_selectable_item_rewards;
  1040. PlayerTitlesList player_titles_list;
  1041. PlayerRecipeList recipe_list;
  1042. PlayerLanguagesList player_languages_list;
  1043. PlayerRecipeBookList recipebook_list;
  1044. PlayerAchievementList achievement_list;
  1045. PlayerAchievementUpdateList achievement_update_list;
  1046. // Need to keep track of the recipe the player is crafting as not all crafting packets have this info
  1047. int32 current_recipe;
  1048. void HandleHistoryNone(int8 subtype, int32 value, int32 value2);
  1049. void HandleHistoryDeath(int8 subtype, int32 value, int32 value2);
  1050. void HandleHistoryDiscovery(int8 subtype, int32 value, int32 value2);
  1051. void HandleHistoryXP(int8 subtype, int32 value, int32 value2);
  1052. /// <summary></summary>
  1053. void ModifySpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  1054. void AddSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  1055. void RemoveSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  1056. void SetSpellEntryRecast(SpellBookEntry* spell, bool modify_recast, int16 recast);
  1057. void InitXPTable();
  1058. map<int8, int32> m_levelXPReq;
  1059. //The following variables are for serializing spawn packets
  1060. PacketStruct* spawn_pos_struct;
  1061. PacketStruct* spawn_info_struct;
  1062. PacketStruct* spawn_vis_struct;
  1063. PacketStruct* spawn_header_struct;
  1064. PacketStruct* spawn_footer_struct;
  1065. PacketStruct* sign_footer_struct;
  1066. PacketStruct* widget_footer_struct;
  1067. uchar* spawn_tmp_vis_xor_packet;
  1068. uchar* spawn_tmp_pos_xor_packet;
  1069. uchar* spawn_tmp_info_xor_packet;
  1070. int32 vis_xor_size;
  1071. int32 pos_xor_size;
  1072. int32 info_xor_size;
  1073. // Character history, map<type, map<subtype, vector<data> > >
  1074. map<int8, map<int8, vector<HistoryData*> > > m_characterHistory;
  1075. map<int32, LUAHistory*> m_charLuaHistory;
  1076. Mutex mLUAHistory;
  1077. int32 tmp_mount_model;
  1078. EQ2_Color tmp_mount_color;
  1079. EQ2_Color tmp_mount_saddle_color;
  1080. bool gm_vision;
  1081. bool stop_save_spell_effects;
  1082. map<int32, Spawn*> player_spawn_id_map;
  1083. map<Spawn*, int32> player_spawn_reverse_id_map;
  1084. map<int32, bool> player_aggro_range_spawns;
  1085. bool all_spells_locked;
  1086. Timer lift_cooldown;
  1087. vector<GMTagFilter> gm_visual_filters;
  1088. int32 current_language_id;
  1089. bool active_reward;
  1090. Quest* GetAnyQuest(int32 quest_id);
  1091. Quest* GetCompletedQuest(int32 quest_id);
  1092. };
  1093. #pragma pack()
  1094. #endif