From 02d45b4b548b1166ee3efa124ab77eab759d1519 Mon Sep 17 00:00:00 2001 From: balrok Date: Sun, 11 Oct 2009 14:19:29 +0200 Subject: [PATCH] [8625] feign_death cleanups use an extra function for setfeigndeath() like it's done with setfeared already.. allow to apply feigndeath on creatures too avoid moving of creatures with feign death applied and start attacking last victim when feigndeath disappears --- src/game/AggressorAI.cpp | 2 +- src/game/ConfusedMovementGenerator.cpp | 2 +- src/game/CreatureEventAI.cpp | 2 +- src/game/FleeingMovementGenerator.cpp | 6 +-- src/game/GridNotifiers.h | 2 +- src/game/HomeMovementGenerator.cpp | 2 +- src/game/MotionMaster.cpp | 2 +- src/game/Object.cpp | 2 +- src/game/PointMovementGenerator.cpp | 2 +- src/game/RandomMovementGenerator.cpp | 2 +- src/game/SpellAuras.cpp | 46 +--------------- src/game/TargetedMovementGenerator.cpp | 4 +- src/game/Unit.cpp | 74 ++++++++++++++++++++++++-- src/game/Unit.h | 7 +-- src/game/WaypointMovementGenerator.cpp | 2 +- src/shared/revision_nr.h | 2 +- 16 files changed, 90 insertions(+), 69 deletions(-) diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 4d1b9c427..5f61eb35c 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -46,7 +46,7 @@ AggressorAI::MoveInLineOfSight(Unit *u) if( !m_creature->canFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) return; - if( !m_creature->hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() && + if( !m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && u->isTargetableForAttack() && ( m_creature->IsHostileTo( u ) /*|| u->getVictim() && m_creature->IsFriendlyTo( u->getVictim() )*/ ) && u->isInAccessablePlaceFor(m_creature) ) { diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index 84ebdfc6b..7db8c9cba 100644 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -102,7 +102,7 @@ ConfusedMovementGenerator::Update(T &unit, const uint32 &diff) if(!&unit) return true; - if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) + if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED)) return true; if( i_nextMoveTime.Passed() ) diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index ef344fe87..ffb9b2803 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -994,7 +994,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who) if (m_creature->isCivilian() || m_creature->IsNeutralToAll()) return; - if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && who->isTargetableForAttack() && + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && who->isTargetableForAttack() && m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature)) { if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 172934340..4f26e226a 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -33,7 +33,7 @@ FleeingMovementGenerator::_setTargetLocation(T &owner) if( !&owner ) return; - if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) + if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) ) return; if(!_setMoveData(owner)) @@ -353,7 +353,7 @@ FleeingMovementGenerator::Update(T &owner, const uint32 & time_diff) { if( !&owner || !owner.isAlive() ) return false; - if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) + if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) ) return true; Traveller traveller(owner); @@ -409,7 +409,7 @@ bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 & time_dif if( !owner.isAlive() ) return false; - if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) + if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) ) return true; i_totalFleeTime.Update(time_diff); diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 92c42cefe..069221511 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -719,7 +719,7 @@ namespace MaNGOS bool operator()(Unit* u) { if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && - (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNNED) || u->hasUnitState(UNIT_STAT_CONFUSED))) + (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED | UNIT_STAT_DIED))) { return true; } diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp index cc13446f0..56f0da15e 100644 --- a/src/game/HomeMovementGenerator.cpp +++ b/src/game/HomeMovementGenerator.cpp @@ -42,7 +42,7 @@ HomeMovementGenerator::_setTargetLocation(Creature & owner) if( !&owner ) return; - if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED) ) + if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED) ) return; float x, y, z; diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 319279a2b..5448e8f2e 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -76,7 +76,7 @@ MotionMaster::~MotionMaster() void MotionMaster::UpdateMotion(uint32 diff) { - if( i_owner->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) + if( i_owner->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) ) return; assert( !empty() ); m_cleanFlag |= MMCF_UPDATE; diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 222b8efad..60e3ac1f7 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1658,7 +1658,7 @@ namespace MaNGOS float x,y,z; - if( !c->isAlive() || c->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED) || + if( !c->isAlive() || c->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED) || !c->GetMotionMaster()->GetDestination(x,y,z) ) { x = c->GetPositionX(); diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 05adbe011..d6ace4f7f 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -42,7 +42,7 @@ bool PointMovementGenerator::Update(T &unit, const uint32 &diff) if(!&unit) return false; - if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) + if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED)) return true; Traveller traveller(unit); diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index 5cb713cbc..bb7b1ab93 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -129,7 +129,7 @@ template<> bool RandomMovementGenerator::Update(Creature &creature, const uint32 &diff) { - if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) + if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED)) { i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer creature.clearUnitState(UNIT_STAT_ROAMING); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index c1723f711..bd852d83f 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3566,51 +3566,7 @@ void Aura::HandleFeignDeath(bool apply, bool Real) if(!Real) return; - if(m_target->GetTypeId() != TYPEID_PLAYER) - return; - - if( apply ) - { - /* - WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); - data<GetGUID(); - data<SendMessageToSet(&data,true); - */ - // blizz like 2.0.x - m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); - // blizz like 2.0.x - m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); - // blizz like 2.0.x - m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); - - m_target->addUnitState(UNIT_STAT_DIED); - m_target->CombatStop(); - m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); - - // prevent interrupt message - if (m_caster_guid==m_target->GetGUID()) - m_target->FinishSpell(CURRENT_GENERIC_SPELL,false); - m_target->InterruptNonMeleeSpells(true); - m_target->getHostilRefManager().deleteReferences(); - } - else - { - /* - WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); - data<GetGUID(); - data<SendMessageToSet(&data,true); - */ - // blizz like 2.0.x - m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); - // blizz like 2.0.x - m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); - // blizz like 2.0.x - m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); - - m_target->clearUnitState(UNIT_STAT_DIED); - } + m_target->SetFeignDeath(apply, GetCasterGUID(), GetId()); } void Aura::HandleAuraModDisarm(bool apply, bool Real) diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 11b1bbdfa..53d037848 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -46,7 +46,7 @@ TargetedMovementGenerator::_setTargetLocation(T &owner) if (!i_target.isValid() || !i_target->IsInWorld()) return; - if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) + if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED)) return; // prevent redundant micro-movement for pets, other followers. @@ -132,7 +132,7 @@ TargetedMovementGenerator::Update(T &owner, const uint32 & time_diff) if (!owner.isAlive()) return true; - if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED)) + if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED)) return true; // prevent movement while casting spells with cast time or channel time diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 9e9649208..e85f3a2bb 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2042,7 +2042,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra ) { - if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) + if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DIED) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) return; if (!pVictim->isAlive()) @@ -11609,7 +11609,7 @@ void Unit::StopMoving() SendMessageToSet(&data,false); } -void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID, uint32 time) +void Unit::SetFeared(bool apply, uint64 const& casterGUID, uint32 spellID, uint32 time) { if( apply ) { @@ -11650,7 +11650,7 @@ void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID, uint32 time) ((Player*)this)->SetClientControl(this, !apply); } -void Unit::SetConfused(bool apply, uint64 casterGUID, uint32 spellID) +void Unit::SetConfused(bool apply, uint64 const& casterGUID, uint32 spellID) { if( apply ) { @@ -11666,11 +11666,13 @@ void Unit::SetConfused(bool apply, uint64 casterGUID, uint32 spellID) GetMotionMaster()->MovementExpired(false); - if (GetTypeId() == TYPEID_UNIT) + if (GetTypeId() != TYPEID_PLAYER && isAlive()) { - // if in combat restore movement generator + // restore appropriate movement generator if(getVictim()) GetMotionMaster()->MoveChase(getVictim()); + else + GetMotionMaster()->Initialize(); } } @@ -11678,6 +11680,68 @@ void Unit::SetConfused(bool apply, uint64 casterGUID, uint32 spellID) ((Player*)this)->SetClientControl(this, !apply); } +void Unit::SetFeignDeath(bool apply, uint64 const& casterGUID, uint32 spellID) +{ + if( apply ) + { + /* + WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); + data<m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE); + + // blizz like 2.0.x + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); + // blizz like 2.0.x + SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); + // blizz like 2.0.x + SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); + + addUnitState(UNIT_STAT_DIED); + CombatStop(); + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); + + // prevent interrupt message + if (casterGUID == GetGUID()) + FinishSpell(CURRENT_GENERIC_SPELL,false); + InterruptNonMeleeSpells(true); + getHostilRefManager().deleteReferences(); + } + else + { + /* + WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); + data<MoveChase(getVictim()); + else + GetMotionMaster()->Initialize(); + } + + } +} + bool Unit::IsSitState() const { uint8 s = getStandState(); diff --git a/src/game/Unit.h b/src/game/Unit.h index a89053a90..43b305d69 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -936,7 +936,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool CanFreeMove() const { return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT | - UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0; + UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED ) && GetOwnerGUID()==0; } uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); } @@ -1488,8 +1488,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); } void StopMoving(); - void SetFeared(bool apply, uint64 casterGUID = 0, uint32 spellID = 0, uint32 time = 0); - void SetConfused(bool apply, uint64 casterGUID = 0, uint32 spellID = 0); + void SetFeared(bool apply, uint64 const& casterGUID = 0, uint32 spellID = 0, uint32 time = 0); + void SetConfused(bool apply, uint64 const& casterGUID = 0, uint32 spellID = 0); + void SetFeignDeath(bool apply, uint64 const& casterGUID = 0, uint32 spellID = 0); void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); } void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); } diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index f33512bdd..00d8f4804 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -83,7 +83,7 @@ bool WaypointMovementGenerator::Update(Creature &creature, const uint3 // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff - if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) + if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED)) return true; // prevent a crash at empty waypoint path. diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c0b60c9a8..dbb0419af 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 "8624" + #define REVISION_NR "8625" #endif // __REVISION_NR_H__