Jump to content

[11812]Allow to send sound/text only to specific zone


Guest stfx
 Share

Recommended Posts

What bug does the patch fix? What features does the patch add?

This patch fixes yell to zone (type=6) for scripts. Also it adds zoneId parameter to MonsterYellToMap to restrict it to a map.

The first part is needed to fix zone yells like the one from Mr. Smite in deadmines. That second part is needed for world bosses like: http://www.wowhead.com/npc=18728 which yell only in zone (in this case Hellfire Peninsula)

For which repository revision was the patch created?

[11811]

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

no

Who has been writing this patch? Please include either forum user names or email addresses.

Me

Here is the patch for core: https://gist.github.com/1245187

Path for sd2: https://gist.github.com/1245190

Link to comment
Share on other sites

Hm if you want I could add a map yell chat-type but this is not really related to this patch and I also did not find any example of a map yell as each instance has only one zone (atleast in TBC and I think in WotLK as well)

EDIT:

Added correct way to send sound for CHAT_TYPE_WHISPER and CHAT_TYPE_BOSS_WHISPER (only used for not yet scripted Yogg Saron according to sd2 script_texts)

Also fixed param mismatch :)

Link to comment
Share on other sites

I also did not find any example of a map yell as each instance has only one zone (atleast in TBC and I think in WotLK as well)

The northrend fishing contest could be an example I think (map with different zones). You can see the yell in each zone of northrend when the contest is announced.

incorrect. the yells cannot be heard in "The Frozen Sea"

Link to comment
Share on other sites

hm - if I don't miss a thing these much simplier changes are enough to improve the things you improve in your patch.

But ofc if more powerfull features are required, more changes will be needed with this simplier approach.

Assuming I have no logic mistake, I think I would prefer this because:

* I think we should change the way Text is handled to, wrapt the many functions into one DoMonsterText(ChatType t, ...) instead of the various chat-type functions

* Clearify if we want to use MonsterYellToZone or replace this with Map::MonsterYellToMap

About the nordend fishing event I think we need a bit more information, like: Text said by one mob that can be heard in all-except-one zones, or are there many mobs who tell texts?

Also I tend to wonder about maybe adding phase checks related to yell (not sure if the default MonsterText workers already take this into account), the Map:: functions don't.

diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 6a4a5e1..bc86d42 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -3230,13 +3230,15 @@ void Map::MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 langu
 * Function to play sound to all players in map
 *
 * @param soundId Played Sound
+ * @param zoneId Id of the Zone to which the sound should be restricted
 */
-void Map::PlayDirectSoundToMap(uint32 soundId)
+void Map::PlayDirectSoundToMap(uint32 soundId, uint32 zoneId /*=0*/)
{
    WorldPacket data(SMSG_PLAY_SOUND, 4);
    data << uint32(soundId);

    Map::PlayerList const& pList = GetPlayers();
    for (PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
-        itr->getSource()->SendDirectMessage(&data);
+        if (!zoneId || itr->getSource()->GetZoneId() == zoneId)
+            itr->getSource()->SendDirectMessage(&data);
}
diff --git a/src/game/Map.h b/src/game/Map.h
index 31e8731..8bcbb9d 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -257,7 +257,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>

        void MonsterYellToMap(ObjectGuid guid, int32 textId, uint32 language, Unit* target);
        void MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 language, Unit* target, uint32 senderLowGuid = 0);
-        void PlayDirectSoundToMap(uint32 soundId);
+        void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId);

    private:
        void LoadMapAndVMap(int gx, int gy);

-- ------------------- Changes in SD2:

diff --git a/ScriptMgr.cpp b/ScriptMgr.cpp
index 04c9ebb..e058b4f 100644
--- a/ScriptMgr.cpp
+++ b/ScriptMgr.cpp
@@ -166,7 +165,12 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
    if (pData->uiSoundId)
    {
        if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
-            pSource->PlayDirectSound(pData->uiSoundId);
+        {
+            if (pData->uiType == CHAT_TYPE_ZONE_YELL)
+                pSource->GetMap()->PlayDirectSoundToMap(pData->uiSoundId, pSource->GetZoneId());
+            else
+                pSource->PlayDirectSound(pData->uiSoundId);
+        }
        else
            error_log("SD2: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
    }

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use