Core/AI: CreatureAI.EnterCombat is now called CreatureAI.JustEngagedWith. There's also two new methods on UnitAI, though they're never invoked right now.

Port From (https://github.com/TrinityCore/TrinityCore/commit/bce43de7f3fba618c370f2aba327d23dd30d1cdd)
This commit is contained in:
hondacrx
2021-04-19 10:22:43 -04:00
parent d0faa12ef6
commit c925d7af40
12 changed files with 41 additions and 39 deletions
+2 -2
View File
@@ -51,7 +51,7 @@ namespace Game.AI
} }
} }
public override void EnterCombat(Unit victim) public override void JustEngagedWith(Unit victim)
{ {
foreach (var id in Spells) foreach (var id in Spells)
{ {
@@ -134,7 +134,7 @@ namespace Game.AI
AttackStartCaster(victim, _attackDist); AttackStartCaster(victim, _attackDist);
} }
public override void EnterCombat(Unit victim) public override void JustEngagedWith(Unit victim)
{ {
if (Spells.Empty()) if (Spells.Empty())
return; return;
+2 -5
View File
@@ -408,11 +408,8 @@ namespace Game.AI
me.DoImmediateBoundaryCheck(); me.DoImmediateBoundaryCheck();
} }
/// <summary> // Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
/// Called for reaction when initially engaged public virtual void JustEngagedWith(Unit who) { }
/// </summary>
/// <param name="victim"></param>
public virtual void EnterCombat(Unit victim) { }
// Called when the creature is killed // Called when the creature is killed
public virtual void JustDied(Unit killer) { } public virtual void JustDied(Unit killer) { }
+7
View File
@@ -478,6 +478,13 @@ namespace Game.AI
public virtual void SetGUID(ObjectGuid guid, int id = 0) { } public virtual void SetGUID(ObjectGuid guid, int id = 0) { }
public virtual ObjectGuid GetGUID(int id = 0) { return ObjectGuid.Empty; } public virtual ObjectGuid GetGUID(int id = 0) { return ObjectGuid.Empty; }
// Called when the unit enters combat
// (NOTE: Creature engage logic should NOT be here, but in JustEngagedWith, which happens once threat is established!)
public virtual void JustEnteredCombat(Unit who) { }
// Called when the unit leaves combat
public virtual void JustExitedCombat() { }
public virtual void DamageDealt(Unit victim, ref uint damage, DamageEffectType damageType) { } public virtual void DamageDealt(Unit victim, ref uint damage, DamageEffectType damageType) { }
public virtual void DamageTaken(Unit attacker, ref uint damage) { } public virtual void DamageTaken(Unit attacker, ref uint damage) { }
public virtual void HealReceived(Unit by, uint addhealth) { } public virtual void HealReceived(Unit by, uint addhealth) { }
+6 -6
View File
@@ -48,7 +48,7 @@ namespace Game.AI
DoStartNoMovement(target); DoStartNoMovement(target);
} }
// Called before EnterCombat even before the creature is in combat. // Called before JustEngagedWith even before the creature is in combat.
public override void AttackStart(Unit target) public override void AttackStart(Unit target)
{ {
if (IsCombatMovementAllowed()) if (IsCombatMovementAllowed())
@@ -411,7 +411,7 @@ namespace Game.AI
public override void Reset() { } public override void Reset() { }
//Called at creature aggro either by MoveInLOS or Attack Start //Called at creature aggro either by MoveInLOS or Attack Start
public override void EnterCombat(Unit victim) { } public override void JustEngagedWith(Unit victim) { }
public bool HealthBelowPct(int pct) { return me.HealthBelowPct(pct); } public bool HealthBelowPct(int pct) { return me.HealthBelowPct(pct); }
public bool HealthAbovePct(int pct) { return me.HealthAbovePct(pct); } public bool HealthAbovePct(int pct) { return me.HealthAbovePct(pct); }
@@ -502,7 +502,7 @@ namespace Game.AI
instance.SetBossState(_bossId, EncounterState.Done); instance.SetBossState(_bossId, EncounterState.Done);
} }
public void _EnterCombat() public void _JustEngagedWith()
{ {
if (instance != null) if (instance != null)
{ {
@@ -602,7 +602,7 @@ namespace Game.AI
public virtual void ScheduleTasks() { } public virtual void ScheduleTasks() { }
public override void Reset() { _Reset(); } public override void Reset() { _Reset(); }
public override void EnterCombat(Unit who) { _EnterCombat(); } public override void JustEngagedWith(Unit who) { _JustEngagedWith(); }
public override void JustDied(Unit killer) { _JustDied(); } public override void JustDied(Unit killer) { _JustDied(); }
public override void JustReachedHome() { _JustReachedHome(); } public override void JustReachedHome() { _JustReachedHome(); }
@@ -635,7 +635,7 @@ namespace Game.AI
summons.DespawnAll(); summons.DespawnAll();
} }
void _EnterCombat() void _JustEngagedWith()
{ {
Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true);
if (target) if (target)
@@ -684,7 +684,7 @@ namespace Game.AI
public override void Reset() { _Reset(); } public override void Reset() { _Reset(); }
public override void EnterCombat(Unit who) { _EnterCombat(); } public override void JustEngagedWith(Unit who) { _JustEngagedWith(); }
public override void JustDied(Unit killer) { _JustDied(); } public override void JustDied(Unit killer) { _JustDied(); }
} }
+1 -1
View File
@@ -609,7 +609,7 @@ namespace Game.AI
me.GetMotionMaster().MoveIdle(); // wait the order of leader me.GetMotionMaster().MoveIdle(); // wait the order of leader
} }
public override void EnterCombat(Unit victim) public override void JustEngagedWith(Unit victim)
{ {
if (IsAIControlled()) if (IsAIControlled())
me.InterruptNonMeleeSpells(false); // must be before ProcessEvents me.InterruptNonMeleeSpells(false); // must be before ProcessEvents
+1 -1
View File
@@ -1443,7 +1443,7 @@ namespace Game.Entities
if (enemy != null) if (enemy != null)
{ {
if (IsAIEnabled) if (IsAIEnabled)
creature.GetAI().EnterCombat(enemy); creature.GetAI().JustEngagedWith(enemy);
if (creature.GetFormation() != null) if (creature.GetFormation() != null)
creature.GetFormation().MemberEngagingTarget(creature, enemy); creature.GetFormation().MemberEngagingTarget(creature, enemy);
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Scripts.Pets
me.GetMotionMaster().MoveFollow(owner, 0.0f, 0.0f); me.GetMotionMaster().MoveFollow(owner, 0.0f, 0.0f);
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void UpdateAI(uint diff) { } public override void UpdateAI(uint diff) { }
+1 -1
View File
@@ -43,7 +43,7 @@ namespace Scripts.Pets
{ {
public npc_pet_hunter_snake_trap(Creature creature) : base(creature) { } public npc_pet_hunter_snake_trap(Creature creature) : base(creature) { }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void Reset() public override void Reset()
{ {
+1 -1
View File
@@ -151,7 +151,7 @@ namespace Scripts.Pets
owner.CastSpell(me, SpellIds.CloneMe, false); owner.CastSpell(me, SpellIds.CloneMe, false);
} }
public override void EnterCombat(Unit victim) public override void JustEngagedWith(Unit victim)
{ {
if (me.GetVictim() && !me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) if (me.GetVictim() && !me.GetVictim().HasBreakableByDamageCrowdControlAura(me))
{ {
+8 -8
View File
@@ -231,10 +231,10 @@ namespace Scripts.World.EmeraldDragons
}); });
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who)
{ {
Talk(TextIds.SayYsondreAggro); Talk(TextIds.SayYsondreAggro);
base.EnterCombat(who); base.JustEngagedWith(who);
} }
// Summon druid spirits on 75%, 50% and 25% health // Summon druid spirits on 75%, 50% and 25% health
@@ -278,10 +278,10 @@ namespace Scripts.World.EmeraldDragons
}); });
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who)
{ {
Talk(TextIds.SayLethonAggro); Talk(TextIds.SayLethonAggro);
base.EnterCombat(who); base.JustEngagedWith(who);
} }
public override void DamageTaken(Unit attacker, ref uint damage) public override void DamageTaken(Unit attacker, ref uint damage)
@@ -361,10 +361,10 @@ namespace Scripts.World.EmeraldDragons
base.KilledUnit(who); base.KilledUnit(who);
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who)
{ {
Talk(TextIds.SayEmerissAggro); Talk(TextIds.SayEmerissAggro);
base.EnterCombat(who); base.JustEngagedWith(who);
} }
public override void DamageTaken(Unit attacker, ref uint damage) public override void DamageTaken(Unit attacker, ref uint damage)
@@ -419,10 +419,10 @@ namespace Scripts.World.EmeraldDragons
}); });
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who)
{ {
Talk(TextIds.SayTaerarAggro); Talk(TextIds.SayTaerarAggro);
base.EnterCombat(who); base.JustEngagedWith(who);
} }
public override void SummonedCreatureDies(Creature summon, Unit killer) public override void SummonedCreatureDies(Creature summon, Unit killer)
+2 -2
View File
@@ -118,7 +118,7 @@ namespace Scripts.World.NpcGuard
DoReplyToTextEmote(textEmote); DoReplyToTextEmote(textEmote);
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who)
{ {
if (me.GetEntry() == CreatureIds.CenarionHoldInfantry) if (me.GetEntry() == CreatureIds.CenarionHoldInfantry)
Talk(TextIds.SayGuardSilAggro, who); Talk(TextIds.SayGuardSilAggro, who);
@@ -202,7 +202,7 @@ namespace Scripts.World.NpcGuard
_scheduler.CancelAll(); _scheduler.CancelAll();
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who)
{ {
ScheduleVanish(); ScheduleVanish();
} }
+9 -11
View File
@@ -619,7 +619,7 @@ namespace Scripts.World.NpcSpecial
me.RemoveNpcFlag(NPCFlags.QuestGiver); me.RemoveNpcFlag(NPCFlags.QuestGiver);
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
@@ -719,7 +719,7 @@ namespace Scripts.World.NpcSpecial
} }
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void ReceiveEmote(Player player, TextEmotes emote) public override void ReceiveEmote(Player player, TextEmotes emote)
{ {
@@ -1038,7 +1038,7 @@ namespace Scripts.World.NpcSpecial
} }
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void QuestAccept(Player player, Quest quest) public override void QuestAccept(Player player, Quest quest)
{ {
@@ -1108,7 +1108,7 @@ namespace Scripts.World.NpcSpecial
} }
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void SpellHit(Unit caster, SpellInfo spell) public override void SpellHit(Unit caster, SpellInfo spell)
{ {
@@ -1230,7 +1230,7 @@ namespace Scripts.World.NpcSpecial
me.SetHealth(me.CountPctFromMaxHealth(70)); me.SetHealth(me.CountPctFromMaxHealth(70));
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void SpellHit(Unit caster, SpellInfo spell) public override void SpellHit(Unit caster, SpellInfo spell)
{ {
@@ -1319,9 +1319,7 @@ namespace Scripts.World.NpcSpecial
me.AddUnitFlag(UnitFlags.NonAttackable); me.AddUnitFlag(UnitFlags.NonAttackable);
} }
public override void EnterCombat(Unit who) public override void JustEngagedWith(Unit who) { }
{
}
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
@@ -1463,7 +1461,7 @@ namespace Scripts.World.NpcSpecial
public npc_steam_tonk(Creature creature) : base(creature) { } public npc_steam_tonk(Creature creature) : base(creature) { }
public override void Reset() { } public override void Reset() { }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void OnPossess(bool apply) public override void OnPossess(bool apply)
{ {
@@ -1501,7 +1499,7 @@ namespace Scripts.World.NpcSpecial
Initialize(); Initialize();
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void AttackStart(Unit who) { } public override void AttackStart(Unit who) { }
public override void MoveInLineOfSight(Unit who) { } public override void MoveInLineOfSight(Unit who) { }
@@ -1966,7 +1964,7 @@ namespace Scripts.World.NpcSpecial
me.GetMotionMaster().MoveFollow(owner, SharedConst.PetFollowDist, SharedConst.PetFollowAngle); me.GetMotionMaster().MoveFollow(owner, SharedConst.PetFollowDist, SharedConst.PetFollowAngle);
} }
public override void EnterCombat(Unit who) { } public override void JustEngagedWith(Unit who) { }
public override void DoAction(int param) public override void DoAction(int param)
{ {