Player.h 34 KB

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