diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Pet/PetDefines.h | 6 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 8 | ||||
-rw-r--r-- | src/server/game/Handlers/PetHandler.cpp | 23 | ||||
-rwxr-xr-x | src/server/game/Server/Packets/PetPackets.cpp | 14 | ||||
-rwxr-xr-x | src/server/game/Server/Packets/PetPackets.h | 25 |
6 files changed, 70 insertions, 26 deletions
diff --git a/src/server/game/Entities/Pet/PetDefines.h b/src/server/game/Entities/Pet/PetDefines.h index 9f4683ef283..b96799db85c 100644 --- a/src/server/game/Entities/Pet/PetDefines.h +++ b/src/server/game/Entities/Pet/PetDefines.h @@ -75,10 +75,10 @@ enum ActionFeedback FEEDBACK_CANT_ATT_TARGET = 3 }; -enum PetTalk +enum PetAction : int32 { - PET_TALK_SPECIAL_SPELL = 0, - PET_TALK_ATTACK = 1 + PET_ACTION_SPECIAL_SPELL = 0, + PET_ACTION_ATTACK = 1 }; #define PET_FOLLOW_DIST 1.0f diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bac4222cf4d..bfbf415c956 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -58,6 +58,7 @@ #include "PassiveAI.h" #include "PetAI.h" #include "Pet.h" +#include "PetPackets.h" #include "Player.h" #include "PlayerAI.h" #include "QuestDef.h" @@ -10242,7 +10243,7 @@ void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProc } ///----------Pet responses methods----------------- -void Unit::SendPetActionFeedback(uint8 msg) +void Unit::SendPetActionFeedback(uint8 msg) const { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) @@ -10253,19 +10254,18 @@ void Unit::SendPetActionFeedback(uint8 msg) owner->ToPlayer()->SendDirectMessage(&data); } -void Unit::SendPetTalk(uint32 pettalk) +void Unit::SendPetActionSound(PetAction action) const { - Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; + SendMessageToSet(WorldPackets::Pet::PetActionSound(GetGUID(), static_cast<int32>(action)).Write(), false); +} - WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); - data << uint64(GetGUID()); - data << uint32(pettalk); - owner->ToPlayer()->SendDirectMessage(&data); +void Unit::SendPetDismissSound() const +{ + if (CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId())) + SendMessageToSet(WorldPackets::Pet::PetDismissSound(static_cast<int32>(displayInfo->ModelID), GetPosition()).Write(), false); } -void Unit::SendPetAIReaction(ObjectGuid guid) +void Unit::SendPetAIReaction(ObjectGuid guid) const { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 5991b268b87..5910b317377 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -21,6 +21,7 @@ #include "Object.h" #include "CombatManager.h" #include "SpellAuraDefines.h" +#include "PetDefines.h" #include "ThreatManager.h" #include "Timer.h" #include "UnitDefines.h" @@ -1707,9 +1708,10 @@ class TC_GAME_API Unit : public WorldObject void ClearComboPointHolders(); ///----------Pet responses methods----------------- - void SendPetActionFeedback(uint8 msg); - void SendPetTalk(uint32 pettalk); - void SendPetAIReaction(ObjectGuid guid); + void SendPetActionFeedback(uint8 msg) const; + void SendPetActionSound(PetAction action) const; + void SendPetDismissSound() const; + void SendPetAIReaction(ObjectGuid guid) const; ///----------End of Pet responses methods---------- void PropagateSpeedChange(); diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 12590139ea9..a0ff9c4bc51 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -212,8 +212,8 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe AI->AttackStart(TargetUnit); // 10% chance to play special pet attack talk, else growl - if (pet->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10) - pet->SendPetTalk((uint32)PET_TALK_ATTACK); + if (pet->IsPet() && pet->ToPet()->getPetType() == SUMMON_PET && pet != TargetUnit && roll_chance_i(10)) + pet->SendPetActionSound(PET_ACTION_ATTACK); else { // 90% chance for pet and 100% chance for charmed creature @@ -242,10 +242,13 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe ASSERT(pet->GetTypeId() == TYPEID_UNIT); if (pet->IsPet()) { - if (((Pet*)pet)->getPetType() == HUNTER_PET) - GetPlayer()->RemovePet((Pet*)pet, PET_SAVE_AS_DELETED); + if (pet->ToPet()->getPetType() == HUNTER_PET) + GetPlayer()->RemovePet(pet->ToPet(), PET_SAVE_AS_DELETED); else - GetPlayer()->RemovePet((Pet*)pet, PET_SAVE_NOT_IN_SLOT); + { + pet->SendPetDismissSound(); + GetPlayer()->RemovePet(pet->ToPet(), PET_SAVE_NOT_IN_SLOT); + } } else if (pet->HasUnitTypeMask(UNIT_MASK_MINION)) { @@ -342,8 +345,8 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe // 10% chance to play special pet attack talk, else growl // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if (pet->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10)) - pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); + if (pet->IsPet() && pet->ToPet()->getPetType() == SUMMON_PET && pet != unit_target && roll_chance_i(10)) + pet->SendPetActionSound(PET_ACTION_SPECIAL_SPELL); else { pet->SendPetAIReaction(guid1); @@ -811,10 +814,10 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) { if (Pet* pet = creature->ToPet()) { - // 10% chance to play special pet attack talk, else growl + // 10% chance to play special pet attack sound, else growl // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if (pet->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) - pet->SendPetTalk(PET_TALK_SPECIAL_SPELL); + if (pet->getPetType() == SUMMON_PET && roll_chance_i(10)) + pet->SendPetActionSound(PET_ACTION_SPECIAL_SPELL); else pet->SendPetAIReaction(guid); } diff --git a/src/server/game/Server/Packets/PetPackets.cpp b/src/server/game/Server/Packets/PetPackets.cpp index 7653e2a2328..1b2ee6532b6 100755 --- a/src/server/game/Server/Packets/PetPackets.cpp +++ b/src/server/game/Server/Packets/PetPackets.cpp @@ -50,3 +50,17 @@ WorldPacket const* WorldPackets::Pet::PetUnlearnedSpell::Write() _worldPacket << uint32(SpellID); return &_worldPacket; } + +WorldPacket const* WorldPackets::Pet::PetActionSound::Write() +{ + _worldPacket << UnitGUID; + _worldPacket << int32(Action); + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Pet::PetDismissSound::Write() +{ + _worldPacket << int32(ModelId); + _worldPacket << ModelPosition; + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/PetPackets.h b/src/server/game/Server/Packets/PetPackets.h index cf175fb6f5a..8893f2497d9 100755 --- a/src/server/game/Server/Packets/PetPackets.h +++ b/src/server/game/Server/Packets/PetPackets.h @@ -19,6 +19,7 @@ #define PetPackets_h__ #include "Packet.h" +#include "Position.h" #include "ObjectGuid.h" namespace WorldPackets @@ -94,6 +95,30 @@ namespace WorldPackets void Read() override { } }; + + class PetActionSound final : public ServerPacket + { + public: + PetActionSound(ObjectGuid unitGUID, int32 action) + : ServerPacket(SMSG_PET_ACTION_SOUND, 8 + 4), UnitGUID(unitGUID), Action(action) { } + + WorldPacket const* Write() override; + + ObjectGuid UnitGUID; + int32 Action = 0; + }; + + class PetDismissSound final : public ServerPacket + { + public: + PetDismissSound(int32 modelId, Position modelPosition) + : ServerPacket(SMSG_PET_DISMISS_SOUND, 4 + 12), ModelId(modelId), ModelPosition(modelPosition) { } + + WorldPacket const* Write() override; + + int32 ModelId = 0; + TaggedPosition<Position::XYZ> ModelPosition; + }; } } |