Core/AI: Move ArcherAI to individual creature script

Port From (https://github.com/TrinityCore/TrinityCore/commit/caa4cfb5695deabd0bb9059f01435f3c8027aff7)
This commit is contained in:
hondacrx
2024-02-02 14:55:26 -05:00
parent 150b978ead
commit c9a11f3ead
2 changed files with 0 additions and 53 deletions
-2
View File
@@ -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":
-51
View File
@@ -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;