diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index fdbd2741..7ce08c52 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1232,7 +1232,6 @@ void Creature::DoFleeToGetAssistance() cell.Visit(p, Trinity::makeGridVisitor(searcher), *GetMap(), *this, radius); SetNoSearchAssistance(true); - UpdateSpeed(MOVE_RUN, false); if (!creature) //SetFeared(true, getVictim()->GetGUID(), 0, sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY)); @@ -2584,11 +2583,7 @@ void Creature::setDeathState(DeathState s) if (hasLootRecipient()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - if (HasSearchedAssistance()) - { - SetNoSearchAssistance(false); - UpdateSpeed(MOVE_RUN, false); - } + SetNoSearchAssistance(false); //Dismiss group if is leader if (m_formation && m_formation->getLeader() == this) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 830619e8..005f4429 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -11485,16 +11485,8 @@ bool Unit::AttackStop() // reset only at real combat stop if (Creature* creature = ToCreature()) - { creature->SetNoCallAssistance(false); - if (creature->HasSearchedAssistance()) - { - creature->SetNoSearchAssistance(false); - UpdateSpeed(MOVE_RUN, false); - } - } - SendMeleeAttackStop(victim); return true; @@ -15751,11 +15743,6 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) break; } - // for creature case, we check explicit if mob searched for assistance - if (auto creature = ToCreature()) - if (creature->HasSearchedAssistance()) - speed *= 0.66f; // best guessed value, so this will be 33% reduction. Based off initial speed, mob can then "run", "walk fast" or "walk". - // Apply strongest slow aura mod to speed float slow = 0.f; @@ -22332,6 +22319,9 @@ void Unit::SetControlled(bool apply, UnitState state) if (HasUnitState(state)) return; + if (state & UNIT_STATE_CONTROLLED) + CastStop(); + AddUnitState(state); switch (state) @@ -22350,7 +22340,6 @@ void Unit::SetControlled(bool apply, UnitState state) SendMeleeAttackStop(); // SendCancelAutoRepeat ? SetConfused(true); - CastStop(); } break; case UNIT_STATE_FLEEING: @@ -22360,7 +22349,6 @@ void Unit::SetControlled(bool apply, UnitState state) SendMeleeAttackStop(); // SendCancelAutoRepeat ? SetFeared(true); - CastStop(); } break; default: @@ -22373,46 +22361,62 @@ void Unit::SetControlled(bool apply, UnitState state) { case UNIT_STATE_STUNNED: { - if (HasAuraType(SPELL_AURA_MOD_STUN)) return; + if (HasAuraType(SPELL_AURA_MOD_STUN)) + return; + + ClearUnitState(state); SetStunned(false); } break; case UNIT_STATE_ROOT: { - if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOTED) || GetVehicle()) return; + if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOTED) || GetVehicle()) + return; + + ClearUnitState(state); SetRooted(false); } break; case UNIT_STATE_CONFUSED: { - if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) return; + if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) + return; + + ClearUnitState(state); SetConfused(false); } break; case UNIT_STATE_FLEEING: { - if (HasAuraType(SPELL_AURA_MOD_FEAR)) return; + if (HasAuraType(SPELL_AURA_MOD_FEAR)) + return; + + ClearUnitState(state); SetFeared(false); } break; - default: return; + default: + return; } - ClearUnitState(state); + ApplyControlStatesIfNeeded(); + } +} - if (HasUnitState(UNIT_STATE_STUNNED)) - SetStunned(true); - else - { - if (HasUnitState(UNIT_STATE_ROOT)) - SetRooted(true); +void Unit::ApplyControlStatesIfNeeded() +{ + // Unit States might have been already cleared but auras still present. I need to check with HasAuraType + if (HasUnitState(UNIT_STATE_STUNNED) || HasAuraType(SPELL_AURA_MOD_STUN)) // || HasAuraType(SPELL_AURA_MOD_STUN_DISABLE_GRAVITY)) + SetStunned(true); - if (HasUnitState(UNIT_STATE_CONFUSED)) - SetConfused(true); - else if (HasUnitState(UNIT_STATE_FLEEING)) - SetFeared(true); - } - } + if (HasUnitState(UNIT_STATE_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT)) // || HasAuraType(SPELL_AURA_MOD_ROOT_2) || HasAuraType(SPELL_AURA_MOD_ROOT_DISABLE_GRAVITY)) + SetRooted(true); + + if (HasUnitState(UNIT_STATE_CONFUSED) || HasAuraType(SPELL_AURA_MOD_CONFUSE)) + SetConfused(true); + + if (HasUnitState(UNIT_STATE_FLEEING) || HasAuraType(SPELL_AURA_MOD_FEAR)) + SetFeared(true); } void Unit::SetStunned(bool apply) @@ -22837,6 +22841,9 @@ void Unit::RemoveCharmedBy(Unit* charmer) charmer->ToPlayer()->SendRemoveControlBar(); else if (IsPlayer() || (IsCreature() && !ToCreature()->isGuardian())) DeleteCharmInfo(); + + // reset confused movement for example + ApplyControlStatesIfNeeded(); } void Unit::RestoreFaction() diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 42e161c9..4e8fe325 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2221,6 +2221,7 @@ class Unit : public WorldObject void SendSetVehicleRecId(uint32 vehicleID); void SetControlled(bool apply, UnitState state); + void ApplyControlStatesIfNeeded(); ///----------Pet responses methods----------------- void SendPetActionFeedback (uint32 spellID, uint8 msg); diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index d59a8aae..038ee7a7 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -682,12 +682,14 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z) { TC_LOG_ERROR("misc", "Player (GUID: %u) attempt to seek assistance", _owner->GetGUIDLow()); } - else + else if (Creature* creature = _owner->ToCreature()) { TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) seek assistance (X: %f Y: %f Z: %f)", - _owner->GetEntry(), _owner->GetGUIDLow(), x, y, z); - _owner->AttackStop(); - _owner->ToCreature()->SetReactState(REACT_PASSIVE); + creature->GetEntry(), creature->GetGUIDLow(), x, y, z); + creature->AttackStop(); + creature->CastStop(); + //creature->DoNotReacquireSpellFocusTarget(); + creature->SetReactState(REACT_PASSIVE); Mutate(new AssistanceMovementGenerator(x, y, z), MOTION_SLOT_ACTIVE); } } diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 741a3a61..97d5fe67 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -52,25 +52,34 @@ namespace Movement move_spline.onTransport = transport; uint32 moveFlags = unit.m_movementInfo.GetMovementFlags(); - if (args.walk) - moveFlags |= MOVEMENTFLAG_WALKING; - else - moveFlags &= ~MOVEMENTFLAG_WALKING; if (!args.flags.backward) moveFlags = (moveFlags & ~MOVEMENTFLAG_BACKWARD) | MOVEMENTFLAG_FORWARD; else moveFlags = (moveFlags & ~MOVEMENTFLAG_FORWARD) | MOVEMENTFLAG_BACKWARD; + if (moveFlags & MOVEMENTFLAG_ROOT) + moveFlags &= ~MOVEMENTFLAG_MASK_MOVING; + if (!args.HasVelocity) - args.velocity = unit.GetSpeed(UnitMoveType(SelectSpeedType(moveFlags))); + { + // If spline is initialized with SetWalk method it only means we need to select + // walk move speed for it but not add walk flag to unit + uint32 moveFlagsForSpeed = moveFlags; + if (args.walk) + moveFlagsForSpeed |= MOVEMENTFLAG_WALKING; + else + moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING; + + args.velocity = unit.GetSpeed(UnitMoveType(SelectSpeedType(moveFlagsForSpeed))); + if (Creature* creature = unit.ToCreature()) + if (creature->HasSearchedAssistance()) + args.velocity *= 0.66f; + } if (!args.Validate()) return 0; - if (moveFlags & MOVEMENTFLAG_ROOT) - moveFlags &= ~MOVEMENTFLAG_MASK_MOVING; - unit.m_movementInfo.SetMovementFlags(moveFlags); move_spline.Initialize(args);