Improved pathfinding logic

This commit is contained in:
Vladislav Khorev committed 2026-05-21 11:48:18 +03:00
1 parent 2659951d8e
commit 3a73f3fbde
36 files changed
+458337 -871

No files matched your search

+22
View File
@@ -7,6 +7,7 @@
#include "GameConstants.h"
#include "Environment.h"
namespace ZL {
const float ATTACK_COOLDOWN_TIME = 1.6f;
@@ -94,6 +95,15 @@ Eigen::Vector3f Character::getCurrentNavigationTarget() const
return walkTarget;
}
void Character::stopInPlace()
{
walkTarget = Eigen::Vector3f(position.x(), 0.f, position.z());
requestedWalkTarget = walkTarget;
pathWaypoints.clear();
currentWaypointIndex = 0;
onArrivedCallback = nullptr;
}
void Character::forceReplan()
{
if (!pathPlanner) {
@@ -343,6 +353,18 @@ void Character::update(int64_t deltaMs) {
}
if (!isPlayer && hp > 0.f && battle_state == 0 && maxHomeDrift > 0.f) {
homeDriftCheckTimer -= static_cast<float>(deltaMs) / 1000.f;
if (homeDriftCheckTimer <= 0.f) {
homeDriftCheckTimer = HOME_DRIFT_CHECK_INTERVAL;
Eigen::Vector3f toHome = homePosition - position;
toHome.y() = 0.f;
if (!isMoving() && toHome.norm() > maxHomeDrift) {
setTarget(homePosition);
}
}
}
if (hitSparkEmitter.isConfigured()) {
hitSparkEmitter.update(static_cast<float>(deltaMs));
}