Core/SmartScripts: implement SMART_ACTION_PLAY_SPELL_VISUAL_KIT

Port From (https://github.com/TrinityCore/TrinityCore/commit/7d999b70a1640b5dbe3042f59463814f13cdc834)
This commit is contained in:
hondacrx
2019-09-05 12:01:18 -04:00
parent 588d7135b2
commit 981e1e04c1
6 changed files with 60 additions and 1 deletions
@@ -430,6 +430,16 @@ namespace Game.AI
return true;
}
bool IsSpellVisualKitValid(SmartScriptHolder e, uint entry)
{
if (!CliDB.SpellVisualKitStorage.ContainsKey(entry))
{
Log.outError(LogFilter.Sql, $"SmartAIMgr: Entry {e.entryOrGuid} SourceType {e.GetScriptType()} Event {e.event_id} Action {e.GetActionType()} uses non-existent SpellVisualKit entry {entry}, skipped.");
return false;
}
return true;
}
bool IsEventValid(SmartScriptHolder e)
{
if (e.Event.type >= SmartEvents.End)
@@ -862,6 +872,10 @@ namespace Game.AI
return false;
}
break;
case SmartActions.PlaySpellVisualKit:
if (e.Action.spellVisualKit.spellVisualKitId != 0 && !IsSpellVisualKitValid(e, e.Action.spellVisualKit.spellVisualKitId))
return false;
break;
case SmartActions.FailQuest:
case SmartActions.OfferQuest:
if (e.Action.quest.questId == 0 || !IsQuestValid(e, e.Action.quest.questId))
@@ -2344,6 +2358,9 @@ namespace Game.AI
[FieldOffset(4)]
public MovementSpeed movementSpeed;
[FieldOffset(4)]
public SpellVisualKit spellVisualKit;
[FieldOffset(4)]
public Raw raw;
@@ -2841,6 +2858,12 @@ namespace Game.AI
public uint speedInteger;
public uint speedFraction;
}
public struct SpellVisualKit
{
public uint spellVisualKitId;
public uint kitType;
public uint duration;
}
public struct Raw
{
public uint param1;
@@ -2640,6 +2640,23 @@ namespace Game.AI
break;
}
case SmartActions.PlaySpellVisualKit:
{
var targets = GetTargets(e, unit);
if (targets.Empty())
break;
foreach (var obj in targets)
{
if (IsUnit(obj))
{
obj.ToUnit().SendPlaySpellVisualKit(e.Action.spellVisualKit.spellVisualKitId, e.Action.spellVisualKit.kitType, e.Action.spellVisualKit.duration);
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript.ProcessAction:: SMART_ACTION_PLAY_SPELL_VISUAL_KIT: target: {obj.GetName()} ({obj.GetGUID().ToString()}), SpellVisualKit: {e.Action.spellVisualKit.spellVisualKitId}");
}
}
break;
}
default:
Log.outError(LogFilter.Sql, "SmartScript.ProcessAction: Entry {0} SourceType {1}, Event {2}, Unhandled Action type {3}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break;