Skip to content

Commit

Permalink
Fix dynamic movement behavior
Browse files Browse the repository at this point in the history
This will stop breaking waypoint movement when creatures cast spells on respawn using eventAI or SD2.

Also add missing spell attirbute check LoS check.

Close cmangos/issues#908

Thanks to @Grz3s and @boxa for the info
  • Loading branch information
xfurry committed Jun 6, 2016
1 parent 8a1974f commit 45591de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/game/CreatureAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell,
if (m_creature->GetPower((Powers)pSpell->powerType) < Spell::CalculatePowerCost(pSpell, m_creature))
return CAST_FAIL_POWER;

if (!m_creature->IsWithinLOSInMap(pTarget) && m_creature != pTarget)
if (!pSpell->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !m_creature->IsWithinLOSInMap(pTarget) && m_creature != pTarget)
return CAST_FAIL_NOT_IN_LOS;
}

Expand Down Expand Up @@ -113,8 +113,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
if (uiCastFlags & CAST_INTERRUPT_PREVIOUS && pCaster->IsNonMeleeSpellCasted(false))
pCaster->InterruptNonMeleeSpells(false);

// Creature should always stop before it will cast a new spell
pCaster->StopMoving();
// Creature should always stop before it will cast a new spell (logic applies to combat movement only)
if (pCaster->isInCombat())
pCaster->StopMoving();

pCaster->CastSpell(pTarget, pSpell, !!(uiCastFlags & CAST_TRIGGERED), nullptr, nullptr, uiOriginalCasterGUID);
return CAST_OK;
Expand Down

0 comments on commit 45591de

Please sign in to comment.