Core/SAI: Add new action SMART_ACTION_SET_HEALTH_PCT
Port From (https://github.com/TrinityCore/TrinityCore/commit/4c30b2a1827b81774136d37cb521dbd5823c3423)
This commit is contained in:
@@ -396,6 +396,7 @@ namespace Framework.Constants
|
|||||||
OverrideWeather = 139, // zoneId, weatherId, intensity
|
OverrideWeather = 139, // zoneId, weatherId, intensity
|
||||||
SetAIAnimKit = 140, // DEPRECATED, DO REUSE (it was never used in any branch, treat as free action id)
|
SetAIAnimKit = 140, // DEPRECATED, DO REUSE (it was never used in any branch, treat as free action id)
|
||||||
SetHover = 141, // 0/1
|
SetHover = 141, // 0/1
|
||||||
|
SetHealthPct = 142, // percent
|
||||||
CreateConversation = 143, // conversation_template.id
|
CreateConversation = 143, // conversation_template.id
|
||||||
SetImmunePC = 144, // 0/1
|
SetImmunePC = 144, // 0/1
|
||||||
SetImmuneNPC = 145, // 0/1
|
SetImmuneNPC = 145, // 0/1
|
||||||
|
|||||||
@@ -1515,6 +1515,15 @@ namespace Game.AI
|
|||||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: Deprecated Event:({e}) skipped.");
|
Log.outError(LogFilter.Sql, $"SmartAIMgr: Deprecated Event:({e}) skipped.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SmartActions.SetHealthPct:
|
||||||
|
{
|
||||||
|
if (e.Action.setHealthPct.percent > 100 || e.Action.setHealthPct.percent == 0)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} is trying to set invalid HP percent {e.Action.setHealthPct.percent}, skipped.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SmartActions.CreateConversation:
|
case SmartActions.CreateConversation:
|
||||||
{
|
{
|
||||||
if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null)
|
if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null)
|
||||||
@@ -2666,6 +2675,9 @@ namespace Game.AI
|
|||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public Evade evade;
|
public Evade evade;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public SetHealthPct setHealthPct;
|
||||||
|
|
||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public Conversation conversation;
|
public Conversation conversation;
|
||||||
|
|
||||||
@@ -3218,6 +3230,10 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
public uint toRespawnPosition;
|
public uint toRespawnPosition;
|
||||||
}
|
}
|
||||||
|
public struct SetHealthPct
|
||||||
|
{
|
||||||
|
public uint percent;
|
||||||
|
}
|
||||||
public struct Conversation
|
public struct Conversation
|
||||||
{
|
{
|
||||||
public uint id;
|
public uint id;
|
||||||
|
|||||||
@@ -2403,6 +2403,17 @@ namespace Game.AI
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SmartActions.PlayCinematic:
|
||||||
|
{
|
||||||
|
foreach (var target in targets)
|
||||||
|
{
|
||||||
|
if (!IsPlayer(target))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
target.ToPlayer().SendCinematicStart(e.Action.cinematic.entry);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SmartActions.SetMovementSpeed:
|
case SmartActions.SetMovementSpeed:
|
||||||
{
|
{
|
||||||
uint speedInteger = e.Action.movementSpeed.speedInteger;
|
uint speedInteger = e.Action.movementSpeed.speedInteger;
|
||||||
@@ -2415,6 +2426,21 @@ namespace Game.AI
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SmartActions.PlaySpellVisualKit:
|
||||||
|
{
|
||||||
|
foreach (var target in targets)
|
||||||
|
{
|
||||||
|
if (IsUnit(target))
|
||||||
|
{
|
||||||
|
target.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: {target.GetName()} ({target.GetGUID()}), SpellVisualKit: {e.Action.spellVisualKit.spellVisualKitId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SmartActions.OverrideLight:
|
case SmartActions.OverrideLight:
|
||||||
{
|
{
|
||||||
WorldObject obj = GetBaseObject();
|
WorldObject obj = GetBaseObject();
|
||||||
@@ -2444,16 +2470,15 @@ namespace Game.AI
|
|||||||
target.ToUnit().SetHover(e.Action.setHover.enable != 0);
|
target.ToUnit().SetHover(e.Action.setHover.enable != 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SmartActions.PlaySpellVisualKit:
|
case SmartActions.SetHealthPct:
|
||||||
{
|
{
|
||||||
foreach (var target in targets)
|
foreach (var target in targets)
|
||||||
{
|
{
|
||||||
if (IsUnit(target))
|
Unit targetUnit = target.ToUnit();
|
||||||
{
|
if (targetUnit != null)
|
||||||
target.ToUnit().SendPlaySpellVisualKit(e.Action.spellVisualKit.spellVisualKitId, e.Action.spellVisualKit.kitType, e.Action.spellVisualKit.duration);
|
targetUnit.SetHealth(targetUnit.CountPctFromMaxHealth((int)e.Action.setHealthPct.percent));
|
||||||
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript.ProcessAction:: SMART_ACTION_PLAY_SPELL_VISUAL_KIT: target: {target.GetName()} ({target.GetGUID()}), SpellVisualKit: {e.Action.spellVisualKit.spellVisualKitId}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SmartActions.CreateConversation:
|
case SmartActions.CreateConversation:
|
||||||
@@ -2474,17 +2499,6 @@ namespace Game.AI
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SmartActions.PlayCinematic:
|
|
||||||
{
|
|
||||||
foreach (WorldObject target in targets)
|
|
||||||
{
|
|
||||||
if (!IsPlayer(target))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
target.ToPlayer().SendCinematicStart(e.Action.cinematic.entry);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SmartActions.AddToStoredTargetList:
|
case SmartActions.AddToStoredTargetList:
|
||||||
{
|
{
|
||||||
if (!targets.Empty())
|
if (!targets.Empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user