Skip to content

Commit

Permalink
feat(Core/Object): Play radius sound/music. (azerothcore#18011)
Browse files Browse the repository at this point in the history
  • Loading branch information
avarishd authored Dec 13, 2023
1 parent 4d40b03 commit 06525cd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2883,6 +2883,22 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= nullptr*/)
SendMessageToSet(WorldPackets::Misc::Playsound(sound_id).Write(), true);
}

void WorldObject::PlayRadiusSound(uint32 sound_id, float radius)
{
std::list<Player*> targets;
Acore::AnyPlayerInObjectRangeCheck check(this, radius, false);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
Cell::VisitWorldObjects(this, searcher, radius);

for (Player* player : targets)
{
if (player)
{
player->SendDirectMessage(WorldPackets::Misc::Playsound(sound_id).Write());
}
}
}

void WorldObject::PlayDirectMusic(uint32 music_id, Player* target /*= nullptr*/)
{
if (target)
Expand All @@ -2895,6 +2911,22 @@ void WorldObject::PlayDirectMusic(uint32 music_id, Player* target /*= nullptr*/)
}
}

void WorldObject::PlayRadiusMusic(uint32 music_id, float radius)
{
std::list<Player*> targets;
Acore::AnyPlayerInObjectRangeCheck check(this, radius, false);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
Cell::VisitWorldObjects(this, searcher, radius);

for (Player* player : targets)
{
if (player)
{
player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music_id).Write());
}
}
}

void WorldObject::DestroyForNearbyPlayers()
{
if (!IsInWorld())
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/Entities/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ class WorldObject : public Object, public WorldLocation

void PlayDistanceSound(uint32 sound_id, Player* target = nullptr);
void PlayDirectSound(uint32 sound_id, Player* target = nullptr);
void PlayRadiusSound(uint32 sound_id, float radius);
void PlayDirectMusic(uint32 music_id, Player* target = nullptr);
void PlayRadiusMusic(uint32 music_id, float radius);

void SendObjectDeSpawnAnim(ObjectGuid guid);

Expand Down

0 comments on commit 06525cd

Please sign in to comment.