Player.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  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. bool CheckPlayerInfo();
  500. void CalculateLocation();
  501. void SetSpawnDeleteTime(int32 id, int32 time);
  502. int32 GetSpawnDeleteTime(int32 id);
  503. void ClearEverything();
  504. bool IsResurrecting();
  505. void SetResurrecting(bool val);
  506. int8 GetArrowColor(int8 spawn_level);
  507. int8 GetTSArrowColor(int8 level);
  508. Spawn* GetSpawnByIndex(int16 index);
  509. int16 GetIndexForSpawn(Spawn* spawn);
  510. bool WasSpawnRemoved(Spawn* spawn);
  511. void RemoveSpawn(Spawn* spawn);
  512. void ClearRemovedSpawn(Spawn* spawn);
  513. bool ShouldSendSpawn(Spawn* spawn);
  514. map<int16, Spawn*>* GetPlayerSpawnMap(){
  515. return &player_spawn_map;
  516. }
  517. map<Spawn*, int16>* GetPlayerSpawnIndexMap(){
  518. return &player_spawn_index_map;
  519. }
  520. Spawn* GetSpawnWithPlayerID(int32 id){
  521. if (player_spawn_id_map.count(id) > 0)
  522. return player_spawn_id_map[id];
  523. return 0;
  524. }
  525. int32 GetIDWithPlayerSpawn(Spawn* spawn){
  526. if (player_spawn_reverse_id_map.count(spawn) > 0)
  527. return player_spawn_reverse_id_map[spawn];
  528. return 0;
  529. }
  530. PacketStruct* GetQuestJournalPacket(bool all_quests, int16 version, int32 crc, int32 current_quest_id);
  531. void RemoveQuest(int32 id, bool delete_quest);
  532. vector<Quest*>* CheckQuestsChatUpdate(Spawn* spawn);
  533. vector<Quest*>* CheckQuestsItemUpdate(Item* item);
  534. vector<Quest*>* CheckQuestsLocationUpdate();
  535. vector<Quest*>* CheckQuestsKillUpdate(Spawn* spawn,bool update = true);
  536. vector<Quest*>* CheckQuestsSpellUpdate(Spell* spell);
  537. void CheckQuestsCraftUpdate(Item* item, int32 qty);
  538. void CheckQuestsHarvestUpdate(Item* item, int32 qty);
  539. vector<Quest*>* CheckQuestsFailures();
  540. bool CheckQuestRemoveFlag(Spawn* spawn);
  541. int8 CheckQuestFlag(Spawn* spawn);
  542. bool CheckQuestRequired(Spawn* spawn);
  543. void AddQuestRequiredSpawn(Spawn* spawn, int32 quest_id);
  544. void AddHistoryRequiredSpawn(Spawn* spawn, int32 event_id);
  545. int16 spawn_index;
  546. int32 spawn_id;
  547. map<Spawn*, int16> player_spawn_index_map;
  548. map<int16, Spawn*> player_spawn_map;
  549. map<int32, Spawn*> player_spawn_id_map;
  550. map<Spawn*, int32> player_spawn_reverse_id_map;
  551. map<int32, vector<int32>*> player_spawn_quests_required;
  552. map<int32, vector<int32>*> player_spawn_history_required;
  553. Mutex m_playerSpawnQuestsRequired;
  554. Mutex m_playerSpawnHistoryRequired;
  555. Quest* GetCompletedQuest(int32 quest_id);
  556. void AddCompletedQuest(Quest* quest);
  557. map<int32, Quest*> pending_quests;
  558. map<int32, Quest*> player_quests;
  559. map<int32, Quest*>* GetPlayerQuests();
  560. map<int32, Quest*>* GetCompletedPlayerQuests();
  561. void LockQuests();
  562. void UnlockQuests();
  563. void SetFactionValue(int32 faction_id, sint32 value){
  564. factions.SetFactionValue(faction_id, value);
  565. }
  566. PlayerFaction* GetFactions(){
  567. return &factions;
  568. }
  569. vector<int32> GetQuestIDs();
  570. map<int32, int16> macro_icons;
  571. bool HasPendingLootItems(int32 id);
  572. bool HasPendingLootItem(int32 id, int32 item_id);
  573. vector<Item*>* GetPendingLootItems(int32 id);
  574. void RemovePendingLootItem(int32 id, int32 item_id);
  575. void RemovePendingLootItems(int32 id);
  576. void AddPendingLootItems(int32 id, vector<Item*>* items);
  577. bool HasSpell(int32 spell_id, int8 tier = 255, bool include_higher_tiers = false);
  578. bool HasRecipeBook(int32 recipe_id);
  579. void AddPlayerStatistic(int32 stat_id, sint32 stat_value, int32 stat_date);
  580. void UpdatePlayerStatistic(int32 stat_id, sint32 stat_value, bool overwrite = false);
  581. sint64 GetPlayerStatisticValue(int32 stat_id);
  582. void WritePlayerStatistics();
  583. //PlayerGroup* GetGroup();
  584. void SetGroup(PlayerGroup* group);
  585. bool IsGroupMember(Entity* player);
  586. void SetGroupInformation(PacketStruct* packet);
  587. void ResetSavedSpawns();
  588. bool IsReturningFromLD();
  589. void SetReturningFromLD(bool val);
  590. bool CheckLevelStatus(int16 new_level);
  591. int16 GetLastMovementActivity();
  592. void DestroyQuests();
  593. string GetAwayMessage() const { return away_message; }
  594. void SetAwayMessage(string val) { away_message = val; }
  595. void SetRangeAttack(bool val);
  596. bool GetRangeAttack();
  597. ZoneServer* GetGroupMemberInZone(int32 zone_id);
  598. bool AddMail(Mail* mail);
  599. MutexMap<int32, Mail*>* GetMail();
  600. Mail* GetMail(int32 mail_id);
  601. void DeleteMail(bool from_database = false);
  602. void DeleteMail(int32 mail_id, bool from_database = false);
  603. CharacterInstances* GetCharacterInstances() { return &character_instances; }
  604. void SetIsTracking(bool val) { is_tracking = val; }
  605. bool GetIsTracking() const { return is_tracking; }
  606. void SetBiography(string new_biography) { biography = new_biography; }
  607. string GetBiography() const { return biography; }
  608. void SetPlayerAdventureClass(int8 new_class);
  609. void SetGuild(Guild* new_guild) { guild = new_guild; }
  610. Guild* GetGuild() { return guild; }
  611. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  612. SkillBonus* GetSkillBonus(int32 spell_id);
  613. virtual void RemoveSkillBonus(int32 spell_id);
  614. bool HasFreeBankSlot();
  615. int8 FindFreeBankSlot();
  616. PlayerCollectionList * GetCollectionList() { return &collection_list; }
  617. PlayerRecipeList * GetRecipeList() { return &recipe_list; }
  618. PlayerRecipeBookList * GetRecipeBookList() { return &recipebook_list; }
  619. PlayerAchievementList * GetAchievementList() { return &achievement_list; }
  620. PlayerAchievementUpdateList * GetAchievementUpdateList() { return &achievement_update_list; }
  621. void SetPendingCollectionReward(Collection *collection) { pending_collection_reward = collection; }
  622. Collection * GetPendingCollectionReward() { return pending_collection_reward; }
  623. void RemoveSpellBookEntry(int32 spell_id, bool remove_passives_from_list = true);
  624. int8 GetSpellSlot(int32 spell_id);
  625. void AddTitle(int32 title_id, const char *name, int8 prefix, bool save_needed = false);
  626. void AddAAEntry(int16 template_id, int8 tab_id, int32 aa_id, int16 order, int8 treeid);
  627. PlayerTitlesList* GetPlayerTitles() { return &player_titles_list; }
  628. void AddLanguage(int32 id, const char *name, bool save_needed = false);
  629. PlayerLanguagesList* GetPlayerLanguages() { return &player_languages_list; }
  630. bool HasLanguage(int32 id);
  631. bool HasLanguage(const char* name);
  632. bool CanReceiveQuest(int32 quest_id);
  633. float GetBoatX() { if (info) return info->GetBoatX(); return 0; }
  634. float GetBoatY() { if (info) return info->GetBoatY(); return 0; }
  635. float GetBoatZ() { if (info) return info->GetBoatZ(); return 0; }
  636. int32 GetBoatSpawn() { if (info) return info->GetBoatSpawn(); return 0; }
  637. void SetBoatX(float x) { if (info) info->SetBoatX(x); }
  638. void SetBoatY(float y) { if (info) info->SetBoatY(y); }
  639. void SetBoatZ(float z) { if (info) info->SetBoatZ(z); }
  640. void SetBoatSpawn(Spawn* boat) { if (info) info->SetBoatSpawn(boat); }
  641. Mutex* GetGroupBuffMutex();
  642. void SetPendingDeletion(bool val) { pending_deletion = val; }
  643. bool GetPendingDeletion() { return pending_deletion; }
  644. float GetPosPacketSpeed() { return pos_packet_speed; }
  645. bool ControlFlagsChanged();
  646. void SetPlayerControlFlag(int8 param, int8 param_value, bool is_active);
  647. void SendControlFlagUpdates(Client* client);
  648. /// <summary>Casts all the passive spells for the player, only call after zoning is complete.</summary>
  649. void ApplyPassiveSpells();
  650. /// <summary>Removes all passive spell effects from the player and clears the passive list</summary>
  651. void RemoveAllPassives();
  652. /// <summary>Gets the current recipie ID</summary>
  653. int32 GetCurrentRecipe() { return current_recipe; }
  654. /// <summary>Sets the current recipie ID</summary>
  655. /// <param name="val">Id of the new recipe</param>
  656. void SetCurrentRecipe(int32 val) { current_recipe = val; }
  657. /// <summary>Reset the pet window info</summary>
  658. void ResetPetInfo();
  659. void ProcessCombat();
  660. /* Character history stuff */
  661. /// <summary>Adds a new history event to the player</summary>
  662. /// <param name="type">The history type</param>
  663. /// <param name="subtype">The history sub type</param>
  664. /// <param name="value">The first history value</param>
  665. /// <param name="value2">The second history value</param>
  666. void UpdatePlayerHistory(int8 type, int8 subtype, int32 value, int32 value2 = 0);
  667. /// <summary>Checks to see if the player has discovered the location</summary>
  668. /// <param name="locationID">The ID of the location to check</param>
  669. /// <returns>True if the player has discovered the location</returns>
  670. bool DiscoveredLocation(int32 locationID);
  671. /// <summary>Load the players history from the database</summary>
  672. /// <param name="type">The history type</param>
  673. /// <param name="subtype">The history sub type</param>
  674. /// <param name="hd">The history data</param>
  675. void LoadPlayerHistory(int8 type, int8 subtype, HistoryData* hd);
  676. /// <summary>Save the player's history to the database</summary>
  677. void SaveHistory();
  678. /* New functions for spell locking and unlocking*/
  679. /// <summary>Lock all Spells, Combat arts, and Abilities (not trade skill spells)</summary>
  680. void LockAllSpells();
  681. /// <summary>Unlocks all Spells, Combat arts, and Abilities (not trade skill spells)</summary>
  682. void UnlockAllSpells(bool modify_recast = false);
  683. /// <summary>Locks the given spell as well as all spells with a shared timer</summary>
  684. void LockSpell(Spell* spell, int16 recast);
  685. /// <summary>Unlocks the given spell as well as all spells with shared timers</summary>
  686. void UnlockSpell(Spell* spell);
  687. /// <summary>Locks all ts spells and unlocks all normal spells</summary>
  688. void LockTSSpells();
  689. /// <summary>Unlocks all ts spells and locks all normal spells</summary>
  690. void UnlockTSSpells();
  691. /// <summary>Queue the given spell</summary>
  692. void QueueSpell(Spell* spell);
  693. /// <summary>Unqueue the given spell</summary>
  694. void UnQueueSpell(Spell* spell);
  695. ///<summary>Get all the spells the player has with the given id</summary>
  696. vector<Spell*> GetSpellBookSpellsByTimer(int32 timerID);
  697. PacketStruct* GetQuestJournalPacket(Quest* quest, int16 version, int32 crc);
  698. void SetSpawnInfoStruct(PacketStruct* packet) { safe_delete(spawn_info_struct); spawn_info_struct = packet; }
  699. void SetSpawnVisStruct(PacketStruct* packet) { safe_delete(spawn_vis_struct); spawn_vis_struct = packet; }
  700. void SetSpawnPosStruct(PacketStruct* packet) { safe_delete(spawn_pos_struct); spawn_pos_struct = packet; }
  701. void SetSpawnHeaderStruct(PacketStruct* packet) { safe_delete(spawn_header_struct); spawn_header_struct = packet; }
  702. void SetSpawnFooterStruct(PacketStruct* packet) { safe_delete(spawn_footer_struct); spawn_footer_struct = packet; }
  703. void SetSignFooterStruct(PacketStruct* packet) { safe_delete(sign_footer_struct); sign_footer_struct = packet; }
  704. void SetWidgetFooterStruct(PacketStruct* packet) { safe_delete(widget_footer_struct); widget_footer_struct = packet; }
  705. PacketStruct* GetSpawnInfoStruct() { return spawn_info_struct; }
  706. PacketStruct* GetSpawnVisStruct() { return spawn_vis_struct; }
  707. PacketStruct* GetSpawnPosStruct() { return spawn_pos_struct; }
  708. PacketStruct* GetSpawnHeaderStruct() { return spawn_header_struct; }
  709. PacketStruct* GetSpawnFooterStruct() { return spawn_footer_struct; }
  710. PacketStruct* GetSignFooterStruct() { return sign_footer_struct; }
  711. PacketStruct* GetWidgetFooterStruct() { return widget_footer_struct; }
  712. Mutex info_mutex;
  713. Mutex pos_mutex;
  714. Mutex vis_mutex;
  715. void SetTempMount(int32 id) { tmp_mount_model = id; }
  716. int32 GetTempMount() { return tmp_mount_model; }
  717. void SetTempMountColor(EQ2_Color* color) { tmp_mount_color = *color; }
  718. EQ2_Color GetTempMountColor() { return tmp_mount_color; }
  719. void SetTempMountSaddleColor(EQ2_Color* color) { tmp_mount_saddle_color = *color; }
  720. EQ2_Color GetTempMountSaddleColor() { return tmp_mount_saddle_color; }
  721. void LoadLUAHistory(int32 event_id, LUAHistory* history);
  722. void SaveLUAHistory();
  723. void UpdateLUAHistory(int32 event_id, int32 value, int32 value2);
  724. LUAHistory* GetLUAHistory(int32 event_id);
  725. AppearanceData SavedApp;
  726. CharFeatures SavedFeatures;
  727. bool custNPC;
  728. Entity* custNPCTarget;
  729. // bot index, spawn id
  730. map<int32, int32> SpawnedBots;
  731. private:
  732. bool range_attack;
  733. int16 last_movement_activity;
  734. bool returning_from_ld;
  735. PlayerGroup* group;
  736. float test_x;
  737. float test_y;
  738. float test_z;
  739. int32 test_time;
  740. map<int32, map<int32, bool> > pending_loot_items;
  741. Mutex MSpellsBook;
  742. Mutex MRecipeBook;
  743. Mutex MPlayerQuests;
  744. map<Spawn*, bool> current_quest_flagged;
  745. PlayerFaction factions;
  746. map<int32, Quest*> completed_quests;
  747. map<Spawn*, int8> player_removed_spawns;
  748. bool charsheet_changed;
  749. map<int32, string> spawn_vis_packet_list;
  750. map<int32, string> spawn_info_packet_list;
  751. map<int32, string> spawn_pos_packet_list;
  752. uchar* movement_packet;
  753. uchar* old_movement_packet;
  754. uchar* spell_orig_packet;
  755. uchar* spell_xor_packet;
  756. int16 spell_count;
  757. //float speed;
  758. int16 target_id;
  759. Spawn* combat_target;
  760. int32 char_id;
  761. bool quickbar_updated;
  762. bool resurrecting;
  763. PlayerInfo* info;
  764. vector<SpellBookEntry*> spells;
  765. vector<QuickBarItem*> quickbar_items;
  766. map<int32, Statistic*> statistics;
  767. void RemovePlayerStatistics();
  768. map<string, int8> friend_list;
  769. map<string, int8> ignore_list;
  770. bool pending_deletion;
  771. float pos_packet_speed;
  772. PlayerControlFlags control_flags;
  773. // JA: POI Discoveries
  774. map<int32, vector<int32> > players_poi_list;
  775. // Jabantiz: Passive spell list, just stores spell id's
  776. vector<int32> passive_spells;
  777. /// <summary>Adds a new passive spell to the list</summary>
  778. /// <param name='id'>Spell id to add</param>
  779. /// <param name='tier'>Tier of spell to add</param>
  780. void AddPassiveSpell(int32 id, int8 tier);
  781. /// <summary>Removes a passive spell from the list</summary>
  782. /// <param name='id'>Spell id to remove</param>
  783. /// <param name='tier'>Tier of spell to remove</param>
  784. /// <param name='remove_from_list'>Remove the spell from this players passive list, default true</param>
  785. void RemovePassive(int32 id, int8 tier, bool remove_from_list = true);
  786. CharacterInstances character_instances;
  787. string away_message;
  788. string biography;
  789. MutexMap<int32, Mail*> mail_list;
  790. bool is_tracking;
  791. Guild* guild;
  792. PlayerCollectionList collection_list;
  793. Collection * pending_collection_reward;
  794. PlayerTitlesList player_titles_list;
  795. PlayerRecipeList recipe_list;
  796. PlayerLanguagesList player_languages_list;
  797. PlayerRecipeBookList recipebook_list;
  798. PlayerAchievementList achievement_list;
  799. PlayerAchievementUpdateList achievement_update_list;
  800. // Need to keep track of the recipe the player is crafting as not all crafting packets have this info
  801. int32 current_recipe;
  802. void HandleHistoryNone(int8 subtype, int32 value, int32 value2);
  803. void HandleHistoryDeath(int8 subtype, int32 value, int32 value2);
  804. void HandleHistoryDiscovery(int8 subtype, int32 value, int32 value2);
  805. void HandleHistoryXP(int8 subtype, int32 value, int32 value2);
  806. /// <summary></summary>
  807. void ModifySpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  808. void AddSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  809. void RemoveSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
  810. void InitXPTable();
  811. map<int8, int32> m_levelXPReq;
  812. //The following variables are for serializing spawn packets
  813. PacketStruct* spawn_pos_struct;
  814. PacketStruct* spawn_info_struct;
  815. PacketStruct* spawn_vis_struct;
  816. PacketStruct* spawn_header_struct;
  817. PacketStruct* spawn_footer_struct;
  818. PacketStruct* sign_footer_struct;
  819. PacketStruct* widget_footer_struct;
  820. uchar* spawn_tmp_vis_xor_packet;
  821. uchar* spawn_tmp_pos_xor_packet;
  822. uchar* spawn_tmp_info_xor_packet;
  823. // Character history, map<type, map<subtype, vector<data> > >
  824. map<int8, map<int8, vector<HistoryData*> > > m_characterHistory;
  825. map<int32, LUAHistory*> m_charLuaHistory;
  826. int32 tmp_mount_model;
  827. EQ2_Color tmp_mount_color;
  828. EQ2_Color tmp_mount_saddle_color;
  829. };
  830. #pragma pack()
  831. #endif