Fix some of the Fix Z logic - Boats no longer snap Z - Even though we checked for water, chances are boats pathing was above water and would snap Z to the floor of the water

This commit is contained in:
Akkadius 2018-05-11 00:43:49 -05:00
parent 2c91d1db6e
commit d43273fd1b

View File

@ -752,25 +752,28 @@ float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset)
timer.reset(); timer.reset();
float new_z = dest.z; float new_z = dest.z;
if (zone->HasMap() && RuleB(Map, FixZWhenMoving) && if (zone->HasMap() && RuleB(Map, FixZWhenMoving)) {
(flymode != 1 && flymode != 2))
{ if (flymode == 1 || flymode == 2)
if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() return new_z;
|| (zone->HasWaterMap() &&
!zone->watermap->InWater(glm::vec3(m_Position)))) if (this->IsBoat())
{ return new_z;
/* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */
if (zone->HasWaterMap() && zone->watermap->InWater(glm::vec3(m_Position)))
return new_z;
/*
* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors
*/
new_z = this->FindDestGroundZ(dest, z_find_offset); new_z = this->FindDestGroundZ(dest, z_find_offset);
if (new_z != BEST_Z_INVALID) if (new_z != BEST_Z_INVALID) {
{
new_z += this->GetZOffset(); new_z += this->GetZOffset();
// If bad new Z restore old one
if (new_z < -2000) { if (new_z < -2000) {
new_z = m_Position.z; new_z = m_Position.z;
} }
} }
}
auto duration = timer.elapsed(); auto duration = timer.elapsed();
@ -782,20 +785,17 @@ float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset)
return new_z; return new_z;
} }
void Mob::FixZ(int32 z_find_offset /*= 5*/) void Mob::FixZ(int32 z_find_offset /*= 5*/) {
{
glm::vec3 current_loc(m_Position); glm::vec3 current_loc(m_Position);
float new_z = GetFixedZ(current_loc, z_find_offset); float new_z = GetFixedZ(current_loc, z_find_offset);
if (!IsClient() && new_z != m_Position.z) if (!IsClient() && new_z != m_Position.z) {
{
if ((new_z > -2000) && new_z != BEST_Z_INVALID) { if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
if (RuleB(Map, MobZVisualDebug)) if (RuleB(Map, MobZVisualDebug))
this->SendAppearanceEffect(78, 0, 0, 0, 0); this->SendAppearanceEffect(78, 0, 0, 0, 0);
m_Position.z = new_z; m_Position.z = new_z;
} } else {
else {
if (RuleB(Map, MobZVisualDebug)) if (RuleB(Map, MobZVisualDebug))
this->SendAppearanceEffect(103, 0, 0, 0, 0); this->SendAppearanceEffect(103, 0, 0, 0, 0);