mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Core/AI: Fix a crash in UnitAI
This commit is contained in:
@@ -42,22 +42,26 @@ void UnitAI::DoMeleeAttackIfReady()
|
|||||||
if (me->HasUnitState(UNIT_STAT_CASTING))
|
if (me->HasUnitState(UNIT_STAT_CASTING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Unit *victim = me->getVictim();
|
||||||
|
if (!victim || !victim->IsInWorld())
|
||||||
|
return;
|
||||||
|
|
||||||
//Make sure our attack is ready and we aren't currently casting before checking distance
|
//Make sure our attack is ready and we aren't currently casting before checking distance
|
||||||
if (me->isAttackReady())
|
if (me->isAttackReady())
|
||||||
{
|
{
|
||||||
//If we are within range melee the target
|
//If we are within range melee the target
|
||||||
if (me->IsWithinMeleeRange(me->getVictim()))
|
if (me->IsWithinMeleeRange(victim))
|
||||||
{
|
{
|
||||||
me->AttackerStateUpdate(me->getVictim());
|
me->AttackerStateUpdate(victim);
|
||||||
me->resetAttackTimer();
|
me->resetAttackTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
|
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
|
||||||
{
|
{
|
||||||
//If we are within range melee the target
|
//If we are within range melee the target
|
||||||
if (me->IsWithinMeleeRange(me->getVictim()))
|
if (me->IsWithinMeleeRange(victim))
|
||||||
{
|
{
|
||||||
me->AttackerStateUpdate(me->getVictim(), OFF_ATTACK);
|
me->AttackerStateUpdate(victim, OFF_ATTACK);
|
||||||
me->resetAttackTimer(OFF_ATTACK);
|
me->resetAttackTimer(OFF_ATTACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user