Minor dialogue and UI bug fixing

This commit is contained in:
Vladislav Khorev 2026-06-13 20:58:44 +03:00
parent fff5a9d4aa
commit db456bde09
11 changed files with 2350 additions and 21 deletions

View File

@ -663,7 +663,7 @@
"fadeOutMs": 0,
"fadeInMs": 500,
"endFadeOutMs": 0,
"endFadeInMs": 500,
"endFadeInMs": 0,
"onFadeInCallback": "",
"imageSegments": [
{

View File

@ -1731,8 +1731,19 @@
"speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_phone.png",
"text": "Спасибо большое!",
"next": "line_6",
"next": "setflag_1",
"chatBubble": "out"
},
{
"id": "setflag_1",
"type": "SetFlag",
"effects": [
{
"flag": "asked_help_locked",
"value": 0
}
],
"next": "line_6"
}
]
},

File diff suppressed because it is too large Load Diff

View File

@ -759,6 +759,8 @@ function setDay1setup()
game_api.set_npc_enabled(3, false)
game_api.set_npc_enabled(4, false)
game_api.set_npc_enabled(5, false)
game_api.npc_set_position(1, 0.98998, 0, -7.525)
end
function setDay1MorningSetup()
@ -768,11 +770,9 @@ function setDay1MorningSetup()
game_api.activate_interactive_object("Room_Cover_South_1_001")
game_api.activate_interactive_object("Room_Cover_South_2_001")
--[[if (teacher_door_opened) then
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
else]]
game_api.activate_interactive_object("Room_Cover_South_3_001")
--end
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
game_api.activate_interactive_object("Room_Cover_Main_Hall_001")
@ -806,6 +806,8 @@ function setDay1MorningSetup()
game_api.set_npc_enabled(4, false)
game_api.set_npc_enabled(5, false)
game_api.npc_set_position(1, 0.98998, 0, -7.525)
if morning_did_open_door_index == 1 then
game_api.deactivate_interactive_object("Room_Cover_South_1_001")
game_api.set_object_rotation("Room_S_0_Leaf001", 90)
@ -1004,10 +1006,6 @@ game_api.set_chat_callbacks(
local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife")
local lection_is_over = game_api.getIntValue("lection_is_over")
print("dialogx step 1")
if (player_hold_knife) and (aiperi_talked_after_knife == 0) then
game_api.start_dialogue("dialog_chat_aiperi003")
game_api.setIntValue("aiperi_talked_after_knife", 1)

View File

@ -117,8 +117,19 @@ public:
std::string npcId;
std::string npcName;
float hp = 200.f;
float initialHp = 200.f;
protected:
float hp = 200.f;
public:
float getHp() const {
return hp;
}
void setHp(float newHp) {
hp = newHp;
if (onHpChanged) onHpChanged(hp, initialHp);
}
// The position the NPC should return to if pushed too far away.
// Initialised to the spawn position; updated whenever a script walk command is issued.

View File

@ -204,6 +204,7 @@ namespace ZL
#endif
std::cout << "Load resurces step 4" << std::endl;
ItemRegistry::instance().loadFromJson("resources/config2/items.json", CONST_ZIP_FILE);
@ -213,8 +214,7 @@ namespace ZL
LocationSetup uniInteriorParams;
uniInteriorParams.gameObjectsJsonPath = "resources/config2/gameobjects_uni_interior_x.json";
uniInteriorParams.npcsJsonPath = "resources/config2/npcs_uni_interior.json";
uniInteriorParams.dialoguesJsonPath = "resources/dialogue/uni_interior_dialogues_005.json";
uniInteriorParams.dialoguesJsonPath = "resources/dialogue/uni_interior_dialogues_006.json";
uniInteriorParams.navigationJsonPaths = {
"resources/navigation/uni_interior4_unlocked_n2.txt", //0

View File

@ -379,7 +379,7 @@ namespace ZL
const auto addCharacter = [&](const Character* other) {
if (!other || other == self) return;
if (other->hp <= 0.f || !other->enabled) return;
if (other->getHp() <= 0.f || !other->enabled) return;
if (other->isMoving()) return;
if (distancePointToSegmentXZ(other->position, start, end) > kDynamicObstacleInfluenceDist) {
@ -533,7 +533,7 @@ namespace ZL
//std::cout << "[RAYCAST_NPC] Starting raycast with " << npcs.size() << " npcs" << std::endl;
for (auto& npc : npcs) {
if (npc->hp <= 0.f) {
if (npc->getHp() <= 0.f) {
//std::cout << "[RAYCAST_NPC] " << npc->npcId << " is dead, skipping" << std::endl;
continue;
}
@ -1248,7 +1248,7 @@ namespace ZL
Character* a = characters[i];
Character* b = characters[j];
if (!a || !b) continue;
if (a->hp <= 0.f || b->hp <= 0.f || !a->enabled || !b->enabled) continue;
if (a->getHp() <= 0.f || b->getHp() <= 0.f || !a->enabled || !b->enabled) continue;
const float minDist = a->collisionRadius + b->collisionRadius;
if (minDist <= 0.f) continue;
@ -1322,6 +1322,8 @@ namespace ZL
static constexpr float kMovedEps = 0.05f;
static constexpr float kReplanTriggerDist = 1.8f;
static constexpr int64_t kReplanCooldownMs = 500;
static constexpr float kStuckMovementThreshold = 0.02f;
static constexpr int kStuckFrameThreshold = 4;
for (auto it = replanCooldownRemainingMs.begin(); it != replanCooldownRemainingMs.end();) {
it->second -= deltaMs;
@ -1355,6 +1357,19 @@ namespace ZL
if (moved > kMovedEps) {
movers.push_back(c);
}
if (c->isMoving()) {
if (moved < kStuckMovementThreshold) {
if (++stuckFrameCounts[c] >= kStuckFrameThreshold) {
c->forceReplan();
stuckFrameCounts[c] = 0;
}
} else {
stuckFrameCounts[c] = 0;
}
} else {
stuckFrameCounts[c] = 0;
}
}
if (movers.empty()) {
@ -1366,7 +1381,7 @@ namespace ZL
for (Character* walker : characters) {
if (!walker || walker == mover) continue;
if (walker->hp <= 0.f || !walker->enabled) continue;
if (walker->getHp() <= 0.f || !walker->enabled) continue;
if (!walker->isMoving()) continue;
if (replanCooldownRemainingMs.find(walker) != replanCooldownRemainingMs.end()) {

View File

@ -182,6 +182,7 @@ namespace ZL
std::unordered_map<Character*, Eigen::Vector3f> lastCharacterPositions;
std::unordered_map<Character*, int64_t> replanCooldownRemainingMs;
std::unordered_map<Character*, int> stuckFrameCounts;
static constexpr float NPC_BUMP_CALLBACK_COOLDOWN = 5.0f;
std::unordered_map<int, float> npcBumpedByPlayerCooldown;

View File

@ -1059,6 +1059,7 @@ namespace ZL {
void MenuManager::setDarklandsMode(bool enabled)
{
std::cout << "MenuManager::setDarklandsMode called" << std::endl;
currentIsDarklands_ = enabled;
if (currentLocationName_ == "uni_interior") {
@ -1149,8 +1150,14 @@ namespace ZL {
}
void MenuManager::applyCurrentHealthBar() {
std::cout << "MenuManager::applyCurrentHealthBar called step 1" << std::endl;
std::cout << "currentPlayerMaxHp_ is " << currentPlayerMaxHp_ << std::endl;
if (currentPlayerMaxHp_ <= 0.f) return;
std::cout << "MenuManager::applyCurrentHealthBar called step 2" << std::endl;
std::cout << "currentPlayerHp_ is " << currentPlayerHp_ << std::endl;
const float fraction = std::clamp(currentPlayerHp_ / currentPlayerMaxHp_, 0.f, 1.f);
uiManager.setSliderValue("healthBarFill", fraction);
std::string hpText = std::to_string(static_cast<int>(currentPlayerHp_)) + "/" +
std::to_string(static_cast<int>(currentPlayerMaxHp_));

View File

@ -324,7 +324,7 @@ namespace ZL {
[loc](float value) {
if (loc->player)
{
loc->player->hp = value;
loc->player->setHp(value);
if (loc->player->currentState == AnimationState::ACTION_TO_DEATH || loc->player->currentState == AnimationState::DEATH_IDLE)
{
loc->player->currentState = AnimationState::STAND;
@ -335,7 +335,7 @@ namespace ZL {
// get_player_hp() → float (0 if no player)
api.set_function("get_player_hp",
[loc]() -> float {
return loc->player ? loc->player->hp : 0.0f;
return loc->player ? loc->player->getHp() : 0.0f;
});
// Global integer store — shared across all location scripts.
@ -453,7 +453,7 @@ namespace ZL {
std::cerr << "[script] npc_set_hp: index " << index << " out of range\n";
return;
}
npcs[index]->hp = value;
npcs[index]->setHp(value);
});
// npc_set_position(index, x, y, z) — teleports an NPC instantly, no walking.

View File

@ -391,7 +391,7 @@ namespace ZL {
npc->modelScale = npcData.modelScale;
npc->position = Eigen::Vector3f(npcData.positionX, npcData.positionY, npcData.positionZ);
npc->facingAngle = npcData.facingAngle;
npc->hp = npcData.hp;
npc->setHp(npcData.hp);
npc->initialHp = npcData.hp;
npc->canAttack = npcData.canAttack;
npc->enabled = npcData.enabled;