[7922] Implement param2 for ACTION_T_COMBAT_MOVEMENT for allow control start/stop melee combat state for creature at start/stop movement in combat. Author: VladimirMangos

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-31 16:24:19 -05:00
parent 552e08b3f0
commit 067cbec40d
6 changed files with 24 additions and 11 deletions
+2
View File
@@ -530,10 +530,12 @@ This is commonly used in combination with EVENT_T_RANGE and ACTION_T_COMBAT_MOVE
21 = ACTION_T_COMBAT_MOVEMENT:
------------------------------
Parameter 1: If zero, then the creature will stop moving towards its victim (if its victim gets out of melee range) and will be stationary. If non-zero, then the creature will either continue to follow its victim (the action would have no effect) or it will start to follow the target with the top threat if its movement was disabled before.
Parameter 2: If non-zero, then stop melee combat state (if param1=0) or start melee combat state (if param1!=0) and creature in combat with selected target.
This action controls whether or not the creature will always move towards its target.
NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values. (0 = Stop Movement, 1 = Start Movement)
This is commonly used with EVENT_T_RANGE and ACTION_T_AUTO_ATTACK for NPC's who engage in Ranged Comabt (Either Spells or Ranged Attacks)
Parameter 2 specialy used for ranged combat proper client side visual show ranged weapon in proper state.
------------------------
22 = ACTION_T_SET_PHASE:
+13 -1
View File
@@ -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;
+1
View File
@@ -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
+1 -1
View File
@@ -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());
}
}
+5 -5
View File
@@ -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;
}
+2 -4
View File
@@ -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);