Player.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  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 NUM_MAINTAINED_EFFECTS 30
  109. #define NUM_SPELL_EFFECTS 45
  110. /* Character History Type Defines */
  111. #define HISTORY_TYPE_NONE 0
  112. #define HISTORY_TYPE_DEATH 1
  113. #define HISTORY_TYPE_DISCOVERY 2
  114. #define HISTORY_TYPE_XP 3
  115. /* Spell Status */
  116. #define SPELL_STATUS_QUEUE 4
  117. #define SPELL_STATUS_LOCK 66
  118. /* Character History Sub Type Defines */
  119. #define HISTORY_SUBTYPE_NONE 0
  120. #define HISTORY_SUBTYPE_ADVENTURE 1
  121. #define HISTORY_SUBTYPE_TRADESKILL 2
  122. #define HISTORY_SUBTYPE_QUEST 3
  123. #define HISTORY_SUBTYPE_AA 4
  124. #define HISTORY_SUBTYPE_ITEM 5
  125. #define HISTORY_SUBTYPE_LOCATION 6
  126. /// <summary>Character history data, should match the `character_history` table in the DB</summary>
  127. struct HistoryData {
  128. int32 Value;
  129. int32 Value2;
  130. char Location[200];
  131. int32 EventID;
  132. int32 EventDate;
  133. };
  134. /// <summary>History set through the LUA system</summary>
  135. struct LUAHistory {
  136. int32 Value;
  137. int32 Value2;
  138. bool SaveNeeded;
  139. };
  140. struct SpellBookEntry{
  141. int32 spell_id;
  142. int8 tier;
  143. int32 type;
  144. sint32 slot;
  145. int32 recast_available;
  146. int8 status;
  147. int16 recast;
  148. int32 timer;
  149. bool save_needed;
  150. Player* player;
  151. bool visible;
  152. };
  153. #define QUICKBAR_NORMAL 1
  154. #define QUICKBAR_INV_SLOT 2
  155. #define QUICKBAR_MACRO 3
  156. #define QUICKBAR_TEXT_CMD 4
  157. #define QUICKBAR_ITEM 6
  158. #define EXP_DISABLED_STATE 0
  159. #define EXP_ENABLED_STATE 1
  160. #define MELEE_COMBAT_STATE 16
  161. #define RANGE_COMBAT_STATE 32
  162. struct QuickBarItem{
  163. bool deleted;
  164. int32 hotbar;
  165. int32 slot;
  166. int32 type;
  167. int16 icon;
  168. int16 icon_type;
  169. int32 id;
  170. int8 tier;
  171. int32 unique_id;
  172. EQ2_16BitString text;
  173. };
  174. struct LoginAppearances {
  175. bool deleted;
  176. int16 equip_type;
  177. int8 red;
  178. int8 green;
  179. int8 blue;
  180. int8 h_red;
  181. int8 h_green;
  182. int8 h_blue;
  183. bool update_needed;
  184. };
  185. class PlayerLoginAppearance {
  186. public:
  187. PlayerLoginAppearance() { appearanceList = new map<int8, LoginAppearances>; }
  188. ~PlayerLoginAppearance() { }
  189. void AddEquipmentToUpdate(int8 slot_id, LoginAppearances* equip)
  190. {
  191. //LoginAppearances data;
  192. //data.equip_type = equip->equip_type;
  193. //appearanceList[slot_id] = data;
  194. }
  195. void DeleteEquipmentFromUpdate(int8 slot_id, LoginAppearances* equip)
  196. {
  197. //LoginAppearances data;
  198. //data.deleted = equip->deleted;
  199. //data.update_needed = true;
  200. //appearanceList[slot_id] = data;
  201. }
  202. void RemoveEquipmentUpdates()
  203. {
  204. appearanceList->clear();
  205. safe_delete(appearanceList);
  206. }
  207. private:
  208. map<int8, LoginAppearances>* appearanceList;
  209. };
  210. struct InstanceData{
  211. int32 db_id;
  212. int32 instance_id;
  213. int32 zone_id;
  214. int8 zone_instance_type;
  215. string zone_name;
  216. int32 last_success_timestamp;
  217. int32 last_failure_timestamp;
  218. int32 success_lockout_time;
  219. int32 failure_lockout_time;
  220. };
  221. class CharacterInstances {
  222. public:
  223. CharacterInstances();
  224. ~CharacterInstances();
  225. ///<summary>Adds an instance data to the player with the given data</summary>
  226. ///<param name='db_id'>The unique id for this record in the database</param>
  227. ///<param name='instance_id'>The id of the instance</param>
  228. ///<param name='last_success_timestamp'>The success timestamp</param>
  229. ///<param name='last_failure_timestamp'>The failure timestamp</param>
  230. ///<param name='success_lockout_time'>The lockout time, in secs, for completing the instance</param>
  231. ///<param name='failure_lockout_time'>The lockout time, in secs, for failing the instance</param>
  232. ///<param name='zone_id'>The id of the zone</param>
  233. ///<param name='zone_instancetype'>The type of instance of the zone</param>
  234. ///<param name='zone_name'>The name of the zone</param>
  235. 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);
  236. ///<summary>Clears all instance data</summary>
  237. void RemoveInstances();
  238. ///<summary>Removes the instace with the given zone id</summary>
  239. ///<param name='zone_id'>The zone id of the instance to remove</param>
  240. ///<returns>True if the instance was found and removed</returns>
  241. bool RemoveInstanceByZoneID(int32 zone_id);
  242. ///<summary>Removes the instance with the given instance id</summary>
  243. ///<param name='instance_id'>the instance id of the instance to remove</param>
  244. ///<returns>True if instance was found and removed</returns>
  245. bool RemoveInstanceByInstanceID(int32 instance_id);
  246. ///<summary>Gets the instance with the given zone id</summary>
  247. ///<param name='zone_id'>The zone id of the instance to get</param>
  248. ///<returns>InstanceData* of the instance record for the given zone id</returns>
  249. InstanceData* FindInstanceByZoneID(int32 zone_id);
  250. ///<summary>Gets the instance with the given database id</summary>
  251. ///<param name='db_id'>The database id of the instance to get</param>
  252. ///<returns>InstanceData* of the instance record for the given database id</returns>
  253. InstanceData* FindInstanceByDBID(int32 db_id);
  254. ///<summary>Gets the instance with the given instance id</summary>
  255. ///<param name='instance_id'>The instance id of the instance to get</param>
  256. ///<returns>InstanceData* of the instance record for the given instance id</returns>
  257. InstanceData* FindInstanceByInstanceID(int32 instance_id);
  258. ///<summary>Gets a list of all the lockout instances</summary>
  259. vector<InstanceData> GetLockoutInstances();
  260. ///<summary>Gets a list of all the persistent instances</summary>
  261. vector<InstanceData> GetPersistentInstances();
  262. ///<summary>Check the timers for the instances</summary>
  263. ///<param name='player'>player we are checking the timers for</param>
  264. void ProcessInstanceTimers(Player* player);
  265. ///<summary>Gets the total number of instances</summary>
  266. int32 GetInstanceCount();
  267. private:
  268. vector<InstanceData> instanceList;
  269. Mutex m_instanceList;
  270. };
  271. class Player;
  272. struct PlayerGroup;
  273. struct GroupMemberInfo;
  274. struct Statistic;
  275. struct Mail;
  276. class PlayerInfo {
  277. public:
  278. ~PlayerInfo();
  279. PlayerInfo(Player* in_player);
  280. EQ2Packet* serialize(int16 version);
  281. PacketStruct* serialize2(int16 version);
  282. EQ2Packet* serialize3(PacketStruct* packet, int16 version);
  283. EQ2Packet* serializePet(int16 version);
  284. void CalculateXPPercentages();
  285. void CalculateTSXPPercentages();
  286. void SetHouseZone(int32 id);
  287. void SetBindZone(int32 id);
  288. void SetBindX(float x);
  289. void SetBindY(float y);
  290. void SetBindZ(float z);
  291. void SetBindHeading(float heading);
  292. void SetAccountAge(int16 days);
  293. int32 GetHouseZoneID();
  294. int32 GetBindZoneID();
  295. float GetBindZoneX();
  296. float GetBindZoneY();
  297. float GetBindZoneZ();
  298. float GetBindZoneHeading();
  299. float GetBoatX() { return boat_x_offset; }
  300. float GetBoatY() { return boat_y_offset; }
  301. float GetBoatZ() { return boat_z_offset; }
  302. int32 GetBoatSpawn();
  303. void SetBoatX(float x) { boat_x_offset = x; }
  304. void SetBoatY(float y) { boat_y_offset = y; }
  305. void SetBoatZ(float z) { boat_z_offset = z; }
  306. void SetBoatSpawn(Spawn* boat);
  307. void RemoveOldPackets();
  308. private:
  309. int32 house_zone_id;
  310. int32 bind_zone_id;
  311. float bind_x;
  312. float bind_y;
  313. float bind_z;
  314. float bind_heading;
  315. uchar* changes;
  316. uchar* orig_packet;
  317. uchar* pet_changes;
  318. uchar* pet_orig_packet;
  319. InfoStruct* info_struct;
  320. Player* player;
  321. float boat_x_offset;
  322. float boat_y_offset;
  323. float boat_z_offset;
  324. int32 boat_spawn;
  325. };
  326. class PlayerControlFlags{
  327. public:
  328. PlayerControlFlags();
  329. ~PlayerControlFlags();
  330. void SetPlayerControlFlag(int8 param, int8 param_value, bool is_active);
  331. bool ControlFlagsChanged();
  332. void SendControlFlagUpdates(Client* client);
  333. private:
  334. bool flags_changed;
  335. map<int8, map<int8, int8> > flag_changes;
  336. map<int8, map<int8, bool> > current_flags;
  337. Mutex MControlFlags;
  338. Mutex MFlagChanges;
  339. };
  340. class Player : public Entity{
  341. public:
  342. Player();
  343. virtual ~Player();
  344. EQ2Packet* serialize(Player* player, int16 version);
  345. //int8 GetMaxArtLevel(){ return info->GetInfo()->max_art_level; }
  346. //int8 GetArtLevel(){ return info->GetInfo()->art_level; }
  347. PlayerInfo* GetPlayerInfo();
  348. void SetCharSheetChanged(bool val);
  349. bool GetCharSheetChanged();
  350. void AddFriend(const char* name, bool save);
  351. bool IsFriend(const char* name);
  352. void RemoveFriend(const char* name);
  353. map<string, int8>* GetFriends();
  354. void AddIgnore(const char* name, bool save);
  355. bool IsIgnored(const char* name);
  356. void RemoveIgnore(const char* name);
  357. map<string, int8>* GetIgnoredPlayers();
  358. // JA: POI Discoveries
  359. map<int32, vector<int32> >* GetPlayerDiscoveredPOIs();
  360. void AddPlayerDiscoveredPOI(int32 location_id);
  361. //
  362. EQ2Packet* Move(float x, float y, float z, int16 version, float heading = -1.0f);
  363. /*void SetMaxArtLevel(int8 new_max){
  364. max_art_level = new_max;
  365. }
  366. void SetArtLevel(int8 new_lvl){
  367. art_level = new_lvl;
  368. }*/
  369. bool WasSentSpawn(int32 spawn_id);
  370. bool NeedsSpawnResent(Spawn* spawn);
  371. void SetSideSpeed(float side_speed, bool updateFlags = true) {
  372. SetPos(&appearance.pos.SideSpeed, side_speed, updateFlags);
  373. }
  374. float GetSideSpeed() {
  375. return appearance.pos.SideSpeed;
  376. }
  377. void AddMaintainedSpell(LuaSpell* spell);
  378. void AddSpellEffect(LuaSpell* spell);
  379. void RemoveMaintainedSpell(LuaSpell* spell);
  380. void RemoveSpellEffect(LuaSpell* spell);
  381. bool HasActiveMaintainedSpell(Spell* spell, Spawn* target);
  382. bool HasActiveSpellEffect(Spell* spell, Spawn* target);
  383. 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);
  384. void RemoveQuickbarItem(int32 bar, int32 slot, bool update = true);
  385. void MoveQuickbarItem(int32 id, int32 new_slot);
  386. void ClearQuickbarItems();
  387. PlayerItemList* GetPlayerItemList();
  388. PlayerItemList item_list;
  389. PlayerSkillList skill_list;
  390. Skill* GetSkillByName(const char* name, bool check_update = false);
  391. PlayerSkillList* GetSkills();
  392. bool DamageEquippedItems(int8 amount = 10, Client* client = 0);
  393. vector<EQ2Packet*> EquipItem(int16 index, int16 version, int8 slot_id = 255);
  394. bool CanEquipItem(Item* item);
  395. void SetEquippedItemAppearances();
  396. vector<EQ2Packet*> UnequipItem(int16 index, sint32 bag_id, int8 slot, int16 version);
  397. EQ2Packet* SwapEquippedItems(int8 slot1, int8 slot2, int16 version);
  398. EQ2Packet* RemoveInventoryItem(int8 bag_slot, int8 slot);
  399. EQ2Packet* SendInventoryUpdate(int16 version);
  400. EQ2Packet* SendBagUpdate(int32 bag_unique_id, int16 version);
  401. void SendQuestRequiredSpawns(int32 quest_id);
  402. void SendHistoryRequiredSpawns(int32 event_id);
  403. map<int32, Item*>* GetItemList();
  404. map<int32, Item*>* GetBankItemList();
  405. vector<Item*>* GetEquippedItemList();
  406. Quest* SetStepComplete(int32 quest_id, int32 step);
  407. Quest* AddStepProgress(int32 quest_id, int32 step, int32 progress);
  408. int32 GetStepProgress(int32 quest_id, int32 step_id);
  409. bool AddItem(Item* item);
  410. bool AddItemToBank(Item* item);
  411. int16 GetSpellSlotMappingCount();
  412. int16 GetSpellPacketCount();
  413. Quest* GetQuest(int32 quest_id);
  414. bool GetQuestStepComplete(int32 quest_id, int32 step_id);
  415. int16 GetQuestStep(int32 quest_id);
  416. int16 GetTaskGroupStep(int32 quest_id);
  417. int8 GetSpellTier(int32 id);
  418. void SetSpellStatus(Spell* spell, int8 status);
  419. void RemoveSpellStatus(Spell* spell, int8 status);
  420. EQ2Packet* GetSpellBookUpdatePacket(int16 version);
  421. EQ2Packet* GetSpellSlotMappingPacket(int16 version);
  422. int32 GetCharacterID();
  423. void SetCharacterID(int32 new_id);
  424. EQ2Packet* GetQuickbarPacket(int16 version);
  425. vector<QuickBarItem*>* GetQuickbar();
  426. bool UpdateQuickbarNeeded();
  427. void ResetQuickbarNeeded();
  428. void set_character_flag(int flag);
  429. void reset_character_flag(int flag);
  430. void toggle_character_flag(int flag);
  431. bool get_character_flag(int flag);
  432. void AddCoins(int64 val);
  433. bool RemoveCoins(int64 val);
  434. /// <summary>Checks to see if the player has the given amount of coins</summary>
  435. /// <param name="val">Amount of coins to check</param>
  436. /// <returns>True if the player has enough coins</returns>
  437. bool HasCoins(int64 val);
  438. void AddSkill(int32 skill_id, int16 current_val, int16 max_val, bool save_needed = false);
  439. void RemoveSkillFromDB(Skill* skill, bool save = false);
  440. void AddSpellBookEntry(int32 spell_id, int8 tier, sint32 slot, int32 type, int32 timer, bool save_needed = false);
  441. SpellBookEntry* GetSpellBookSpell(int32 spell_id);
  442. vector<SpellBookEntry*>* GetSpellsSaveNeeded();
  443. sint32 GetFreeSpellBookSlot(int32 type);
  444. /// <summary>Get a vector of spell ids for all spells in the spell book for the given skill</summary>
  445. /// <param name='skill_id'>The id of the skill to check</param>
  446. /// <returns>A vector of int32's of the spell id's</returns>
  447. vector<int32> GetSpellBookSpellIDBySkill(int32 skill_id);
  448. EQ2Packet* MoveInventoryItem(sint32 to_bag_id, int16 from_index, int8 new_slot, int8 charges, int16 version = 1);
  449. bool IsPlayer(){ return true; }
  450. MaintainedEffects* GetFreeMaintainedSpellSlot();
  451. MaintainedEffects* GetMaintainedSpell(int32 id);
  452. MaintainedEffects* GetMaintainedSpellBySlot(int8 slot);
  453. MaintainedEffects* GetMaintainedSpells();
  454. SpellEffects* GetFreeSpellEffectSlot();
  455. SpellEffects* GetSpellEffects();
  456. int32 GetCoinsCopper();
  457. int32 GetCoinsSilver();
  458. int32 GetCoinsGold();
  459. int32 GetCoinsPlat();
  460. int32 GetBankCoinsCopper();
  461. int32 GetBankCoinsSilver();
  462. int32 GetBankCoinsGold();
  463. int32 GetBankCoinsPlat();
  464. float GetXPVitality();
  465. float GetTSXPVitality();
  466. bool AdventureXPEnabled();
  467. bool TradeskillXPEnabled();
  468. void SetNeededXP(int32 val);
  469. void SetNeededXP();
  470. void SetXP(int32 val);
  471. void SetNeededTSXP(int32 val);
  472. void SetNeededTSXP();
  473. void SetTSXP(int32 val);
  474. int32 GetNeededXP();
  475. int32 GetXPDebt();
  476. int32 GetXP();
  477. int32 GetNeededTSXP();
  478. int32 GetTSXP();
  479. bool AddXP(int32 xp_amount);
  480. bool AddTSXP(int32 xp_amount);
  481. bool DoubleXPEnabled();
  482. float CalculateXP(Spawn* victim);
  483. float CalculateTSXP(int8 level);
  484. void InCombat(bool val, bool range = false);
  485. void PrepareIncomingMovementPacket(int32 len, uchar* data, int16 version);
  486. uchar* GetMovementPacketData(){
  487. return movement_packet;
  488. }
  489. void AddSpawnInfoPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  490. uchar* GetSpawnInfoPacketForXOR(int32 spawn_id);
  491. void AddSpawnVisPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  492. uchar* GetSpawnVisPacketForXOR(int32 spawn_id);
  493. void AddSpawnPosPacketForXOR(int32 spawn_id, uchar* packet, int16 packet_size);
  494. uchar* GetSpawnPosPacketForXOR(int32 spawn_id);
  495. uchar* GetTempInfoPacketForXOR();
  496. uchar* GetTempVisPacketForXOR();
  497. uchar* GetTempPosPacketForXOR();
  498. uchar* SetTempInfoPacketForXOR(int16 size);
  499. uchar* SetTempVisPacketForXOR(int16 size);
  500. uchar* SetTempPosPacketForXOR(int16 size);
  501. int32 GetTempInfoXorSize() { return info_xor_size; }
  502. int32 GetTempVisXorSize() { return vis_xor_size; }
  503. int32 GetTempPosXorSize() { return pos_xor_size; }
  504. bool CheckPlayerInfo();
  505. void CalculateLocation();
  506. void SetSpawnDeleteTime(int32 id, int32 time);
  507. int32 GetSpawnDeleteTime(int32 id);
  508. void ClearEverything();
  509. bool IsResurrecting();
  510. void SetResurrecting(bool val);
  511. int8 GetArrowColor(int8 spawn_level);
  512. int8 GetTSArrowColor(int8 level);
  513. Spawn* GetSpawnByIndex(int16 index);
  514. int16 GetIndexForSpawn(Spawn* spawn);
  515. bool WasSpawnRemoved(Spawn* spawn);
  516. void RemoveSpawn(Spawn* spawn);
  517. void ClearRemovedSpawn(Spawn* spawn);
  518. bool ShouldSendSpawn(Spawn* spawn);
  519. map<int16, Spawn*>* GetPlayerSpawnMap(){
  520. return &player_spawn_map;
  521. }
  522. map<Spawn*, int16>* GetPlayerSpawnIndexMap(){
  523. return &player_spawn_index_map;
  524. }
  525. Spawn* GetSpawnWithPlayerID(int32 id){
  526. if (player_spawn_id_map.count(id) > 0)
  527. return player_spawn_id_map[id];
  528. return 0;
  529. }
  530. int32 GetIDWithPlayerSpawn(Spawn* spawn){
  531. if (player_spawn_reverse_id_map.count(spawn) > 0)
  532. return player_spawn_reverse_id_map[spawn];
  533. return 0;
  534. }
  535. PacketStruct* GetQuestJournalPacket(bool all_quests, int16 version, int32 crc, int32 current_quest_id);
  536. void RemoveQuest(int32 id, bool delete_quest);
  537. vector<Quest*>* CheckQuestsChatUpdate(Spawn* spawn);
  538. vector<Quest*>* CheckQuestsItemUpdate(Item* item);
  539. vector<Quest*>* CheckQuestsLocationUpdate();
  540. vector<Quest*>* CheckQuestsKillUpdate(Spawn* spawn,bool update = true);
  541. vector<Quest*>* CheckQuestsSpellUpdate(Spell* spell);
  542. void CheckQuestsCraftUpdate(Item* item, int32 qty);
  543. void CheckQuestsHarvestUpdate(Item* item, int32 qty);
  544. vector<Quest*>* CheckQuestsFailures();
  545. bool CheckQuestRemoveFlag(Spawn* spawn);
  546. int8 CheckQuestFlag(Spawn* spawn);
  547. bool CheckQuestRequired(Spawn* spawn);
  548. void AddQuestRequiredSpawn(Spawn* spawn, int32 quest_id);
  549. void AddHistoryRequiredSpawn(Spawn* spawn, int32 event_id);
  550. int16 spawn_index;
  551. int32 spawn_id;
  552. map<Spawn*, int16> player_spawn_index_map;
  553. map<int16, Spawn*> player_spawn_map;
  554. map<int32, Spawn*> player_spawn_id_map;
  555. map<Spawn*, int32> player_spawn_reverse_id_map;
  556. map<int32, vector<int32>*> player_spawn_quests_required;
  557. map<int32, vector<int32>*> player_spawn_history_required;
  558. Mutex m_playerSpawnQuestsRequired;
  559. Mutex m_playerSpawnHistoryRequired;
  560. Quest* GetCompletedQuest(int32 quest_id);
  561. void AddCompletedQuest(Quest* quest);
  562. map<int32, Quest*> pending_quests;
  563. map<int32, Quest*> player_quests;
  564. map<int32, Quest*>* GetPlayerQuests();
  565. map<int32, Quest*>* GetCompletedPlayerQuests();
  566. void LockQuests();
  567. void UnlockQuests();
  568. void SetFactionValue(int32 faction_id, sint32 value){
  569. factions.SetFactionValue(faction_id, value);
  570. }
  571. PlayerFaction* GetFactions(){
  572. return &factions;
  573. }
  574. vector<int32> GetQuestIDs();
  575. map<int32, int16> macro_icons;
  576. bool HasPendingLootItems(int32 id);
  577. bool HasPendingLootItem(int32 id, int32 item_id);
  578. vector<Item*>* GetPendingLootItems(int32 id);
  579. void RemovePendingLootItem(int32 id, int32 item_id);
  580. void RemovePendingLootItems(int32 id);
  581. void AddPendingLootItems(int32 id, vector<Item*>* items);
  582. bool HasSpell(int32 spell_id, int8 tier = 255, bool include_higher_tiers = false);
  583. bool HasRecipeBook(int32 recipe_id);
  584. void AddPlayerStatistic(int32 stat_id, sint32 stat_value, int32 stat_date);
  585. void UpdatePlayerStatistic(int32 stat_id, sint32 stat_value, bool overwrite = false);
  586. sint64 GetPlayerStatisticValue(int32 stat_id);
  587. void WritePlayerStatistics();
  588. //PlayerGroup* GetGroup();
  589. void SetGroup(PlayerGroup* group);
  590. bool IsGroupMember(Entity* player);
  591. void SetGroupInformation(PacketStruct* packet);
  592. void ResetSavedSpawns();
  593. bool IsReturningFromLD();
  594. void SetReturningFromLD(bool val);
  595. bool CheckLevelStatus(int16 new_level);
  596. int16 GetLastMovementActivity();
  597. void DestroyQuests();
  598. string GetAwayMessage() const { return away_message; }
  599. void SetAwayMessage(string val) { away_message = val; }
  600. void SetRangeAttack(bool val);
  601. bool GetRangeAttack();
  602. ZoneServer* GetGroupMemberInZone(int32 zone_id);
  603. bool AddMail(Mail* mail);
  604. MutexMap<int32, Mail*>* GetMail();
  605. Mail* GetMail(int32 mail_id);
  606. void DeleteMail(bool from_database = false);
  607. void DeleteMail(int32 mail_id, bool from_database = false);
  608. CharacterInstances* GetCharacterInstances() { return &character_instances; }
  609. void SetIsTracking(bool val) { is_tracking = val; }
  610. bool GetIsTracking() const { return is_tracking; }
  611. void SetBiography(string new_biography) { biography = new_biography; }
  612. string GetBiography() const { return biography; }
  613. void SetPlayerAdventureClass(int8 new_class);
  614. void SetGuild(Guild* new_guild) { guild = new_guild; }
  615. Guild* GetGuild() { return guild; }
  616. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  617. SkillBonus* GetSkillBonus(int32 spell_id);
  618. virtual void RemoveSkillBonus(int32 spell_id);
  619. virtual bool CanSeeInvis(Entity* target);
  620. bool CheckChangeInvisHistory(Entity* target);
  621. void UpdateTargetInvisHistory(int32 targetID, bool canSeeStatus);
  622. void RemoveTargetInvisHistory(int32 targetID);
  623. bool HasFreeBankSlot();
  624. int8 FindFreeBankSlot();
  625. PlayerCollectionList * GetCollectionList() { return &collection_list; }
  626. PlayerRecipeList * GetRecipeList() { return &recipe_list; }
  627. PlayerRecipeBookList * GetRecipeBookList() { return &recipebook_list; }
  628. PlayerAchievementList * GetAchievementList() { return &achievement_list; }
  629. PlayerAchievementUpdateList * GetAchievementUpdateList() { return &achievement_update_list; }
  630. void SetPendingCollectionReward(Collection *collection) { pending_collection_reward = collection; }
  631. Collection * GetPendingCollectionReward() { return pending_collection_reward; }
  632. void RemoveSpellBookEntry(int32 spell_id, bool remove_passives_from_list = true);
  633. void ResortSpellBook(int32 sort_by, int32 order, int32 pattern, int32 maxlvl_only, int32 book_type);
  634. static bool SortSpellEntryByName(SpellBookEntry* s1, SpellBookEntry* s2);
  635. static bool SortSpellEntryByCategory(SpellBookEntry* s1, SpellBookEntry* s2);
  636. static bool SortSpellEntryByLevel(SpellBookEntry* s1, SpellBookEntry* s2);
  637. static bool SortSpellEntryByNameReverse(SpellBookEntry* s1, SpellBookEntry* s2);
  638. static bool SortSpellEntryByCategoryReverse(SpellBookEntry* s1, SpellBookEntry* s2);
  639. static bool SortSpellEntryByLevelReverse(SpellBookEntry* s1, SpellBookEntry* s2);
  640. int8 GetSpellSlot(int32 spell_id);
  641. void AddTitle(int32 title_id, const char *name, int8 prefix, bool save_needed = false);
  642. void AddAAEntry(int16 template_id, int8 tab_id, int32 aa_id, int16 order, int8 treeid);
  643. PlayerTitlesList* GetPlayerTitles() { return &player_titles_list; }
  644. void AddLanguage(int32 id, const char *name, bool save_needed = false);
  645. PlayerLanguagesList* GetPlayerLanguages() { return &player_languages_list; }
  646. bool HasLanguage(int32 id);
  647. bool HasLanguage(const char* name);
  648. bool CanReceiveQuest(int32 quest_id);
  649. float GetBoatX() { if (info) return info->GetBoatX(); return 0; }
  650. float GetBoatY() { if (info) return info->GetBoatY(); return 0; }
  651. float GetBoatZ() { if (info) return info->GetBoatZ(); return 0; }
  652. int32 GetBoatSpawn() { if (info) return info->GetBoatSpawn(); return 0; }
  653. void SetBoatX(float x) { if (info) info->SetBoatX(x); }
  654. void SetBoatY(float y) { if (info) info->SetBoatY(y); }
  655. void SetBoatZ(float z) { if (info) info->SetBoatZ(z); }
  656. void SetBoatSpawn(Spawn* boat) { if (info) info->SetBoatSpawn(boat); }
  657. Mutex* GetGroupBuffMutex();
  658. void SetPendingDeletion(bool val) { pending_deletion = val; }
  659. bool GetPendingDeletion() { return pending_deletion; }
  660. float GetPosPacketSpeed() { return pos_packet_speed; }
  661. bool ControlFlagsChanged();
  662. void SetPlayerControlFlag(int8 param, int8 param_value, bool is_active);
  663. void SendControlFlagUpdates(Client* client);
  664. /// <summary>Casts all the passive spells for the player, only call after zoning is complete.</summary>
  665. void ApplyPassiveSpells();
  666. /// <summary>Removes all passive spell effects from the player and clears the passive list</summary>
  667. void RemoveAllPassives();
  668. /// <summary>Gets the current recipie ID</summary>
  669. int32 GetCurrentRecipe() { return current_recipe; }
  670. /// <summary>Sets the current recipie ID</summary>
  671. /// <param name="val">Id of the new recipe</param>
  672. void SetCurrentRecipe(int32 val) { current_recipe = val; }
  673. /// <summary>Reset the pet window info</summary>
  674. void ResetPetInfo();
  675. void ProcessCombat();
  676. /* Character history stuff */
  677. /// <summary>Adds a new history event to the player</summary>
  678. /// <param name="type">The history type</param>
  679. /// <param name="subtype">The history sub type</param>
  680. /// <param name="value">The first history value</param>
  681. /// <param name="value2">The second history value</param>
  682. void UpdatePlayerHistory(int8 type, int8 subtype, int32 value, int32 value2 = 0);
  683. /// <summary>Checks to see if the player has discovered the location</summary>
  684. /// <param name="locationID">The ID of the location to check</param>
  685. /// <returns>True if the player has discovered the location</returns>
  686. bool DiscoveredLocation(int32 locationID);
  687. /// <summary>Load the players history from the database</summary>
  688. /// <param name="type">The history type</param>
  689. /// <param name="subtype">The history sub type</param>
  690. /// <param name="hd">The history data</param>
  691. void LoadPlayerHistory(int8 type, int8 subtype, HistoryData* hd);
  692. /// <summary>Save the player's history to the database</summary>
  693. void SaveHistory();
  694. /* New functions for spell locking and unlocking*/
  695. /// <summary>Lock all Spells, Combat arts, and Abilities (not trade skill spells)</summary>
  696. void LockAllSpells();
  697. /// <summary>Unlocks all Spells, Combat arts, and Abilities (not trade skill spells)</summary>
  698. void UnlockAllSpells(bool modify_recast = false);
  699. /// <summary>Locks the given spell as well as all spells with a shared timer</summary>
  700. void LockSpell(Spell* spell, int16 recast);
  701. /// <summary>Unlocks the given spell as well as all spells with shared timers</summary>
  702. void UnlockSpell(Spell* spell);
  703. /// <summary>Locks all ts spells and unlocks all normal spells</summary>
  704. void LockTSSpells();
  705. /// <summary>Unlocks all ts spells and locks all normal spells</summary>
  706. void UnlockTSSpells();
  707. /// <summary>Queue the given spell</summary>
  708. void QueueSpell(Spell* spell);
  709. /// <summary>Unqueue the given spell</summary>
  710. void UnQueueSpell(Spell* spell);
  711. ///<summary>Get all the spells the player has with the given id</summary>
  712. vector<Spell*> GetSpellBookSpellsByTimer(int32 timerID);
  713. PacketStruct* GetQuestJournalPacket(Quest* quest, int16 version, int32 crc);
  714. void SetSpawnInfoStruct(PacketStruct* packet) { safe_delete(spawn_info_struct); spawn_info_struct = packet; }
  715. void SetSpawnVisStruct(PacketStruct* packet) { safe_delete(spawn_vis_struct); spawn_vis_struct = packet; }
  716. void SetSpawnPosStruct(PacketStruct* packet) { safe_delete(spawn_pos_struct); spawn_pos_struct = packet; }
  717. void SetSpawnHeaderStruct(PacketStruct* packet) { safe_delete(spawn_header_struct); spawn_header_struct = packet; }
  718. void SetSpawnFooterStruct(PacketStruct* packet) { safe_delete(spawn_footer_struct); spawn_footer_struct = packet; }
  719. void SetSignFooterStruct(PacketStruct* packet) { safe_delete(sign_footer_struct); sign_footer_struct = packet; }
  720. void SetWidgetFooterStruct(PacketStruct* packet) { safe_delete(widget_footer_struct); widget_footer_struct = packet; }
  721. PacketStruct* GetSpawnInfoStruct() { return spawn_info_struct; }
  722. PacketStruct* GetSpawnVisStruct() { return spawn_vis_struct; }
  723. PacketStruct* GetSpawnPosStruct() { return spawn_pos_struct; }
  724. PacketStruct* GetSpawnHeaderStruct() { return spawn_header_struct; }
  725. PacketStruct* GetSpawnFooterStruct() { return spawn_footer_struct; }
  726. PacketStruct* GetSignFooterStruct() { return sign_footer_struct; }
  727. PacketStruct* GetWidgetFooterStruct() { return widget_footer_struct; }
  728. Mutex info_mutex;
  729. Mutex pos_mutex;
  730. Mutex vis_mutex;
  731. void SetTempMount(int32 id) { tmp_mount_model = id; }
  732. int32 GetTempMount() { return tmp_mount_model; }
  733. void SetTempMountColor(EQ2_Color* color) { tmp_mount_color = *color; }
  734. EQ2_Color GetTempMountColor() { return tmp_mount_color; }
  735. void SetTempMountSaddleColor(EQ2_Color* color) { tmp_mount_saddle_color = *color; }
  736. EQ2_Color GetTempMountSaddleColor() { return tmp_mount_saddle_color; }
  737. void LoadLUAHistory(int32 event_id, LUAHistory* history);
  738. void SaveLUAHistory();
  739. void UpdateLUAHistory(int32 event_id, int32 value, int32 value2);
  740. LUAHistory* GetLUAHistory(int32 event_id);
  741. bool HasGMVision() { return gm_vision; }
  742. void SetGMVision(bool val) { gm_vision = val; }
  743. AppearanceData SavedApp;
  744. CharFeatures SavedFeatures;
  745. bool custNPC;
  746. Entity* custNPCTarget;
  747. // bot index, spawn id
  748. map<int32, int32> SpawnedBots;
  749. private:
  750. bool range_attack;
  751. int16 last_movement_activity;
  752. bool returning_from_ld;
  753. PlayerGroup* group;
  754. float test_x;
  755. float test_y;
  756. float test_z;
  757. int32 test_time;
  758. map<int32, map<int32, bool> > pending_loot_items;
  759. Mutex MSpellsBook;
  760. Mutex MRecipeBook;
  761. Mutex MPlayerQuests;
  762. map<Spawn*, bool> current_quest_flagged;
  763. PlayerFaction factions;
  764. map<int32, Quest*> completed_quests;
  765. map<Spawn*, int8> player_removed_spawns;
  766. bool charsheet_changed;
  767. map<int32, string> spawn_vis_packet_list;
  768. map<int32, string> spawn_info_packet_list;
  769. map<int32, string> spawn_pos_packet_list;
  770. uchar* movement_packet;
  771. uchar* old_movement_packet;
  772. uchar* spell_orig_packet;
  773. uchar* spell_xor_packet;
  774. int16 spell_count;
  775. //float speed;
  776. int16 target_id;
  777. Spawn* combat_target;
  778. int32 char_id;
  779. bool quickbar_updated;
  780. bool resurrecting;
  781. PlayerInfo* info;
  782. vector<SpellBookEntry*> spells;
  783. vector<QuickBarItem*> quickbar_items;
  784. map<int32, Statistic*> statistics;
  785. void RemovePlayerStatistics();
  786. map<string, int8> friend_list;
  787. map<string, int8> ignore_list;
  788. bool pending_deletion;
  789. float pos_packet_speed;
  790. PlayerControlFlags control_flags;
  791. map<int32, bool> target_invis_history;
  792. // JA: POI Discoveries
  793. map<int32, vector<int32> > players_poi_list;
  794. // Jabantiz: Passive spell list, just stores spell id's
  795. vector<int32> passive_spells;
  796. /// <summary>Adds a new passive spell to the list</summary>
  797. /// <param name='id'>Spell id to add</param>
  798. /// <param name='tier'>Tier of spell to add</param>
  799. void AddPassiveSpell(int32 id, int8 tier);
  800. /// <summary>Removes a passive spell from the list</summary>
  801. /// <param name='id'>Spell id to remove</param>
  802. /// <param name='tier'>Tier of spell to remove</param>
  803. /// <param name='remove_from_list'>Remove the spell from this players passive list, default true</param>
  804. void RemovePassive(int32 id, int8 tier, bool remove_from_list = true);
  805. CharacterInstances character_instances;
  806. string away_message;
  807. string biography;
  808. MutexMap<int32, Mail*> mail_list;
  809. bool is_tracking;
  810. Guild* guild;
  811. PlayerCollectionList collection_list;
  812. Collection * pending_collection_reward;
  813. PlayerTitlesList player_titles_list;
  814. PlayerRecipeList recipe_list;
  815. PlayerLanguagesList player_languages_list;
  816. PlayerRecipeBookList recipebook_list;
  817. PlayerAchievementList achievement_list;
  818. PlayerAchievementUpdateList achievement_update_list;
  819. // Need to keep track of the recipe the player is crafting as not all crafting packets have this info
  820. int32 current_recipe;
  821. void HandleHistoryNone(int8 subtype, int32 value, int32 value2);
  822. void HandleHistoryDeath(int8 subtype, int32 value, int32 value2);
  823. void HandleHistoryDiscovery(int8 subtype, int32 value, int32 value2);
  824. void HandleHistoryXP(int8 subtype, int32 value, int32 value2);
  825. /// <summary></summary>
  826. void ModifySpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  827. void AddSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  828. void RemoveSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  829. void InitXPTable();
  830. map<int8, int32> m_levelXPReq;
  831. //The following variables are for serializing spawn packets
  832. PacketStruct* spawn_pos_struct;
  833. PacketStruct* spawn_info_struct;
  834. PacketStruct* spawn_vis_struct;
  835. PacketStruct* spawn_header_struct;
  836. PacketStruct* spawn_footer_struct;
  837. PacketStruct* sign_footer_struct;
  838. PacketStruct* widget_footer_struct;
  839. uchar* spawn_tmp_vis_xor_packet;
  840. uchar* spawn_tmp_pos_xor_packet;
  841. uchar* spawn_tmp_info_xor_packet;
  842. int32 vis_xor_size;
  843. int32 pos_xor_size;
  844. int32 info_xor_size;
  845. // Character history, map<type, map<subtype, vector<data> > >
  846. map<int8, map<int8, vector<HistoryData*> > > m_characterHistory;
  847. map<int32, LUAHistory*> m_charLuaHistory;
  848. int32 tmp_mount_model;
  849. EQ2_Color tmp_mount_color;
  850. EQ2_Color tmp_mount_saddle_color;
  851. bool gm_vision;
  852. };
  853. #pragma pack()
  854. #endif