Advertisement
Guest User

Player.h

a guest
Oct 11th, 2010
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 95.69 KB | None | 0 0
  1.  
  2. #ifndef _PLAYER_H
  3. #define _PLAYER_H
  4.  
  5. #include "Common.h"
  6. #include "ItemPrototype.h"
  7. #include "Unit.h"
  8. #include "Item.h"
  9.  
  10. #include "Database/DatabaseEnv.h"
  11. #include "NPCHandler.h"
  12. #include "QuestDef.h"
  13. #include "Group.h"
  14. #include "Bag.h"
  15. #include "WorldSession.h"
  16. #include "Pet.h"
  17. #include "MapReference.h"
  18. #include "Util.h"                                           // for Tokens typedef
  19.  
  20. #include<string>
  21. #include<vector>
  22.  
  23. struct Mail;
  24. class Channel;
  25. class DynamicObject;
  26. class Creature;
  27. class Pet;
  28. class PlayerMenu;
  29. class Transport;
  30. class UpdateMask;
  31. class PlayerSocial;
  32. class OutdoorPvP;
  33.  
  34. typedef std::deque<Mail*> PlayerMails;
  35.  
  36. #define PLAYER_MAX_SKILLS       127
  37. #define PLAYER_MAX_DAILY_QUESTS 25
  38.  
  39. // Note: SPELLMOD_* values is aura types in fact
  40. enum SpellModType
  41. {
  42.     SPELLMOD_FLAT         = 107,                            // SPELL_AURA_ADD_FLAT_MODIFIER
  43.     SPELLMOD_PCT          = 108                             // SPELL_AURA_ADD_PCT_MODIFIER
  44. };
  45.  
  46. enum PlayerSpellState
  47. {
  48.     PLAYERSPELL_UNCHANGED = 0,
  49.     PLAYERSPELL_CHANGED   = 1,
  50.     PLAYERSPELL_NEW       = 2,
  51.     PLAYERSPELL_REMOVED   = 3
  52. };
  53.  
  54. struct PlayerSpell
  55. {
  56.     uint16 slotId          : 16;
  57.     PlayerSpellState state : 8;
  58.     bool active            : 1;
  59.     bool disabled          : 1;
  60. };
  61.  
  62. #define SPELL_WITHOUT_SLOT_ID uint16(-1)
  63.  
  64. struct SpellModifier
  65. {
  66.     SpellModOp   op   : 8;
  67.     SpellModType type : 8;
  68.     int16 charges     : 16;
  69.     int32 value;
  70.     uint64 mask;
  71.     uint32 spellId;
  72.     uint32 effectId;
  73.     Spell const* lastAffected;
  74. };
  75.  
  76. typedef UNORDERED_MAP<uint16, PlayerSpell*> PlayerSpellMap;
  77. typedef std::list<SpellModifier*> SpellModList;
  78.  
  79. struct SpellCooldown
  80. {
  81.     time_t end;
  82.     uint16 itemid;
  83. };
  84.  
  85. typedef std::map<uint32, SpellCooldown> SpellCooldowns;
  86.  
  87. enum TrainerSpellState
  88. {
  89.     TRAINER_SPELL_GREEN = 0,
  90.     TRAINER_SPELL_RED   = 1,
  91.     TRAINER_SPELL_GRAY  = 2
  92. };
  93.  
  94. enum ActionButtonUpdateState
  95. {
  96.     ACTIONBUTTON_UNCHANGED = 0,
  97.     ACTIONBUTTON_CHANGED   = 1,
  98.     ACTIONBUTTON_NEW       = 2,
  99.     ACTIONBUTTON_DELETED   = 3
  100. };
  101.  
  102. struct ActionButton
  103. {
  104.     ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {}
  105.     ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {}
  106.  
  107.     uint16 action;
  108.     uint8 type;
  109.     uint8 misc;
  110.     ActionButtonUpdateState uState;
  111. };
  112.  
  113. enum ActionButtonType
  114. {
  115.     ACTION_BUTTON_SPELL = 0,
  116.     ACTION_BUTTON_MACRO = 64,
  117.     ACTION_BUTTON_CMACRO= 65, //[TZERO] Tbc  [?]
  118.     ACTION_BUTTON_ITEM  = 128
  119. };
  120.  
  121. #define  MAX_ACTION_BUTTONS 120        // 132 in tbc  //checked in 2.3.0
  122.  
  123. typedef std::map<uint8,ActionButton> ActionButtonList;
  124.  
  125. typedef std::pair<uint16, uint8> CreateSpellPair;
  126.  
  127. struct PlayerCreateInfoItem
  128. {
  129.     PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {}
  130.  
  131.     uint32 item_id;
  132.     uint32 item_amount;
  133. };
  134.  
  135. typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems;
  136.  
  137. struct PlayerClassLevelInfo
  138. {
  139.     PlayerClassLevelInfo() : basehealth(0), basemana(0) {}
  140.     uint16 basehealth;
  141.     uint16 basemana;
  142. };
  143.  
  144. struct PlayerClassInfo
  145. {
  146.     PlayerClassInfo() : levelInfo(NULL) { }
  147.  
  148.     PlayerClassLevelInfo* levelInfo;                        //[level-1] 0..MaxPlayerLevel-1
  149. };
  150.  
  151. struct PlayerLevelInfo
  152. {
  153.     PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
  154.  
  155.     uint8 stats[MAX_STATS];
  156. };
  157.  
  158. struct PlayerInfo
  159. {
  160.                                                             // existence checked by displayId != 0             // existence checked by displayId != 0
  161.     PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL)
  162.     {
  163.     }
  164.  
  165.     uint32 mapId;
  166.     uint32 zoneId;
  167.     float positionX;
  168.     float positionY;
  169.     float positionZ;
  170.     uint16 displayId_m;
  171.     uint16 displayId_f;
  172.     PlayerCreateInfoItems item;
  173.     std::list<CreateSpellPair> spell;
  174.     std::list<uint16> action[4];
  175.  
  176.     PlayerLevelInfo* levelInfo;                             //[level-1] 0..MaxPlayerLevel-1
  177. };
  178.  
  179. struct PvPInfo
  180. {
  181.     PvPInfo() : inHostileArea(false), endTimer(0) {}
  182.  
  183.     bool inHostileArea;
  184.     time_t endTimer;
  185. };
  186.  
  187. struct DuelInfo
  188. {
  189.     DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
  190.  
  191.     Player *initiator;
  192.     Player *opponent;
  193.     time_t startTimer;
  194.     time_t startTime;
  195.     time_t outOfBound;
  196. };
  197.  
  198. struct Areas
  199. {
  200.     uint32 areaID;
  201.     uint32 areaFlag;
  202.     float x1;
  203.     float x2;
  204.     float y1;
  205.     float y2;
  206. };
  207.  
  208. enum FactionFlags
  209. {
  210.     FACTION_FLAG_VISIBLE            = 0x01,                 // makes visible in client (set or can be set at interaction with target of this faction)
  211.     FACTION_FLAG_AT_WAR             = 0x02,                 // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
  212.     FACTION_FLAG_HIDDEN             = 0x04,                 // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
  213.     FACTION_FLAG_INVISIBLE_FORCED   = 0x08,                 // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
  214.     FACTION_FLAG_PEACE_FORCED       = 0x10,                 // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
  215.     FACTION_FLAG_INACTIVE           = 0x20,                 // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
  216.     FACTION_FLAG_RIVAL              = 0x40                  // flag for the two competing outland factions
  217. };
  218.  
  219. typedef uint32 RepListID;
  220. struct FactionState
  221. {
  222.     uint32 ID;
  223.     RepListID ReputationListID;
  224.     uint32 Flags;
  225.     int32  Standing;
  226.     bool Changed;
  227. };
  228.  
  229. typedef std::map<RepListID,FactionState> FactionStateList;
  230.  
  231. typedef std::map<uint32,ReputationRank> ForcedReactions;
  232.  
  233. typedef std::set<uint64> GuardianPetList;
  234.  
  235. struct EnchantDuration
  236. {
  237.     EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {};
  238.     EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); };
  239.  
  240.     Item * item;
  241.     EnchantmentSlot slot;
  242.     uint32 leftduration;
  243. };
  244.  
  245. typedef std::list<EnchantDuration> EnchantDurationList;
  246. typedef std::list<Item*> ItemDurationList;
  247.  
  248. struct LookingForGroupSlot
  249. {
  250.     LookingForGroupSlot() : entry(0), type(0) {}
  251.     bool Empty() const { return !entry && !type; }
  252.     void Clear() { entry = 0; type = 0; }
  253.     void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; }
  254.     bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; }
  255.     bool canAutoJoin() const { return entry && (type == 1 || type == 5); }
  256.  
  257.     uint32 entry;
  258.     uint32 type;
  259. };
  260.  
  261. #define MAX_LOOKING_FOR_GROUP_SLOT 3
  262.  
  263. struct LookingForGroup
  264. {
  265.     LookingForGroup() {}
  266.     bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); }
  267.     bool HaveInSlot(uint32 _entry, uint32 _type) const
  268.     {
  269.         for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
  270.             if(slots[i].Is(_entry,_type))
  271.                 return true;
  272.         return false;
  273.     }
  274.  
  275.     bool canAutoJoin() const
  276.     {
  277.         for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
  278.             if(slots[i].canAutoJoin())
  279.                 return true;
  280.         return false;
  281.     }
  282.  
  283.     bool Empty() const
  284.     {
  285.         for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i)
  286.             if(!slots[i].Empty())
  287.                 return false;
  288.         return more.Empty();
  289.     }
  290.  
  291.     LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT];
  292.     LookingForGroupSlot more;
  293.     std::string comment;
  294. };
  295.  
  296. enum PlayerMovementType
  297. {
  298.     MOVE_ROOT       = 1,
  299.     MOVE_UNROOT     = 2,
  300.     MOVE_WATER_WALK = 3,
  301.     MOVE_LAND_WALK  = 4
  302. };
  303.  
  304. enum DrunkenState
  305. {
  306.     DRUNKEN_SOBER   = 0,
  307.     DRUNKEN_TIPSY   = 1,
  308.     DRUNKEN_DRUNK   = 2,
  309.     DRUNKEN_SMASHED = 3
  310. };
  311.  
  312. enum PlayerStateType
  313. {
  314.     /*
  315.         PLAYER_STATE_DANCE
  316.         PLAYER_STATE_SLEEP
  317.         PLAYER_STATE_SIT
  318.         PLAYER_STATE_STAND
  319.         PLAYER_STATE_READYUNARMED
  320.         PLAYER_STATE_WORK
  321.         PLAYER_STATE_POINT(DNR)
  322.         PLAYER_STATE_NONE // not used or just no state, just standing there?
  323.         PLAYER_STATE_STUN
  324.         PLAYER_STATE_DEAD
  325.         PLAYER_STATE_KNEEL
  326.         PLAYER_STATE_USESTANDING
  327.         PLAYER_STATE_STUN_NOSHEATHE
  328.         PLAYER_STATE_USESTANDING_NOSHEATHE
  329.         PLAYER_STATE_WORK_NOSHEATHE
  330.         PLAYER_STATE_SPELLPRECAST
  331.         PLAYER_STATE_READYRIFLE
  332.         PLAYER_STATE_WORK_NOSHEATHE_MINING
  333.         PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD
  334.         PLAYER_STATE_AT_EASE
  335.         PLAYER_STATE_READY1H
  336.         PLAYER_STATE_SPELLKNEELSTART
  337.         PLAYER_STATE_SUBMERGED
  338.     */
  339.  
  340.     PLAYER_STATE_NONE              = 0,
  341.     PLAYER_STATE_SIT               = 1,
  342.     PLAYER_STATE_SIT_CHAIR         = 2,
  343.     PLAYER_STATE_SLEEP             = 3,
  344.     PLAYER_STATE_SIT_LOW_CHAIR     = 4,
  345.     PLAYER_STATE_SIT_MEDIUM_CHAIR  = 5,
  346.     PLAYER_STATE_SIT_HIGH_CHAIR    = 6,
  347.     PLAYER_STATE_DEAD              = 7,
  348.     PLAYER_STATE_KNEEL             = 8,
  349.  
  350.     PLAYER_STATE_FORM_ALL          = 0x00FF0000,
  351.  
  352.     PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01,                  // byte 4 [TZERO] maybe we should use : PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01000000,
  353.     PLAYER_STATE_FLAG_CREEP        = 0x02000000,
  354.     PLAYER_STATE_FLAG_UNTRACKABLE  = 0x04000000,
  355.     PLAYER_STATE_FLAG_ALL          = 0xFF000000,
  356. };
  357.  
  358. enum TYPE_OF_KILL
  359. {
  360.     HONORABLE_KILL    = 1,
  361.     DISHONORABLE_KILL = 2,
  362. };
  363.  
  364. #define HONOR_RANK_COUNT 16
  365.  
  366.  
  367. enum PlayerFlags
  368. {
  369.     PLAYER_FLAGS_GROUP_LEADER   = 0x00000001,
  370.     PLAYER_FLAGS_AFK            = 0x00000002,
  371.     PLAYER_FLAGS_DND            = 0x00000004,
  372.     PLAYER_FLAGS_GM             = 0x00000008,
  373.     PLAYER_FLAGS_GHOST          = 0x00000010,
  374.     PLAYER_FLAGS_RESTING        = 0x00000020,
  375.     PLAYER_FLAGS_IN_PVP         = 0x00000200,
  376.     PLAYER_FLAGS_HIDE_HELM      = 0x00000400,
  377.     PLAYER_FLAGS_HIDE_CLOAK     = 0x00000800,
  378.     PLAYER_FLAGS_UNK            = 0x00001000,               //played long time
  379.     PLAYER_FLAGS_UNK2           = 0x00002000,               //played too long time
  380.  
  381.     //[TZERO] Tbc enumeration [?]
  382.     PLAYER_FLAGS_FFA_PVP        = 0x00000080,
  383.     PLAYER_FLAGS_CONTESTED_PVP  = 0x00000100,               // Player has been involved in a PvP combat and will be attacked by contested guards
  384.     PLAYER_FLAGS_SANCTUARY      = 0x00010000,               // player entered sanctuary
  385. };
  386.  
  387. // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
  388. // can't use enum for uint64 values
  389. #define PLAYER_TITLE_DISABLED              0x0000000000000000LL
  390. #define PLAYER_TITLE_NONE                  0x0000000000000001LL
  391. #define PLAYER_TITLE_PRIVATE               0x0000000000000002LL // 1
  392. #define PLAYER_TITLE_CORPORAL              0x0000000000000004LL // 2
  393. #define PLAYER_TITLE_SERGEANT_A            0x0000000000000008LL // 3
  394. #define PLAYER_TITLE_MASTER_SERGEANT       0x0000000000000010LL // 4
  395. #define PLAYER_TITLE_SERGEANT_MAJOR        0x0000000000000020LL // 5
  396. #define PLAYER_TITLE_KNIGHT                0x0000000000000040LL // 6
  397. #define PLAYER_TITLE_KNIGHT_LIEUTENANT     0x0000000000000080LL // 7
  398. #define PLAYER_TITLE_KNIGHT_CAPTAIN        0x0000000000000100LL // 8
  399. #define PLAYER_TITLE_KNIGHT_CHAMPION       0x0000000000000200LL // 9
  400. #define PLAYER_TITLE_LIEUTENANT_COMMANDER  0x0000000000000400LL // 10
  401. #define PLAYER_TITLE_COMMANDER             0x0000000000000800LL // 11
  402. #define PLAYER_TITLE_MARSHAL               0x0000000000001000LL // 12
  403. #define PLAYER_TITLE_FIELD_MARSHAL         0x0000000000002000LL // 13
  404. #define PLAYER_TITLE_GRAND_MARSHAL         0x0000000000004000LL // 14
  405. #define PLAYER_TITLE_SCOUT                 0x0000000000008000LL // 15
  406. #define PLAYER_TITLE_GRUNT                 0x0000000000010000LL // 16
  407. #define PLAYER_TITLE_SERGEANT_H            0x0000000000020000LL // 17
  408. #define PLAYER_TITLE_SENIOR_SERGEANT       0x0000000000040000LL // 18
  409. #define PLAYER_TITLE_FIRST_SERGEANT        0x0000000000080000LL // 19
  410. #define PLAYER_TITLE_STONE_GUARD           0x0000000000100000LL // 20
  411. #define PLAYER_TITLE_BLOOD_GUARD           0x0000000000200000LL // 21
  412. #define PLAYER_TITLE_LEGIONNAIRE           0x0000000000400000LL // 22
  413. #define PLAYER_TITLE_CENTURION             0x0000000000800000LL // 23
  414. #define PLAYER_TITLE_CHAMPION              0x0000000001000000LL // 24
  415. #define PLAYER_TITLE_LIEUTENANT_GENERAL    0x0000000002000000LL // 25
  416. #define PLAYER_TITLE_GENERAL               0x0000000004000000LL // 26
  417. #define PLAYER_TITLE_WARLORD               0x0000000008000000LL // 27
  418. #define PLAYER_TITLE_HIGH_WARLORD          0x0000000010000000LL // 28
  419. #define PLAYER_TITLE_GLADIATOR             0x0000000020000000LL // 29
  420. #define PLAYER_TITLE_DUELIST               0x0000000040000000LL // 30
  421. #define PLAYER_TITLE_RIVAL                 0x0000000080000000LL // 31
  422. #define PLAYER_TITLE_CHALLENGER            0x0000000100000000LL // 32
  423. #define PLAYER_TITLE_SCARAB_LORD           0x0000000200000000LL // 33
  424. #define PLAYER_TITLE_CONQUEROR             0x0000000400000000LL // 34
  425. #define PLAYER_TITLE_JUSTICAR              0x0000000800000000LL // 35
  426. #define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36
  427. #define PLAYER_TITLE_MERCILESS_GLADIATOR   0x0000002000000000LL // 37
  428. #define PLAYER_TITLE_OF_THE_SHATTERED_SUN  0x0000004000000000LL // 38
  429. #define PLAYER_TITLE_HAND_OF_ADAL          0x0000008000000000LL // 39
  430. #define PLAYER_TITLE_VENGEFUL_GLADIATOR    0x0000010000000000LL // 40
  431.  
  432. // used in PLAYER_FIELD_BYTES values
  433. enum PlayerFieldByteFlags
  434. {
  435.     PLAYER_FIELD_BYTE_TRACK_STEALTHED   = 0x00000002,
  436.     PLAYER_FIELD_BYTE_RELEASE_TIMER     = 0x00000008,       // Display time till auto release spirit
  437.     PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010        // Display no "release spirit" window at all
  438. };
  439.  
  440. // used in PLAYER_FIELD_BYTES2 values
  441. enum PlayerFieldByte2Flags
  442. {
  443.     PLAYER_FIELD_BYTE2_NONE              = 0x0000,
  444.     PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW = 0x4000
  445. };
  446.  
  447. enum ActivateTaxiReplies
  448. {
  449.     ERR_TAXIOK                      = 0,
  450.     ERR_TAXIUNSPECIFIEDSERVERERROR  = 1,
  451.     ERR_TAXINOSUCHPATH              = 2,
  452.     ERR_TAXINOTENOUGHMONEY          = 3,
  453.     ERR_TAXITOOFARAWAY              = 4,
  454.     ERR_TAXINOVENDORNEARBY          = 5,
  455.     ERR_TAXINOTVISITED              = 6,
  456.     ERR_TAXIPLAYERBUSY              = 7,
  457.     ERR_TAXIPLAYERALREADYMOUNTED    = 8,
  458.     ERR_TAXIPLAYERSHAPESHIFTED      = 9,
  459.     ERR_TAXIPLAYERMOVING            = 10,
  460.     ERR_TAXISAMENODE                = 11,
  461.     ERR_TAXINOTSTANDING             = 12
  462. };
  463.  
  464. enum LootType
  465. {
  466.     LOOT_CORPSE                 = 1,
  467.     LOOT_SKINNING               = 2,
  468.     LOOT_FISHING                = 3,
  469.     LOOT_PICKPOCKETING          = 4,                        // unsupported by client, sending LOOT_SKINNING instead
  470.     LOOT_DISENCHANTING          = 5,                        // unsupported by client, sending LOOT_SKINNING instead
  471.     LOOT_INSIGNIA               = 7,                        // unsupported by client, sending LOOT_SKINNING instead
  472.     LOOT_FISHINGHOLE            = 8                         // unsupported by client, sending LOOT_FISHING instead
  473. };
  474.  
  475. enum MirrorTimerType
  476. {
  477.     FATIGUE_TIMER      = 0,
  478.     BREATH_TIMER       = 1,
  479.     FIRE_TIMER         = 2
  480. };
  481.  
  482. // 2^n values
  483. enum PlayerExtraFlags
  484. {
  485.     // gm abilities
  486.     PLAYER_EXTRA_GM_ON              = 0x0001,
  487.     PLAYER_EXTRA_ACCEPT_WHISPERS    = 0x0004,
  488.     PLAYER_EXTRA_TAXICHEAT          = 0x0008,
  489.     PLAYER_EXTRA_GM_INVISIBLE       = 0x0010,
  490.     //[TZERO] PLAYER_EXTRA_GM_CHAT            = 0x0020,               // Show GM badge in chat messages
  491.  
  492.     // other states
  493.     PLAYER_EXTRA_PVP_DEATH          = 0x0100                // store PvP death status until corpse creating.
  494. };
  495.  
  496. // 2^n values
  497. enum AtLoginFlags
  498. {
  499.     AT_LOGIN_NONE          = 0,
  500.     AT_LOGIN_RENAME        = 1,
  501.     AT_LOGIN_RESET_SPELLS  = 2,
  502.     AT_LOGIN_RESET_TALENTS = 4
  503. };
  504.  
  505. typedef std::map<uint32, QuestStatusData> QuestStatusMap;
  506.  
  507. enum QuestSlotOffsets
  508. {
  509.     QUEST_ID_OFFSET     = 0,
  510.     QUEST_STATE_OFFSET  = 1,
  511.     QUEST_TIME_OFFSET   = 2
  512. };
  513.  
  514. #define MAX_QUEST_OFFSET 3
  515.  
  516. enum QuestSlotStateMask
  517. {
  518.     QUEST_STATE_NONE     = 0x0000,
  519.     QUEST_STATE_COMPLETE = 0x0001,
  520.     QUEST_STATE_FAIL     = 0x0002
  521. };
  522.  
  523. class Quest;
  524. class Spell;
  525. class Item;
  526. class WorldSession;
  527.  
  528. enum PlayerSlots
  529. {
  530.     // first slot for item stored (in any way in player m_items data)
  531.     PLAYER_SLOT_START           = 0,
  532.     // last+1 slot for item stored (in any way in player m_items data)
  533.     PLAYER_SLOT_END             = 97, //118 in tbc
  534.     PLAYER_SLOTS_COUNT          = (PLAYER_SLOT_END - PLAYER_SLOT_START)
  535. };
  536.  
  537. enum EquipmentSlots
  538. {
  539.     EQUIPMENT_SLOT_START        = 0,
  540.     EQUIPMENT_SLOT_HEAD         = 0,
  541.     EQUIPMENT_SLOT_NECK         = 1,
  542.     EQUIPMENT_SLOT_SHOULDERS    = 2,
  543.     EQUIPMENT_SLOT_BODY         = 3,
  544.     EQUIPMENT_SLOT_CHEST        = 4,
  545.     EQUIPMENT_SLOT_WAIST        = 5,
  546.     EQUIPMENT_SLOT_LEGS         = 6,
  547.     EQUIPMENT_SLOT_FEET         = 7,
  548.     EQUIPMENT_SLOT_WRISTS       = 8,
  549.     EQUIPMENT_SLOT_HANDS        = 9,
  550.     EQUIPMENT_SLOT_FINGER1      = 10,
  551.     EQUIPMENT_SLOT_FINGER2      = 11,
  552.     EQUIPMENT_SLOT_TRINKET1     = 12,
  553.     EQUIPMENT_SLOT_TRINKET2     = 13,
  554.     EQUIPMENT_SLOT_BACK         = 14,
  555.     EQUIPMENT_SLOT_MAINHAND     = 15,
  556.     EQUIPMENT_SLOT_OFFHAND      = 16,
  557.     EQUIPMENT_SLOT_RANGED       = 17,
  558.     EQUIPMENT_SLOT_TABARD       = 18,
  559.     EQUIPMENT_SLOT_END          = 19
  560. };
  561.  
  562. enum InventorySlots
  563. {
  564.     INVENTORY_SLOT_BAG_0        = 255,
  565.     INVENTORY_SLOT_BAG_START    = 19,
  566.     INVENTORY_SLOT_BAG_1        = 19,
  567.     INVENTORY_SLOT_BAG_2        = 20,
  568.     INVENTORY_SLOT_BAG_3        = 21,
  569.     INVENTORY_SLOT_BAG_4        = 22,
  570.     INVENTORY_SLOT_BAG_END      = 23,
  571.  
  572.     INVENTORY_SLOT_ITEM_START   = 23,
  573.     INVENTORY_SLOT_ITEM_1       = 23,
  574.     INVENTORY_SLOT_ITEM_2       = 24,
  575.     INVENTORY_SLOT_ITEM_3       = 25,
  576.     INVENTORY_SLOT_ITEM_4       = 26,
  577.     INVENTORY_SLOT_ITEM_5       = 27,
  578.     INVENTORY_SLOT_ITEM_6       = 28,
  579.     INVENTORY_SLOT_ITEM_7       = 29,
  580.     INVENTORY_SLOT_ITEM_8       = 30,
  581.     INVENTORY_SLOT_ITEM_9       = 31,
  582.     INVENTORY_SLOT_ITEM_10      = 32,
  583.     INVENTORY_SLOT_ITEM_11      = 33,
  584.     INVENTORY_SLOT_ITEM_12      = 34,
  585.     INVENTORY_SLOT_ITEM_13      = 35,
  586.     INVENTORY_SLOT_ITEM_14      = 36,
  587.     INVENTORY_SLOT_ITEM_15      = 37,
  588.     INVENTORY_SLOT_ITEM_16      = 38,
  589.     INVENTORY_SLOT_ITEM_END     = 39
  590. };
  591.  
  592. enum BankSlots
  593. {
  594.     BANK_SLOT_ITEM_START        = 39,
  595.     BANK_SLOT_ITEM_1            = 39,
  596.     BANK_SLOT_ITEM_2            = 40,
  597.     BANK_SLOT_ITEM_3            = 41,
  598.     BANK_SLOT_ITEM_4            = 42,
  599.     BANK_SLOT_ITEM_5            = 43,
  600.     BANK_SLOT_ITEM_6            = 44,
  601.     BANK_SLOT_ITEM_7            = 45,
  602.     BANK_SLOT_ITEM_8            = 46,
  603.     BANK_SLOT_ITEM_9            = 47,
  604.     BANK_SLOT_ITEM_10           = 48,
  605.     BANK_SLOT_ITEM_11           = 49,
  606.     BANK_SLOT_ITEM_12           = 50,
  607.     BANK_SLOT_ITEM_13           = 51,
  608.     BANK_SLOT_ITEM_14           = 52,
  609.     BANK_SLOT_ITEM_15           = 53,
  610.     BANK_SLOT_ITEM_16           = 54,
  611.     BANK_SLOT_ITEM_17           = 55,
  612.     BANK_SLOT_ITEM_18           = 56,
  613.     BANK_SLOT_ITEM_19           = 57,
  614.     BANK_SLOT_ITEM_20           = 58,
  615.     BANK_SLOT_ITEM_21           = 59,
  616.     BANK_SLOT_ITEM_22           = 60,
  617.     BANK_SLOT_ITEM_23           = 61,
  618.     BANK_SLOT_ITEM_24           = 62,
  619.     BANK_SLOT_ITEM_END          = 63,
  620.  
  621.     BANK_SLOT_BAG_START         = 63,
  622.     BANK_SLOT_BAG_1             = 63,
  623.     BANK_SLOT_BAG_2             = 64,
  624.     BANK_SLOT_BAG_3             = 65,
  625.     BANK_SLOT_BAG_4             = 66,
  626.     BANK_SLOT_BAG_5             = 67,
  627.     BANK_SLOT_BAG_6             = 68,
  628.     BANK_SLOT_BAG_END           = 69
  629. };
  630.  
  631. enum BuyBackSlots
  632. {
  633.     // strored in m_buybackitems
  634.     BUYBACK_SLOT_START          = 69,
  635.     BUYBACK_SLOT_1              = 69,
  636.     BUYBACK_SLOT_2              = 70,
  637.     BUYBACK_SLOT_3              = 71,
  638.     BUYBACK_SLOT_4              = 72,
  639.     BUYBACK_SLOT_5              = 73,
  640.     BUYBACK_SLOT_6              = 74,
  641.     BUYBACK_SLOT_7              = 75,
  642.     BUYBACK_SLOT_8              = 76,
  643.     BUYBACK_SLOT_9              = 77,
  644.     BUYBACK_SLOT_10             = 78,
  645.     BUYBACK_SLOT_11             = 79,
  646.     BUYBACK_SLOT_12             = 80,
  647.     BUYBACK_SLOT_END            = 81
  648. };
  649.  
  650. enum KeyRingSLots
  651. {
  652.     KEYRING_SLOT_START          = 81,
  653.     KEYRING_SLOT_END            = 97
  654. };
  655.  
  656. struct ItemPosCount
  657. {
  658.     ItemPosCount(uint16 _pos, uint8 _count) : pos(_pos), count(_count) {}
  659.     bool isContainedIn(std::vector<ItemPosCount> const& vec) const;
  660.     uint16 pos;
  661.     uint8 count;
  662. };
  663. typedef std::vector<ItemPosCount> ItemPosCountVec;
  664.  
  665. enum TradeSlots
  666. {
  667.     TRADE_SLOT_COUNT            = 7,
  668.     TRADE_SLOT_TRADED_COUNT     = 6,
  669.     TRADE_SLOT_NONTRADED        = 6
  670. };
  671.  
  672. enum TransferAbortReason
  673. {
  674.     TRANSFER_ABORT_MAX_PLAYERS          = 0x0001,           // Transfer Aborted: instance is full
  675.     TRANSFER_ABORT_NOT_FOUND            = 0x0002,           // Transfer Aborted: instance not found
  676.     TRANSFER_ABORT_TOO_MANY_INSTANCES   = 0x0003,           // You have entered too many instances recently.
  677.     TRANSFER_ABORT_ZONE_IN_COMBAT       = 0x0005,           // Unable to zone in while an encounter is in progress.
  678.     TRANSFER_ABORT_DIFFICULTY1          = 0x0007,           // Normal difficulty mode is not available for %s.
  679. };
  680.  
  681. enum InstanceResetWarningType
  682. {
  683.     RAID_INSTANCE_WARNING_HOURS     = 1,                    // WARNING! %s is scheduled to reset in %d hour(s).
  684.     RAID_INSTANCE_WARNING_MIN       = 2,                    // WARNING! %s is scheduled to reset in %d minute(s)!
  685.     RAID_INSTANCE_WARNING_MIN_SOON  = 3,                    // WARNING! %s is scheduled to reset in %d minute(s). Please exit the zone or you will be returned to your bind location!
  686.     RAID_INSTANCE_WELCOME           = 4                     // Welcome to %s. This raid instance is scheduled to reset in %s.
  687. };
  688.  
  689. struct MovementInfo
  690. {
  691.     // common
  692.     //uint32  flags;
  693.     uint8   unk1;
  694.     uint32  time;
  695.     float   x, y, z, o;
  696.     // transport
  697.     uint64  t_guid;
  698.     float   t_x, t_y, t_z, t_o;
  699.     uint32  t_time;
  700.     // swimming and unk
  701.     float   s_pitch;
  702.     // last fall time
  703.     uint32  fallTime;
  704.     // jumping
  705.     float   j_unk, j_sinAngle, j_cosAngle, j_xyspeed;
  706.     // spline
  707.     float   u_unk1;
  708.  
  709.     MovementInfo()
  710.     {
  711.         //flags =
  712.         time = t_time = fallTime = 0;
  713.         unk1 = 0;
  714.         x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f;
  715.         t_guid = 0;
  716.     }
  717.  
  718.     /*void SetMovementFlags(uint32 _flags)
  719.     {
  720.         flags = _flags;
  721.     }*/
  722. };
  723.  
  724. // flags that use in movement check for example at spell casting
  725. MovementFlags const movementFlagsMask = MovementFlags(
  726.     MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD  |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
  727.     MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1    |
  728.     MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING   |MOVEMENTFLAG_SPLINE
  729. );
  730.  
  731. MovementFlags const movementOrTurningFlagsMask = MovementFlags(
  732.     movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
  733. );
  734. class InstanceSave;
  735.  
  736. enum RestType
  737. {
  738.     REST_TYPE_NO        = 0,
  739.     REST_TYPE_IN_TAVERN = 1,
  740.     REST_TYPE_IN_CITY   = 2
  741. };
  742.  
  743. enum DuelCompleteType
  744. {
  745.     DUEL_INTERUPTED = 0,
  746.     DUEL_WON        = 1,
  747.     DUEL_FLED       = 2
  748. };
  749.  
  750. enum TeleportToOptions
  751. {
  752.     TELE_TO_GM_MODE             = 0x01,
  753.     TELE_TO_NOT_LEAVE_TRANSPORT = 0x02,
  754.     TELE_TO_NOT_LEAVE_COMBAT    = 0x04,
  755.     TELE_TO_NOT_UNSUMMON_PET    = 0x08,
  756.     TELE_TO_SPELL               = 0x10,
  757. };
  758.  
  759. /// Type of environmental damages
  760. enum EnvironmentalDamageType
  761. {
  762.     DAMAGE_EXHAUSTED = 0,
  763.     DAMAGE_DROWNING  = 1,
  764.     DAMAGE_FALL      = 2,
  765.     DAMAGE_LAVA      = 3,
  766.     DAMAGE_SLIME     = 4,
  767.     DAMAGE_FIRE      = 5,
  768.     DAMAGE_FALL_TO_VOID = 6                                 // custom case for fall without durability loss
  769. };
  770.  
  771. // used at player loading query list preparing, and later result selection
  772. enum PlayerLoginQueryIndex
  773. {
  774.     PLAYER_LOGIN_QUERY_LOADFROM                 = 0,
  775.     PLAYER_LOGIN_QUERY_LOADGROUP                = 1,
  776.     PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES       = 2,
  777.     PLAYER_LOGIN_QUERY_LOADAURAS                = 3,
  778.     PLAYER_LOGIN_QUERY_LOADSPELLS               = 4,
  779.     PLAYER_LOGIN_QUERY_LOADQUESTSTATUS          = 5,
  780.     PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS     = 6,
  781.     PLAYER_LOGIN_QUERY_LOADTUTORIALS            = 7,        // common for all characters for some account at specific realm
  782.     PLAYER_LOGIN_QUERY_LOADREPUTATION           = 8,
  783.     PLAYER_LOGIN_QUERY_LOADINVENTORY            = 9,
  784.     PLAYER_LOGIN_QUERY_LOADACTIONS              = 10,
  785.     PLAYER_LOGIN_QUERY_LOADMAILCOUNT            = 11,
  786.     PLAYER_LOGIN_QUERY_LOADMAILDATE             = 12,
  787.     PLAYER_LOGIN_QUERY_LOADSOCIALLIST           = 13,
  788.     PLAYER_LOGIN_QUERY_LOADHOMEBIND             = 14,
  789.     PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS       = 15,
  790.     PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES        = 16,
  791.     PLAYER_LOGIN_QUERY_LOADGUILD                = 17,
  792.  
  793.     MAX_PLAYER_LOGIN_QUERY
  794. };
  795.  
  796. // Player summoning auto-decline time (in secs)
  797. #define MAX_PLAYER_SUMMON_DELAY                   (2*MINUTE)
  798. #define MAX_MONEY_AMOUNT                       (0x7FFFFFFF-1)
  799.  
  800. struct InstancePlayerBind
  801. {
  802.     InstanceSave *save;
  803.     bool perm;
  804.     /* permanent PlayerInstanceBinds are created in Raid instances for players
  805.        that aren't already permanently bound when they are inside when a boss is killed
  806.        or when they enter an instance that the group leader is permanently bound to. */
  807.     InstancePlayerBind() : save(NULL), perm(false) {}
  808. };
  809.  
  810. struct AccessRequirement
  811. {
  812.     uint8  levelMin;
  813.     uint8  levelMax;
  814.     uint32 item;
  815.     uint32 item2;
  816.     uint32 quest;
  817.     std::string questFailedText;
  818.  };
  819.  
  820. class TRINITY_DLL_SPEC PlayerTaxi
  821. {
  822.     public:
  823.         PlayerTaxi();
  824.         ~PlayerTaxi() {}
  825.         // Nodes
  826.         void InitTaxiNodes(uint32 race, uint32 level);
  827.         void LoadTaxiMask(const char* data);
  828.         void SaveTaxiMask(const char* data);
  829.  
  830.         uint32 GetTaximask( uint8 index ) const { return m_taximask[index]; }
  831.         bool IsTaximaskNodeKnown(uint32 nodeidx) const
  832.         {
  833.             uint8  field   = uint8((nodeidx - 1) / 32);
  834.             uint32 submask = 1<<((nodeidx-1)%32);
  835.             return (m_taximask[field] & submask) == submask;
  836.         }
  837.         bool SetTaximaskNode(uint32 nodeidx)
  838.         {
  839.             uint8  field   = uint8((nodeidx - 1) / 32);
  840.             uint32 submask = 1<<((nodeidx-1)%32);
  841.             if ((m_taximask[field] & submask) != submask )
  842.             {
  843.                 m_taximask[field] |= submask;
  844.                 return true;
  845.             }
  846.             else
  847.                 return false;
  848.         }
  849.         void AppendTaximaskTo(ByteBuffer& data,bool all);
  850.  
  851.         // Destinations
  852.         bool LoadTaxiDestinationsFromString(const std::string& values);
  853.         std::string SaveTaxiDestinationsToString();
  854.  
  855.         void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
  856.         void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
  857.         uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
  858.         uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
  859.         uint32 GetCurrentTaxiPath() const;
  860.         uint32 NextTaxiDestination()
  861.         {
  862.             m_TaxiDestinations.pop_front();
  863.             return GetTaxiDestination();
  864.         }
  865.         bool empty() const { return m_TaxiDestinations.empty(); }
  866.     private:
  867.         TaxiMask m_taximask;
  868.         std::deque<uint32> m_TaxiDestinations;
  869. };
  870.  
  871. class TRINITY_DLL_SPEC Player : public Unit
  872. {
  873.     friend class WorldSession;
  874.     friend void Item::AddToUpdateQueueOf(Player *player);
  875.     friend void Item::RemoveFromUpdateQueueOf(Player *player);
  876.     public:
  877.         explicit Player (WorldSession *session);
  878.         ~Player ( );
  879.  
  880.         void CleanupsBeforeDelete();
  881.  
  882.         static UpdateMask updateVisualBits;
  883.         static void InitVisibleBits();
  884.  
  885.         void AddToWorld();
  886.         void RemoveFromWorld();
  887.  
  888.         void SetViewport(uint64 guid, bool movable);
  889.         void StopCastingCharm() { Uncharm(); }
  890.         void StopCastingBindSight();
  891.         WorldObject* GetFarsightTarget() const;
  892.         void ClearFarsight();
  893.         void SetFarsightTarget(WorldObject* target);
  894.         // Controls if vision is currently on farsight object, updated in FAR_SIGHT opcode
  895.         void SetFarsightVision(bool apply) { m_farsightVision = apply; }
  896.         bool HasFarsightVision() const { return m_farsightVision; }
  897.  
  898.         bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
  899.  
  900.         bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
  901.         {
  902.             return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options);
  903.         }
  904.  
  905.         void SetSummonPoint(uint32 mapid, float x, float y, float z)
  906.         {
  907.             m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
  908.             m_summon_mapid = mapid;
  909.             m_summon_x = x;
  910.             m_summon_y = y;
  911.             m_summon_z = z;
  912.         }
  913.         void SummonIfPossible(bool agree);
  914.  
  915.         bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId );
  916.  
  917.         void Update( uint32 time );
  918.  
  919.         void BuildEnumData( QueryResult * result,  WorldPacket * p_data );
  920.  
  921.         void SetInWater(bool apply);
  922.  
  923.         bool IsInWater() const { return m_isInWater; }
  924.         bool IsUnderWater() const;
  925.  
  926.         void SendInitialPacketsBeforeAddToMap();
  927.         void SendInitialPacketsAfterAddToMap();
  928.         void SendTransferAborted(uint32 mapid, uint16 reason);
  929.         void SendInstanceResetWarning(uint32 mapid, uint32 time);
  930.  
  931.         bool CanInteractWithNPCs(bool alive = true) const;
  932.  
  933.         bool ToggleAFK();
  934.         bool ToggleDND();
  935.         bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); };
  936.         bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); };
  937.         uint8 chatTag() const;
  938.         std::string afkMsg;
  939.         std::string dndMsg;
  940.  
  941.         PlayerSocial *GetSocial() { return m_social; }
  942.  
  943.         PlayerTaxi m_taxi;
  944.         void InitTaxiNodes() { m_taxi.InitTaxiNodes(getRace(),getLevel()); }
  945.         bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, uint32 mount_id = 0 , Creature* npc = NULL);
  946.                                                             // mount_id can be used in scripting calls
  947.         bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
  948.         void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
  949.         bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
  950.         void SetGameMaster(bool on);
  951.         bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_ON); }
  952.         void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ON; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ON; }
  953.         bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
  954.         void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
  955.         bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
  956.         void SetGMVisible(bool on);
  957.         void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
  958.  
  959.         void GiveXP(uint32 xp, Unit* victim);
  960.         void GiveLevel(uint32 level);
  961.         void InitStatsForLevel(bool reapplyMods = false);
  962.  
  963.         // Played Time Stuff
  964.         time_t m_logintime;
  965.         time_t m_Last_tick;
  966.         uint32 m_Played_time[2];
  967.         uint32 GetTotalPlayedTime() { return m_Played_time[0]; };
  968.         uint32 GetLevelPlayedTime() { return m_Played_time[1]; };
  969.  
  970.         void setDeathState(DeathState s);                   // overwrite Unit::setDeathState
  971.  
  972.         void InnEnter (int time,uint32 mapid, float x,float y,float z)
  973.         {
  974.             inn_pos_mapid = mapid;
  975.             inn_pos_x = x;
  976.             inn_pos_y = y;
  977.             inn_pos_z = z;
  978.             time_inn_enter = time;
  979.         };
  980.  
  981.         float GetRestBonus() const { return m_rest_bonus; };
  982.         void SetRestBonus(float rest_bonus_new);
  983.  
  984.         RestType GetRestType() const { return rest_type; };
  985.         void SetRestType(RestType n_r_type) { rest_type = n_r_type; };
  986.  
  987.         uint32 GetInnPosMapId() const { return inn_pos_mapid; };
  988.         float GetInnPosX() const { return inn_pos_x; };
  989.         float GetInnPosY() const { return inn_pos_y; };
  990.         float GetInnPosZ() const { return inn_pos_z; };
  991.  
  992.         int GetTimeInnEnter() const { return time_inn_enter; };
  993.         void UpdateInnerTime (int time) { time_inn_enter = time; };
  994.  
  995.         Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime);
  996.         void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
  997.         void RemoveMiniPet();
  998.         Pet* GetMiniPet();
  999.         void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); }
  1000.         void RemoveGuardians();
  1001.         bool HasGuardianWithEntry(uint32 entry);
  1002.         void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); }
  1003.         GuardianPetList const& GetGuardians() const { return m_guardianPets; }
  1004.         void Uncharm();
  1005.  
  1006.         void Say(const std::string& text, const uint32 language);
  1007.         void Yell(const std::string& text, const uint32 language);
  1008.         void TextEmote(const std::string& text);
  1009.         void Whisper(const std::string& text, const uint32 language,uint64 receiver);
  1010.         void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
  1011.  
  1012.         /*********************************************************/
  1013.         /***                    STORAGE SYSTEM                 ***/
  1014.         /*********************************************************/
  1015.  
  1016.         void SetVirtualItemSlot( uint8 i, Item* item);
  1017.         void SetSheath( uint32 sheathed );
  1018.         uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
  1019.         uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const;
  1020.         Item* GetItemByGuid( uint64 guid ) const;
  1021.         Item* GetItemByPos( uint16 pos ) const;
  1022.         Item* GetItemByPos( uint8 bag, uint8 slot ) const;
  1023.         Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
  1024.         Item* GetShield(bool useable = false) const;
  1025.         static uint32 GetAttackBySlot( uint8 slot );        // MAX_ATTACK if not weapon slot
  1026.         std::vector<Item *> &GetItemUpdateQueue() { return m_itemUpdateQueue; }
  1027.         static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); }
  1028.         static bool IsInventoryPos( uint8 bag, uint8 slot );
  1029.         static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); }
  1030.         static bool IsEquipmentPos( uint8 bag, uint8 slot );
  1031.         static bool IsBagPos( uint16 pos );
  1032.         static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
  1033.         static bool IsBankPos( uint8 bag, uint8 slot );
  1034.         bool IsValidPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); }
  1035.         bool IsValidPos( uint8 bag, uint8 slot );
  1036.         bool HasBankBagSlot( uint8 slot ) const;
  1037.         bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
  1038.         bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
  1039.         Item* GetItemOrItemWithGemEquipped( uint32 item ) const;
  1040.         uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); }
  1041.         uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); }
  1042.         uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
  1043.         {
  1044.             return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
  1045.         }
  1046.         uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
  1047.         {
  1048.             if(!pItem)
  1049.                 return EQUIP_ERR_ITEM_NOT_FOUND;
  1050.             uint32 count = pItem->GetCount();
  1051.             return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
  1052.  
  1053.         }
  1054.         uint8 CanStoreItems( Item **pItem,int count) const;
  1055.         uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
  1056.         uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
  1057.         uint8 CanUnequipItems( uint32 item, uint32 count ) const;
  1058.         uint8 CanUnequipItem( uint16 src, bool swap ) const;
  1059.         uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
  1060.         uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
  1061.         bool CanUseItem( ItemPrototype const *pItem );
  1062.         uint8 CanUseAmmo( uint32 item ) const;
  1063.         Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
  1064.         Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
  1065.         Item* EquipNewItem( uint16 pos, uint32 item, bool update );
  1066.         Item* EquipItem( uint16 pos, Item *pItem, bool update );
  1067.         void AutoUnequipOffhandIfNeed();
  1068.         bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
  1069.  
  1070.         uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
  1071.         uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
  1072.  
  1073.         void ApplyEquipCooldown( Item * pItem );
  1074.         void SetAmmo( uint32 item );
  1075.         void RemoveAmmo();
  1076.         float GetAmmoDPS() const { return m_ammoDPS; }
  1077.         bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const;
  1078.         void QuickEquipItem( uint16 pos, Item *pItem);
  1079.         void VisualizeItem( uint8 slot, Item *pItem);
  1080.         void SetVisibleItemSlot(uint8 slot, Item *pItem);
  1081.         Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update )
  1082.         {
  1083.             return StoreItem( dest, pItem, update);
  1084.         }
  1085.         Item* BankItem( uint16 pos, Item *pItem, bool update );
  1086.         void RemoveItem( uint8 bag, uint8 slot, bool update );
  1087.         void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
  1088.                                                             // in trade, auction, guild bank, mail....
  1089.         void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
  1090.                                                             // in trade, guild bank, mail....
  1091.         void RemoveItemDependentAurasAndCasts( Item * pItem );
  1092.         void DestroyItem( uint8 bag, uint8 slot, bool update );
  1093.         void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
  1094.         void DestroyItemCount( Item* item, uint32& count, bool update );
  1095.         void DestroyConjuredItems( bool update );
  1096.         void DestroyZoneLimitedItem( bool update, uint32 new_zone );
  1097.         void SplitItem( uint16 src, uint16 dst, uint32 count );
  1098.         void SwapItem( uint16 src, uint16 dst );
  1099.         void AddItemToBuyBackSlot( Item *pItem );
  1100.         Item* GetItemFromBuyBackSlot( uint32 slot );
  1101.         void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
  1102.         uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
  1103.         void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 );
  1104.         void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
  1105.         void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
  1106.         void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
  1107.         void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
  1108.         uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
  1109.         uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
  1110.         bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; }
  1111.         bool IsUseEquipedWeapon( bool mainhand ) const
  1112.         {
  1113.             // disarm applied only to mainhand weapon
  1114.             return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
  1115.         }
  1116.         void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false );
  1117.         bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot);
  1118.  
  1119.         float GetReputationPriceDiscount( Creature const* pCreature ) const;
  1120.         Player* GetTrader() const { return pTrader; }
  1121.         void ClearTrade();
  1122.         void TradeCancel(bool sendback);
  1123.         uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; }
  1124.  
  1125.         void UpdateEnchantTime(uint32 time);
  1126.         void UpdateItemDuration(uint32 time, bool realtimeonly=false);
  1127.         void AddEnchantmentDurations(Item *item);
  1128.         void RemoveEnchantmentDurations(Item *item);
  1129.         void RemoveAllEnchantments(EnchantmentSlot slot);
  1130.         void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration);
  1131.         void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false);
  1132.         void ApplyEnchantment(Item *item,bool apply);
  1133.         void SendEnchantmentDurations();
  1134.         void AddItemDurations(Item *item);
  1135.         void RemoveItemDurations(Item *item);
  1136.         void SendItemDurations();
  1137.         void LoadCorpse();
  1138.         void LoadPet();
  1139.  
  1140.         uint32 m_stableSlots;
  1141.  
  1142.         /*********************************************************/
  1143.         /***                    QUEST SYSTEM                   ***/
  1144.         /*********************************************************/
  1145.  
  1146.         void PrepareQuestMenu( uint64 guid );
  1147.         void SendPreparedQuest( uint64 guid );
  1148.         bool IsActiveQuest( uint32 quest_id ) const;
  1149.         Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
  1150.         bool CanSeeStartQuest( Quest const *pQuest );
  1151.         bool CanTakeQuest( Quest const *pQuest, bool msg );
  1152.         bool CanAddQuest( Quest const *pQuest, bool msg );
  1153.         bool CanCompleteQuest( uint32 quest_id );
  1154.         bool CanCompleteRepeatableQuest(Quest const *pQuest);
  1155.         bool CanRewardQuest( Quest const *pQuest, bool msg );
  1156.         bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
  1157.         void AddQuest( Quest const *pQuest, Object *questGiver );
  1158.         void CompleteQuest( uint32 quest_id );
  1159.         void IncompleteQuest( uint32 quest_id );
  1160.         void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
  1161.         void FailQuest( uint32 quest_id );
  1162.         void FailTimedQuest( uint32 quest_id );
  1163.         bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
  1164.         bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
  1165.         bool SatisfyQuestLog( bool msg );
  1166.         bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
  1167.         bool SatisfyQuestRace( Quest const* qInfo, bool msg );
  1168.         bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
  1169.         bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
  1170.         bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
  1171.         bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
  1172.         bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
  1173.         bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
  1174.         bool SatisfyQuestDay( Quest const* qInfo, bool msg );
  1175.         bool GiveQuestSourceItem( Quest const *pQuest );
  1176.         bool TakeQuestSourceItem( uint32 quest_id, bool msg );
  1177.         bool GetQuestRewardStatus( uint32 quest_id ) const;
  1178.         QuestStatus GetQuestStatus( uint32 quest_id ) const;
  1179.         void SetQuestStatus( uint32 quest_id, QuestStatus status );
  1180.  
  1181.         uint16 FindQuestSlot( uint32 quest_id ) const;
  1182.         uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
  1183.         uint32 GetQuestSlotState(uint16 slot)   const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
  1184.         uint32 GetQuestSlotTime(uint16 slot)    const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
  1185.         void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0)
  1186.         {
  1187.             SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id);
  1188.             SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0);
  1189.             SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer);
  1190.         }
  1191.         void SetQuestSlotState(uint16 slot,uint32 state) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); }
  1192.         void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); }
  1193.         void SwapQuestSlot(uint16 slot1,uint16 slot2)
  1194.         {
  1195.             for (int i = 0; i < MAX_QUEST_OFFSET ; ++i )
  1196.             {
  1197.                 uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i);
  1198.                 uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i);
  1199.  
  1200.                 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2);
  1201.                 SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1);
  1202.             }
  1203.         }
  1204.         uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
  1205.         void AdjustQuestReqItemCount( Quest const* pQuest );
  1206.         void AreaExploredOrEventHappens( uint32 questId );
  1207.         void GroupEventHappens( uint32 questId, WorldObject const* pEventObject );
  1208.         void ItemAddedQuestCheck( uint32 entry, uint32 count );
  1209.         void ItemRemovedQuestCheck( uint32 entry, uint32 count );
  1210.         void KilledMonster( uint32 entry, uint64 guid );
  1211.         void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
  1212.         void TalkedToCreature( uint32 entry, uint64 guid );
  1213.         void MoneyChanged( uint32 value );
  1214.         bool HasQuestForItem( uint32 itemid ) const;
  1215.         bool HasQuestForGO(int32 GOId);
  1216.         void UpdateForQuestsGO();
  1217.         bool CanShareQuest(uint32 quest_id) const;
  1218.  
  1219.         void SendQuestComplete( uint32 quest_id );
  1220.         void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
  1221.         void SendQuestFailed( uint32 quest_id );
  1222.         void SendQuestTimerFailed( uint32 quest_id );
  1223.         void SendCanTakeQuestResponse( uint32 msg );
  1224.         void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
  1225.         void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
  1226.         void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
  1227.  
  1228.         uint64 GetDivider() { return m_divider; };
  1229.         void SetDivider( uint64 guid ) { m_divider = guid; };
  1230.  
  1231.         uint32 GetInGameTime() { return m_ingametime; };
  1232.  
  1233.         void SetInGameTime( uint32 time ) { m_ingametime = time; };
  1234.  
  1235.         void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); }
  1236.  
  1237.         /*********************************************************/
  1238.         /***                   LOAD SYSTEM                     ***/
  1239.         /*********************************************************/
  1240.  
  1241.         bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
  1242.         bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
  1243.         static bool   LoadValuesArrayFromDB(Tokens& data,uint64 guid);
  1244.         static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
  1245.         static float  GetFloatValueFromArray(Tokens const& data, uint16 index);
  1246.         static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
  1247.         static float  GetFloatValueFromDB(uint16 index, uint64 guid);
  1248.         static uint32 GetZoneIdFromDB(uint64 guid);
  1249.         static bool   LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
  1250.  
  1251.         /*********************************************************/
  1252.         /***                   SAVE SYSTEM                     ***/
  1253.         /*********************************************************/
  1254.  
  1255.         void SaveToDB();
  1256.         void SaveInventoryAndGoldToDB();                    // fast save function for item/money cheating preventing
  1257.         void SaveDataFieldToDB();
  1258.         static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
  1259.         static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
  1260.         static void SetFloatValueInArray(Tokens& data,uint16 index, float value);
  1261.         static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid);
  1262.         static void SetFloatValueInDB(uint16 index, float value, uint64 guid);
  1263.         static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
  1264.  
  1265.         bool m_mailsLoaded;
  1266.         bool m_mailsUpdated;
  1267.  
  1268.         void SetBindPoint(uint64 guid);
  1269.         void SendTalentWipeConfirm(uint64 guid);
  1270.         void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
  1271.         void SendPetSkillWipeConfirm();
  1272.         void CalcRage( uint32 damage,bool attacker );
  1273.         void RegenerateAll();
  1274.         void Regenerate(Powers power);
  1275.         void RegenerateHealth();
  1276.         void setRegenTimer(uint32 time) {m_regenTimer = time;}
  1277.         void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
  1278.  
  1279.         uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
  1280.         void ModifyMoney( int32 d )
  1281.         {
  1282.             if(d < 0)
  1283.                 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
  1284.             else
  1285.                 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
  1286.  
  1287.             // "At Gold Limit"
  1288.             if(GetMoney() >= MAX_MONEY_AMOUNT)
  1289.                 SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL);
  1290.         }
  1291.         void SetMoney( uint32 value )
  1292.         {
  1293.             SetUInt32Value (PLAYER_FIELD_COINAGE, value);
  1294.             MoneyChanged( value );
  1295.         }
  1296.  
  1297.         uint32 GetTutorialInt(uint32 intId )
  1298.         {
  1299.             ASSERT( (intId < 8) );
  1300.             return m_Tutorials[intId];
  1301.         }
  1302.  
  1303.         void SetTutorialInt(uint32 intId, uint32 value)
  1304.         {
  1305.             ASSERT( (intId < 8) );
  1306.             if(m_Tutorials[intId]!=value)
  1307.             {
  1308.                 m_Tutorials[intId] = value;
  1309.                 m_TutorialsChanged = true;
  1310.             }
  1311.         }
  1312.  
  1313.         QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
  1314.  
  1315.         const uint64& GetSelection( ) const { return m_curSelection; }
  1316.         void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); }
  1317.  
  1318.         uint8 GetComboPoints() { return m_comboPoints; }
  1319.         uint64 GetComboTarget() { return m_comboTarget; }
  1320.  
  1321.         void AddComboPoints(Unit* target, int8 count);
  1322.         void ClearComboPoints();
  1323.         void SendComboPoints();
  1324.  
  1325.         void SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
  1326.         void SendNewMail();
  1327.         void UpdateNextMailTimeAndUnreads();
  1328.         void AddNewMailDeliverTime(time_t deliver_time);
  1329.         bool IsMailsLoaded() const { return m_mailsLoaded; }
  1330.  
  1331.         //void SetMail(Mail *m);
  1332.         void RemoveMail(uint32 id);
  1333.  
  1334.         void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo
  1335.         uint32 GetMailSize() { return m_mail.size();};
  1336.         Mail* GetMail(uint32 id);
  1337.  
  1338.         PlayerMails::iterator GetmailBegin() { return m_mail.begin();};
  1339.         PlayerMails::iterator GetmailEnd() { return m_mail.end();};
  1340.  
  1341.         /*********************************************************/
  1342.         /*** MAILED ITEMS SYSTEM ***/
  1343.         /*********************************************************/
  1344.  
  1345.         uint8 unReadMails;
  1346.         time_t m_nextMailDelivereTime;
  1347.  
  1348.         typedef UNORDERED_MAP<uint32, Item*> ItemMap;
  1349.  
  1350.         ItemMap mMitems;                                    //template defined in objectmgr.cpp
  1351.  
  1352.         Item* GetMItem(uint32 id)
  1353.         {
  1354.             ItemMap::const_iterator itr = mMitems.find(id);
  1355.             if (itr != mMitems.end())
  1356.                 return itr->second;
  1357.  
  1358.             return NULL;
  1359.         }
  1360.  
  1361.         void AddMItem(Item* it)
  1362.         {
  1363.             ASSERT( it );
  1364.             //assert deleted, because items can be added before loading
  1365.             mMitems[it->GetGUIDLow()] = it;
  1366.         }
  1367.  
  1368.         bool RemoveMItem(uint32 id)
  1369.         {
  1370.             ItemMap::iterator i = mMitems.find(id);
  1371.             if (i == mMitems.end())
  1372.                 return false;
  1373.  
  1374.             mMitems.erase(i);
  1375.             return true;
  1376.         }
  1377.  
  1378.         void PetSpellInitialize();
  1379.         void CharmSpellInitialize();
  1380.         void PossessSpellInitialize();
  1381.         bool HasSpell(uint32 spell) const;
  1382.         TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
  1383.         bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
  1384.  
  1385.         void SendProficiency(uint8 pr1, uint32 pr2);
  1386.         void SendInitialSpells();
  1387.         bool addSpell(uint32 spell_id, bool active, bool learning = true, bool loading = false, uint16 slot_id=SPELL_WITHOUT_SLOT_ID, bool disabled = false);
  1388.         void learnSpell(uint32 spell_id);
  1389.         void removeSpell(uint32 spell_id, bool disabled = false);
  1390.         void resetSpells();
  1391.         void learnDefaultSpells(bool loading = false);
  1392.         void learnQuestRewardedSpells();
  1393.         void learnQuestRewardedSpells(Quest const* quest);
  1394.  
  1395.         uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
  1396.         void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
  1397.         bool resetTalents(bool no_cost = false);
  1398.         uint32 resetTalentsCost() const;
  1399.         void InitTalentForLevel();
  1400.  
  1401.         uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
  1402.         void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); }
  1403.         void InitPrimaryProfessions();
  1404.  
  1405.         PlayerSpellMap const& GetSpellMap() const { return m_spells; }
  1406.         PlayerSpellMap      & GetSpellMap()       { return m_spells; }
  1407.  
  1408.         void AddSpellMod(SpellModifier* mod, bool apply);
  1409.         int32 GetTotalFlatMods(uint32 spellId, SpellModOp op);
  1410.         int32 GetTotalPctMods(uint32 spellId, SpellModOp op);
  1411.         bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL);
  1412.         template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
  1413.         void RemoveSpellMods(Spell const* spell);
  1414.  
  1415.         bool HasSpellCooldown(uint32 spell_id) const
  1416.         {
  1417.             SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
  1418.             return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
  1419.         }
  1420.         uint32 GetSpellCooldownDelay(uint32 spell_id) const
  1421.         {
  1422.             SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
  1423.             time_t t = time(NULL);
  1424.             return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
  1425.         }
  1426.         void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
  1427.         void SendCooldownEvent(SpellEntry const *spellInfo);
  1428.         void ProhibitSpellScholl(SpellSchools idSchool, uint32 unTimeMs );
  1429.         void RemoveSpellCooldown(uint32 spell_id) { m_spellCooldowns.erase(spell_id); }
  1430.         void RemoveAllSpellCooldown();
  1431.         void _LoadSpellCooldowns(QueryResult *result);
  1432.         void _SaveSpellCooldowns();
  1433.  
  1434.         void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
  1435.         {
  1436.             m_resurrectGUID = guid;
  1437.             m_resurrectMap = mapId;
  1438.             m_resurrectX = X;
  1439.             m_resurrectY = Y;
  1440.             m_resurrectZ = Z;
  1441.             m_resurrectHealth = health;
  1442.             m_resurrectMana = mana;
  1443.         };
  1444.         void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); }
  1445.         bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
  1446.         bool isRessurectRequested() const { return m_resurrectGUID != 0; }
  1447.         void ResurectUsingRequestData();
  1448.  
  1449.         int getCinematic()
  1450.         {
  1451.             return m_cinematic;
  1452.         }
  1453.         void setCinematic(int cine)
  1454.         {
  1455.             m_cinematic = cine;
  1456.         }
  1457.  
  1458.         void addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc);
  1459.         void removeActionButton(uint8 button);
  1460.         void SendInitialActionButtons() const;
  1461.  
  1462.         PvPInfo pvpInfo;
  1463.         void UpdatePvP(bool state, bool ovrride=false);
  1464.         void UpdateZone(uint32 newZone);
  1465.         void UpdateArea(uint32 newArea);
  1466.  
  1467.         void UpdateZoneDependentAuras( uint32 zone_id );    // zones
  1468.         void UpdateAreaDependentAuras( uint32 area_id );    // subzones
  1469.  
  1470.         void UpdateAfkReport(time_t currTime);
  1471.         void UpdatePvPFlag(time_t currTime);
  1472.         void UpdateContestedPvP(uint32 currTime);
  1473.         void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
  1474.         void ResetContestedPvP()
  1475.         {
  1476.             clearUnitState(UNIT_STAT_ATTACK_PLAYER);
  1477.             RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
  1478.             m_contestedPvPTimer = 0;
  1479.         }
  1480.  
  1481.         /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
  1482.         DuelInfo *duel;
  1483.         void UpdateDuelFlag(time_t currTime);
  1484.         void CheckDuelDistance(time_t currTime);
  1485.         void DuelComplete(DuelCompleteType type);
  1486.  
  1487.         bool IsGroupVisibleFor(Player* p) const;
  1488.         bool IsInSameGroupWith(Player const* p) const;
  1489.         bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
  1490.         void UninviteFromGroup();
  1491.         static void RemoveFromGroup(Group* group, uint64 guid);
  1492.         void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
  1493.         void SendUpdateToOutOfRangeGroupMembers();
  1494.  
  1495.         void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
  1496.         void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
  1497.         void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
  1498.         uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID);  }
  1499.         static uint32 GetGuildIdFromDB(uint64 guid);
  1500.         uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
  1501.         static uint32 GetRankFromDB(uint64 guid);
  1502.         int GetGuildIdInvited() { return m_GuildIdInvited; }
  1503.         static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
  1504.  
  1505.         bool UpdateSkill(uint32 skill_id, uint32 step);
  1506.         bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step);
  1507.  
  1508.         bool UpdateCraftSkill(uint32 spellid);
  1509.         bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
  1510.         bool UpdateFishingSkill();
  1511.  
  1512.         uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); }
  1513.         uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const;
  1514.  
  1515.         uint32 GetSpellByProto(ItemPrototype *proto);
  1516.  
  1517.         float GetHealthBonusFromStamina();
  1518.         float GetManaBonusFromIntellect();
  1519.  
  1520.         bool UpdateStats(Stats stat);
  1521.         bool UpdateAllStats();
  1522.         void UpdateResistances(uint32 school);
  1523.         void UpdateArmor();
  1524.         void UpdateMaxHealth();
  1525.         void UpdateMaxPower(Powers power);
  1526.         void UpdateAttackPowerAndDamage(bool ranged = false);
  1527.         void UpdateShieldBlockValue();
  1528.         void UpdateDamagePhysical(WeaponAttackType attType);
  1529.         void UpdateSpellDamageAndHealingBonus(); // [TZERO] should be removed
  1530.  
  1531.         void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage);
  1532.  
  1533.         void UpdateDefenseBonusesMod();
  1534.         float GetMeleeCritFromAgility();
  1535.         float GetDodgeFromAgility();
  1536.         float GetSpellCritFromIntellect();
  1537.         float OCTRegenHPPerSpirit();
  1538.         float OCTRegenMPPerSpirit();
  1539.  
  1540.         void UpdateBlockPercentage();
  1541.         void UpdateCritPercentage(WeaponAttackType attType);
  1542.         void UpdateAllCritPercentages();
  1543.         void UpdateParryPercentage();
  1544.         void UpdateDodgePercentage();
  1545.         void UpdateAllSpellCritChances();
  1546.         void UpdateSpellCritChance(uint32 school);
  1547.         void UpdateManaRegen();
  1548.  
  1549.         const uint64& GetLootGUID() const { return m_lootGuid; }
  1550.         void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
  1551.  
  1552.         void RemovedInsignia(Player* looterPlr);
  1553.  
  1554.         WorldSession* GetSession() const { return m_session; }
  1555.         void SetSession(WorldSession *s) { m_session = s; }
  1556.  
  1557.         void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
  1558.         void DestroyForPlayer( Player *target ) const;
  1559.         void SendDelayResponse(const uint32);
  1560.         void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
  1561.  
  1562.         //Low Level Packets
  1563.         void PlaySound(uint32 Sound, bool OnlySelf);
  1564.         //notifiers
  1565.         void SendAttackSwingCantAttack();
  1566.         void SendAttackSwingCancelAttack();
  1567.         void SendAttackSwingDeadTarget();
  1568.         void SendAttackSwingNotStanding();
  1569.         void SendAttackSwingNotInRange();
  1570.         void SendAttackSwingBadFacingAttack();
  1571.         void SendAutoRepeatCancel();
  1572.         void SendExplorationExperience(uint32 Area, uint32 Experience);
  1573.  
  1574.         void ResetInstances(uint8 method);
  1575.         void SendResetInstanceSuccess(uint32 MapId);
  1576.         void SendResetInstanceFailed(uint32 reason, uint32 MapId);
  1577.         void SendResetFailedNotify(uint32 mapid);
  1578.  
  1579.         bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
  1580.         void UpdateUnderwaterState( Map * m, float x, float y, float z );
  1581.  
  1582.         void SendMessageToSet(WorldPacket *data, bool self, bool to_possessor = true);// overwrite Object::SendMessageToSet
  1583.         void SendMessageToSetInRange(WorldPacket *data, float fist, bool self, bool to_possessor = true);// overwrite Object::SendMessageToSetInRange
  1584.         void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool to_possessor, bool own_team_only);
  1585.  
  1586.         static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);
  1587.  
  1588.         Corpse *GetCorpse() const;
  1589.         void SpawnCorpseBones();
  1590.         void CreateCorpse();
  1591.         void KillPlayer();
  1592.         uint32 GetResurrectionSpellId();
  1593.         void ResurrectPlayer(float restore_percent, bool applySickness = false);
  1594.         void BuildPlayerRepop();
  1595.         void RepopAtGraveyard();
  1596.  
  1597.         void DurabilityLossAll(double percent, bool inventory);
  1598.         void DurabilityLoss(Item* item, double percent);
  1599.         void DurabilityPointsLossAll(int32 points, bool inventory);
  1600.         void DurabilityPointsLoss(Item* item, int32 points);
  1601.         void DurabilityPointLossForEquipSlot(EquipmentSlots slot);
  1602.         uint32 DurabilityRepairAll(bool cost, float discountMod);
  1603.         uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod);
  1604.  
  1605.         void StopMirrorTimers()
  1606.         {
  1607.             StopMirrorTimer(FATIGUE_TIMER);
  1608.             StopMirrorTimer(BREATH_TIMER);
  1609.             StopMirrorTimer(FIRE_TIMER);
  1610.         }
  1611.  
  1612.         void SetMovement(PlayerMovementType pType);
  1613.  
  1614.         void JoinedChannel(Channel *c);
  1615.         void LeftChannel(Channel *c);
  1616.         void CleanupChannels();
  1617.         void UpdateLocalChannels( uint32 newZone );
  1618.         void LeaveLFGChannel();
  1619.  
  1620.         void UpdateDefense();
  1621.         void UpdateWeaponSkill (WeaponAttackType attType);
  1622.         void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, MeleeHitOutcome outcome, bool defence);
  1623.  
  1624.         void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
  1625.         uint16 GetMaxSkillValue(uint32 skill) const;        // max + perm. bonus
  1626.         uint16 GetPureMaxSkillValue(uint32 skill) const;    // max
  1627.         uint16 GetSkillValue(uint32 skill) const;           // skill value + perm. bonus + temp bonus
  1628.         uint16 GetBaseSkillValue(uint32 skill) const;       // skill value + perm. bonus
  1629.         uint16 GetPureSkillValue(uint32 skill) const;       // skill value
  1630.         int16 GetSkillTempBonusValue(uint32 skill) const;
  1631.         bool HasSkill(uint32 skill) const;
  1632.         void learnSkillRewardedSpells( uint32 id );
  1633.         void learnSkillRewardedSpells();
  1634.  
  1635.         void SetDontMove(bool dontMove);
  1636.         bool GetDontMove() const { return m_dontMove; }
  1637.  
  1638.         void CheckExploreSystem(void);
  1639.  
  1640.         static uint32 TeamForRace(uint8 race);
  1641.         uint32 GetTeam() const { return m_team; }
  1642.         static uint32 getFactionForRace(uint8 race);
  1643.         void setFactionForRace(uint8 race);
  1644.  
  1645.         bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
  1646.         bool RewardPlayerAndGroupAtKill(Unit* pVictim);
  1647.         void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
  1648.  
  1649.         FactionStateList m_factions;
  1650.         ForcedReactions m_forcedReactions;
  1651.         FactionStateList const& GetFactionStateList() { return m_factions; }
  1652.         uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const;
  1653.         int32 GetBaseReputation(const FactionEntry *factionEntry) const;
  1654.         int32 GetReputation(uint32 faction_id) const;
  1655.         int32 GetReputation(const FactionEntry *factionEntry) const;
  1656.         ReputationRank GetReputationRank(uint32 faction) const;
  1657.         ReputationRank GetReputationRank(const FactionEntry *factionEntry) const;
  1658.         ReputationRank GetBaseReputationRank(const FactionEntry *factionEntry) const;
  1659.         ReputationRank ReputationToRank(int32 standing) const;
  1660.         const static int32 ReputationRank_Length[MAX_REPUTATION_RANK];
  1661.         const static int32 Reputation_Cap    =  42999;
  1662.         const static int32 Reputation_Bottom = -42000;
  1663.         bool ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation);
  1664.         bool ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing);
  1665.         bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
  1666.         bool SetFactionReputation(uint32 FactionTemplateId, int32 standing);
  1667.         bool SetFactionReputation(FactionEntry const* factionEntry, int32 standing);
  1668.         bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
  1669.         int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest);
  1670.         void RewardReputation(Unit *pVictim, float rate);
  1671.         void RewardReputation(Quest const *pQuest);
  1672.         void SetInitialFactions();
  1673.         void UpdateReputation() const;
  1674.         void SendFactionState(FactionState const* faction) const;
  1675.         void SendInitialReputations();
  1676.         FactionState const* GetFactionState( FactionEntry const* factionEntry) const;
  1677.         void SetFactionAtWar(FactionState* faction, bool atWar);
  1678.         void SetFactionInactive(FactionState* faction, bool inactive);
  1679.         void SetFactionVisible(FactionState* faction);
  1680.         void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId);
  1681.         void SetFactionVisibleForFactionId(uint32 FactionId);
  1682.         void UpdateSkillsForLevel();
  1683.         void UpdateSkillsToMaxSkillsForLevel();             // for .levelup
  1684.         void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
  1685.  
  1686.         /*********************************************************/
  1687.         /***                  HONOR SYSTEM                     ***/
  1688.         /*********************************************************/
  1689.         void UpdateHonor();
  1690.         void CalculateHonor(Unit *pVictim);
  1691.         uint32 CalculateHonorRank(float honor) const;
  1692.         uint32 GetHonorRank() const;
  1693.         int  CalculateTotalKills(Player *pVictim) const;
  1694.         //Acessors of total honor points
  1695.         void SetTotalHonor(float total_honor_points) { m_total_honor_points = total_honor_points; };
  1696.         float GetTotalHonor(void) const { return m_total_honor_points; };
  1697.         //Acessors of righest rank
  1698.         uint32 GetHonorHighestRank() const { return m_highest_rank; }
  1699.         void SetHonorHighestRank(uint32 hr) { m_highest_rank = hr; }
  1700.         //Acessors of rating
  1701.         float GetStoredHonor() const { return m_stored_honor; }
  1702.         void SetStoredHonor(float rating) { m_stored_honor = rating; }
  1703.         //Acessors of lifetime
  1704.         uint32 GetHonorStoredKills(bool honorable) const { return honorable? m_stored_honorableKills : m_stored_dishonorableKills; }
  1705.         void SetHonorStoredKills(uint32 kills,bool honorable) { if (honorable) m_stored_honorableKills = kills; else m_stored_dishonorableKills = kills; }
  1706.         //Acessors of last week standing
  1707.         int32 GetHonorLastWeekStanding() const { return m_standing; }
  1708.         void SetHonorLastWeekStanding(int32 standing){ m_standing = standing; }
  1709.  
  1710.         float m_total_honor_points;
  1711.         float m_stored_honor;
  1712.         float m_pending_honor;
  1713.         uint32 m_pending_honorableKills;
  1714.         uint32 m_pending_dishonorableKills;
  1715.         uint32 m_storingDate;
  1716.         uint32 m_stored_honorableKills;
  1717.         uint32 m_stored_dishonorableKills;
  1718.         uint32 m_highest_rank;
  1719.         int32 m_standing;
  1720.  
  1721.         //End of Honor System
  1722.  
  1723.         void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
  1724.         uint16 GetDrunkValue() const { return m_drunk; }
  1725.         static DrunkenState GetDrunkenstateByValue(uint16 value);
  1726.  
  1727.         uint32 GetDeathTimer() const { return m_deathTimer; }
  1728.         uint32 GetCorpseReclaimDelay(bool pvp) const;
  1729.         void UpdateCorpseReclaimDelay();
  1730.         void SendCorpseReclaimDelay(bool load = false);
  1731.  
  1732.         uint32 GetShieldBlockValue() const;                 // overwrite Unit version (virtual)
  1733.         bool CanParry() const { return m_canParry; }
  1734.         void SetCanParry(bool value);
  1735.         bool CanBlock() const { return m_canBlock; }
  1736.         void SetCanBlock(bool value);
  1737.  
  1738.         void SetRegularAttackTime();
  1739.         void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
  1740.         void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
  1741.         float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
  1742.         float GetTotalBaseModValue(BaseModGroup modGroup) const;
  1743.         float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
  1744.         void _ApplyAllStatBonuses();
  1745.         void _RemoveAllStatBonuses();
  1746.  
  1747.         void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
  1748.         void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
  1749.         void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
  1750.  
  1751.         void _ApplyItemMods(Item *item,uint8 slot,bool apply);
  1752.         void _RemoveAllItemMods();
  1753.         void _ApplyAllItemMods();
  1754.         void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply);
  1755.         void _ApplyAmmoBonuses();
  1756.         bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
  1757.         void InitDataForForm(bool reapplyMods = false);
  1758.  
  1759.         void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
  1760.         void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
  1761.         void UpdateEquipSpellsAtFormChange();
  1762.         void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType);
  1763.  
  1764.         void SendInitWorldStates(bool force = false, uint32 forceZoneId = 0);
  1765.         void SendUpdateWorldState(uint32 Field, uint32 Value);
  1766.         void SendDirectMessage(WorldPacket *data);
  1767.  
  1768.         void SendAuraDurationsForTarget(Unit* target);
  1769.  
  1770.         PlayerMenu* PlayerTalkClass;
  1771.         std::vector<ItemSetEffect *> ItemSetEff;
  1772.  
  1773.         void SendLoot(uint64 guid, LootType loot_type);
  1774.         void SendLootRelease( uint64 guid );
  1775.         void SendNotifyLootItemRemoved(uint8 lootSlot);
  1776.         void SendNotifyLootMoneyRemoved();
  1777.  
  1778.         /*********************************************************/
  1779.         /***               BATTLEGROUND SYSTEM                 ***/
  1780.         /*********************************************************/
  1781.  
  1782.         bool InBattleGround() const { return m_bgBattleGroundID != 0; }
  1783.         uint32 GetBattleGroundId() const    { return m_bgBattleGroundID; }
  1784.         BattleGround* GetBattleGround() const;
  1785.  
  1786.         static uint32 GetMinLevelForBattleGroundQueueId(uint32 queue_id);
  1787.         static uint32 GetMaxLevelForBattleGroundQueueId(uint32 queue_id);
  1788.         uint32 GetBattleGroundQueueIdFromLevel() const;
  1789.  
  1790.         bool InBattleGroundQueue() const
  1791.         {
  1792.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1793.                 if (m_bgBattleGroundQueueID[i].bgQueueType != 0)
  1794.                     return true;
  1795.             return false;
  1796.         }
  1797.  
  1798.         uint32 GetBattleGroundQueueId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueType; }
  1799.         uint32 GetBattleGroundQueueIndex(uint32 bgQueueType) const
  1800.         {
  1801.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1802.                 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
  1803.                     return i;
  1804.             return PLAYER_MAX_BATTLEGROUND_QUEUES;
  1805.         }
  1806.         bool IsInvitedForBattleGroundQueueType(uint32 bgQueueType) const
  1807.         {
  1808.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1809.                 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
  1810.                     return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
  1811.             return PLAYER_MAX_BATTLEGROUND_QUEUES;
  1812.         }
  1813.         bool InBattleGroundQueueForBattleGroundQueueType(uint32 bgQueueType) const
  1814.         {
  1815.             return GetBattleGroundQueueIndex(bgQueueType) < PLAYER_MAX_BATTLEGROUND_QUEUES;
  1816.         }
  1817.  
  1818.         void SetBattleGroundId(uint32 val)  { m_bgBattleGroundID = val; }
  1819.         uint32 AddBattleGroundQueueId(uint32 val)
  1820.         {
  1821.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1822.             {
  1823.                 if (m_bgBattleGroundQueueID[i].bgQueueType == 0 || m_bgBattleGroundQueueID[i].bgQueueType == val)
  1824.                 {
  1825.                     m_bgBattleGroundQueueID[i].bgQueueType = val;
  1826.                     m_bgBattleGroundQueueID[i].invitedToInstance = 0;
  1827.                     return i;
  1828.                 }
  1829.             }
  1830.             return PLAYER_MAX_BATTLEGROUND_QUEUES;
  1831.         }
  1832.         bool HasFreeBattleGroundQueueId()
  1833.         {
  1834.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1835.                 if (m_bgBattleGroundQueueID[i].bgQueueType == 0)
  1836.                     return true;
  1837.             return false;
  1838.         }
  1839.         void RemoveBattleGroundQueueId(uint32 val)
  1840.         {
  1841.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1842.             {
  1843.                 if (m_bgBattleGroundQueueID[i].bgQueueType == val)
  1844.                 {
  1845.                     m_bgBattleGroundQueueID[i].bgQueueType = 0;
  1846.                     m_bgBattleGroundQueueID[i].invitedToInstance = 0;
  1847.                     return;
  1848.                 }
  1849.             }
  1850.         }
  1851.         void SetInviteForBattleGroundQueueType(uint32 bgQueueType, uint32 instanceId)
  1852.         {
  1853.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1854.                 if (m_bgBattleGroundQueueID[i].bgQueueType == bgQueueType)
  1855.                     m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
  1856.         }
  1857.         bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
  1858.         {
  1859.             for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
  1860.                 if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
  1861.                     return true;
  1862.             return false;
  1863.         }
  1864.         uint32 GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap; }
  1865.         float GetBattleGroundEntryPointX() const { return m_bgEntryPointX; }
  1866.         float GetBattleGroundEntryPointY() const { return m_bgEntryPointY; }
  1867.         float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ; }
  1868.         float GetBattleGroundEntryPointO() const { return m_bgEntryPointO; }
  1869.         void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO )
  1870.         {
  1871.             m_bgEntryPointMap = Map;
  1872.             m_bgEntryPointX = PosX;
  1873.             m_bgEntryPointY = PosY;
  1874.             m_bgEntryPointZ = PosZ;
  1875.             m_bgEntryPointO = PosO;
  1876.         }
  1877.  
  1878.         void SetBGTeam(uint32 team) { m_bgTeam = team; }
  1879.         uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); }
  1880.  
  1881.         void LeaveBattleground(bool teleportToEntryPoint = true);
  1882.         bool CanJoinToBattleground() const;
  1883.         bool CanReportAfkDueToLimit();
  1884.         void ReportedAfkBy(Player* reporter);
  1885.         void ClearAfkReports() { m_bgAfkReporter.clear(); }
  1886.  
  1887.         bool GetBGAccessByLevel(uint32 bgTypeId) const;
  1888.         bool isAllowUseBattleGroundObject();
  1889.         bool isTotalImmunity();
  1890.  
  1891.         /*********************************************************/
  1892.         /***               OUTDOOR PVP SYSTEM                  ***/
  1893.         /*********************************************************/
  1894.  
  1895.         OutdoorPvP * GetOutdoorPvP() const;
  1896.         // returns true if the player is in active state for outdoor pvp objective capturing, false otherwise
  1897.         bool IsOutdoorPvPActive();
  1898.  
  1899.         /*********************************************************/
  1900.         /***                    REST SYSTEM                    ***/
  1901.         /*********************************************************/
  1902.  
  1903.         bool isRested() const { return GetRestTime() >= 10000; }
  1904.         uint32 GetXPRestBonus(uint32 xp);
  1905.         uint32 GetRestTime() const { return m_restTime;};
  1906.         void SetRestTime(uint32 v) { m_restTime = v;};
  1907.  
  1908.         /*********************************************************/
  1909.         /***              ENVIRONMENTAL SYSTEM                  ***/
  1910.         /*********************************************************/
  1911.  
  1912.         void EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage);
  1913.  
  1914.         /*********************************************************/
  1915.         /***               FLOOD FILTER SYSTEM                 ***/
  1916.         /*********************************************************/
  1917.  
  1918.         void UpdateSpeakTime();
  1919.         bool CanSpeak() const;
  1920.         void ChangeSpeakTime(int utime);
  1921.  
  1922.         /*********************************************************/
  1923.         /***                 VARIOUS SYSTEMS                   ***/
  1924.         /*********************************************************/
  1925.         float m_modManaRegen[2];  // 0: mana regen 1: mana regen interrupt
  1926.         MovementInfo m_movementInfo;
  1927.         uint32 m_lastFallTime;
  1928.         float  m_lastFallZ;
  1929.         void SetFallInformation(uint32 time, float z)
  1930.         {
  1931.             m_lastFallTime = time;
  1932.             m_lastFallZ = z;
  1933.         }
  1934.         bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
  1935.         bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
  1936.  
  1937.         void HandleDrowning();
  1938.         void HandleFallDamage(MovementInfo& movementInfo);
  1939.         void HandleFallUnderMap();
  1940.  
  1941.         void SetClientControl(Unit* target, uint8 allowMove);
  1942.  
  1943.         uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
  1944.         void SetFarSight(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
  1945.  
  1946.         // Transports
  1947.         Transport * GetTransport() const { return m_transport; }
  1948.         void SetTransport(Transport * t) { m_transport = t; }
  1949.  
  1950.         float GetTransOffsetX() const { return m_movementInfo.t_x; }
  1951.         float GetTransOffsetY() const { return m_movementInfo.t_y; }
  1952.         float GetTransOffsetZ() const { return m_movementInfo.t_z; }
  1953.         float GetTransOffsetO() const { return m_movementInfo.t_o; }
  1954.         uint32 GetTransTime() const { return m_movementInfo.t_time; }
  1955.  
  1956.         uint32 GetSaveTimer() const { return m_nextSave; }
  1957.         void   SetSaveTimer(uint32 timer) { m_nextSave = timer; }
  1958.  
  1959.         // Recall position
  1960.         uint32 m_recallMap;
  1961.         float  m_recallX;
  1962.         float  m_recallY;
  1963.         float  m_recallZ;
  1964.         float  m_recallO;
  1965.         void   SaveRecallPosition();
  1966.  
  1967.         // Homebind coordinates
  1968.         uint32 m_homebindMapId;
  1969.         uint16 m_homebindZoneId;
  1970.         float m_homebindX;
  1971.         float m_homebindY;
  1972.         float m_homebindZ;
  1973.  
  1974.         // currently visible objects at player client
  1975.         typedef std::set<uint64> ClientGUIDs;
  1976.         ClientGUIDs m_clientGUIDs;
  1977.  
  1978.         bool HaveAtClient(WorldObject const* u) const { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
  1979.  
  1980.         bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
  1981.         bool IsVisibleInGridForPlayer(Player const* pl) const;
  1982.         bool IsVisibleGloballyFor(Player* pl) const;
  1983.  
  1984.         void UpdateVisibilityOf(WorldObject* target);
  1985.         void SendInitialVisiblePackets(Unit* target);
  1986.  
  1987.         template<class T>
  1988.             void UpdateVisibilityOf(T* target, UpdateData& data, std::set<WorldObject*>& visibleNow);
  1989.  
  1990.         // Stealth detection system
  1991.         uint32 m_DetectInvTimer;
  1992.         void HandleStealthedUnitsDetection();
  1993.  
  1994.         uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
  1995.  
  1996.         bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
  1997.         void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
  1998.  
  1999.         LookingForGroup m_lookingForGroup;
  2000.  
  2001.         // Temporarily removed pet cache
  2002.         uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
  2003.         void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
  2004.         uint32 GetOldPetSpell() const { return m_oldpetspell; }
  2005.         void SetOldPetSpell(uint32 petspell) { m_oldpetspell = petspell; }
  2006.  
  2007.  
  2008.         /*********************************************************/
  2009.         /***                 INSTANCE SYSTEM                   ***/
  2010.         /*********************************************************/
  2011.  
  2012.         typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap;
  2013.  
  2014.         void UpdateHomebindTime(uint32 time);
  2015.  
  2016.         uint32 m_HomebindTimer;
  2017.         bool m_InstanceValid;
  2018.         // permanent binds and solo binds
  2019.         BoundInstancesMap m_boundInstances;
  2020.         InstancePlayerBind* GetBoundInstance(uint32 mapid);
  2021.         BoundInstancesMap& GetBoundInstances() { return m_boundInstances; }
  2022.         void UnbindInstance(uint32 mapid, bool unload = false);
  2023.         void UnbindInstance(BoundInstancesMap::iterator &itr, bool unload = false);
  2024.         InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false);
  2025.         void SendRaidInfo();
  2026.         void SendSavedInstances();
  2027.         static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
  2028.         bool Satisfy(AccessRequirement const*, uint32 target_map, bool report = false);
  2029.  
  2030.         /*********************************************************/
  2031.         /***                   GROUP SYSTEM                    ***/
  2032.         /*********************************************************/
  2033.  
  2034.         Group * GetGroupInvite() { return m_groupInvite; }
  2035.         void SetGroupInvite(Group *group) { m_groupInvite = group; }
  2036.         Group * GetGroup() { return m_group.getTarget(); }
  2037.         const Group * GetGroup() const { return (const Group*)m_group.getTarget(); }
  2038.         GroupReference& GetGroupRef() { return m_group; }
  2039.         void SetGroup(Group *group, int8 subgroup = -1);
  2040.         uint8 GetSubGroup() const { return m_group.getSubGroup(); }
  2041.         uint32 GetGroupUpdateFlag() { return m_groupUpdateMask; }
  2042.         void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
  2043.         uint64 GetAuraUpdateMask() { return m_auraUpdateMask; }
  2044.         void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
  2045.         void UnsetAuraUpdateMask(uint8 slot) { m_auraUpdateMask &= ~(uint64(1) << slot); }
  2046.         Player* GetNextRandomRaidMember(float radius);
  2047.         PartyResult CanUninviteFromGroup() const;
  2048.  
  2049.         GridReference<Player> &GetGridRef() { return m_gridRef; }
  2050.         MapReference &GetMapRef() { return m_mapRef; }
  2051.  
  2052.         bool isAllowedToLoot(Creature* creature);
  2053.  
  2054.         WorldLocation& GetTeleportDest() { return m_teleport_dest; }
  2055.  
  2056.         DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
  2057.  
  2058.     protected:
  2059.  
  2060.         /*********************************************************/
  2061.         /***               BATTLEGROUND SYSTEM                 ***/
  2062.         /*********************************************************/
  2063.  
  2064.         /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
  2065.         uint32 m_bgBattleGroundID;
  2066.         /*
  2067.         this is an array of BG queues (BgTypeIDs) in which is player
  2068.         */
  2069.         struct BgBattleGroundQueueID_Rec
  2070.         {
  2071.             uint32 bgQueueType;
  2072.             uint32 invitedToInstance;
  2073.         };
  2074.         BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES];
  2075.         uint32 m_bgEntryPointMap;
  2076.         float m_bgEntryPointX;
  2077.         float m_bgEntryPointY;
  2078.         float m_bgEntryPointZ;
  2079.         float m_bgEntryPointO;
  2080.  
  2081.         std::set<uint32> m_bgAfkReporter;
  2082.         uint8 m_bgAfkReportedCount;
  2083.         time_t m_bgAfkReportedTimer;
  2084.         uint32 m_contestedPvPTimer;
  2085.  
  2086.         uint32 m_bgTeam;    // what side the player will be added to
  2087.  
  2088.         /*********************************************************/
  2089.         /***                    QUEST SYSTEM                   ***/
  2090.         /*********************************************************/
  2091.  
  2092.         std::set<uint32> m_timedquests;
  2093.  
  2094.         uint64 m_divider;
  2095.         uint32 m_ingametime;
  2096.  
  2097.         /*********************************************************/
  2098.         /***                   LOAD SYSTEM                     ***/
  2099.         /*********************************************************/
  2100.  
  2101.         void _LoadActions(QueryResult *result);
  2102.         void _LoadAuras(QueryResult *result, uint32 timediff);
  2103.         void _LoadBoundInstances(QueryResult *result);
  2104.         void _LoadInventory(QueryResult *result, uint32 timediff);
  2105.         void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery);
  2106.         void _LoadMail();
  2107.         void _LoadMailedItems(Mail *mail);
  2108.         void _LoadQuestStatus(QueryResult *result);
  2109.         void _LoadDailyQuestStatus(QueryResult *result);
  2110.         void _LoadGroup(QueryResult *result);
  2111.         void _LoadReputation(QueryResult *result);
  2112.         void _LoadSpells(QueryResult *result);
  2113.         void _LoadTutorials(QueryResult *result);
  2114.         void _LoadFriendList(QueryResult *result);
  2115.         bool _LoadHomeBind(QueryResult *result);
  2116.         void _LoadDeclinedNames(QueryResult *result);
  2117.  
  2118.         /*********************************************************/
  2119.         /***                   SAVE SYSTEM                     ***/
  2120.         /*********************************************************/
  2121.  
  2122.         void _SaveActions();
  2123.         void _SaveAuras();
  2124.         void _SaveInventory();
  2125.         void _SaveMail();
  2126.         void _SaveQuestStatus();
  2127.         void _SaveDailyQuestStatus();
  2128.         void _SaveReputation();
  2129.         void _SaveSpells();
  2130.         void _SaveTutorials();
  2131.  
  2132.         void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
  2133.         void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
  2134.  
  2135.         /*********************************************************/
  2136.         /***              ENVIRONMENTAL SYSTEM                 ***/
  2137.         /*********************************************************/
  2138.         void HandleLava();
  2139.         void HandleSobering();
  2140.         void StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue);
  2141.         void ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen);
  2142.         void StopMirrorTimer(MirrorTimerType Type);
  2143.         uint8 m_isunderwater;
  2144.         bool m_isInWater;
  2145.  
  2146.  
  2147.  
  2148.         void outDebugValues() const;
  2149.         bool _removeSpell(uint16 spell_id);
  2150.         uint64 m_lootGuid;
  2151.  
  2152.         uint32 m_race;
  2153.         uint32 m_class;
  2154.         uint32 m_team;
  2155.         uint32 m_nextSave;
  2156.         time_t m_speakTime;
  2157.         uint32 m_speakCount;
  2158.  
  2159.         uint32 m_atLoginFlags;
  2160.  
  2161.         Item* m_items[PLAYER_SLOTS_COUNT];
  2162.         uint32 m_currentBuybackSlot;
  2163.  
  2164.         std::vector<Item*> m_itemUpdateQueue;
  2165.         bool m_itemUpdateQueueBlocked;
  2166.  
  2167.         uint32 m_ExtraFlags;
  2168.         uint64 m_curSelection;
  2169.  
  2170.         uint64 m_comboTarget;
  2171.         int8 m_comboPoints;
  2172.  
  2173.         QuestStatusMap mQuestStatus;
  2174.  
  2175.         uint32 m_GuildIdInvited;
  2176.  
  2177.         PlayerMails m_mail;
  2178.         PlayerSpellMap m_spells;
  2179.         SpellCooldowns m_spellCooldowns;
  2180.  
  2181.         ActionButtonList m_actionButtons;
  2182.  
  2183.         float m_auraBaseMod[BASEMOD_END][MOD_END];
  2184.  
  2185.         SpellModList m_spellMods[MAX_SPELLMOD];
  2186.         int32 m_SpellModRemoveCount;
  2187.         EnchantDurationList m_enchantDuration;
  2188.         ItemDurationList m_itemDuration;
  2189.  
  2190.         uint64 m_resurrectGUID;
  2191.         uint32 m_resurrectMap;
  2192.         float m_resurrectX, m_resurrectY, m_resurrectZ;
  2193.         uint32 m_resurrectHealth, m_resurrectMana;
  2194.  
  2195.         WorldSession *m_session;
  2196.  
  2197.         typedef std::list<Channel*> JoinedChannelsList;
  2198.         JoinedChannelsList m_channels;
  2199.  
  2200.         bool m_dontMove;
  2201.  
  2202.         int m_cinematic;
  2203.  
  2204.         Player *pTrader;
  2205.         bool acceptTrade;
  2206.         uint16 tradeItems[TRADE_SLOT_COUNT];
  2207.         uint32 tradeGold;
  2208.  
  2209.         time_t m_nextThinkTime;
  2210.  
  2211.         uint32 m_Tutorials[8];
  2212.         bool   m_TutorialsChanged;
  2213.  
  2214.         bool   m_DailyQuestChanged;
  2215.         time_t m_lastDailyQuestTime;
  2216.  
  2217.         uint32 m_regenTimer;
  2218.         uint32 m_breathTimer;
  2219.         uint32 m_drunkTimer;
  2220.         uint16 m_drunk;
  2221.         uint32 m_weaponChangeTimer;
  2222.  
  2223.         uint32 m_zoneUpdateId;
  2224.         uint32 m_zoneUpdateTimer;
  2225.         uint32 m_areaUpdateId;
  2226.  
  2227.         uint32 m_deathTimer;
  2228.         time_t m_deathExpireTime;
  2229.  
  2230.         uint32 m_restTime;
  2231.  
  2232.         uint32 m_WeaponProficiency;
  2233.         uint32 m_ArmorProficiency;
  2234.         bool m_canParry;
  2235.         bool m_canBlock;
  2236.         uint8 m_swingErrorMsg;
  2237.         float m_ammoDPS;
  2238.         ////////////////////Rest System/////////////////////
  2239.         int time_inn_enter;
  2240.         uint32 inn_pos_mapid;
  2241.         float  inn_pos_x;
  2242.         float  inn_pos_y;
  2243.         float  inn_pos_z;
  2244.         float m_rest_bonus;
  2245.         RestType rest_type;
  2246.         ////////////////////Rest System/////////////////////
  2247.  
  2248.         // Transports
  2249.         Transport * m_transport;
  2250.  
  2251.         uint32 m_resetTalentsCost;
  2252.         time_t m_resetTalentsTime;
  2253.         uint32 m_usedTalentCount;
  2254.  
  2255.         // Social
  2256.         PlayerSocial *m_social;
  2257.  
  2258.         // Groups
  2259.         GroupReference m_group;
  2260.         Group *m_groupInvite;
  2261.         uint32 m_groupUpdateMask;
  2262.         uint64 m_auraUpdateMask;
  2263.  
  2264.         // Temporarily removed pet cache
  2265.         uint32 m_temporaryUnsummonedPetNumber;
  2266.         uint32 m_oldpetspell;
  2267.  
  2268.         uint64 m_miniPet;
  2269.         GuardianPetList m_guardianPets;
  2270.  
  2271.         // Player summoning
  2272.         time_t m_summon_expire;
  2273.         uint32 m_summon_mapid;
  2274.         float  m_summon_x;
  2275.         float  m_summon_y;
  2276.         float  m_summon_z;
  2277.  
  2278.         // Far Teleport
  2279.         WorldLocation m_teleport_dest;
  2280.  
  2281.         bool m_farsightVision;
  2282.  
  2283.         DeclinedName *m_declinedname;
  2284.     private:
  2285.         // internal common parts for CanStore/StoreItem functions
  2286.         uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
  2287.         uint8 _CanStoreItem_InBag( uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const;
  2288.         uint8 _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const;
  2289.         Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
  2290.  
  2291.         GridReference<Player> m_gridRef;
  2292.         MapReference m_mapRef;
  2293.  
  2294.         void UpdateCharmedAI();
  2295.         UnitAI *i_AI;
  2296. };
  2297.  
  2298. void AddItemsSetItem(Player*player,Item *item);
  2299. void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
  2300.  
  2301. // "the bodies of template functions must be made available in a header file"
  2302. template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
  2303. {
  2304.     SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
  2305.     if (!spellInfo) return 0;
  2306.     int32 totalpct = 0;
  2307.     int32 totalflat = 0;
  2308.     for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
  2309.     {
  2310.         SpellModifier *mod = *itr;
  2311.  
  2312.         if(!IsAffectedBySpellmod(spellInfo,mod,spell))
  2313.             continue;
  2314.         if (mod->type == SPELLMOD_FLAT)
  2315.             totalflat += mod->value;
  2316.         else if (mod->type == SPELLMOD_PCT)
  2317.         {
  2318.             // skip percent mods for null basevalue (most important for spell mods with charges )
  2319.             if(basevalue == T(0))
  2320.                 continue;
  2321.  
  2322.             // special case (skip >10sec spell casts for instant cast setting)
  2323.             if( mod->op==SPELLMOD_CASTING_TIME  && basevalue >= T(10000) && mod->value <= -100)
  2324.                 continue;
  2325.  
  2326.             totalpct += mod->value;
  2327.         }
  2328.  
  2329.         if (mod->charges > 0 )
  2330.         {
  2331.           if( !(spellInfo->SpellFamilyName == 8 && spellInfo->SpellFamilyFlags & 0x200000000LL) )
  2332.             --mod->charges;
  2333.             if (mod->charges == 0)
  2334.             {
  2335.                 mod->charges = -1;
  2336.                 mod->lastAffected = spell;
  2337.                 if(!mod->lastAffected)
  2338.                     mod->lastAffected = FindCurrentSpellBySpellId(spellId);
  2339.                 ++m_SpellModRemoveCount;
  2340.             }
  2341.         }
  2342.     }
  2343.  
  2344.     float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
  2345.     basevalue = T((float)basevalue + diff);
  2346.     return T(diff);
  2347. }
  2348. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement