Implementing CAST_FAIL_NO_LOS EventAI
Tries to fix issue [85](https://www.getmangos.eu/issue.php?issueid=85)
This commit is contained in:
parent
28a9c59c89
commit
33749b7dbe
@ -57,6 +57,9 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell,
|
|||||||
if (pSpell->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
|
if (pSpell->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
|
||||||
{ return CAST_FAIL_STATE; }
|
{ return CAST_FAIL_STATE; }
|
||||||
|
|
||||||
|
if (!m_creature->IsWithinLOSInMap(pTarget))
|
||||||
|
{ return CAST_FAIL_NO_LOS; }
|
||||||
|
|
||||||
// Check for power (also done by Spell::CheckCast())
|
// Check for power (also done by Spell::CheckCast())
|
||||||
if (m_creature->GetPower((Powers)pSpell->powerType) < Spell::CalculatePowerCost(pSpell, m_creature))
|
if (m_creature->GetPower((Powers)pSpell->powerType) < Spell::CalculatePowerCost(pSpell, m_creature))
|
||||||
{ return CAST_FAIL_POWER; }
|
{ return CAST_FAIL_POWER; }
|
||||||
@ -145,10 +148,19 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals
|
|||||||
|
|
||||||
if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat
|
if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat
|
||||||
{
|
{
|
||||||
|
MotionMaster* creatureMotion = m_creature->GetMotionMaster();
|
||||||
if (enable)
|
if (enable)
|
||||||
{ m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); }
|
{
|
||||||
else if (!enable && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
m_creature->CastStop();
|
||||||
{ m_creature->StopMoving(); }
|
creatureMotion->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle);
|
||||||
|
}
|
||||||
|
else if (creatureMotion->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
||||||
|
{
|
||||||
|
creatureMotion->MovementExpired();
|
||||||
|
creatureMotion->Clear(false);
|
||||||
|
m_creature->StopMoving();
|
||||||
|
creatureMotion->MoveIdle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +172,8 @@ void CreatureAI::HandleMovementOnAttackStart(Unit* victim)
|
|||||||
// TODO - adapt this to only stop OOC-MMGens when MotionMaster rewrite is finished
|
// TODO - adapt this to only stop OOC-MMGens when MotionMaster rewrite is finished
|
||||||
else if (creatureMotion->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE || creatureMotion->GetCurrentMovementGeneratorType() == RANDOM_MOTION_TYPE)
|
else if (creatureMotion->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE || creatureMotion->GetCurrentMovementGeneratorType() == RANDOM_MOTION_TYPE)
|
||||||
{
|
{
|
||||||
creatureMotion->MoveIdle();
|
|
||||||
m_creature->StopMoving();
|
m_creature->StopMoving();
|
||||||
|
creatureMotion->MoveIdle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ enum CanCastResult
|
|||||||
CAST_FAIL_TOO_CLOSE = 4,
|
CAST_FAIL_TOO_CLOSE = 4,
|
||||||
CAST_FAIL_POWER = 5,
|
CAST_FAIL_POWER = 5,
|
||||||
CAST_FAIL_STATE = 6,
|
CAST_FAIL_STATE = 6,
|
||||||
CAST_FAIL_TARGET_AURA = 7
|
CAST_FAIL_TARGET_AURA = 7,
|
||||||
|
CAST_FAIL_NO_LOS = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CastFlags
|
enum CastFlags
|
||||||
|
@ -637,7 +637,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||||||
if (!target)
|
if (!target)
|
||||||
{
|
{
|
||||||
if (reportTargetError)
|
if (reportTargetError)
|
||||||
{ sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId); }
|
{ sLog.outErrorEventAI("NULL target for ACTION_T_CAST %s casting spell id %u", m_creature->GetGuidStr().c_str(), action.cast.spellId); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,30 +647,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||||||
{
|
{
|
||||||
case CAST_FAIL_POWER:
|
case CAST_FAIL_POWER:
|
||||||
case CAST_FAIL_TOO_FAR:
|
case CAST_FAIL_TOO_FAR:
|
||||||
|
case CAST_FAIL_NO_LOS:
|
||||||
{
|
{
|
||||||
// Melee current victim if flag not set
|
// Melee current victim if flag not set
|
||||||
if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM))
|
if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM))
|
||||||
{
|
{
|
||||||
switch (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType())
|
SetCombatMovement(true,true);
|
||||||
{
|
|
||||||
case CHASE_MOTION_TYPE:
|
|
||||||
case FOLLOW_MOTION_TYPE:
|
|
||||||
m_attackDistance = 0.0f;
|
|
||||||
m_attackAngle = 0.0f;
|
|
||||||
|
|
||||||
m_creature->GetMotionMaster()->Clear(false);
|
|
||||||
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_T_SUMMON: //12
|
case ACTION_T_SUMMON: //12
|
||||||
|
Loading…
x
Reference in New Issue
Block a user