OregonCore  revision 3611e8a-git
Your Favourite TBC server
NPCHandler.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "Common.h"
19 #include "Language.h"
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
23 #include "Opcodes.h"
24 #include "Log.h"
25 #include "World.h"
26 #include "ObjectMgr.h"
27 #include "SpellMgr.h"
28 #include "Player.h"
29 #include "GossipDef.h"
30 #include "SpellAuras.h"
31 #include "Creature.h"
32 #include "MapManager.h"
33 #include "Pet.h"
34 #include "BattlegroundMgr.h"
35 #include "Battleground.h"
36 #include "Guild.h"
37 #include "ScriptMgr.h"
38 #include "CreatureAI.h"
39 
41 {
42  uint64 guid;
43  recv_data >> guid;
44 
46  if (!unit)
47  {
48  sLog.outDebug("WORLD: HandleTabardVendorActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
49  return;
50  }
51 
52  // remove fake death
53  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
55 
57 }
58 
60 {
62  data << guid;
63  SendPacket(&data);
64 }
65 
67 {
68  sLog.outDebug( "WORLD: Received CMSG_BANKER_ACTIVATE");
69 
70  uint64 guid;
71  recv_data >> guid;
72 
74  if (!unit)
75  {
76  sLog.outDebug("WORLD: HandleBankerActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
77  return;
78  }
79 
80  // remove fake death
81  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
83 
84  SendShowBank(guid);
85 }
86 
88 {
89  WorldPacket data(SMSG_SHOW_BANK, 8);
90  data << guid;
91  SendPacket(&data);
92 }
93 
95 {
96  uint64 guid;
97 
98  recv_data >> guid;
99  SendTrainerList(guid);
100 }
101 
103 {
104  std::string str = GetOregonString(LANG_NPC_TAINER_HELLO);
105  SendTrainerList(guid, str);
106 }
107 
108 void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
109 {
110  sLog.outDebug("WORLD: SendTrainerList");
111 
113  if (!unit)
114  {
115  sLog.outDebug("WORLD: SendTrainerList - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
116  return;
117  }
118 
119  // remove fake death
120  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
122 
123  // trainer list loaded at check;
124  if (!unit->IsTrainerOf(_player, true))
125  return;
126 
127  CreatureInfo const* ci = unit->GetCreatureTemplate();
128 
129  if (!ci)
130  {
131  sLog.outDebug("WORLD: SendTrainerList - (GUID: %u) NO CREATUREINFO!", GUID_LOPART(guid));
132  return;
133  }
134 
135  TrainerSpellData const* trainer_spells = unit->GetTrainerSpells();
136  if (!trainer_spells)
137  {
138  sLog.outDebug("WORLD: SendTrainerList - Training spells not found for creature (GUID: %u Entry: %u)",
139  GUID_LOPART(guid), unit->GetEntry());
140  return;
141  }
142 
143  WorldPacket data(SMSG_TRAINER_LIST, 8 + 4 + 4 + trainer_spells->spellList.size() * 38 + strTitle.size() + 1);
144  data << guid;
145  data << uint32(trainer_spells->trainerType);
146 
147  size_t count_pos = data.wpos();
148  data << uint32(trainer_spells->spellList.size());
149 
150  // reputation discount
151  float fDiscountMod = _player->GetReputationPriceDiscount(unit);
152 
153  uint32 count = 0;
154  for (TrainerSpellList::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr)
155  {
156  TrainerSpell const* tSpell = *itr;
157 
158  if (!_player->IsSpellFitByClassAndRace(tSpell->spell))
159  continue;
160 
161  ++count;
162 
163  bool primary_prof_first_rank = sSpellMgr.IsPrimaryProfessionFirstRankSpell(tSpell->spell);
164 
165  SpellChainNode const* chain_node = sSpellMgr.GetSpellChainNode(tSpell->spell);
166  uint32 req_spell = sSpellMgr.GetSpellRequired(tSpell->spell);
167 
168  data << uint32(tSpell->spell);
169  data << uint8(_player->GetTrainerSpellState(tSpell));
170  data << uint32(floor(tSpell->spellcost * fDiscountMod));
171 
172  data << uint32(primary_prof_first_rank ? 1 : 0); // primary prof. learn confirmation dialog
173  data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state
174  data << uint8(tSpell->reqlevel);
175  data << uint32(tSpell->reqskill);
176  data << uint32(tSpell->reqskillvalue);
177  data << uint32(chain_node && chain_node->prev ? chain_node->prev : req_spell);
178  data << uint32(chain_node && chain_node->prev ? req_spell : 0);
179  data << uint32(0);
180  }
181 
182  data << strTitle;
183 
184  data.put<uint32>(count_pos, count);
185  SendPacket(&data);
186 }
187 
189 {
190  uint64 guid;
191  uint32 spellId = 0;
192 
193  recv_data >> guid >> spellId;
194  sLog.outDebug("WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u", uint32(GUID_LOPART(guid)), spellId);
195 
197  if (!unit)
198  {
199  sLog.outDebug("WORLD: HandleTrainerBuySpellOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
200  return;
201  }
202 
203  // remove fake death
204  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
206 
207  if (!unit->IsTrainerOf(_player, true))
208  return;
209 
210  // check present spell in trainer spell list
211  TrainerSpellData const* trainer_spells = unit->GetTrainerSpells();
212  if (!trainer_spells)
213  return;
214 
215  // not found, cheat?
216  TrainerSpell const* trainer_spell = trainer_spells->Find(spellId);
217  if (!trainer_spell)
218  return;
219 
220  // can't be learn, cheat? Or double learn with lags...
221  if (_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN)
222  return;
223 
224  // apply reputation discount
225  uint32 nSpellCost = uint32(floor(trainer_spell->spellcost * _player->GetReputationPriceDiscount(unit)));
226 
227  // check money requirement
228  if (_player->GetMoney() < nSpellCost)
229  return;
230 
231  WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer
232  data << uint64(guid) << uint32(0xB3);
233  SendPacket(&data);
234 
235  data.Initialize(SMSG_PLAY_SPELL_IMPACT, 12); // visual effect on player
236  data << uint64(_player->GetGUID()) << uint32(0x016A);
237  SendPacket(&data);
238 
239  _player->ModifyMoney(-int32(nSpellCost));
240 
241  // learn explicitly to prevent lost money at lags, learning spell will be only show spell animation
242  _player->LearnSpell(trainer_spell->spell);
243 
245  data << uint64(guid) << uint32(spellId);
246  SendPacket(&data);
247 }
248 
250 {
251  sLog.outDebug("WORLD: Received CMSG_GOSSIP_HELLO");
252 
253  uint64 guid;
254  recv_data >> guid;
255 
257  if (!unit)
258  {
259  sLog.outDebug("WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
260  return;
261  }
262 
263  // Set faction visible if needed
264  if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
265  _player->GetReputationMgr().SetVisible(factionTemplateEntry);
266 
268  // remove fake death
269  //if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
270  // GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
271 
272  if (!unit->IsStopped())
273  unit->StopMoving();
274 
275 
276  // If spiritguide, no need for gossip menu, just put player into resurrect queue
277  if (unit->isSpiritGuide())
278  {
280  if (bg)
281  {
283  sBattlegroundMgr.SendAreaSpiritHealerQueryOpcode(_player, bg, unit->GetGUID());
284  return;
285  }
286  }
287 
288  if (!sScriptMgr.GossipHello(_player, unit))
289  {
290  _player->TalkedToCreature(unit->GetEntry(), unit->GetGUID());
293  }
294  unit->AI()->sGossipHello(_player);
295 }
296 
297 /*void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
298 {
299  sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION");
300 
301  uint32 option;
302  uint32 unk;
303  uint64 guid;
304  std::string code = "";
305 
306  recv_data >> guid >> unk >> option;
307 
308  if (_player->PlayerTalkClass->GossipOptionCoded(option))
309  {
310  sLog.outDebug("reading string");
311  recv_data >> code;
312  sLog.outDebug("string read: %s", code.c_str());
313  }
314 
315  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
316  if (!unit)
317  {
318  sLog.outDebug("WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
319  return;
320  }
321 
322  // remove fake death
323  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
324  GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
325 
326  if (!code.empty())
327  {
328  if (!sScriptMgr.GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction(option), code.c_str()))
329  unit->OnGossipSelect (_player, option);
330  }
331  else
332  {
333  if (!sScriptMgr.GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option)))
334  unit->OnGossipSelect (_player, option);
335  }
336 }*/
337 
339 {
340  sLog.outDebug("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE");
341 
342  uint64 guid;
343 
344  recv_data >> guid;
345 
347  if (!unit)
348  {
349  sLog.outDebug("WORLD: HandleSpiritHealerActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
350  return;
351  }
352 
353  // remove fake death
354  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
356 
358 }
359 
361 {
362  _player->ResurrectPlayer(0.5f, true);
363 
364  _player->DurabilityLossAll(0.25f, true);
365 
366  // get corpse nearest graveyard
367  WorldSafeLocsEntry const* corpseGrave = NULL;
368  Corpse* corpse = _player->GetCorpse();
369  if (corpse)
370  corpseGrave = sObjectMgr.GetClosestGraveYard(
371  corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam());
372 
373  // now can spawn bones
375 
376  // teleport to nearest from corpse graveyard, if different from nearest to player ghost
377  if (corpseGrave)
378  {
379  WorldSafeLocsEntry const* ghostGrave = sObjectMgr.GetClosestGraveYard(
381 
382  if (corpseGrave != ghostGrave)
383  _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());
384  // or update at original position
385  else
387  }
388  // or update at original position
389  else
391 }
392 
394 {
395  uint64 npcGUID;
396  recv_data >> npcGUID;
397 
398  if (!GetPlayer()->IsInWorld() || !GetPlayer()->IsAlive())
399  return;
400 
402  if (!unit)
403  {
404  sLog.outDebug("WORLD: HandleBinderActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
405  return;
406  }
407 
408  // remove fake death
409  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
411 
412  SendBindPoint(unit);
413 }
414 
416 {
417  // prevent set homebind to instances in any case
418  if (GetPlayer()->GetMap()->Instanceable())
419  return;
420 
421  // send spell for bind 3286 bind magic
422  npc->CastSpell(_player, 3286, true); // Bind
423 
425  data << npc->GetGUID();
426  data << uint32(3286); // Bind
427  SendPacket(&data);
428 
430 }
431 
432 //Need fix
434 {
435  sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS");
436  uint64 npcGUID;
437 
438  recv_data >> npcGUID;
439 
441  if (!unit)
442  {
443  sLog.outDebug("WORLD: HandleListStabledPetsOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
444  return;
445  }
446 
447  // remove fake death
448  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
450 
451  // remove mounts this fix bug where getting pet from stable while mounted deletes pet.
452  if (GetPlayer()->IsMounted())
454 
455  SendStablePet(npcGUID);
456 }
457 
459 {
460  sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS Send.");
461 
462  WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size
463  data << uint64 (guid);
464 
465  Pet* pet = _player->GetPet();
466 
467  data << uint8(0); // place holder for slot show number
468  data << uint8(GetPlayer()->m_stableSlots);
469 
470  uint8 num = 0; // counter for place holder
471 
472  // not let move dead pet in slot
473  if (pet && pet->IsAlive() && pet->getPetType() == HUNTER_PET)
474  {
475  data << uint32(pet->GetCharmInfo()->GetPetNumber());
476  data << uint32(pet->GetEntry());
477  data << uint32(pet->getLevel());
478  data << pet->GetName(); // petname
479  data << uint32(pet->GetLoyaltyLevel()); // loyalty
480  data << uint8(0x01); // client slot 1 == current pet (0)
481  ++num;
482  }
483 
484  // 0 1 2 3 4 5 6
485  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT owner, slot, id, entry, level, loyalty, name FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3", _player->GetGUIDLow());
486 
487  if (result)
488  {
489  do
490  {
491  Field* fields = result->Fetch();
492 
493  data << uint32(fields[2].GetUInt32()); // petnumber
494  data << uint32(fields[3].GetUInt32()); // creature entry
495  data << uint32(fields[4].GetUInt32()); // level
496  data << fields[6].GetString(); // name
497  data << uint32(fields[5].GetUInt32()); // loyalty
498  data << uint8(fields[1].GetUInt32() + 1); // slot
499 
500  ++num;
501  }
502  while (result->NextRow());
503  }
504 
505  data.put<uint8>(8, num); // set real data to placeholder
506  SendPacket(&data);
507 }
508 
510 {
511  sLog.outDebug("WORLD: Recv CMSG_STABLE_PET");
512  uint64 npcGUID;
513 
514  recv_data >> npcGUID;
515 
516  if (!GetPlayer()->IsAlive())
517  return;
518 
520  if (!unit)
521  {
522  sLog.outDebug("WORLD: HandleStablePet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
523  return;
524  }
525 
526  // remove fake death
527  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
529 
530  Pet* pet = _player->GetPet();
531 
532  WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size
533 
534  // can't place in stable dead pet
535  if (!pet || !pet->IsAlive() || pet->getPetType() != HUNTER_PET)
536  {
537  data << uint8(0x06);
538  SendPacket(&data);
539  return;
540  }
541 
542  uint32 free_slot = 1;
543 
544  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3 ORDER BY slot ", _player->GetGUIDLow());
545  if (result)
546  {
547  do
548  {
549  Field* fields = result->Fetch();
550 
551  uint32 slot = fields[1].GetUInt32();
552 
553  if (slot == free_slot) // this slot not free
554  ++free_slot;
555  }
556  while (result->NextRow());
557  }
558 
559  if (free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots)
560  {
561  _player->RemovePet(pet, PetSaveMode(free_slot));
562  data << uint8(0x08);
563  }
564  else
565  data << uint8(0x06);
566 
567  SendPacket(&data);
568 }
569 
571 {
572  sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET.");
573  uint64 npcGUID;
574  uint32 petnumber;
575 
576  recv_data >> npcGUID >> petnumber;
577 
579  if (!unit)
580  {
581  sLog.outDebug("WORLD: HandleUnstablePet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
582  return;
583  }
584 
585  // remove fake death
586  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
588 
589  WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size
590 
591  Pet* pet = _player->GetPet();
592  if (pet && pet->IsAlive())
593  {
594  uint8 i = 0x06;
595  data << uint8(i);
596  SendPacket(&data);
597  return;
598  }
599 
600  // delete dead pet
601  if (pet)
603 
604  Pet* newpet = NULL;
605 
606  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot > 0 AND slot < 3", _player->GetGUIDLow(), petnumber);
607  if (result)
608  {
609  Field* fields = result->Fetch();
610  uint32 petentry = fields[0].GetUInt32();
611 
612  newpet = new Pet(_player, HUNTER_PET);
613  if (!newpet->LoadPetFromDB(_player, petentry, petnumber))
614  {
615  delete newpet;
616  newpet = NULL;
617  }
618  }
619 
620  if (newpet)
621  data << uint8(0x09);
622  else
623  data << uint8(0x06);
624  SendPacket(&data);
625 }
626 
628 {
629  sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT.");
630  uint64 npcGUID;
631 
632  recv_data >> npcGUID;
633 
635  if (!unit)
636  {
637  sLog.outDebug("WORLD: HandleBuyStableSlot - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
638  return;
639  }
640 
641  // remove fake death
642  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
644 
645  WorldPacket data(SMSG_STABLE_RESULT, 200);
646 
647  if (GetPlayer()->m_stableSlots < 2) // max slots amount = 2
648  {
649  StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots + 1);
650  if (_player->GetMoney() >= SlotPrice->Price)
651  {
653  _player->ModifyMoney(-int32(SlotPrice->Price));
654  data << uint8(0x0A); // success buy
655  }
656  else
657  data << uint8(0x06);
658  }
659  else
660  data << uint8(0x06);
661 
662  SendPacket(&data);
663 }
664 
666 {
667  sLog.outDebug("HandleStableRevivePet: Not implemented");
668 }
669 
671 {
672  sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET.");
673  uint64 npcGUID;
674  uint32 pet_number;
675 
676  recv_data >> npcGUID >> pet_number;
677 
679  if (!unit)
680  {
681  sLog.outDebug("WORLD: HandleStableSwapPet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
682  return;
683  }
684 
685  // remove fake death
686  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
688 
689  WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size
690 
691  Pet* pet = _player->GetPet();
692 
693  if (!pet || pet->getPetType() != HUNTER_PET)
694  return;
695 
696  // find swapped pet slot in stable
697  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet_number);
698  if (!result)
699  return;
700 
701  Field* fields = result->Fetch();
702 
703  uint32 slot = fields[0].GetUInt32();
704  uint32 petentry = fields[1].GetUInt32();
705 
706  // move alive pet to slot or delele dead pet
707  _player->RemovePet(pet, pet->IsAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
708 
709  // summon unstabled pet
710  Pet* newpet = new Pet(_player);
711  if (!newpet->LoadPetFromDB(_player, petentry, pet_number))
712  {
713  delete newpet;
714  data << uint8(0x06);
715  }
716  else
717  data << uint8(0x09);
718 
719  SendPacket(&data);
720 }
721 
723 {
724  sLog.outDebug("WORLD: CMSG_REPAIR_ITEM");
725 
726  uint64 npcGUID, itemGUID;
727  uint8 guildBank; // new in 2.3.2, bool that means from guild bank money
728 
729  recv_data >> npcGUID >> itemGUID >> guildBank;
730 
732  if (!unit)
733  {
734  sLog.outDebug("WORLD: HandleRepairItemOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
735  return;
736  }
737 
738  // remove fake death
739  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
741 
742  // reputation discount
743  float discountMod = _player->GetReputationPriceDiscount(unit);
744 
745  uint32 TotalCost = 0;
746  if (itemGUID)
747  {
748  sLog.outDebug("ITEM: Repair item, itemGUID = %u, npcGUID = %u", GUID_LOPART(itemGUID), GUID_LOPART(npcGUID));
749 
750  Item* item = _player->GetItemByGuid(itemGUID);
751 
752  if (item)
753  TotalCost = _player->DurabilityRepair(item->GetPos(), true, discountMod, guildBank > 0 ? true : false);
754  }
755  else
756  {
757  sLog.outDebug("ITEM: Repair all items, npcGUID = %u", GUID_LOPART(npcGUID));
758 
759  TotalCost = _player->DurabilityRepairAll(true, discountMod, guildBank > 0 ? true : false);
760  }
761  if (guildBank)
762  {
763  uint32 GuildId = _player->GetGuildId();
764  if (!GuildId)
765  return;
766  Guild* pGuild = sObjectMgr.GetGuildById(GuildId);
767  if (!pGuild)
768  return;
769  pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost);
770  pGuild->SendMoneyInfo(this, _player->GetGUIDLow());
771  }
772 }
773 
PetSaveMode
Definition: Pet.h:33
void HandleGossipHelloOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:249
void SendMoneyInfo(WorldSession *session, uint32 LowGuid)
Definition: Guild.cpp:1315
void HandleBuyStableSlot(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:627
Definition: Corpse.h:48
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
Battleground * GetBattleground() const
Definition: Player.cpp:19386
float GetReputationPriceDiscount(Creature const *pCreature) const
Definition: Player.cpp:19452
PlayerMenu * PlayerTalkClass
Definition: Player.h:2194
void TalkedToCreature(uint32 entry, uint64 guid)
Definition: Player.cpp:13995
bool IsTrainerOf(Player *player, bool msg) const
Definition: Creature.cpp:825
uint32 reqskill
Definition: Creature.h:407
void LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0)
Definition: Guild.cpp:1652
uint32 getFaction() const
Definition: Unit.h:1111
uint32 reqlevel
Definition: Creature.h:409
void HandleTabardVendorActivateOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:40
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
void SendShowBank(uint64 guid)
Definition: NPCHandler.cpp:87
Definition: Field.h:24
uint32 trainerType
Definition: Creature.h:419
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:648
TrainerSpellData const * GetTrainerSpells() const
Definition: Creature.cpp:2459
#define sLog
Log class singleton.
Definition: Log.h:187
uint16 GetPos() const
Definition: Item.h:279
ACE_INT32 int32
Definition: Define.h:67
TrainerSpellList spellList
Definition: Creature.h:418
bool isSpiritGuide() const
Definition: Unit.h:1272
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:37
void HandleRepairItemOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:722
Player * GetPlayer() const
Definition: WorldSession.h:104
uint32 GetGUIDLow() const
Definition: Object.h:160
void HandleStableSwapPet(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:670
Definition: Pet.h:28
void SpawnCorpseBones()
Definition: Player.cpp:4380
void HandleBankerActivateOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:66
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
CharmInfo * GetCharmInfo()
Definition: Unit.h:1567
bool IsSpellFitByClassAndRace(uint32 spell_id) const
Definition: Player.cpp:19465
const char * GetString() const
Definition: Field.h:41
void PrepareGossipMenu(WorldObject *pSource, uint32 menuId=0)
Definition: Player.cpp:12174
void HandleBinderActivateOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:393
void SendTrainerList(uint64 guid)
Definition: NPCHandler.cpp:102
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
Definition: Player.cpp:1556
void SendPreparedGossip(WorldObject *pSource)
Definition: Player.cpp:12332
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
void SendBindPoint(Creature *npc)
Definition: NPCHandler.cpp:415
uint32 m_stableSlots
Definition: Player.h:1299
void HandleTrainerListOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:94
bool IsStopped() const
Definition: Unit.h:2006
void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except=0)
Definition: Unit.cpp:687
uint32 GetPetNumber() const
Definition: Unit.h:779
TrainerSpell const * Find(uint32 spell_id) const
Definition: Creature.cpp:55
uint32 GossipMenuId
Definition: Creature.h:141
bool IsAlive() const
Definition: Unit.h:1433
float GetPositionY() const
Definition: Position.h:98
void put(size_t pos, T value)
Definition: ByteBuffer.h:79
Definition: Item.h:196
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1174
uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank)
Definition: Player.cpp:4510
CreatureAI * AI() const
Definition: Creature.h:548
#define sSpellMgr
Definition: SpellMgr.h:1239
uint32 spellcost
Definition: Creature.h:406
float GetPositionZ() const
Definition: Position.h:99
void RemovePet(Pet *pet, PetSaveMode mode, bool returnreagent=false)
Definition: Player.cpp:17122
void HandleUnstablePet(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:570
void SendSpiritResurrect()
Definition: NPCHandler.cpp:360
void UpdateObjectVisibility(bool forced=true) override
Definition: Player.cpp:18873
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4209
void SetVisible(FactionTemplateEntry const *factionTemplateEntry)
uint32 GetMapId() const
Definition: Object.h:585
uint32 GetLoyaltyLevel()
Definition: Pet.h:204
Corpse * GetCorpse() const
Definition: Player.cpp:4386
void HandleStableRevivePet(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:665
const char * GetOregonString(int32 entry) const
void DurabilityLossAll(double percent, bool inventory)
Definition: Player.cpp:4391
uint32 GetGuildId()
Definition: Player.h:1837
uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank)
Definition: Player.cpp:4494
const char * GetName() const
Definition: Object.h:692
ReputationMgr & GetReputationMgr()
Definition: Player.h:2091
DBCStorage< StableSlotPricesEntry > sStableSlotPricesStore(StableSlotPricesfmt)
ACE_UINT64 uint64
Definition: Define.h:70
void CloseGossip()
Definition: GossipDef.cpp:187
void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid)
void SendStablePet(uint64 guid)
Definition: NPCHandler.cpp:458
TrainerSpellState GetTrainerSpellState(TrainerSpell const *trainer_spell) const
Definition: Player.cpp:3827
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:598
void SendTabardVendorActivate(uint64 guid)
Definition: NPCHandler.cpp:59
Player * _player
Definition: WorldSession.h:729
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
uint32 GetMoney()
Definition: Player.h:1524
bool LoadPetFromDB(Player *owner, uint32 petentry=0, uint32 petnumber=0, bool current=false)
Definition: Pet.cpp:131
#define sBattlegroundMgr
uint32 GetTeam() const
Definition: Player.h:2075
Creature * GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
Definition: Player.cpp:2191
void HandleListStabledPetsOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:433
uint32 prev
Definition: SpellMgr.h:779
uint32 spell
Definition: Creature.h:405
void HandleSpiritHealerActivateOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:338
#define sScriptMgr
Definition: Group.h:526
uint32 GetEntry() const
Definition: Object.h:186
void HandleStablePet(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:509
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void ModifyMoney(int32 d)
Definition: Player.h:1528
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
Pet * GetPet() const
Definition: Player.cpp:17104
Definition: Guild.h:265
uint32 getLevel() const
Definition: Unit.h:1029
void StopMoving()
Definition: Unit.cpp:11838
uint32 reqskillvalue
Definition: Creature.h:408
Definition: Pet.h:146
void LearnSpell(uint32 spell_id)
Definition: Player.cpp:3198
PetType getPetType() const
Definition: Pet.h:155
Item * GetItemByGuid(uint64 guid) const
Definition: Player.cpp:8583
void HandleTrainerBuySpellOpcode(WorldPacket &recvPacket)
Definition: NPCHandler.cpp:188
const uint64 & GetGUID() const
Definition: Object.h:156
virtual void sGossipHello(Player *)
Definition: UnitAI.h:111