[Pathing] Improvements to z-clipping, z-recovery and z-calculations (#2975)

* zclip adjustments

* Remove debug
This commit is contained in:
Chris Miles 2023-02-21 10:24:25 -06:00 committed by GitHub
parent 33bb5aa8e5
commit 1e50f19f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 15 deletions

View File

@ -103,6 +103,7 @@ Mob::Mob(
attack_dw_timer(2000),
ranged_timer(2000),
hp_regen_per_second_timer(1000),
m_z_clip_check_timer(1000),
tic_timer(6000),
mana_timer(2000),
spellend_timer(0),

View File

@ -1427,6 +1427,8 @@ protected:
int _GetRunSpeed() const;
int _GetFearSpeed() const;
Timer m_z_clip_check_timer;
virtual bool AI_EngagedCastCheck() { return(false); }
virtual bool AI_PursueCastCheck() { return(false); }
virtual bool AI_IdleCastCheck() { return(false); }

View File

@ -1071,6 +1071,14 @@ void Mob::AI_Process() {
}
if (engaged) {
if (IsNPC() && m_z_clip_check_timer.Check()) {
auto t = GetTarget();
if (t && DistanceNoZ(GetPosition(), t->GetPosition()) < 75 && std::abs(GetPosition().z - t->GetPosition().z) > 15 && !CheckLosFN(t)) {
GMMove(t->GetPosition().x, t->GetPosition().y, t->GetPosition().z, t->GetPosition().w);
FaceTarget(t);
}
}
if (!(m_PlayerState & static_cast<uint32>(PlayerState::Aggressive)))
SendAddPlayerState(PlayerState::Aggressive);

View File

@ -781,7 +781,19 @@ float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
return new_z;
}
new_z = FindDestGroundZ(destination, (-GetZOffset() / 2));
new_z = FindDestGroundZ(destination, ((-GetZOffset() / 2) + z_find_offset));
if (RuleB(Map, MobPathingVisualDebug)) {
DrawDebugCoordinateNode(
fmt::format("{} search z node", GetCleanName()),
glm::vec4{
m_Position.x,
m_Position.y,
((-GetZOffset() / 2) + z_find_offset),
m_Position.w
}
);
}
if (new_z != BEST_Z_INVALID) {
new_z += GetZOffset();
@ -790,20 +802,6 @@ float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
}
}
// prevent ceiling clipping
// if client is close in distance (not counting Z) and we clipped up into a ceiling
// this helps us snap back down (or up) if it were to happen
// other fixes were put in place to prevent clipping into the ceiling to begin with
if (std::abs(new_z - m_Position.z) > 15) {
LogFixZ("TRIGGER clipping detection");
auto t = GetTarget();
if (t && DistanceNoZ(GetPosition(), t->GetPosition()) < 20) {
new_z = FindDestGroundZ(t->GetPosition(), -t->GetZOffset());
new_z += GetZOffset();
GMMove(t->GetPosition().x, t->GetPosition().y, new_z, t->GetPosition().w);
}
}
auto duration = timer.elapsed();
LogFixZ("[{}] returned [{}] at [{}] [{}] [{}] - Took [{}]",