Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. 8880d849d0ff7c32b082d54c5f6fcd301827b9dc
  2. diff --git a/ScriptMgr.cpp b/ScriptMgr.cpp
  3. index 04c9ebb..a9ff829 100644
  4. --- a/ScriptMgr.cpp
  5. +++ b/ScriptMgr.cpp
  6. @@ -146,17 +146,14 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
  7. {
  8. error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.",
  9. pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
  10. -
  11. return;
  12. }
  13.  
  14. const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
  15. -
  16. if (!pData)
  17. {
  18. error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",
  19. pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
  20. -
  21. return;
  22. }
  23.  
  24. @@ -166,7 +163,17 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
  25. if (pData->uiSoundId)
  26. {
  27. if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
  28. - pSource->PlayDirectSound(pData->uiSoundId);
  29. + {
  30. + if (pData->uiType == CHAT_TYPE_WHISPER || pData->uiType == CHAT_TYPE_BOSS_WHISPER)
  31. + {
  32. + if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
  33. + pSource->PlayDirectSound(pData->uiSoundId, pTarget);
  34. + }
  35. + else if (pData->uiType == CHAT_TYPE_ZONE_YELL)
  36. + pSource->GetMap()->PlayDirectSoundToMap(pData->uiSoundId, pSource->GetZoneId());
  37. + else
  38. + pSource->PlayDirectSound(pData->uiSoundId);
  39. + }
  40. else
  41. error_log("SD2: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
  42. }
  43. @@ -223,58 +230,55 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
  44. * @param iTextEntry Entry of the text, stored in SD2-database, only type CHAT_TYPE_ZONE_YELL supported
  45. * @param uiCreatureEntry Id of the creature of whom saying will be simulated
  46. * @param pMap Given Map on which the map-wide text is displayed
  47. - * @param pCreatureSource Can be NULL. If pointer to Creature is given, then the creature does the map-wide text
  48. + * @param iZoneId Only sent to players within that zone. If a negative value is used it is sent to whole map
  49. * @param pTarget Can be NULL. Possible target for the text
  50. */
  51. -void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, Creature* pCreatureSource /*=NULL*/, Unit* pTarget /*=NULL*/)
  52. +void SimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, int32 iZoneId /*= -1*/, Unit* pTarget /*=NULL*/)
  53. {
  54. if (!pMap)
  55. {
  56. - error_log("SD2: DoOrSimulateScriptTextForMap entry %i, invalid Map pointer.", iTextEntry);
  57. + error_log("SD2: SimulateScriptTextForMap entry %i, invalid Map pointer.", iTextEntry);
  58. return;
  59. }
  60.  
  61. if (iTextEntry >= 0)
  62. {
  63. - 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);
  64. + 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);
  65. return;
  66. }
  67.  
  68. CreatureInfo const* pInfo = GetCreatureTemplateStore(uiCreatureEntry);
  69. if (!pInfo)
  70. {
  71. - error_log("SD2: DoOrSimulateScriptTextForMap has invalid source entry %u for map %u.", uiCreatureEntry, pMap->GetId());
  72. + error_log("SD2: SimulateScriptTextForMap has invalid source entry %u for map %u.", uiCreatureEntry, pMap->GetId());
  73. return;
  74. }
  75.  
  76. const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
  77. -
  78. if (!pData)
  79. {
  80. - error_log("SD2: DoOrSimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
  81. + error_log("SD2: SimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
  82. return;
  83. }
  84.  
  85. - debug_log("SD2: DoOrSimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
  86. + if (pData->uiType != CHAT_TYPE_ZONE_YELL)
  87. + {
  88. + error_log("SD2: SimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
  89. + return;
  90. + }
  91. +
  92. + debug_log("SD2: SimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
  93. iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);
  94.  
  95. if (pData->uiSoundId)
  96. {
  97. if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
  98. - pMap->PlayDirectSoundToMap(pData->uiSoundId);
  99. + pMap->PlayDirectSoundToMap(pData->uiSoundId, iZoneId);
  100. else
  101. - error_log("SD2: DoOrSimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
  102. + error_log("SD2: SimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
  103. }
  104.  
  105. - if (pData->uiType == CHAT_TYPE_ZONE_YELL)
  106. - {
  107. - if (pCreatureSource) // If provided pointer for sayer, use direct version
  108. - pMap->MonsterYellToMap(pCreatureSource->GetObjectGuid(), iTextEntry, pData->uiLanguage, pTarget);
  109. - else // Simulate yell
  110. - pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget);
  111. - }
  112. - else
  113. - error_log("SD2: DoSimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
  114. + pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget, iZoneId);
  115. }
  116.  
  117. //*********************************
  118. diff --git a/ScriptMgr.h b/ScriptMgr.h
  119. index 4ff4584..3775a51 100644
  120. --- a/ScriptMgr.h
  121. +++ b/ScriptMgr.h
  122. @@ -113,7 +113,7 @@ struct Script
  123.  
  124. // Generic scripting text function
  125. void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget = NULL);
  126. -void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, Creature* pCreatureSource = NULL, Unit* pTarget = NULL);
  127. +void SimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map* pMap, int32 iZoneId = -1, Unit* pTarget = NULL);
  128.  
  129. // *********************************************************
  130. // **************** Internal hook mechanics ****************
  131. diff --git a/include/sc_instance.h b/include/sc_instance.h
  132. index 36c9336..c04f474 100644
  133. --- a/include/sc_instance.h
  134. +++ b/include/sc_instance.h
  135. @@ -51,7 +51,10 @@ class MANGOS_DLL_DECL ScriptedInstance : public InstanceData
  136. void DoOrSimulateScriptTextForThisInstance(int32 iTextEntry, uint32 uiCreatureEntry)
  137. {
  138. // Prevent debug output in GetSingleCreatureFromStorage
  139. - DoOrSimulateScriptTextForMap(iTextEntry, uiCreatureEntry, instance, GetSingleCreatureFromStorage(uiCreatureEntry, true));
  140. + if (Creature* pCreatureSource = GetSingleCreatureFromStorage(uiCreatureEntry, true))
  141. + DoScriptText(iTextEntry, pCreatureSource);
  142. + else
  143. + SimulateScriptTextForMap(iTextEntry, uiCreatureEntry, instance);
  144. }
  145.  
  146. // Starts a timed achievement criteria for all players in instance
Add Comment
Please, Sign In to add comment