Working on fixing dorm bugs and some uni

This commit is contained in:
Vladislav Khorev committed 2026-06-16 14:05:18 +03:00
1 parent 939136c705
commit c891161d69
16 files changed
+200 -230

No files matched your search

+7 -2
View File
@@ -240,7 +240,7 @@ void Character::update(int64_t deltaMs) {
lookTarget = attackTarget->position;
}
targetFacingAngle = facingAngle;
//targetFacingAngle = facingAngle;
if (currentState == AnimationState::WALK || currentState == AnimationState::STAND)
{
@@ -294,7 +294,7 @@ void Character::update(int64_t deltaMs) {
}
}
else {
targetFacingAngle = facingAngle;
//targetFacingAngle = facingAngle;
}
}
}
@@ -355,6 +355,9 @@ void Character::update(int64_t deltaMs) {
while (angleDiff > static_cast<float>(M_PI)) angleDiff -= 2.f * static_cast<float>(M_PI);
while (angleDiff < -static_cast<float>(M_PI)) angleDiff += 2.f * static_cast<float>(M_PI);
float rotStep = rotationSpeed * static_cast<float>(deltaMs) / 1000.f;
//std::cout << this->npcName << " targetFacingAngle: " << targetFacingAngle << " radians, " << (targetFacingAngle * 180.f / static_cast<float>(M_PI)) << " degrees\n";
//std::cout << this->npcName << " facingAngle: " << facingAngle << " radians, " << (facingAngle * 180.f / static_cast<float>(M_PI)) << " degrees\n";
if (std::fabs(angleDiff) <= rotStep) {
facingAngle = targetFacingAngle;
// One-shot face-target: once aligned, stop tracking. Otherwise the NPC
@@ -362,6 +365,8 @@ void Character::update(int64_t deltaMs) {
// started, even as the player moved away.
faceTarget = nullptr;
} else {
//std::cout << this->npcName << " facingAngle difference: " << angleDiff << " radians, " << (angleDiff * 180.f / static_cast<float>(M_PI)) << " degrees\n";
facingAngle += (angleDiff > 0.f ? rotStep : -rotStep);
}
+11 -4
View File
@@ -14,7 +14,6 @@
#include <android/log.h>
#endif
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif
@@ -223,6 +222,14 @@ namespace ZL
#endif
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_aiperi.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_ghost.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_hero_neutral.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_hero_think.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_phone.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_student_boy.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_student_girl.png", CONST_ZIP_FILE);
renderer.textureManager.LoadFromPng("resources/dialogue/portrait_teacher.png", CONST_ZIP_FILE);
std::cout << "Load resurces step 4" << std::endl;
@@ -380,12 +387,12 @@ namespace ZL
"resources/navigation/dorm3_all_open.json",
};*/
params_dorm.navigationJsonPaths = {
"resources/navigation/dorm3_bca.txt",
"resources/navigation/dorm3_ca.txt",
"resources/navigation/dorm3_bca.txt", //0
"resources/navigation/dorm3_ca.txt", //1
"resources/navigation/dorm3_ba.txt",
"resources/navigation/dorm3_a.txt",
"resources/navigation/dorm3_b.txt",
"resources/navigation/dorm3_all_open.txt",
"resources/navigation/dorm3_all_open.txt", //5
};
params_dorm.teleportsJsonPath = "resources/config2/teleports_dorm.json";
+30
View File
@@ -67,6 +67,21 @@ namespace ZL {
npcs[index]->setTarget(Eigen::Vector3f(x, y, z), std::move(cb));
});
api.set_function("npc_rotate_to",
[loc](int index, float angle) {
auto& npcs = loc->npcs;
if (index < 0 || index >= static_cast<int>(npcs.size())) {
std::cerr << "[script] npc_rotate_to: index " << index
<< " out of range (0.." << npcs.size() - 1 << ")\n";
return;
}
const float rad = angle * static_cast<float>(M_PI) / 180.f;
std::cout << "[script] npc_rotate_to: index " << index << " angle " << angle << " degrees (" << rad << " radians)" << std::endl;
npcs[index]->targetFacingAngle = rad;
});
api.set_function("player_walk_to",
[loc](float x, float y, float z, sol::object on_arrived) {
@@ -502,6 +517,21 @@ namespace ZL {
npcs[index]->battle_state = 0;
});
api.set_function("player_set_position",
[loc](float x, float y, float z) {
Eigen::Vector3f pos(x, y, z);
loc->player->position = pos;
loc->player->homePosition = pos;
loc->player->setTarget(pos);
});
api.set_function("player_set_rotation",
[loc](float angle) {
const float rad = angle * static_cast<float>(M_PI) / 180.f;
loc->player->facingAngle = rad;
loc->player->targetFacingAngle = rad;
});
// move_object(name, x, y, z, duration_sec [, on_complete])
api.set_function("move_object",
[loc](const std::string& name, float x, float y, float z,
+4 -4
View File
@@ -12,8 +12,8 @@ bool CutsceneOverlay::init(Renderer& renderer, const std::string& zipFile) {
rendererRef = &renderer;
zipFilename = zipFile;
choiceMainTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_main.png", zipFile);
choiceOptionalTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_optional.png", zipFile);
//choiceMainTexture = renderer.textureManager.LoadFchoiceMainTextureromPng("resources/dialogue/choice_main.png", zipFile);
//choiceOptionalTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_optional.png", zipFile);
cutsceneSubtitleTexture = renderer.textureManager.LoadFromPng("resources/dialogue/cutscene_subtitle_bg.png", zipFile);
nameRenderer = std::make_unique<TextRenderer>();
@@ -176,7 +176,7 @@ void CutsceneOverlay::draw(Renderer& renderer, const ZL::Dialogue::PresentationM
}
if (model.cutsceneSkippable && cutsceneSkipHintVisible) {
const UiRect hintBg{ W - 250.0f, H - 62.0f, 226.0f, 42.0f };
/*const UiRect hintBg{W - 250.0f, H - 62.0f, 226.0f, 42.0f};
skipHintBgQuad.rebuild(hintBg);
glBindTexture(GL_TEXTURE_2D, choiceOptionalTexture->getTexID());
renderer.DrawVertexRenderStruct(skipHintBgQuad.mesh);
@@ -194,7 +194,7 @@ void CutsceneOverlay::draw(Renderer& renderer, const ZL::Dialogue::PresentationM
skipProgressFillQuad.rebuild(progressFill);
glBindTexture(GL_TEXTURE_2D, choiceMainTexture->getTexID());
renderer.DrawVertexRenderStruct(skipProgressFillQuad.mesh);
}
}*/
}
renderer.PopMatrix();
+2 -2
View File
@@ -28,8 +28,8 @@ private:
Renderer* rendererRef = nullptr;
std::string zipFilename;
std::shared_ptr<Texture> choiceMainTexture;
std::shared_ptr<Texture> choiceOptionalTexture;
//std::shared_ptr<Texture> choiceMainTexture;
//std::shared_ptr<Texture> choiceOptionalTexture;
std::shared_ptr<Texture> cutsceneSubtitleTexture;
mutable UiRect lastCutsceneAdvanceRect{};