[1456] Applied MaNGOS coding style.
[mangos-git.git] / src / game / Player.h
blobf4786a159aa0e3bcdcb3f77bb50847c904a7a15f
1 /*
2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _PLAYER_H
20 #define _PLAYER_H
22 #include "Common.h"
23 #include "ItemPrototype.h"
24 #include "Unit.h"
25 #include "Item.h"
27 #include "Database/DatabaseEnv.h"
28 #include "NPCHandler.h"
29 #include "QuestDef.h"
30 #include "Bag.h"
31 #include "Weather.h"
33 struct Mail;
34 class Channel;
35 class DynamicObject;
36 class Creature;
37 class PlayerMenu;
39 enum Team
41 ALLIANCE = 469,
42 HORDE = 67,
43 ALLIANCE_FORCES = 891,
44 HORDE_FORCES = 892,
45 STEAMWHEEDLE_CARTEL = 169,
48 enum Classes
50 WARRIOR = 1,
51 PALADIN = 2,
52 HUNTER = 3,
53 ROGUE = 4,
54 PRIEST = 5,
55 SHAMAN = 7,
56 MAGE = 8,
57 WARLOCK = 9,
58 DRUID = 11,
61 enum Races
63 HUMAN = 1,
64 ORC = 2,
65 DWARF = 3,
66 NIGHTELF = 4,
67 // if it needs be to official, it's actually SCOURGE acording to the story/.dbc
68 UNDEAD_PLAYER = 5,
69 TAUREN = 6,
70 GNOME = 7,
71 TROLL = 8,
72 // officialy, this exists but was never taken into use.. neutral faction which could
73 // learn some skills/spells from horde/alliance. maybe it'll be of some use later on.
74 GOBLIN = 9,
77 struct Playerspell
79 uint16 spellId;
80 uint16 slotId;
83 struct actions
85 uint8 button;
86 uint8 type;
87 uint8 misc;
88 uint16 action;
91 struct PlayerCreateInfo
93 uint8 createId;
94 uint8 race;
95 uint8 class_;
96 uint32 mapId;
97 uint32 zoneId;
98 float positionX;
99 float positionY;
100 float positionZ;
101 uint16 displayId;
102 uint8 strength;
103 uint8 ability;
104 uint8 stamina;
105 uint8 intellect;
106 uint8 spirit;
107 uint32 basearmor;
108 uint32 health;
109 uint32 mana;
110 uint32 rage;
111 uint32 focus;
112 uint32 energy;
113 uint32 attackpower;
114 float mindmg;
115 float maxdmg;
116 float ranmindmg;
117 float ranmaxdmg;
118 std::list<uint32> item_id;
119 std::list<uint8> item_bagIndex;
120 std::list<uint8> item_slot;
121 std::list<uint32> item_amount;
122 std::list<uint16> spell;
123 std::list<uint16> skill[3];
124 std::list<uint16> action[4];
127 struct Areas
129 uint32 areaID;
130 uint32 areaFlag;
131 float x1;
132 float x2;
133 float y1;
134 float y2;
137 struct Factions
139 uint32 ID;
140 uint32 ReputationListID;
141 uint32 Flags;
142 uint32 Standing;
145 enum PlayerMovementType
147 MOVE_ROOT = 1,
148 MOVE_UNROOT = 2,
149 MOVE_WATER_WALK = 3,
150 MOVE_LAND_WALK = 4,
153 enum PlayerStateType
156 PLAYER_STATE_DANCE
157 PLAYER_STATE_SLEEP
158 PLAYER_STATE_SIT
159 PLAYER_STATE_STAND
160 PLAYER_STATE_READYUNARMED
161 PLAYER_STATE_WORK
162 PLAYER_STATE_POINT(DNR)
163 PLAYER_STATE_NONE // not used or just no state, just standing there?
164 PLAYER_STATE_STUN
165 PLAYER_STATE_DEAD
166 PLAYER_STATE_KNEEL
167 PLAYER_STATE_USESTANDING
168 PLAYER_STATE_STUN_NOSHEATHE
169 PLAYER_STATE_USESTANDING_NOSHEATHE
170 PLAYER_STATE_WORK_NOSHEATHE
171 PLAYER_STATE_SPELLPRECAST
172 PLAYER_STATE_READYRIFLE
173 PLAYER_STATE_WORK_NOSHEATHE_MINING
174 PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD
175 PLAYER_STATE_AT_EASE
176 PLAYER_STATE_READY1H
177 PLAYER_STATE_SPELLKNEELSTART
178 PLAYER_STATE_SUBMERGED
181 PLAYER_STATE_NONE = 0,
182 PLAYER_STATE_SIT = 1,
183 PLAYER_STATE_SIT_CHAIR = 2,
184 PLAYER_STATE_SLEEP = 3,
185 PLAYER_STATE_SIT_LOW_CHAIR = 4,
186 PLAYER_STATE_SIT_MEDIUM_CHAIR = 5,
187 PLAYER_STATE_SIT_HIGH_CHAIR = 6,
188 PLAYER_STATE_DEAD = 7,
189 PLAYER_STATE_KNEEL = 8
192 enum CLIENT_CONTAINER_SLOT //add by vendy
194 CLIENT_SLOT_BACK = 0xFF,
195 CLIENT_SLOT_01 = 0x13,
196 CLIENT_SLOT_02 = 0x14,
197 CLIENT_SLOT_03 = 0x15,
198 CLIENT_SLOT_04 = 0x16,
201 enum TYPE_OF_KILL
203 HONORABLE_KILL = 1,
204 DISHONORABLE_KILL = 2,
207 #define IS_BACK_SLOT(s) (s == 0xFF)
209 class Quest;
210 class Spell;
211 class Item;
212 class WorldSession;
214 #define EQUIPMENT_SLOT_START 0
215 #define EQUIPMENT_SLOT_HEAD 0
216 #define EQUIPMENT_SLOT_NECK 1
217 #define EQUIPMENT_SLOT_SHOULDERS 2
218 #define EQUIPMENT_SLOT_BODY 3
219 #define EQUIPMENT_SLOT_CHEST 4
220 #define EQUIPMENT_SLOT_WAIST 5
221 #define EQUIPMENT_SLOT_LEGS 6
222 #define EQUIPMENT_SLOT_FEET 7
223 #define EQUIPMENT_SLOT_WRISTS 8
224 #define EQUIPMENT_SLOT_HANDS 9
225 #define EQUIPMENT_SLOT_FINGER1 10
226 #define EQUIPMENT_SLOT_FINGER2 11
227 #define EQUIPMENT_SLOT_TRINKET1 12
228 #define EQUIPMENT_SLOT_TRINKET2 13
229 #define EQUIPMENT_SLOT_BACK 14
230 #define EQUIPMENT_SLOT_MAINHAND 15
231 #define EQUIPMENT_SLOT_OFFHAND 16
232 #define EQUIPMENT_SLOT_RANGED 17
233 #define EQUIPMENT_SLOT_TABARD 18
234 #define EQUIPMENT_SLOT_END 19
236 #define INVENTORY_SLOT_BAG_START 19
237 #define INVENTORY_SLOT_BAG_1 19
238 #define INVENTORY_SLOT_BAG_2 20
239 #define INVENTORY_SLOT_BAG_3 21
240 #define INVENTORY_SLOT_BAG_4 22
241 #define INVENTORY_SLOT_BAG_END 23
243 #define INVENTORY_SLOT_ITEM_START 23
244 #define INVENTORY_SLOT_ITEM_1 23
245 #define INVENTORY_SLOT_ITEM_2 24
246 #define INVENTORY_SLOT_ITEM_3 25
247 #define INVENTORY_SLOT_ITEM_4 26
248 #define INVENTORY_SLOT_ITEM_5 27
249 #define INVENTORY_SLOT_ITEM_6 28
250 #define INVENTORY_SLOT_ITEM_7 29
251 #define INVENTORY_SLOT_ITEM_8 30
252 #define INVENTORY_SLOT_ITEM_9 31
253 #define INVENTORY_SLOT_ITEM_10 32
254 #define INVENTORY_SLOT_ITEM_11 33
255 #define INVENTORY_SLOT_ITEM_12 34
256 #define INVENTORY_SLOT_ITEM_13 35
257 #define INVENTORY_SLOT_ITEM_14 36
258 #define INVENTORY_SLOT_ITEM_15 37
259 #define INVENTORY_SLOT_ITEM_16 38
260 #define INVENTORY_SLOT_ITEM_END 39
262 #define BANK_SLOT_ITEM_START 39
263 #define BANK_SLOT_ITEM_1 39
264 #define BANK_SLOT_ITEM_2 40
265 #define BANK_SLOT_ITEM_3 41
266 #define BANK_SLOT_ITEM_4 42
267 #define BANK_SLOT_ITEM_5 43
268 #define BANK_SLOT_ITEM_6 44
269 #define BANK_SLOT_ITEM_7 45
270 #define BANK_SLOT_ITEM_8 46
271 #define BANK_SLOT_ITEM_9 47
272 #define BANK_SLOT_ITEM_10 48
273 #define BANK_SLOT_ITEM_11 49
274 #define BANK_SLOT_ITEM_12 50
275 #define BANK_SLOT_ITEM_13 51
276 #define BANK_SLOT_ITEM_14 52
277 #define BANK_SLOT_ITEM_15 53
278 #define BANK_SLOT_ITEM_16 54
279 #define BANK_SLOT_ITEM_17 55
280 #define BANK_SLOT_ITEM_18 56
281 #define BANK_SLOT_ITEM_19 57
282 #define BANK_SLOT_ITEM_20 58
283 #define BANK_SLOT_ITEM_21 59
284 #define BANK_SLOT_ITEM_22 60
285 #define BANK_SLOT_ITEM_23 61
286 #define BANK_SLOT_ITEM_24 62
287 #define BANK_SLOT_ITEM_END 63
289 #define BANK_SLOT_BAG_START 63
290 #define BANK_SLOT_BAG_1 63
291 #define BANK_SLOT_BAG_2 64
292 #define BANK_SLOT_BAG_3 65
293 #define BANK_SLOT_BAG_4 66
294 #define BANK_SLOT_BAG_5 67
295 #define BANK_SLOT_BAG_6 68
296 #define BANK_SLOT_BAG_END 69
298 #define BUYBACK_SLOT_START 0
299 #define BUYBACK_SLOT_1 0
300 #define BUYBACK_SLOT_2 1
301 #define BUYBACK_SLOT_3 2
302 #define BUYBACK_SLOT_4 3
303 #define BUYBACK_SLOT_5 4
304 #define BUYBACK_SLOT_6 5
305 #define BUYBACK_SLOT_7 6
306 #define BUYBACK_SLOT_8 7
307 #define BUYBACK_SLOT_9 8
308 #define BUYBACK_SLOT_10 9
309 #define BUYBACK_SLOT_11 10
310 #define BUYBACK_SLOT_12 11
311 #define BUYBACK_SLOT_END 12
313 class MANGOS_DLL_SPEC Player : public Unit
315 friend class WorldSession;
316 public:
317 Player (WorldSession *session);
318 ~Player ( );
320 void AddToWorld();
321 void RemoveFromWorld();
323 void SendNewWorld(uint32 mapid, float x, float y, float z, float orientation);
325 bool Create ( uint32 guidlow, WorldPacket &data );
327 void Update( uint32 time );
329 void BuildEnumData( WorldPacket * p_data );
331 uint8 ToggleAFK() { m_afk = !m_afk; return m_afk; };
332 const char* GetName() { return m_name.c_str(); };
333 PlayerCreateInfo* GetPlayerInfo(){return info;}
335 void GiveXP(uint32 xp, const uint64 &guid);
337 void BuildLvlUpStats(uint32 *HP,uint32 *MP,uint32 *STR,uint32 *STA,uint32 *AGI,uint32 *INT,uint32 *SPI);
339 void setDismountCost(uint32 money) { m_dismountCost = money; };
341 /*********************************************************/
342 /*** STORAGE SYSTEM ***/
343 /*********************************************************/
345 bool AddItemToBackpack (uint32 itemId, uint32 count = 1) { return false; }
346 bool RemoveItemFromBackpack (uint32 itemId, uint32 count = 1) { return false; }
348 void AddItemToBuyBackSlot( uint32 slot, Item *pItem );
349 Item* GetItemFromBuyBackSlot( uint32 slot );
350 void RemoveItemFromBuyBackSlot( uint32 slot );
351 void SendEquipError( uint8 msg );
353 /*********************************************************/
354 /*** QUEST SYSTEM ***/
355 /*********************************************************/
357 bool CanSeeStartQuest( Quest *pQuest );
358 bool CanTakeQuest( Quest *pQuest, bool msg );
359 bool CanAddQuest( Quest *pQuest, bool msg );
360 bool CanCompleteQuest( Quest *pQuest );
361 bool CanRewardQuest( Quest *pQuest, uint32 reward, bool msg );
362 void AddQuest( Quest *pQuest );
363 void CompleteQuest( Quest *pQuest );
364 void IncompleteQuest( Quest *pQuest );
365 void RewardQuest( Quest *pQuest, uint32 reward );
366 void FailQuest( Quest *pQuest );
367 void FailTimedQuest( Quest *pQuest );
368 bool SatisfyQuestClass( Quest *pQuest, bool msg );
369 bool SatisfyQuestLevel( Quest *pQuest, bool msg );
370 bool SatisfyQuestLog( bool msg );
371 bool SatisfyQuestPreviousQuest( Quest *pQuest, bool msg );
372 bool SatisfyQuestRace( Quest *pQuest, bool msg );
373 bool SatisfyQuestReputation( Quest *pQuest, bool msg );
374 bool SatisfyQuestSkill( Quest *pQuest, bool msg );
375 bool SatisfyQuestStatus( Quest *pQuest, bool msg );
376 bool SatisfyQuestTimed( Quest *pQuest, bool msg );
377 bool GiveQuestSourceItem( Quest *pQuest );
378 void TakeQuestSourceItem( Quest *pQuest );
379 bool GetQuestRewardStatus( Quest *pQuest );
380 uint32 GetQuestStatus( Quest *pQuest );
381 void SetQuestStatus( Quest *pQuest, uint32 status );
382 void AdjustQuestReqItemCount( Quest *pQuest );
383 uint16 GetQuestSlot( Quest *pQuest );
384 void ItemAdded( uint32 entry, uint32 count );
385 void ItemRemoved( uint32 entry, uint32 count );
386 void KilledMonster( uint32 entry, uint64 guid );
387 void AddQuestsLoot( Creature* creature );
389 void SendQuestComplete( Quest *pQuest );
390 void SendQuestReward( Quest *pQuest );
391 void SendQuestFailed( Quest *pQuest );
392 void SendQuestTimerFailed( Quest *pQuest );
393 void SendCanTakeQuestResponse( uint32 msg );
394 void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
396 uint64 GetDivider() { return m_divider; };
397 void SetDivider( uint64 guid ) { m_divider = guid; };
399 uint32 GetInGameTime() { return m_ingametime; };
400 void SetInGameTime( uint32 time ) { m_ingametime = time; };
402 uint32 GetTimedQuest() { return m_timedquest; };
403 void SetTimedQuest( Quest *pQuest )
405 if( pQuest )
406 m_timedquest = pQuest->GetQuestInfo()->QuestId;
407 else
408 m_timedquest = 0;
411 /*********************************************************/
412 /*** LOAD SYSTEM ***/
413 /*********************************************************/
415 bool LoadFromDB(uint32 guid);
417 /*********************************************************/
418 /*** SAVE SYSTEM ***/
419 /*********************************************************/
421 void SaveToDB();
423 void SetBindPoint(uint64 guid);
424 void RemoveItemFromInventory(uint32 itemId,uint32 itemcount);
425 void CalcRage( uint32 damage,bool attacker );
426 void RegenerateAll();
427 void Regenerate(uint16 field_cur, uint16 field_max);
428 void setRegenTimer(uint32 time) {m_regenTimer = time;}
430 inline uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
431 inline void ModifyMoney (int32 d) { SetMoney (GetMoney() + d); }
432 void SetMoney (uint32 value) { SetUInt32Value (PLAYER_FIELD_COINAGE, value); }
434 uint32 GetTutorialInt(uint32 intId )
436 ASSERT( (intId < 8) );
437 return m_Tutorials[intId];
440 void SetTutorialInt(uint32 intId, uint32 value)
442 ASSERT( (intId < 8) );
443 m_Tutorials[intId] = value;
446 bool HasItemInBackpack (uint32 itemId, uint32 count = 1) { return false; }
447 bool HasSpaceForItemInBackpack (uint32 itemId, uint32 count = 1) { return false; }
449 void AddMail(Mail *m);
451 std::map<uint32, struct quest_status> getQuestStatusMap() { return mQuestStatus; };
453 const uint64& GetSelection( ) const { return m_curSelection; }
454 const uint64& GetTarget( ) const { return m_curTarget; }
456 void SetSelection(const uint64 &guid) { m_curSelection = guid; }
457 void SetTarget(const uint64 &guid) { m_curTarget = guid; }
459 uint32 GetMailSize() { return m_mail.size();};
460 Mail* GetMail(uint32 id);
461 void RemoveMail(uint32 id);
462 std::list<Mail*>::iterator GetmailBegin() { return m_mail.begin();};
463 std::list<Mail*>::iterator GetmailEnd() { return m_mail.end();};
464 void AddBid(bidentry *be);
465 bidentry* GetBid(uint32 id);
466 std::list<bidentry*>::iterator GetBidBegin() { return m_bids.begin();};
467 std::list<bidentry*>::iterator GetBidEnd() { return m_bids.end();};
469 bool HasSpell(uint32 spell);
470 void SendInitialSpells();
471 void addSpell(uint16 spell_id, uint16 slot_id=0xffff);
472 void learnSpell(uint16 spell_id);
473 bool removeSpell(uint16 spell_id);
474 void DealWithSpellDamage(DynamicObject &);
475 inline std::list<Playerspell*> getSpellList() { return m_spells; };
476 void setResurrect(uint64 guid,float X, float Y, float Z, uint32 health, uint32 mana)
478 m_resurrectGUID = guid;
479 m_resurrectX = X;
480 m_resurrectY = Y;
481 m_resurrectZ = Z;
482 m_resurrectHealth = health;
483 m_resurrectMana = mana;
486 int getCinematic()
488 return m_cinematic;
490 void setCinematic(int cine)
492 m_cinematic = cine;
495 uint32 getFaction()
497 return m_faction;
500 void UpdatePVPFlag(time_t currTime);
502 void SetPVPCount(time_t count)
504 if(!m_pvp_counting)
506 m_pvp_count = count;
507 m_pvp_counting = true;
511 void SetPvP(bool b)
513 pvpOn = b;
515 if(!b) SetFlag(UNIT_FIELD_FLAGS , 0x08); //PvP OFF
516 else RemoveFlag(UNIT_FIELD_FLAGS , 0x08); //PvP ON
518 m_pvp_counting = false;
521 bool GetPvP()
523 return pvpOn;
526 void setGold(int gold)
528 uint32 moneyuser = GetUInt32Value(PLAYER_FIELD_COINAGE);
529 SetUInt32Value( PLAYER_FIELD_COINAGE, moneyuser + gold );
532 void setFaction(uint8 race, uint32 faction);
534 inline std::list<struct actions> getActionList() { return m_actions; };
535 void addAction(uint8 button, uint16 action, uint8 type, uint8 misc);
536 void removeAction(uint8 button);
537 void SendInitialActions();
539 void SetInvited() { m_isInvited = true; }
540 void SetInGroup() { m_isInGroup = true; }
541 void SetLeader(const uint64 &guid) { m_groupLeader = guid; }
543 int IsInGroup() { return m_isInGroup; }
544 int IsInvited() { return m_isInvited; }
545 const uint64& GetGroupLeader() const { return m_groupLeader; }
547 void UnSetInvited() { m_isInvited = false; }
548 void UnSetInGroup() { m_isInGroup = false; }
550 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
551 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
552 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
554 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
555 uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
556 int GetGuildIdInvited() { return m_GuildIdInvited; }
558 void SetDuelVs(Player *plyr) { m_pDuel = plyr; }
559 void SetInDuel(const bool &val) { m_isInDuel = val; }
560 void SetDuelSender(Player *plyr) { m_pDuelSender = plyr; }
562 uint32 GetCurrentBuybackSlot() { return m_currentBuybackSlot; }
563 void SetCurrentBuybackSlot(uint32 Slot) { Slot=Slot%12; m_currentBuybackSlot=Slot; }
565 bool IsGroupMember(Player *plyr);
567 void UpdateSlot(uint8 slot)
569 Item* Up = RemoveItemFromSlot(0, slot);
570 if (Up != NULL) AddItem(0, slot, Up, true);
572 void UpdateSlot(uint8 bagindex,uint8 slot)
574 Item* Up = RemoveItemFromSlot(bagindex, slot);
575 if (Up != NULL) AddItem(bagindex,slot, Up, true);
578 Item* GetItemBySlot(uint8 bagIndex,uint8 slot) const;
579 Item* GetItemBySlot(uint8 slot) const
581 ASSERT(slot < BANK_SLOT_BAG_END);
582 return m_items[slot];
584 Item* GetItemByGUID(uint64 guid) const
586 for (int i=0; i < BANK_SLOT_BAG_END; i++)
588 if (m_items[i])
589 if (m_items[i]->GetGUID() == guid) return m_items[i];
591 return NULL;
593 Item* GetItemByItemType(uint32 type);
594 uint32 GetSlotByItemID(uint32 ID);
595 bool GetSlotByItemID(uint32 ID,uint8 &bagIndex,uint8 &slot,bool CheckInventorySlot,bool additems);
596 uint32 GetSlotByItemGUID(uint64 guid);
597 bool GetSlotByItemGUID(uint64 guid,uint8 &bagIndex,uint8 &slot);
599 Bag* GetBagBySlot(uint8 slot) const
601 return (Bag *)m_items[slot];
603 void UpdateSkill(uint32 skill_id);
604 void UpdateSkillPro(uint32 spellid);
605 uint32 GetSkillByProto(ItemPrototype *proto);
606 uint32 GetSpellByProto(ItemPrototype *proto);
607 void GetSlotByItem(uint32 type, uint8 slots[4]);
608 uint8 FindEquipSlot(uint32 type);
609 uint8 FindFreeItemSlot(uint32 type);
610 uint32 CanAddItemCount(Item* item, uint32 where = 1);
611 uint32 CanAddItemCount(uint32 itemid, uint32 where = 1);
613 uint8 CanEquipItemInSlot(uint8 bag, uint8 slot, Item* item, Item* swapitem);
614 bool CanUseItem (ItemPrototype* proto);
615 bool SplitItem(uint8 srcBag, uint8 srcSlot, uint8 dstBag, uint8 dstSlot, uint8 count);
616 bool SwapItem(uint8 dstBag,uint8 dstSlot,uint8 srcBag,uint8 srcSlot);
618 Item* CreateNewItem (uint32 itemId, uint8 count = 1);
619 uint16 GetItemCount(uint32 itemId, bool includebank = false);
620 uint16 GetItemCountAll(uint32 itemId, bool includeEquipment , bool includebank = false);
621 uint32 AddNewItem(uint32 itemId, uint32 count, bool addmaxpossible);
622 uint8 AddItem(uint8 bagIndex, uint8 slot, Item *item, bool allowstack);
623 uint8 AddItemToInventory(Item *item, bool addmaxpossible = false);
624 uint8 AddItemToBank(Item *item, bool addmaxpossible = false);
626 Item* RemoveItemFromSlot(uint8 bagIndex, uint8 slot, bool client_remove=true);
627 int CountFreeBagSlot();
629 const uint64& GetLootGUID() const { return m_lootGuid; }
630 void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; }
632 WorldSession* GetSession() const { return m_session; }
633 void SetSession(WorldSession *s) { m_session = s; }
635 void CreateYourself( );
636 void DestroyYourself( );
638 void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const;
639 void DestroyForPlayer( Player *target ) const;
640 void SendDelayResponse(const uint32);
641 void SendLogXPGain(uint64 GUID,uint32 GivenXP,bool Type, bool Rested);
643 void SendAttackStart(Unit* pVictim);
645 //Low Level Packets
646 void PlaySound(uint32 Sound, bool OnlySelf);
647 //notifiers
648 void SendAttackSwingCantAttack();
649 void SendAttackSwingCancelAttack();
650 void SendAttackSwingDeadTarget();
651 void SendAttackSwingNotStanding();
652 void SendAttackSwingNotInRange();
653 void SendAttackSwingBadFacingAttack();
655 bool SetPosition(const float &x, const float &y, const float &z, const float &orientation);
656 void SendMessageToSet(WorldPacket *data, bool self);
657 void SetSheath (uint32 sheathed);
659 void DeleteFromDB();
660 void DeleteCorpse();
662 void SpawnCorpseBones();
663 void CreateCorpse();
664 void KillPlayer();
665 void ResurrectPlayer();
666 void BuildPlayerRepop();
667 void DeathDurabilityLoss(double percent);
668 void RepopAtGraveyard();
669 void DuelComplete();
671 void SetMovement(uint8 pType);
672 void SetPlayerSpeed(uint8 SpeedType, float value, bool forced=false);
674 void JoinedChannel(Channel *c);
675 void LeftChannel(Channel *c);
676 void CleanupChannels();
678 void BroadcastToFriends(std::string msg);
680 void UpdateDefense();
681 void UpdateSkillWeapon();
683 void SetSkill(uint32 id, uint16 currVal, uint16 maxVal);
684 uint16 GetSkillValue(uint32 skill);
686 void SetDontMove(bool dontMove);
687 bool GetDontMove() { return m_dontMove; }
689 void CheckExploreSystem(void);
691 uint32 GetTeam()
693 return m_team;
695 uint32 getLevel()
697 return (GetUInt32Value(UNIT_FIELD_LEVEL));
699 void SetLastManaUse(time_t spellCastTime) { m_lastManaUse = spellCastTime; }
700 bool SetStanding(uint32 FTemplate, int standing);
701 void CalculateReputation(Unit *pVictim);
702 void CalculateReputation(Quest *pQuest, uint64 guid);
703 void SetInitialFactions();
704 void UpdateReputation(void);
705 void UpdateMaxSkills();
706 void ModifySkillBonus(uint32 skillid,int32 val);
708 //Honor System
709 void UpdateHonor(void);
710 void CalculateHonor(Unit *pVictim);
711 int CalculateHonorRank(float honor);
712 int GetHonorRank();
713 int CalculateTotalKills(Player *pVictim);
714 float GetTotalHonor(void) { return m_total_honor_points; };
715 int GetHonorHighestRank(void) { return m_highest_rank; };
716 int GetHonorLastWeekRank(void) { return m_last_week_rank; };
717 //End of Honor System
719 void SetDrunkValue(uint16 newDrunkValue);
720 uint16 GetDrunkValue() { return m_drunk; }
722 void ApplyItemMods(Item *item,uint8 slot,bool apply)
724 _ApplyItemMods(item, slot, apply);
726 void _ApplyItemMods(Item *item,uint8 slot,bool apply);
727 void _RemoveAllItemMods();
728 void _ApplyAllItemMods();
730 void CastItemSpell(Item *item,Unit* Target);
731 bool IsItemSpellToEquip(SpellEntry *spellInfo);
732 bool IsItemSpellToCombat(SpellEntry *spellInfo);
734 void SendInitWorldStates(uint32 MapID);
735 void SendUpdateWordState(uint16 Field, uint16 Value);
736 void SendDirectMessage(WorldPacket *data);
738 PlayerMenu* PlayerTalkClass;
739 ItemsSetEffect * ItemsSetEff[3];
740 void FlightComplete(void);
741 void SendLoot(uint64 guid,uint8 loot_type);
742 uint8 CheckFishingAble();
744 uint32 m_bgBattleGroundID;
745 bool m_bgInBattleGround;
746 uint8 m_bgTeam;
747 uint32 m_bgEntryPointMap;
748 uint32 m_bgEntryPointO;
749 float m_bgEntryPointX;
750 float m_bgEntryPointY;
751 float m_bgEntryPointZ;
753 uint32 ApplyRestBonus(uint32 xp);
754 uint32 GetRestTime() { return m_restTime;}
755 void SetRestTime(uint32 v) { m_restTime = v;}
757 protected:
759 /*********************************************************/
760 /*** QUEST SYSTEM ***/
761 /*********************************************************/
763 uint32 m_timedquest;
764 uint64 m_divider;
765 uint32 m_ingametime;
767 /*********************************************************/
768 /*** LOAD SYSTEM ***/
769 /*********************************************************/
771 void _LoadActions();
772 void _LoadAuras();
773 void _LoadBids();
774 void _LoadCorpse();
775 void _LoadInventory();
776 void _LoadMail();
777 void _LoadQuestStatus();
778 void _LoadReputation();
779 void _LoadSpells();
780 void _LoadTutorials();
782 /*********************************************************/
783 /*** SAVE SYSTEM ***/
784 /*********************************************************/
786 void _SaveActions();
787 void _SaveAuctions();
788 void _SaveAuras();
789 void _SaveBids();
790 void _SaveInventory();
791 void _SaveMail();
792 void _SaveQuestStatus();
793 void _SaveReputation();
794 void _SaveSpells();
795 void _SaveTutorials();
797 void AddWeather();
798 void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
799 void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
800 void _SetVisibleBits(UpdateMask *updateMask, Player *target) const;
802 bool FactionIsInTheList(uint32 faction);
804 void HandleDrowing (uint32 UnderWaterTime);
805 void HandleLava();
806 void HandleSobering();
808 void StartMirrorTimer(uint8 Type, uint32 MaxValue);
809 void ModifyMirrorTimer(uint8 Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen);
810 void StopMirrorTimer(uint8 Type);
811 void EnvironmentalDamage(uint64 Guid, uint8 Type, uint32 Amount);
813 uint64 m_lootGuid;
815 std::string m_name;
816 std::string m_rank_name;
818 PlayerCreateInfo *info;
820 uint32 m_race;
821 uint32 m_class;
822 uint32 m_faction;
823 uint32 m_team;
824 uint8 m_outfitId;
825 uint16 m_petInfoId;
826 uint16 m_petLevel;
827 uint16 m_petFamilyId;
828 uint32 m_dismountCost;
829 uint32 m_nextSave;
831 Item* m_items[BANK_SLOT_BAG_END];
832 Item* m_buybackitems[BUYBACK_SLOT_END];
834 uint8 m_afk;
835 uint64 m_curTarget;
836 uint64 m_curSelection;
838 typedef std::map<uint32, struct quest_status> StatusMap;
839 StatusMap mQuestStatus;
841 uint64 m_groupLeader;
842 bool m_isInGroup;
843 bool m_isInvited;
845 uint32 m_GuildIdInvited;
847 uint32 m_currentBuybackSlot; //0~11
849 std::list<struct Factions> factions;
850 std::list<bidentry*> m_bids;
851 std::list<Mail*> m_mail;
852 std::list<Playerspell*> m_spells;
853 std::list<struct actions> m_actions;
855 uint64 m_resurrectGUID;
856 float m_resurrectX, m_resurrectY, m_resurrectZ;
857 uint32 m_resurrectHealth, m_resurrectMana;
859 Corpse *m_pCorpse;
861 WorldSession *m_session;
863 std::list<Channel*> m_channels;
865 bool m_dontMove;
867 float m_total_honor_points;
868 int m_highest_rank;
869 int m_last_week_rank;
871 int m_cinematic;
873 Player *pTrader;
874 bool acceptTrade;
875 int tradeItems[7];
876 uint32 tradeGold;
878 bool pvpOn;
879 Player *m_pDuel;
880 bool m_isInDuel;
881 Player *m_pDuelSender;
883 time_t m_nextThinkTime;
884 uint32 m_Tutorials[8];
885 uint32 m_regenTimer;
886 uint32 m_breathTimer;
887 uint32 m_drunkTimer;
888 uint16 m_drunk;
889 time_t m_lastManaUse;
891 uint8 m_isunderwater;
893 uint32 m_restTime;
894 time_t m_pvp_count;
895 bool m_pvp_counting;
898 int irand(int min, int max);
899 uint32 urand(uint32 min, uint32 max);
900 void AddItemsSetItem(Player*player,ItemPrototype *proto);
901 void RemoveItemsSetItem(Player*player,ItemPrototype *proto);
902 #endif