Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 8880d849d0ff7c32b082d54c5f6fcd301827b9dc
- diff --git a/ScriptMgr.cpp b/ScriptMgr.cpp
- index 04c9ebb..a9ff829 100644
- --- a/ScriptMgr.cpp
- +++ b/ScriptMgr.cpp
- @@ -146,17 +146,14 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
- {
- error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.",
- pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
- -
- return;
- }
- const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
- -
- if (!pData)
- {
- error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",
- pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
- -
- return;
- }
- @@ -166,7 +163,17 @@ 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_WHISPER || pData->uiType == CHAT_TYPE_BOSS_WHISPER)
- + {
- + if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
- + pSource->PlayDirectSound(pData->uiSoundId, pTarget);
- + }
- + else 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);
- }
- @@ -223,58 +230,55 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
- * @param iTextEntry Entry of the text, stored in SD2-database, only type CHAT_TYPE_ZONE_YELL supported
- * @param uiCreatureEntry Id of the creature of whom saying will be simulated
- * @param pMap Given Map on which the map-wide text is displayed
- - * @param pCreatureSource Can be NULL. If pointer to Creature is given, then the creature does the map-wide text
- + * @param iZoneId Only sent to players within that zone. If a negative value is used it is sent to whole map
- * @param pTarget Can be NULL. Possible target for the text
- */
- -void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, Creature* pCreatureSource /*=NULL*/, Unit* pTarget /*=NULL*/)
- +void SimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, int32 iZoneId /*= -1*/, Unit* pTarget /*=NULL*/)
- {
- if (!pMap)
- {
- - error_log("SD2: DoOrSimulateScriptTextForMap entry %i, invalid Map pointer.", iTextEntry);
- + error_log("SD2: SimulateScriptTextForMap entry %i, invalid Map pointer.", iTextEntry);
- return;
- }
- if (iTextEntry >= 0)
- {
- - error_log("SD2: DoOrSimulateScriptTextForMap with source entry %u for map %u attempts to process text entry %i, but text entry must be negative.", uiCreatureEntry, pMap->GetId(), iTextEntry);
- + error_log("SD2: SimulateScriptTextForMap with source entry %u for map %u attempts to process text entry %i, but text entry must be negative.", uiCreatureEntry, pMap->GetId(), iTextEntry);
- return;
- }
- CreatureInfo const* pInfo = GetCreatureTemplateStore(uiCreatureEntry);
- if (!pInfo)
- {
- - error_log("SD2: DoOrSimulateScriptTextForMap has invalid source entry %u for map %u.", uiCreatureEntry, pMap->GetId());
- + error_log("SD2: SimulateScriptTextForMap has invalid source entry %u for map %u.", uiCreatureEntry, pMap->GetId());
- return;
- }
- const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
- -
- if (!pData)
- {
- - error_log("SD2: DoOrSimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
- + error_log("SD2: SimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
- return;
- }
- - debug_log("SD2: DoOrSimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
- + if (pData->uiType != CHAT_TYPE_ZONE_YELL)
- + {
- + error_log("SD2: SimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
- + return;
- + }
- +
- + debug_log("SD2: SimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
- iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);
- if (pData->uiSoundId)
- {
- if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
- - pMap->PlayDirectSoundToMap(pData->uiSoundId);
- + pMap->PlayDirectSoundToMap(pData->uiSoundId, iZoneId);
- else
- - error_log("SD2: DoOrSimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
- + error_log("SD2: SimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
- }
- - if (pData->uiType == CHAT_TYPE_ZONE_YELL)
- - {
- - if (pCreatureSource) // If provided pointer for sayer, use direct version
- - pMap->MonsterYellToMap(pCreatureSource->GetObjectGuid(), iTextEntry, pData->uiLanguage, pTarget);
- - else // Simulate yell
- - pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget);
- - }
- - else
- - error_log("SD2: DoSimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
- + pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget, iZoneId);
- }
- //*********************************
- diff --git a/ScriptMgr.h b/ScriptMgr.h
- index 4ff4584..3775a51 100644
- --- a/ScriptMgr.h
- +++ b/ScriptMgr.h
- @@ -113,7 +113,7 @@ struct Script
- // Generic scripting text function
- void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget = NULL);
- -void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, Creature* pCreatureSource = NULL, Unit* pTarget = NULL);
- +void SimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, int32 iZoneId = -1, Unit* pTarget = NULL);
- // *********************************************************
- // **************** Internal hook mechanics ****************
- diff --git a/include/sc_instance.h b/include/sc_instance.h
- index 36c9336..c04f474 100644
- --- a/include/sc_instance.h
- +++ b/include/sc_instance.h
- @@ -51,7 +51,10 @@ class MANGOS_DLL_DECL ScriptedInstance : public InstanceData
- void DoOrSimulateScriptTextForThisInstance(int32 iTextEntry, uint32 uiCreatureEntry)
- {
- // Prevent debug output in GetSingleCreatureFromStorage
- - DoOrSimulateScriptTextForMap(iTextEntry, uiCreatureEntry, instance, GetSingleCreatureFromStorage(uiCreatureEntry, true));
- + if (Creature* pCreatureSource = GetSingleCreatureFromStorage(uiCreatureEntry, true))
- + DoScriptText(iTextEntry, pCreatureSource);
- + else
- + SimulateScriptTextForMap(iTextEntry, uiCreatureEntry, instance);
- }
- // Starts a timed achievement criteria for all players in instance
Add Comment
Please, Sign In to add comment