From c9a11f3eadaf9f9f5bf5395a1263fcb51610a0d0 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 2 Feb 2024 14:55:26 -0500 Subject: [PATCH] Core/AI: Move ArcherAI to individual creature script Port From (https://github.com/TrinityCore/TrinityCore/commit/caa4cfb5695deabd0bb9059f01435f3c8027aff7) --- Source/Game/AI/AISelector.cs | 2 -- Source/Game/AI/CoreAI/CombatAI.cs | 51 ------------------------------- 2 files changed, 53 deletions(-) diff --git a/Source/Game/AI/AISelector.cs b/Source/Game/AI/AISelector.cs index 140c63470..95025b123 100644 --- a/Source/Game/AI/AISelector.cs +++ b/Source/Game/AI/AISelector.cs @@ -23,8 +23,6 @@ namespace Game.AI { case "AggressorAI": return new AggressorAI(creature); - case "ArcherAI": - return new ArcherAI(creature); case "CombatAI": return new CombatAI(creature); case "CritterAI": diff --git a/Source/Game/AI/CoreAI/CombatAI.cs b/Source/Game/AI/CoreAI/CombatAI.cs index 70a9f4ab1..581159b24 100644 --- a/Source/Game/AI/CoreAI/CombatAI.cs +++ b/Source/Game/AI/CoreAI/CombatAI.cs @@ -180,57 +180,6 @@ namespace Game.AI } } - public class ArcherAI : CreatureAI - { - float _minRange; - - public ArcherAI(Creature creature) : base(creature) - { - if (creature.m_spells[0] == 0) - Log.outError(LogFilter.ScriptsAi, $"ArcherAI set for creature with spell1=0. AI will do nothing ({me.GetGUID()})"); - - var spellInfo = Global.SpellMgr.GetSpellInfo(creature.m_spells[0], creature.GetMap().GetDifficultyID()); - _minRange = spellInfo != null ? spellInfo.GetMinRange(false) : 0; - - if (_minRange == 0) - _minRange = SharedConst.MeleeRange; - - creature.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0; - creature.m_SightDistance = creature.m_CombatDistance; - } - - public override void AttackStart(Unit who) - { - if (who == null) - return; - - if (me.IsWithinCombatRange(who, _minRange)) - { - if (me.Attack(who, true) && !who.IsFlying()) - me.GetMotionMaster().MoveChase(who); - } - else - { - if (me.Attack(who, false) && !who.IsFlying()) - me.GetMotionMaster().MoveChase(who, me.m_CombatDistance); - } - - if (who.IsFlying()) - me.GetMotionMaster().MoveIdle(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (!me.IsWithinCombatRange(me.GetVictim(), _minRange)) - DoSpellAttackIfReady(me.m_spells[0]); - else - DoMeleeAttackIfReady(); - } - } - public class TurretAI : CreatureAI { float _minRange;