[6844] Daily quest fixes.
[getmangos.git] / src / game / PetHandler.cpp
blob787b08661641f5999e71133c19b9ba4cca2b89df
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
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 #include "Common.h"
20 #include "WorldPacket.h"
21 #include "WorldSession.h"
22 #include "World.h"
23 #include "ObjectMgr.h"
24 #include "SpellMgr.h"
25 #include "Log.h"
26 #include "Opcodes.h"
27 #include "Spell.h"
28 #include "ObjectAccessor.h"
29 #include "MapManager.h"
30 #include "CreatureAI.h"
31 #include "Util.h"
32 #include "Pet.h"
33 #include "Language.h"
35 void WorldSession::HandlePetAction( WorldPacket & recv_data )
37 CHECK_PACKET_SIZE(recv_data,8+2+2+8);
39 uint64 guid1;
40 uint16 spellid;
41 uint16 flag;
42 uint64 guid2;
43 recv_data >> guid1; //pet guid
44 recv_data >> spellid;
45 recv_data >> flag; //delete = 0x0700 CastSpell = C100
46 recv_data >> guid2; //tag guid
48 // used also for charmed creature
49 Unit* pet= ObjectAccessor::GetUnit(*_player,guid1);
50 sLog.outDetail( "HandlePetAction.Pet %u flag is %u, spellid is %u, target %u.\n", uint32(GUID_LOPART(guid1)), flag, spellid, uint32(GUID_LOPART(guid2)) );
51 if(!pet)
53 sLog.outError( "Pet %u not exist.\n", uint32(GUID_LOPART(guid1)) );
54 return;
57 if(pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())
59 sLog.outError( "HandlePetAction.Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid1)),GetPlayer()->GetName() );
60 return;
63 if(!pet->isAlive())
64 return;
66 if(pet->GetTypeId() == TYPEID_PLAYER && !(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))
67 return;
69 CharmInfo *charmInfo = pet->GetCharmInfo();
70 if(!charmInfo)
72 sLog.outError("WorldSession::HandlePetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
73 return;
76 switch(flag)
78 case ACT_COMMAND: //0x0700
79 switch(spellid)
81 case COMMAND_STAY: //flat=1792 //STAY
82 pet->StopMoving();
83 pet->GetMotionMaster()->Clear();
84 pet->GetMotionMaster()->MoveIdle();
85 charmInfo->SetCommandState( COMMAND_STAY );
86 break;
87 case COMMAND_FOLLOW: //spellid=1792 //FOLLOW
88 pet->AttackStop();
89 pet->GetMotionMaster()->MoveFollow(_player,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
90 charmInfo->SetCommandState( COMMAND_FOLLOW );
91 break;
92 case COMMAND_ATTACK: //spellid=1792 //ATTACK
94 // only place where pet can be player
95 pet->clearUnitState(UNIT_STAT_FOLLOW);
96 uint64 selguid = _player->GetSelection();
97 Unit *TargetUnit = ObjectAccessor::GetUnit(*_player, selguid);
98 if(!TargetUnit)
99 return;
101 // not let attack friendly units.
102 if( GetPlayer()->IsFriendlyTo(TargetUnit))
103 return;
105 if(pet->getVictim())
106 pet->AttackStop();
108 if(pet->GetTypeId() != TYPEID_PLAYER)
110 pet->GetMotionMaster()->Clear();
111 if (((Creature*)pet)->AI())
112 ((Creature*)pet)->AI()->AttackStart(TargetUnit);
114 //10% chance to play special pet attack talk, else growl
115 if(((Creature*)pet)->isPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10)
116 pet->SendPetTalk((uint32)PET_TALK_ATTACK);
117 else
119 // 90% chance for pet and 100% chance for charmed creature
120 pet->SendPetAIReaction(guid1);
123 else // charmed player
125 pet->Attack(TargetUnit,true);
126 pet->SendPetAIReaction(guid1);
128 break;
130 case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
131 if(((Creature*)pet)->isPet())
133 Pet* p = (Pet*)pet;
134 if(p->getPetType() == HUNTER_PET)
135 _player->RemovePet(p,PET_SAVE_AS_DELETED);
136 else
137 //dismissing a summoned pet is like killing them (this prevents returning a soulshard...)
138 p->setDeathState(CORPSE);
140 else // charmed
141 _player->Uncharm();
142 break;
143 default:
144 sLog.outError("WORLD: unknown PET flag Action %i and spellid %i.\n", flag, spellid);
146 break;
147 case ACT_REACTION: // 0x600
148 switch(spellid)
150 case REACT_PASSIVE: //passive
151 case REACT_DEFENSIVE: //recovery
152 case REACT_AGGRESSIVE: //activete
153 charmInfo->SetReactState( ReactStates(spellid) );
154 break;
156 break;
157 case ACT_DISABLED: //0x8100 spell (disabled), ignore
158 case ACT_CAST: //0x0100
159 case ACT_ENABLED: //0xc100 spell
161 Unit* unit_target;
162 if(guid2)
163 unit_target = ObjectAccessor::GetUnit(*_player,guid2);
164 else
165 unit_target = NULL;
167 if (((Creature*)pet)->GetGlobalCooldown() > 0)
168 return;
170 // do not cast unknown spells
171 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid );
172 if(!spellInfo)
174 sLog.outError("WORLD: unknown PET spell id %i\n", spellid);
175 return;
178 for(uint32 i = 0; i < 3;i++)
180 if(spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED)
181 return;
184 // do not cast not learned spells
185 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
186 return;
188 pet->clearUnitState(UNIT_STAT_FOLLOW);
190 Spell *spell = new Spell(pet, spellInfo, false);
192 int16 result = spell->PetCanCast(unit_target);
194 //auto turn to target unless possessed
195 if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
197 pet->SetInFront(unit_target);
198 if( unit_target->GetTypeId() == TYPEID_PLAYER )
199 pet->SendUpdateToPlayer( (Player*)unit_target );
200 if(Unit* powner = pet->GetCharmerOrOwner())
201 if(powner->GetTypeId() == TYPEID_PLAYER)
202 pet->SendUpdateToPlayer((Player*)powner);
203 result = -1;
206 if(result == -1)
208 ((Creature*)pet)->AddCreatureSpellCooldown(spellid);
209 if (((Creature*)pet)->isPet())
210 ((Pet*)pet)->CheckLearning(spellid);
212 unit_target = spell->m_targets.getUnitTarget();
214 //10% chance to play special pet attack talk, else growl
215 //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
216 if(((Creature*)pet)->isPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10))
217 pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
218 else
220 pet->SendPetAIReaction(guid1);
223 if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
225 pet->clearUnitState(UNIT_STAT_FOLLOW);
226 if(pet->getVictim())
227 pet->AttackStop();
228 pet->GetMotionMaster()->Clear();
229 if (((Creature*)pet)->AI())
230 ((Creature*)pet)->AI()->AttackStart(unit_target);
233 spell->prepare(&(spell->m_targets));
235 else
237 if(pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
239 WorldPacket data(SMSG_CAST_FAILED, (4+1+1));
240 data << uint32(spellid) << uint8(2) << uint8(result);
241 switch (result)
243 case SPELL_FAILED_REQUIRES_SPELL_FOCUS:
244 data << uint32(spellInfo->RequiresSpellFocus);
245 break;
246 case SPELL_FAILED_REQUIRES_AREA:
247 data << uint32(spellInfo->AreaId);
248 break;
250 SendPacket(&data);
252 else
253 pet->SendPetCastFail(spellid, result);
255 if(!((Creature*)pet)->HasSpellCooldown(spellid))
256 pet->SendPetClearCooldown(spellid);
258 spell->finish(false);
259 delete spell;
261 break;
263 default:
264 sLog.outError("WORLD: unknown PET flag Action %i and spellid %i.\n", flag, spellid);
268 void WorldSession::HandlePetNameQuery( WorldPacket & recv_data )
270 CHECK_PACKET_SIZE(recv_data,4+8);
272 sLog.outDetail( "HandlePetNameQuery. CMSG_PET_NAME_QUERY\n" );
274 uint32 petnumber;
275 uint64 petguid;
277 recv_data >> petnumber;
278 recv_data >> petguid;
280 SendPetNameQuery(petguid,petnumber);
283 void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
285 Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player, petguid);
286 if(!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
287 return;
289 std::string name = pet->GetName();
291 WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
292 data << uint32(petnumber);
293 data << name.c_str();
294 data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));
296 if( pet->isPet() && ((Pet*)pet)->GetDeclinedNames() )
298 data << uint8(1);
299 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
300 data << ((Pet*)pet)->GetDeclinedNames()->name[i];
302 else
303 data << uint8(0);
305 _player->GetSession()->SendPacket(&data);
308 void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
310 CHECK_PACKET_SIZE(recv_data,8+4+2+2);
312 sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION\n" );
314 uint64 petguid;
315 uint32 position;
316 uint16 spell_id;
317 uint16 act_state;
318 uint8 count;
320 recv_data >> petguid;
322 // FIXME: charmed case
323 //Pet* pet = ObjectAccessor::Instance().GetPet(petguid);
324 if(ObjectAccessor::FindPlayer(petguid))
325 return;
327 Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player, petguid);
329 if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
331 sLog.outError( "HandlePetSetAction: Unknown pet or pet owner.\n" );
332 return;
335 CharmInfo *charmInfo = pet->GetCharmInfo();
336 if(!charmInfo)
338 sLog.outError("WorldSession::HandlePetSetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
339 return;
342 count = (recv_data.size() == 24) ? 2 : 1;
343 for(uint8 i = 0; i < count; i++)
345 recv_data >> position;
346 recv_data >> spell_id;
347 recv_data >> act_state;
349 sLog.outDetail( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X\n", _player->GetName(), position, spell_id, act_state);
351 //if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
352 if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_CAST) && spell_id && !pet->HasSpell(spell_id)))
354 //sign for autocast
355 if(act_state == ACT_ENABLED && spell_id)
357 if(pet->isCharmed())
358 charmInfo->ToggleCreatureAutocast(spell_id, true);
359 else
360 ((Pet*)pet)->ToggleAutocast(spell_id, true);
362 //sign for no/turn off autocast
363 else if(act_state == ACT_DISABLED && spell_id)
365 if(pet->isCharmed())
366 charmInfo->ToggleCreatureAutocast(spell_id, false);
367 else
368 ((Pet*)pet)->ToggleAutocast(spell_id, false);
371 charmInfo->GetActionBarEntry(position)->Type = act_state;
372 charmInfo->GetActionBarEntry(position)->SpellOrAction = spell_id;
377 void WorldSession::HandlePetRename( WorldPacket & recv_data )
379 CHECK_PACKET_SIZE(recv_data, 8+1);
381 sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME\n" );
383 uint64 petguid;
384 uint8 isdeclined;
386 std::string name;
387 DeclinedName declinedname;
389 recv_data >> petguid;
390 recv_data >> name;
391 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
392 recv_data >> isdeclined;
394 Pet* pet = ObjectAccessor::GetPet(petguid);
395 // check it!
396 if( !pet || !pet->isPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET ||
397 pet->GetByteValue(UNIT_FIELD_BYTES_2, 2) != UNIT_RENAME_ALLOWED ||
398 pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() )
399 return;
401 if(!ObjectMgr::IsValidPetName(name))
403 SendPetNameInvalid(PET_NAME_INVALID, name, NULL);
404 return;
407 if(objmgr.IsReservedName(name))
409 SendPetNameInvalid(PET_NAME_RESERVED, name, NULL);
410 return;
413 pet->SetName(name);
415 Unit *owner = pet->GetOwner();
416 if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
417 ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
419 pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED);
421 if(isdeclined)
423 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
425 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
426 recv_data >> declinedname.name[i];
429 std::wstring wname;
430 Utf8toWStr(name, wname);
431 if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname))
433 SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname);
434 return;
438 CharacterDatabase.BeginTransaction();
439 if(isdeclined)
441 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
442 CharacterDatabase.escape_string(declinedname.name[i]);
443 CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
444 CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
445 pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
448 CharacterDatabase.escape_string(name);
449 CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
450 CharacterDatabase.CommitTransaction();
452 pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
455 void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
457 CHECK_PACKET_SIZE(recv_data, 8);
459 uint64 guid;
460 recv_data >> guid; //pet guid
461 sLog.outDetail( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) );
463 // pet/charmed
464 Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player, guid);
465 if(pet)
467 if(pet->isPet())
469 if(pet->GetGUID() == _player->GetPetGUID())
471 uint32 feelty = pet->GetPower(POWER_HAPPINESS);
472 pet->SetPower(POWER_HAPPINESS ,(feelty-50000) > 0 ?(feelty-50000) : 0);
475 _player->RemovePet((Pet*)pet,PET_SAVE_AS_DELETED);
477 else if(pet->GetGUID() == _player->GetCharmGUID())
479 _player->Uncharm();
484 void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
486 CHECK_PACKET_SIZE(recvPacket,8);
488 sLog.outDetail("CMSG_PET_UNLEARN");
489 uint64 guid;
490 recvPacket >> guid;
492 Pet* pet = _player->GetPet();
494 if(!pet || pet->getPetType() != HUNTER_PET || pet->m_spells.size() <= 1)
495 return;
497 if(guid != pet->GetGUID())
499 sLog.outError( "HandlePetUnlearnOpcode.Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
500 return;
503 CharmInfo *charmInfo = pet->GetCharmInfo();
504 if(!charmInfo)
506 sLog.outError("WorldSession::HandlePetUnlearnOpcode: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
507 return;
510 uint32 cost = pet->resetTalentsCost();
512 if (GetPlayer()->GetMoney() < cost)
514 GetPlayer()->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
515 return;
518 for(PetSpellMap::iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end();)
520 uint32 spell_id = itr->first; // Pet::removeSpell can invalidate iterator at erase NEW spell
521 ++itr;
522 pet->removeSpell(spell_id);
525 pet->SetTP(pet->getLevel() * (pet->GetLoyaltyLevel() - 1));
527 for(uint8 i = 0; i < 10; i++)
529 if(charmInfo->GetActionBarEntry(i)->SpellOrAction && charmInfo->GetActionBarEntry(i)->Type == ACT_ENABLED || charmInfo->GetActionBarEntry(i)->Type == ACT_DISABLED)
530 charmInfo->GetActionBarEntry(i)->SpellOrAction = 0;
533 // relearn pet passives
534 pet->LearnPetPassives();
536 pet->m_resetTalentsTime = time(NULL);
537 pet->m_resetTalentsCost = cost;
538 GetPlayer()->ModifyMoney(-(int32)cost);
540 GetPlayer()->PetSpellInitialize();
543 void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
545 CHECK_PACKET_SIZE(recvPacket,8+2+2+1);
547 sLog.outDetail("CMSG_PET_SPELL_AUTOCAST");
548 uint64 guid;
549 uint16 spellid;
550 uint16 spellid2; //maybe second spell, automatically toggled off when first toggled on?
551 uint8 state; //1 for on, 0 for off
552 recvPacket >> guid >> spellid >> spellid2 >> state;
554 if(!_player->GetPet() && !_player->GetCharm())
555 return;
557 if(ObjectAccessor::FindPlayer(guid))
558 return;
560 Creature* pet=ObjectAccessor::GetCreatureOrPet(*_player,guid);
562 if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
564 sLog.outError( "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
565 return;
568 // do not add not learned spells/ passive spells
569 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
570 return;
572 CharmInfo *charmInfo = pet->GetCharmInfo();
573 if(!charmInfo)
575 sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
576 return;
579 if(pet->isCharmed())
580 //state can be used as boolean
581 pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
582 else
583 ((Pet*)pet)->ToggleAutocast(spellid, state);
585 for(uint8 i = 0; i < 10; ++i)
587 if((charmInfo->GetActionBarEntry(i)->Type == ACT_ENABLED || charmInfo->GetActionBarEntry(i)->Type == ACT_DISABLED) && spellid == charmInfo->GetActionBarEntry(i)->SpellOrAction)
588 charmInfo->GetActionBarEntry(i)->Type = state ? ACT_ENABLED : ACT_DISABLED;
592 void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
594 sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL");
596 CHECK_PACKET_SIZE(recvPacket,8+4);
597 uint64 guid;
598 uint32 spellid;
600 recvPacket >> guid >> spellid;
602 if(!_player->GetPet() && !_player->GetCharm())
603 return;
605 if(ObjectAccessor::FindPlayer(guid))
606 return;
608 Creature* pet=ObjectAccessor::GetCreatureOrPet(*_player,guid);
610 if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm()))
612 sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
613 return;
616 if (pet->GetGlobalCooldown() > 0)
617 return;
619 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);
620 if(!spellInfo)
622 sLog.outError("WORLD: unknown PET spell id %i\n", spellid);
623 return;
626 // do not cast not learned spells
627 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
628 return;
630 SpellCastTargets targets;
631 if(!targets.read(&recvPacket,pet))
632 return;
634 pet->clearUnitState(UNIT_STAT_FOLLOW);
636 Spell *spell = new Spell(pet, spellInfo, false);
637 spell->m_targets = targets;
639 int16 result = spell->PetCanCast(NULL);
640 if(result == -1)
642 pet->AddCreatureSpellCooldown(spellid);
643 if(pet->isPet())
645 Pet* p = (Pet*)pet;
646 p->CheckLearning(spellid);
647 //10% chance to play special pet attack talk, else growl
648 //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
649 if(p->getPetType() == SUMMON_PET && (urand(0, 100) < 10))
650 pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
651 else
652 pet->SendPetAIReaction(guid);
655 spell->prepare(&(spell->m_targets));
657 else
659 pet->SendPetCastFail(spellid, result);
660 if(!pet->HasSpellCooldown(spellid))
661 pet->SendPetClearCooldown(spellid);
663 spell->finish(false);
664 delete spell;
668 void WorldSession::SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName)
670 WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1);
671 data << uint32(error);
672 data << name;
673 if(declinedName)
675 data << uint8(1);
676 for(uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
677 data << declinedName->name[i];
679 else
680 data << uint8(0);
681 SendPacket(&data);