diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 664cf4aed2..ea7660f1cb 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2511,6 +2511,38 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ENSURE_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0); break; } + case SMART_ACTION_PLAY_ANIMKIT: + { + ObjectList* targets = GetTargets(e, unit); + if (!targets) + break; + + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) + { + if (IsCreature(*itr)) + { + if (e.action.animKit.type == 0) + (*itr)->ToCreature()->PlayOneShotAnimKitId(e.action.animKit.animKit); + else if (e.action.animKit.type == 1) + (*itr)->ToCreature()->SetAIAnimKitId(e.action.animKit.animKit); + else if (e.action.animKit.type == 2) + (*itr)->ToCreature()->SetMeleeAnimKitId(e.action.animKit.animKit); + else if (e.action.animKit.type == 3) + (*itr)->ToCreature()->SetMovementAnimKitId(e.action.animKit.animKit); + else + { + TC_LOG_ERROR("sql.sql", "SmartScript: Invalid type for SMART_ACTION_PLAY_ANIMKIT, skipping"); + break; + } + + TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_ANIMKIT: target: %s (%s), AnimKit: %u, Type: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), e.action.animKit.animKit, e.action.animKit.type); + } + } + + delete targets; + break; + } case SMART_ACTION_REMOVE_AURAS_BY_TYPE: // can be used to exit vehicle for example { ObjectList* targets = GetTargets(e, unit); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 7ef9459d77..1e1b17bfc2 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -853,6 +853,16 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) if (!IsEmoteValid(e, e.action.emote.emote)) return false; break; + case SMART_ACTION_PLAY_ANIMKIT: + if (!IsAnimKitValid(e, e.action.animKit.animKit)) + return false; + + if (e.action.animKit.type > 3) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid AnimKit type %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.animKit.type); + return false; + } + break; case SMART_ACTION_FAIL_QUEST: case SMART_ACTION_OFFER_QUEST: if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest)) diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 3ebcd75903..b7c2ba5c8e 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -584,8 +584,9 @@ enum SMART_ACTION SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT = 125, // id min range, id max range SMART_ACTION_REMOVE_ALL_GAMEOBJECTS = 126, SMART_ACTION_STOP_MOTION = 127, // stopMoving, movementExpired + SMART_ACTION_PLAY_ANIMKIT = 128, // id, type (0 = oneShot, 1 = aiAnim, 2 = meleeAnim, 3 = movementAnim) - SMART_ACTION_END = 128 + SMART_ACTION_END = 129 }; struct SmartAction @@ -1117,6 +1118,12 @@ struct SmartAction uint32 disable; } disableEvade; + struct + { + uint32 animKit; + uint32 type; + } animKit; + struct { uint32 type; @@ -1775,6 +1782,16 @@ class TC_GAME_API SmartAIMgr return true; } + bool IsAnimKitValid(SmartScriptHolder const& e, uint32 entry) + { + if (!sAnimKitStore.LookupEntry(entry)) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent AnimKit entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry); + return false; + } + return true; + } + bool IsTextValid(SmartScriptHolder const& e, uint32 id); // Helpers