Permalink
Browse files

[12576] DB Scripts SCRIPT_COMMAND_EMOTE

Add support to display a random emote.
If dataint1..dataintX is set to an emote, a random out of datalong1, dataint1..dataintX will be sued as displayed emote.

Thanks to grz3s for testing
  • Loading branch information...
1 parent 5bc4891 commit 55dc3ddb27110d62a19aeacefcfb360e422e13c2 @Schmoozerd Schmoozerd committed with rsa Nov 5, 2013
Showing with 22 additions and 4 deletions.
  1. +1 −0 doc/script_commands.txt
  2. +19 −2 src/game/ScriptMgr.cpp
  3. +1 −1 src/game/ScriptMgr.h
  4. +1 −1 src/shared/revision_nr.h
View
@@ -154,6 +154,7 @@ Where "A -> B" means that the command is executed from A with B as target.
1 SCRIPT_COMMAND_EMOTE resultingSource = Unit, resultingTarget = Unit/none
* datalong = emote_id
+ * dataint1-dataint4 optionally, for random selection of emote
2 SCRIPT_COMMAND_FIELD_SET source = any
* datalong = field_id
View
@@ -263,7 +263,7 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
{
if (tmp.textId[i] && (tmp.textId[i] < MIN_DB_SCRIPT_STRING_ID || tmp.textId[i] >= MAX_DB_SCRIPT_STRING_ID))
{
- sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u", tablename, tmp.textId[i], MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, tmp.id);
+ sLog.outErrorDb("Table `%s` has out of range text_id%u (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u", tablename, i + 1, tmp.textId[i], MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, tmp.id);
continue;
}
}
@@ -278,6 +278,14 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
sLog.outErrorDb("Table `%s` has invalid emote id (datalong = %u) in SCRIPT_COMMAND_EMOTE for script id %u", tablename, tmp.emote.emoteId, tmp.id);
continue;
}
+ for (int i = 0; i < MAX_TEXT_ID; ++i)
+ {
+ if (tmp.textId[i] && !sEmotesStore.LookupEntry(tmp.textId[i]))
+ {
+ sLog.outErrorDb("Table `%s` has invalid emote id (text_id%u = %u) in SCRIPT_COMMAND_EMOTE for script id %u", tablename, i + 1, tmp.textId[i], tmp.id);
+ continue;
+ }
+ }
break;
}
case SCRIPT_COMMAND_FIELD_SET: // 2
@@ -1126,7 +1134,16 @@ bool ScriptAction::HandleScriptStep()
if (LogIfNotUnit(pSource))
break;
- ((Unit*)pSource)->HandleEmote(m_script->emote.emoteId);
+ std::vector<uint32> emotes;
+ emotes.push_back(m_script->emote.emoteId);
+ for (int i = 0; i < MAX_TEXT_ID; ++i)
+ {
+ if (!m_script->textId[i])
+ break;
+ emotes.push_back(uint32(m_script->textId[i]));
+ }
+
+ ((Unit*)pSource)->HandleEmote(emotes[urand(0, emotes.size() - 1)]);
break;
}
case SCRIPT_COMMAND_FIELD_SET: // 2
View
@@ -46,7 +46,7 @@ enum ScriptCommand // resSource, resTar
SCRIPT_COMMAND_TALK = 0, // resSource = WorldObject, resTarget = Unit/none
// dataint = text entry from db_script_string -table. dataint2-4 optional for random selected texts.
SCRIPT_COMMAND_EMOTE = 1, // resSource = Unit, resTarget = Unit/none
- // datalong1 = emote_id
+ // datalong1 = emote_id, dataint1-4 optional for random selected emotes
SCRIPT_COMMAND_FIELD_SET = 2, // source = any, datalong = field_id, datalong2 = value
SCRIPT_COMMAND_MOVE_TO = 3, // resSource = Creature, datalong2 = travel_speed*100, x/y/z
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: teleport unit to position
View
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "12575"
+ #define REVISION_NR "12576"
#endif // __REVISION_NR_H__

0 comments on commit 55dc3dd

Please sign in to comment.