diff options
author | megamage <none@none> | 2009-05-31 16:24:19 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-05-31 16:24:19 -0500 |
commit | 067cbec40d33b865b30299368534ae0cd673f336 (patch) | |
tree | 32df305081bddb28a8f24ed9997454adc3462b80 | |
parent | 552e08b3f0efc19f3aa3504badccffbb05a983bd (diff) |
[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
-rw-r--r-- | doc/EventAI.txt | 2 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 14 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 1 | ||||
-rw-r--r-- | src/game/Player.cpp | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 10 | ||||
-rw-r--r-- | src/game/Unit.h | 6 |
6 files changed, 24 insertions, 11 deletions
diff --git a/doc/EventAI.txt b/doc/EventAI.txt index 5137c26dd18..76e4fa20c35 100644 --- a/doc/EventAI.txt +++ b/doc/EventAI.txt @@ -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: 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); |