Jump to content

Spaces in BuildMonsterChat (used in MonsterTextEmote)


HiTmAn

Recommended Posts

Hi everybody!

I don't know if this is the right forum because it has to do with MaNGOS and ScriptDev2, I will post this here. Also if it's the wrong section, please move it ;)

I noticed that many boss encounter addons don't work and I researched in the lua scripts. The "problem" is plain easy:

MaNGOS adds a space after the name of the NPC doing the emote. e.g. "[big tied up Mob (I hope you know who I mean ;)] 's bonds begin to weaken!"

Here is what I've changed to remove the space...

diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 24ce65d..ac1f301 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1301,9 +1301,9 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const*
        *data << (uint32)1;                                 // target name length
        *data << (uint8)0;                                  // target name
    }
-    *data << (uint32)(strlen(text)+1+(pre?3:0));
+    *data << (uint32)(strlen(text)+1+(pre?2:0));
    if(pre)
-        data->append("%s ",3);
+        data->append("%s",2);
    *data << text;
    *data << (uint8)0;                                      // ChatTag
}

It works great if the emote is triggered by ScriptDev2's DoScriptText. If you use ".npc textemote begins to..." there's one space missing "[NPC]begins to..." but as we all know SD2 just use MaNGOS functions, so it cant be the problem.

I hope you understand what I mean and help fix this ;)

bye

HiTmAn

Link to comment
Share on other sites

I've posted this plenty of times...

Official does NOT prefix the creatures name in monster text emotes. There are some monster text emotes that do not even have their name in them.

All monster text emotes should be forced to use %s for their name if they would like to use it or simply leave that out if they do not.

Examples:

"%s runs away in fear!"

"The walls begin to crumble!"

The first would be displayed as "Ntsc runs away in fear!" while the second one should be displayed as "The walls begin to crumble!" with no name prefixed. This also allows users to do things like "%'s mana is low". I think there are a few emotes like this.

Link to comment
Share on other sites

  • 7 months later...

A fix for this: I just add a condition to not add a supplementary %s if it is in text emote. So you can correct text and keep compatibility with old emote ...

--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1478,7 +1478,7 @@ void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisp

void WorldObject::BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 targetGuid) const
{
-    bool pre = (msgtype==CHAT_MSG_MONSTER_EMOTE || msgtype==CHAT_MSG_RAID_BOSS_EMOTE);
+    bool pre = (msgtype==CHAT_MSG_MONSTER_EMOTE || msgtype==CHAT_MSG_RAID_BOSS_EMOTE) && !strstr(text,"%s");

    *data << (uint8)msgtype;
    *data << (uint32)language;

Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • 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