diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 64d6a0986..3387685f7 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -424,7 +424,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->PlayDirectSound(action.sound.soundId); break; case ACTION_T_EMOTE: - m_creature->HandleEmoteCommand(action.emote.emoteId); + m_creature->HandleEmote(action.emote.emoteId); break; case ACTION_T_RANDOM_SOUND: { @@ -437,7 +437,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3); if (temp >= 0) - m_creature->HandleEmoteCommand(temp); + m_creature->HandleEmote(temp); break; } case ACTION_T_CAST: @@ -1314,7 +1314,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* { if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER) { - ((Unit*)pSource)->HandleEmoteCommand((*i).second.Emote); + ((Unit*)pSource)->HandleEmote((*i).second.Emote); } else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).",textEntry,pSource->GetTypeId()); diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 87fdfe468..462ae23c1 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -3659,7 +3659,11 @@ bool ChatHandler::HandleModifyStandStateCommand(const char* args) return false; uint32 anim_id = atoi((char*)args); - m_session->GetPlayer( )->SetUInt32Value( UNIT_NPC_EMOTESTATE , anim_id ); + + if (!sEmotesStore.LookupEntry(anim_id)) + return false; + + m_session->GetPlayer()->HandleEmoteState(anim_id); return true; } diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 6849e9ded..520251d7a 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3857,7 +3857,7 @@ bool ChatHandler::HandleNpcPlayEmoteCommand(const char* args) return false; } - target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); + target->HandleEmote(emote); return true; } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index d682a9bb9..4586ebc86 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2973,7 +2973,7 @@ void Map::ScriptsProcess() break; } - ((Creature *)source)->HandleEmoteCommand(step.script->datalong); + ((Creature *)source)->HandleEmote(step.script->datalong); break; case SCRIPT_COMMAND_FIELD_SET: if(!source) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 1fd0c16c9..f39b89837 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -854,7 +854,10 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry } if (!sEmotesStore.LookupEntry(addon->emote)) + { sLog.outErrorDb("Creature (%s %u) have invalid emote (%u) defined in `%s`.", entryName, addon->guidOrEntry, addon->emote, creatureaddons.GetTableName()); + const_cast(addon)->emote = 0; + } if (addon->splineFlags & (SPLINEFLAG_TRAJECTORY|SPLINEFLAG_UNKNOWN3)) { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 777b0d13b..981b40c55 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1744,6 +1744,24 @@ void Unit::HandleEmoteCommand(uint32 anim_id) SendMessageToSet(&data, true); } +void Unit::HandleEmoteState(uint32 anim_id) +{ + SetUInt32Value(UNIT_NPC_EMOTESTATE, anim_id); +} + +void Unit::HandleEmote(uint32 anim_id) +{ + if (!anim_id) + HandleEmoteState(0); + else if (EmotesEntry const* emoteEntry = sEmotesStore.LookupEntry(anim_id)) + { + if (emoteEntry->EmoteType) // 1,2 states, 0 command + HandleEmoteState(anim_id); + else + HandleEmoteCommand(anim_id); + } +} + uint32 Unit::CalcNotIgnoreAbsorbDamage( uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo /*= NULL*/) { float absorb_affected_rate = 1.0f; diff --git a/src/game/Unit.h b/src/game/Unit.h index b84329452..1b5a1b811 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1241,7 +1241,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL); void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage ); + void HandleEmote(uint32 anim_id); // auto-select command/state void HandleEmoteCommand(uint32 anim_id); + void HandleEmoteState(uint32 anim_id); void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false ); float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const; diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index c8d2a2fc7..54617565d 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -174,7 +174,7 @@ bool WaypointMovementGenerator::Update(Creature &creature, const uint3 if (WaypointBehavior *behavior = i_path->at(idx).behavior) { if (behavior->emote != 0) - creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, behavior->emote); + creature.HandleEmote(behavior->emote); if (behavior->spell != 0) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 61d3f9aba..cc68ce7ed 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9643" + #define REVISION_NR "9644" #endif // __REVISION_NR_H__