Working on cutscenes and pathfinding

This commit is contained in:
Vladislav Khorev committed 2026-06-14 22:31:11 +03:00
1 parent 80825e3220
commit 020f31e1e4
17 files changed
+192 -73

No files matched your search

+2 -1
View File
@@ -1004,9 +1004,10 @@ namespace ZL
case SDLK_f:
currentLocation->dialogueSystem.startDialogue("phone_night_aiperi001");
break;
case SDLK_e:
//currentLocation->dialogueSystem.startCutscene("lection_cutscene001"); //.startDialogue("test_cutscene_pan_dialogue");
currentLocation->dialogueSystem.startCutscene("computer_cutscene001"); //.startDialogue("test_cutscene_pan_dialogue");
break;
+27 -1
View File
@@ -10,6 +10,7 @@
#include <memory>
#include <cfloat>
#include <limits>
#include <random>
#include "GameConstants.h"
#include "Character.h"
#include "external/nlohmann/json.hpp"
@@ -1325,6 +1326,23 @@ namespace ZL
static constexpr int64_t kReplanCooldownMs = 500;
static constexpr float kStuckMovementThreshold = 0.02f;
static constexpr int kStuckFrameThreshold = 4;
static constexpr float kStuckPauseMin = 0.5f;
static constexpr float kStuckPauseMax = 1.0f;
const float deltaS = static_cast<float>(deltaMs) / 1000.f;
// Tick down pause timers; replan NPCs when their pause expires.
for (auto it = stuckPauseRemainingS.begin(); it != stuckPauseRemainingS.end();) {
it->second -= deltaS;
if (it->second <= 0.f) {
if (!it->first->isPlayer) {
it->first->forceReplan();
}
it = stuckPauseRemainingS.erase(it);
} else {
++it;
}
}
for (auto it = replanCooldownRemainingMs.begin(); it != replanCooldownRemainingMs.end();) {
it->second -= deltaMs;
@@ -1362,8 +1380,16 @@ namespace ZL
if (c->isMoving()) {
if (moved < kStuckMovementThreshold) {
if (++stuckFrameCounts[c] >= kStuckFrameThreshold) {
c->forceReplan();
c->stopInPlace();
stuckFrameCounts[c] = 0;
if (stuckPauseRemainingS.find(c) == stuckPauseRemainingS.end()) {
if (!c->isPlayer) {
static std::mt19937 rng(std::random_device{}());
std::uniform_real_distribution<float> pauseDist(kStuckPauseMin, kStuckPauseMax);
stuckPauseRemainingS[c] = pauseDist(rng);
}
// Player just stops; replan is not scheduled.
}
}
} else {
stuckFrameCounts[c] = 0;
+1
View File
@@ -183,6 +183,7 @@ namespace ZL
std::unordered_map<Character*, Eigen::Vector3f> lastCharacterPositions;
std::unordered_map<Character*, int64_t> replanCooldownRemainingMs;
std::unordered_map<Character*, int> stuckFrameCounts;
std::unordered_map<Character*, float> stuckPauseRemainingS;
static constexpr float NPC_BUMP_CALLBACK_COOLDOWN = 5.0f;
std::unordered_map<int, float> npcBumpedByPlayerCooldown;