Core/SAI: implement SMART_EVENT_SUMMONED_UNIT_DIES (82), useable by creatures and gameobjects

Port From (https://github.com/TrinityCore/TrinityCore/commit/d4a1a7a040be0ca0d6428669135bcc64d92be1c2)
This commit is contained in:
hondacrx
2022-02-27 13:57:18 -05:00
parent c4fa1a27ea
commit 1b28a8260c
4 changed files with 16 additions and 11 deletions
+2 -5
View File
@@ -244,12 +244,9 @@ namespace Framework.Constants
SceneTrigger = 79, // param_string : triggerName SceneTrigger = 79, // param_string : triggerName
SceneCancel = 80, // none SceneCancel = 80, // none
SceneComplete = 81, // none SceneComplete = 81, // none
SummonedUnitDies = 82, // CreatureId(0 all), CooldownMin, CooldownMax
//New End = 83
SpellEffectHit = 82,
SpellEffectHitTarget = 83,
End = 84
} }
public enum SmartActions public enum SmartActions
+10
View File
@@ -641,6 +641,11 @@ namespace Game.AI
GetScript().ProcessEventsFor(SmartEvents.SummonedUnit, summon); GetScript().ProcessEventsFor(SmartEvents.SummonedUnit, summon);
} }
public override void SummonedCreatureDies(Creature summon, Unit killer)
{
GetScript().ProcessEventsFor(SmartEvents.SummonedUnitDies, summon);
}
public override void AttackStart(Unit who) public override void AttackStart(Unit who)
{ {
// dont allow charmed npcs to act on their own // dont allow charmed npcs to act on their own
@@ -1199,6 +1204,11 @@ namespace Game.AI
GetScript().ProcessEventsFor(SmartEvents.SummonedUnit, creature); GetScript().ProcessEventsFor(SmartEvents.SummonedUnit, creature);
} }
public override void SummonedCreatureDies(Creature summon, Unit killer)
{
GetScript().ProcessEventsFor(SmartEvents.SummonedUnitDies, summon);
}
public override void SummonedCreatureDespawn(Creature unit) public override void SummonedCreatureDespawn(Creature unit)
{ {
GetScript().ProcessEventsFor(SmartEvents.SummonDespawned, unit, unit.GetEntry()); GetScript().ProcessEventsFor(SmartEvents.SummonDespawned, unit, unit.GetEntry());
@@ -383,6 +383,7 @@ namespace Game.AI
case SmartEvents.Death: case SmartEvents.Death:
case SmartEvents.Kill: case SmartEvents.Kill:
case SmartEvents.SummonedUnit: case SmartEvents.SummonedUnit:
case SmartEvents.SummonedUnitDies:
case SmartEvents.SpellHit: case SmartEvents.SpellHit:
case SmartEvents.SpellHitTarget: case SmartEvents.SpellHitTarget:
case SmartEvents.Damaged: case SmartEvents.Damaged:
@@ -679,6 +680,7 @@ namespace Game.AI
break; break;
case SmartEvents.SummonDespawned: case SmartEvents.SummonDespawned:
case SmartEvents.SummonedUnit: case SmartEvents.SummonedUnit:
case SmartEvents.SummonedUnitDies:
if (e.Event.summoned.creature != 0 && !IsCreatureValid(e, e.Event.summoned.creature)) if (e.Event.summoned.creature != 0 && !IsCreatureValid(e, e.Event.summoned.creature))
return false; return false;
@@ -932,7 +934,6 @@ namespace Game.AI
case SmartEvents.SceneCancel: case SmartEvents.SceneCancel:
case SmartEvents.SceneComplete: case SmartEvents.SceneComplete:
case SmartEvents.SceneTrigger: case SmartEvents.SceneTrigger:
case SmartEvents.SpellEffectHit:
break; break;
default: default:
Log.outError(LogFilter.ScriptsAi, "SmartAIMgr: Not handled event_type({0}), Entry {1} SourceType {2} Event {3} Action {4}, skipped.", e.GetEventType(), e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType()); Log.outError(LogFilter.ScriptsAi, "SmartAIMgr: Not handled event_type({0}), Entry {1} SourceType {2} Event {3} Action {4}, skipped.", e.GetEventType(), e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType());
@@ -1892,8 +1893,7 @@ namespace Game.AI
SmartEvents.SceneTrigger => SmartScriptTypeMaskId.Scene, SmartEvents.SceneTrigger => SmartScriptTypeMaskId.Scene,
SmartEvents.SceneCancel => SmartScriptTypeMaskId.Scene, SmartEvents.SceneCancel => SmartScriptTypeMaskId.Scene,
SmartEvents.SceneComplete => SmartScriptTypeMaskId.Scene, SmartEvents.SceneComplete => SmartScriptTypeMaskId.Scene,
SmartEvents.SpellEffectHit => SmartScriptTypeMaskId.Spell, SmartEvents.SummonedUnitDies => SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject,
SmartEvents.SpellEffectHitTarget => SmartScriptTypeMaskId.Spell,
_ => 0, _ => 0,
}; };
} }
+1 -3
View File
@@ -3423,6 +3423,7 @@ namespace Game.AI
break; break;
} }
case SmartEvents.SummonedUnit: case SmartEvents.SummonedUnit:
case SmartEvents.SummonedUnitDies:
{ {
if (!IsCreature(unit)) if (!IsCreature(unit))
return; return;
@@ -3711,9 +3712,6 @@ namespace Game.AI
ProcessAction(e, unit, var0, 0, false, null, null, varString); ProcessAction(e, unit, var0, 0, false, null, null, varString);
break; break;
} }
case SmartEvents.SpellEffectHit:
ProcessAction(e, unit, var0);
break;
default: default:
Log.outError(LogFilter.Sql, "SmartScript.ProcessEvent: Unhandled Event type {0}", e.GetEventType()); Log.outError(LogFilter.Sql, "SmartScript.ProcessEvent: Unhandled Event type {0}", e.GetEventType());
break; break;