From 50e489d260d923231ec1e8c5780c0723437daf6f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 31 May 2009 04:31:55 +0400 Subject: [PATCH] [7922] Implement param2 for ACTION_T_COMBAT_MOVEMENT for allow control start/stop melee combat state for creature at start/stop movement in combat. Also small fix for avoid unexpected set pet speed to owner speed for non-player case. In player case this hack speed setting still required. --- doc/EventAI.txt | 2 ++ src/game/CreatureEventAI.cpp | 22 ++++++++++++++++++---- src/game/CreatureEventAI.h | 1 + src/game/Unit.cpp | 12 ++++++------ src/game/Unit.h | 5 ++--- src/shared/revision_nr.h | 2 +- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/doc/EventAI.txt b/doc/EventAI.txt index 5137c26dd..76e4fa20c 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 8d01b7687..e895595d1 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -578,11 +578,19 @@ 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) { + if(action.combat_movement.melee && m_creature->isInCombat()) + if(Unit* victim = m_creature->getVictim()) + m_creature->SendMeleeAttackStart(victim); + if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) { m_creature->GetMotionMaster()->Clear(false); @@ -590,11 +598,17 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } } else - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); + if(action.combat_movement.melee && m_creature->isInCombat()) + if(Unit* victim = m_creature->getVictim()) + m_creature->SendMeleeAttackStop(victim); + + if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->StopMoving(); + } } break; case ACTION_T_SET_PHASE: diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 852d47576..ac97badd8 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -281,6 +281,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/Unit.cpp b/src/game/Unit.cpp index b2e29f955..c8f19e0f8 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2317,7 +2317,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()); @@ -2327,7 +2327,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; @@ -7244,7 +7244,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; @@ -7285,7 +7285,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) resetAttackTimer(OFF_ATTACK); if(meleeAttack) - SendAttackStart(victim); + SendMeleeAttackStart(victim); return true; } @@ -7314,7 +7314,7 @@ bool Unit::AttackStop(bool targetSwitch /*=false*/) ((Creature*)this)->SetNoSearchAssistance(false); } - SendAttackStop(victim); + SendMeleeAttackStop(victim); return true; } @@ -7505,7 +7505,7 @@ void Unit::SetPet(Pet* pet) SetUInt64Value(UNIT_FIELD_SUMMON, pet ? pet->GetGUID() : 0); // FIXME: hack, speed must be set only at follow - if(pet) + if(pet && GetTypeId()==TYPEID_PLAYER) for(int i = 0; i < MAX_MOVE_TYPE; ++i) pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true); } diff --git a/src/game/Unit.h b/src/game/Unit.h index b54c96317..e5946c6e8 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -921,6 +921,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void CombatStopWithPets(bool includingCast = false); Unit* SelectNearbyTarget() 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); } @@ -1548,9 +1550,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 m_regenTimer; 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, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); bool HandleHasteAuraProc( Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 98e81a10d..eb0538268 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7921" + #define REVISION_NR "7922" #endif // __REVISION_NR_H__ -- 2.11.4.GIT