mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
fix(Core/Movement): fix multiple creature movement issues (#5097)
This commit is contained in:
@@ -3671,7 +3671,7 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
float radiusWidth = GetCollisionRadius();
|
||||
float radiusHeight = GetCollisionHeight() / 2;
|
||||
float radiusAvg = (radiusWidth + radiusHeight) / 2;
|
||||
if (option <= 1 && GetExactDistSq(&m_last_environment_position) < radiusAvg*radiusAvg)
|
||||
if (option <= 1 && GetExactDistSq(&m_last_environment_position) < radiusAvg * radiusAvg)
|
||||
return;
|
||||
|
||||
m_last_environment_position.Relocate(GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
@@ -3687,7 +3687,8 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
m_is_updating_environment = false;
|
||||
return;
|
||||
}
|
||||
bool canChangeFlying = option == 3 || GetMotionMaster()->GetCurrentMovementGeneratorType() != WAYPOINT_MOTION_TYPE;
|
||||
|
||||
bool canChangeFlying = option == 3 || ((c->GetScriptId() == 0 || GetInstanceId() == 0) && GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE);
|
||||
bool canFallGround = option == 0 && canChangeFlying && GetInstanceId() == 0 && !IsInCombat() && !GetVehicle() && !GetTransport() && !HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && !c->IsTrigger() && !c->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && GetMotionMaster()->GetCurrentMovementGeneratorType() <= RANDOM_MOTION_TYPE && !HasUnitState(UNIT_STATE_EVADE) && !IsControlledByPlayer();
|
||||
float x = GetPositionX(), y = GetPositionY(), z = GetPositionZ();
|
||||
bool isInAir = true;
|
||||
@@ -3747,16 +3748,17 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
}
|
||||
}
|
||||
|
||||
bool canUpdateEnvironment = !HasUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
|
||||
bool flyingBarelyInWater = false;
|
||||
// Refresh being in water
|
||||
if (m_last_isinwater_status)
|
||||
{
|
||||
if (!c->CanFly() || enoughWater)
|
||||
{
|
||||
if (!HasUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD) && c->CanSwim() && (!HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) || !HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY)))
|
||||
if (canUpdateEnvironment && c->CanSwim() && (!HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) || !HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY)))
|
||||
{
|
||||
SetSwim(true);
|
||||
// SetDisableGravity(true);
|
||||
changed = true;
|
||||
}
|
||||
isInAir = false;
|
||||
@@ -3770,11 +3772,9 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
|
||||
if (!m_last_isinwater_status)
|
||||
{
|
||||
if (!HasUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD) && c->CanWalk() && HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
|
||||
if (canUpdateEnvironment && c->CanWalk() && HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
|
||||
{
|
||||
SetSwim(false);
|
||||
if (!c->CanFly()) // if can fly, this will be removed below if needed
|
||||
SetDisableGravity(false);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -3801,7 +3801,7 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
}
|
||||
}
|
||||
|
||||
if (!HasUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD) && canChangeFlying)
|
||||
if (canUpdateEnvironment && canChangeFlying)
|
||||
{
|
||||
// xinef: summoned vehicles are treated as always in air, fixes flying on such units
|
||||
if (IsVehicle() && !c->GetDBTableGUIDLow())
|
||||
@@ -3822,7 +3822,6 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
}
|
||||
else if (c->CanFly() && isInAir && !c->IsFalling())
|
||||
{
|
||||
|
||||
if (!HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY) || !HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY))
|
||||
{
|
||||
SetCanFly(true);
|
||||
@@ -3835,7 +3834,6 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
SetHover(false);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3869,7 +3867,7 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option)
|
||||
if (changed)
|
||||
propagateSpeedChange();
|
||||
|
||||
if (!HasUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD) && canFallGround && !c->CanFly() && !c->IsFalling() && !m_last_isinwater_status && (c->GetUnitMovementFlags() & (MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_HOVER | MOVEMENTFLAG_SWIMMING)) == 0 && z - ground_z > 5.0f && z - ground_z < 80.0f)
|
||||
if (canUpdateEnvironment && canFallGround && !c->CanFly() && !c->IsFalling() && !m_last_isinwater_status && (c->GetUnitMovementFlags() & (MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_HOVER | MOVEMENTFLAG_SWIMMING)) == 0 && z - ground_z > 5.0f && z - ground_z < 80.0f)
|
||||
GetMotionMaster()->MoveFall();
|
||||
|
||||
m_is_updating_environment = false;
|
||||
@@ -20197,7 +20195,7 @@ float Unit::GetCollisionRadius() const
|
||||
float Unit::GetCollisionHeight() const
|
||||
{
|
||||
float scaleMod = GetObjectScale(); // 99% sure about this
|
||||
float defaultHeight = DEFAULT_WORLD_OBJECT_SIZE * scaleMod;
|
||||
float defaultHeight = DEFAULT_COLLISION_HEIGHT * scaleMod;
|
||||
|
||||
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId());
|
||||
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelId);
|
||||
|
||||
Reference in New Issue
Block a user