Guest User

Untitled

a guest
Jan 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. 94514e58064d0fde1189d6850a86e8d59b96b643
  2. diff --git a/src/game/Map.cpp b/src/game/Map.cpp
  3. index 6a4a5e1..b944a38 100644
  4. --- a/src/game/Map.cpp
  5. +++ b/src/game/Map.cpp
  6. @@ -3176,36 +3176,6 @@ class StaticMonsterChatBuilder
  7. Unit* i_target;
  8. };
  9.  
  10. -
  11. -/**
  12. - * Function simulates yell of creature
  13. - *
  14. - * @param guid must be creature guid of whom to Simulate the yell, non-creature guids not supported at this moment
  15. - * @param textId Id of the simulated text
  16. - * @param language language of the text
  17. - * @param target, can be NULL
  18. - */
  19. -void Map::MonsterYellToMap(ObjectGuid guid, int32 textId, uint32 language, Unit* target)
  20. -{
  21. - if (guid.IsAnyTypeCreature())
  22. - {
  23. - CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(guid.GetEntry());
  24. - if (!cInfo)
  25. - {
  26. - sLog.outError("Map::MonsterYellToMap: Called for nonexistent creature entry in guid: %s", guid.GetString().c_str());
  27. - return;
  28. - }
  29. -
  30. - MonsterYellToMap(cInfo, textId, language, target, guid.GetCounter());
  31. - }
  32. - else
  33. - {
  34. - sLog.outError("Map::MonsterYellToMap: Called for non creature guid: %s", guid.GetString().c_str());
  35. - return;
  36. - }
  37. -}
  38. -
  39. -
  40. /**
  41. * Function simulates yell of creature
  42. *
  43. @@ -3213,30 +3183,34 @@ void Map::MonsterYellToMap(ObjectGuid guid, int32 textId, uint32 language, Unit*
  44. * @param textId Id of the simulated text
  45. * @param language language of the text
  46. * @param target, can be NULL
  47. + * @param zoneId Only sent to players within that zone. If a negative value is used it is sent to whole map
  48. * @param senderLowGuid provide way proper show yell for near spawned creature with known lowguid,
  49. * 0 accepted by client else if this not important
  50. */
  51. -void Map::MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 language, Unit* target, uint32 senderLowGuid /*= 0*/)
  52. +void Map::MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 language, Unit* target, int32 zoneId /*= -1*/, uint32 senderLowGuid /*= 0*/)
  53. {
  54. StaticMonsterChatBuilder say_build(cinfo, CHAT_MSG_MONSTER_YELL, textId, language, target, senderLowGuid);
  55. MaNGOS::LocalizedPacketDo<StaticMonsterChatBuilder> say_do(say_build);
  56.  
  57. Map::PlayerList const& pList = GetPlayers();
  58. for (PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
  59. - say_do(itr->getSource());
  60. + if (zoneId < 0 || itr->getSource()->GetZoneId() == zoneId)
  61. + say_do(itr->getSource());
  62. }
  63.  
  64. /**
  65. * Function to play sound to all players in map
  66. *
  67. * @param soundId Played Sound
  68. + * @param zoneId Only sent to players within that zone. If a negative value is used it is sent to whole map
  69. */
  70. -void Map::PlayDirectSoundToMap(uint32 soundId)
  71. +void Map::PlayDirectSoundToMap(uint32 soundId, int32 zoneId /*= -1*/)
  72. {
  73. WorldPacket data(SMSG_PLAY_SOUND, 4);
  74. data << uint32(soundId);
  75.  
  76. Map::PlayerList const& pList = GetPlayers();
  77. for (PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
  78. - itr->getSource()->SendDirectMessage(&data);
  79. + if (zoneId < 0 || itr->getSource()->GetZoneId() == zoneId)
  80. + itr->getSource()->SendDirectMessage(&data);
  81. }
  82. diff --git a/src/game/Map.h b/src/game/Map.h
  83. index 31e8731..319000f 100644
  84. --- a/src/game/Map.h
  85. +++ b/src/game/Map.h
  86. @@ -255,9 +255,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
  87. InstanceData* GetInstanceData() { return i_data; }
  88. uint32 GetScriptId() const { return i_script_id; }
  89.  
  90. - void MonsterYellToMap(ObjectGuid guid, int32 textId, uint32 language, Unit* target);
  91. - void MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 language, Unit* target, uint32 senderLowGuid = 0);
  92. - void PlayDirectSoundToMap(uint32 soundId);
  93. + void MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 language, Unit* target, int32 zoneId = -1, uint32 senderLowGuid = 0);
  94. + void PlayDirectSoundToMap(uint32 soundId, int32 zoneId = -1);
  95.  
  96. private:
  97. void LoadMapAndVMap(int gx, int gy);
  98. diff --git a/src/game/Object.cpp b/src/game/Object.cpp
  99. index 77fde06..11e524a 100644
  100. --- a/src/game/Object.cpp
  101. +++ b/src/game/Object.cpp
  102. @@ -1419,16 +1419,14 @@ void WorldObject::MonsterYell(int32 textId, uint32 language, Unit* target)
  103. Cell::VisitWorldObjects(this, say_worker, range);
  104. }
  105.  
  106. -void WorldObject::MonsterYellToZone(int32 textId, uint32 language, Unit* target)
  107. +void WorldObject::MonsterYellToMap(int32 textId, uint32 language, Unit* target, int zoneId /*= -1*/)
  108. {
  109. MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, target);
  110. MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
  111.  
  112. - uint32 zoneid = GetZoneId();
  113. -
  114. Map::PlayerList const& pList = GetMap()->GetPlayers();
  115. - for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
  116. - if(itr->getSource()->GetZoneId()==zoneid)
  117. + for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
  118. + if (zoneId < 0 || itr->getSource()->GetZoneId() == zoneId)
  119. say_do(itr->getSource());
  120. }
  121.  
  122. diff --git a/src/game/Object.h b/src/game/Object.h
  123. index 000ebf8..e71cfc5 100644
  124. --- a/src/game/Object.h
  125. +++ b/src/game/Object.h
  126. @@ -540,7 +540,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
  127. void MonsterYell(int32 textId, uint32 language, Unit* target = NULL);
  128. void MonsterTextEmote(int32 textId, Unit* target, bool IsBossEmote = false);
  129. void MonsterWhisper(int32 textId, Unit* receiver, bool IsBossWhisper = false);
  130. - void MonsterYellToZone(int32 textId, uint32 language, Unit* target);
  131. + void MonsterYellToZone(int32 textId, uint32 language, Unit* target) { MonsterYellToMap(textId, language, target, GetZoneId()); }
  132. + void MonsterYellToMap(int32 textId, uint32 language, Unit* target, int zoneId = -1);
  133. static void BuildMonsterChat(WorldPacket *data, ObjectGuid senderGuid, uint8 msgtype, char const* text, uint32 language, char const* name, ObjectGuid targetGuid, char const* targetName);
  134.  
  135. void PlayDistanceSound(uint32 sound_id, Player* target = NULL);
Add Comment
Please, Sign In to add comment