Skip to content

Commit

Permalink
A simple combat movement scheme of silenced mob-caster
Browse files Browse the repository at this point in the history
  • Loading branch information
Olion17 authored and billy1arm committed Aug 21, 2017
1 parent 37ae1f2 commit 22da350
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/game/Object/CreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ enum CombatMovementFlags
COMBAT_MOVEMENT_SCRIPT = 0x01, // Combat movement enforced by script
COMBAT_MOVEMENT_LOS = 0x02, // Combat movement triggered by LoS issues
COMBAT_MOVEMENT_OOM = 0x04, // Combat movement triggered by power exhaustion
COMBAT_MOVEMENT_DISTANCE = 0x08 // Combat movement triggered by distance checks
COMBAT_MOVEMENT_DISTANCE = 0x08, // Combat movement triggered by distance checks
COMBAT_MOVEMENT_SILENCE = 0x10 // Combat movement of a caster while silenced
};

enum AIEventType
Expand Down Expand Up @@ -318,7 +319,7 @@ class CreatureAI
CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, ObjectGuid OriginalCasterGuid = ObjectGuid());

/// Combat movement functions
void SetCombatMovement(bool enable, bool stopOrStartMovement = false);
void SetCombatMovement(bool enable, bool stopOrStartMovement = true);
bool IsCombatMovement() const { return m_combatMovement != 0; }
void AddCombatMovementFlags(uint32 cmFlags);
void ClearCombatMovementFlags(uint32 cmFlags);
Expand Down
15 changes: 10 additions & 5 deletions src/game/Object/CreatureEventAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case CAST_FAIL_NO_LOS:
cmFlags |= COMBAT_MOVEMENT_LOS;
break;
case CAST_FAIL_STATE:
cmFlags |= COMBAT_MOVEMENT_SILENCE;
break;
default:
break;
}
Expand All @@ -690,18 +693,20 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM))
{
AddCombatMovementFlags(cmFlags);
SetCombatMovement(true,true);
SetCombatMovement(true, true);
}
}
else
{
if (m_combatMovement & (COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM))
if (m_combatMovement & (COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM | COMBAT_MOVEMENT_SILENCE))
{
ClearCombatMovementFlags(COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM);
bool silenceOff = m_combatMovement & COMBAT_MOVEMENT_SILENCE;
ClearCombatMovementFlags(COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM | COMBAT_MOVEMENT_SILENCE);

if (!IsCombatMovement() && m_creature->IsNonMeleeSpellCasted(false) && m_creature->IsInCombat() && m_creature->getVictim())
if (m_creature->IsInCombat() && m_creature->getVictim() &&
(silenceOff || (!IsCombatMovement() && m_creature->IsNonMeleeSpellCasted(false))))
{
SetCombatMovement(false,true);
SetCombatMovement(true, true); // resetting the same chase movegen
m_creature->SendMeleeAttackStop(m_creature->getVictim());
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/game/WorldHandlers/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4857,6 +4857,14 @@ void Spell::EffectInterruptCast(SpellEffectIndex /*eff_idx*/)
{
unitTarget->ProhibitSpellSchool(GetSpellSchoolMask(curSpellInfo), GetSpellDuration(m_spellInfo));
unitTarget->InterruptSpell(CurrentSpellTypes(i), false);
if (unitTarget->ToCreature())
{
if (CreatureAI* ai = unitTarget->ToCreature()->AI()) // TODO setup a better way to inform AI
{
ai->SetCombatMovement(true, true);
ai->AddCombatMovementFlags(COMBAT_MOVEMENT_SILENCE);
}
}
}
}
}
Expand Down

0 comments on commit 22da350

Please sign in to comment.