Core/AI: Move ArcherAI to individual creature script
Port From (https://github.com/TrinityCore/TrinityCore/commit/caa4cfb5695deabd0bb9059f01435f3c8027aff7)
This commit is contained in:
@@ -23,8 +23,6 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
case "AggressorAI":
|
case "AggressorAI":
|
||||||
return new AggressorAI(creature);
|
return new AggressorAI(creature);
|
||||||
case "ArcherAI":
|
|
||||||
return new ArcherAI(creature);
|
|
||||||
case "CombatAI":
|
case "CombatAI":
|
||||||
return new CombatAI(creature);
|
return new CombatAI(creature);
|
||||||
case "CritterAI":
|
case "CritterAI":
|
||||||
|
|||||||
@@ -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
|
public class TurretAI : CreatureAI
|
||||||
{
|
{
|
||||||
float _minRange;
|
float _minRange;
|
||||||
|
|||||||
Reference in New Issue
Block a user