aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/CreatureEventAI.cpp14
-rw-r--r--src/game/CreatureEventAI.h1
-rw-r--r--src/game/Player.cpp2
-rw-r--r--src/game/Unit.cpp10
-rw-r--r--src/game/Unit.h6
5 files changed, 22 insertions, 11 deletions
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp
index 42f64ccdcd0..e2c51f40804 100644
--- a/src/game/CreatureEventAI.cpp
+++ b/src/game/CreatureEventAI.cpp
@@ -577,15 +577,27 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
MeleeEnabled = action.auto_attack.state != 0;
break;
case ACTION_T_COMBAT_MOVEMENT:
+ // ignore no affect case
+ if(CombatMovementEnabled==(action.combat_movement.state!=0))
+ return;
+
CombatMovementEnabled = action.combat_movement.state != 0;
//Allow movement (create new targeted movement gen only if idle)
if (CombatMovementEnabled)
{
- m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle);
+ if(action.combat_movement.melee && m_creature->isInCombat())
+ if(Unit* victim = m_creature->getVictim())
+ m_creature->SendMeleeAttackStart(victim);
+
+ m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle);
}
else
{
+ if(action.combat_movement.melee && m_creature->isInCombat())
+ if(Unit* victim = m_creature->getVictim())
+ m_creature->SendMeleeAttackStop(victim);
+
m_creature->GetMotionMaster()->MoveIdle();
}
break;
diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h
index bdb64f279e9..d94ceeeac18 100644
--- a/src/game/CreatureEventAI.h
+++ b/src/game/CreatureEventAI.h
@@ -287,6 +287,7 @@ struct CreatureEventAI_Action
struct
{
uint32 state; // 0 = stop combat based movement, anything else continue attacking
+ uint32 melee; // if set: at stop send melee combat stop if in combat, use for terminate melee fighting state for switch to ranged
} combat_movement;
// ACTION_T_SET_PHASE = 22
struct
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index d05e7f2cd80..48386d8416f 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -18389,7 +18389,7 @@ void Player::SendInitialVisiblePackets(Unit* target)
if(target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE)
target->SendMonsterMoveWithSpeedToCurrentDestination(this);
if(target->hasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim())
- target->SendAttackStart(target->getVictim());
+ target->SendMeleeAttackStart(target->getVictim());
}
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 3e3bf254af5..57181aa3f77 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -2641,7 +2641,7 @@ float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const
return (100.0f - LvlPenalty) * LvlFactor / 100.0f;
}
-void Unit::SendAttackStart(Unit* pVictim)
+void Unit::SendMeleeAttackStart(Unit* pVictim)
{
WorldPacket data( SMSG_ATTACKSTART, 8 + 8 );
data << uint64(GetGUID());
@@ -2651,7 +2651,7 @@ void Unit::SendAttackStart(Unit* pVictim)
DEBUG_LOG( "WORLD: Sent SMSG_ATTACKSTART" );
}
-void Unit::SendAttackStop(Unit* victim)
+void Unit::SendMeleeAttackStop(Unit* victim)
{
if(!victim)
return;
@@ -8025,7 +8025,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) )
{
addUnitState(UNIT_STAT_MELEE_ATTACKING);
- SendAttackStart(victim);
+ SendMeleeAttackStart(victim);
return true;
}
return false;
@@ -8074,7 +8074,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
resetAttackTimer(OFF_ATTACK);
if(meleeAttack)
- SendAttackStart(victim);
+ SendMeleeAttackStart(victim);
return true;
}
@@ -8103,7 +8103,7 @@ bool Unit::AttackStop()
((Creature*)this)->SetNoSearchAssistance(false);
}
- SendAttackStop(victim);
+ SendMeleeAttackStop(victim);
return true;
}
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 1259d888293..375e21e5f4d 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1038,6 +1038,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void CombatStopWithPets(bool includingCast = false);
Unit* SelectNearbyTarget(float dist = NOMINAL_MELEE_RANGE) const;
bool hasNegativeAuraWithInterruptFlag(uint32 flag);
+ void SendMeleeAttackStop(Unit* victim);
+ void SendMeleeAttackStart(Unit* pVictim);
void addUnitState(uint32 f) { m_state |= f; }
bool hasUnitState(const uint32 f) const { return (m_state & f); }
@@ -1261,7 +1263,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void DeMorph();
- void SendAttackStart(Unit* pVictim);
void SendAttackStateUpdate(CalcDamageInfo *damageInfo);
void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount);
void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log);
@@ -1793,9 +1794,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
ThreatManager m_ThreatManager;
private:
- void SendAttackStop(Unit* victim); // only from AttackStop(Unit*)
- //void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*)
-
bool IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry const * procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const *& spellProcEvent );
bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
bool HandleObsModEnergyAuraProc( Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);