Add more dialogs logic

This commit is contained in:
Vladislav Khorev 2026-04-19 20:28:22 +03:00
parent 61d806a7a1
commit 28a3ace187
5 changed files with 80 additions and 11 deletions

View File

@ -369,7 +369,7 @@
"text": "У нас бензин кончается.",
"next": "line_2"
},
{
{
"id": "line_2",
"type": "Line",
"speaker": "Hero",
@ -652,7 +652,7 @@
"portrait": "resources/hero.png",
"text": ".. Счастливого пути!",
"next": "end_1"
}
},
{
"id": "end_1",
"type": "End"

BIN
resources/hero.png (Stored with Git LFS)

Binary file not shown.

BIN
resources/phone.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -165,15 +165,16 @@ void Location::setup()
police->position = Vector3f{ 1000, -0, 10 };
police->setTarget(police->position);
std::cout << "[LOCATION] Setting up FOREST location (custom models only)" << std::endl;
carPosition ={ 7, 0, -7 + 200 };
carPosition ={ 7, 0, -7 + 300 };
npcCar.position = Vector3f(9, 0, -335) + Vector3f(1000,0,0);
girlfriend->position = Vector3f{ 5, 0, 0.9 + 200 };
girlfriend->position = Vector3f{ 5, 0, 0.9 + 300 };
girlfriend->setTarget(girlfriend->position);
player->position = { 9.5, 0, 0.95 + 200 };
player->position = { 9.5, 0, 0.95 + 300 };
player->setTarget(player->position);
Vector3f azsShift = { -17,0,0 };
@ -1327,7 +1328,9 @@ void Location::setup()
if (girlfriendInCar)
{
if (!dialoguePlayedDrivingGas1 && !dialogueSystem.isActive()) {
if (dialogueSystem.startDialogue("driving_dialogue_gas1")) {
if (dialogueSystem.startDialogue("driving_dialogue_gas1", [this]() {
dialogueDrivingGas1Finished = true;
})) {
dialoguePlayedDrivingGas1 = true;
}
}
@ -1456,6 +1459,35 @@ void Location::setup()
if (locationId == "forest")
{
// Loop the player back in Z until the driving-gas dialogue has been
// completed. Mirrors the village-intro loop in the "default" location,
// but inverted: spawn is at positive Z and the player drives toward Z-.
if (!dialogueDrivingGas1Finished) {
constexpr float tileSize = 100.0f;
constexpr float loopStartZ = -7.0f + 300.0f;
constexpr float loopForwardThreshold = loopStartZ - tileSize;
const Eigen::Vector3f anchor = inCar
? carPosition
: (player ? player->position : Eigen::Vector3f::Zero());
if (anchor.z() < loopForwardThreshold) {
const Eigen::Vector3f shift(0.f, 0.f, tileSize);
if (inCar) {
carPosition += shift;
if (player) player->position = carPosition;
}
else if (player) {
player->position += shift;
player->setTarget(player->position);
player->clearPath();
}
if (npcCar.mode == NpcCar::Mode::FOLLOW_PLAYER || npcCar.mode == NpcCar::Mode::NONE_STAY) {
npcCar.position += shift;
}
}
}
// After the gas-station sale, once the player has walked away from the
// salesperson, the girlfriend chimes in — fires once.
if (!dialoguePlayedGirlfriend1 && dialoguePlayedGas1 && salesperson && player && !dialogueSystem.isActive()) {
@ -1552,9 +1584,41 @@ void Location::setup()
if (locationId == "default")
{
// Loop the player back in Z until the village-intro dialogue has been
// completed. Mirrors the generic tile-wrap teleport above, but constrained
// to the stretch near the car's spawn point so the player can't reach the
// village center prematurely.
if (!dialogueVillageIntro1Finished) {
constexpr float tileSize = 100.0f;
constexpr float loopStartZ = -30.7197f - 300.0f;
constexpr float loopForwardThreshold = loopStartZ + tileSize;
const Eigen::Vector3f anchor = inCar
? carPosition
: (player ? player->position : Eigen::Vector3f::Zero());
if (anchor.z() > loopForwardThreshold) {
const Eigen::Vector3f shift(0.f, 0.f, -tileSize);
if (inCar) {
carPosition += shift;
if (player) player->position = carPosition;
}
else if (player) {
player->position += shift;
player->setTarget(player->position);
player->clearPath();
}
if (npcCar.mode == NpcCar::Mode::FOLLOW_PLAYER || npcCar.mode == NpcCar::Mode::NONE_STAY) {
npcCar.position += shift;
}
}
}
if (player && !dialoguePlayedVillageIntro1 && !dialogueSystem.isActive()) {
if (player->position.z() > -36.f - 300) {
if (dialogueSystem.startDialogue("dialogue_village_intro1")) {
if (dialogueSystem.startDialogue("dialogue_village_intro1", [this]() {
dialogueVillageIntro1Finished = true;
})) {
dialoguePlayedVillageIntro1 = true;
}
}
@ -1586,7 +1650,7 @@ void Location::setup()
if (bandit && player && !dialoguePlayedBanditCaught1) {
Eigen::Vector3f toBandit = bandit->position - player->position;
toBandit.y() = 0.f;
if (toBandit.norm() < 12.0f && !dialogueSystem.isActive()) {
if (toBandit.norm() < 10.0f && !dialogueSystem.isActive()) {
if (dialogueSystem.startDialogue("dialogue_village_caught1_car")) {
dialoguePlayedBanditCaught1 = true;
banditFollowingPlayer = true;
@ -1834,7 +1898,7 @@ void Location::setup()
if (!bandit || !player || !banditFollowingPlayer) return;
constexpr float retargetThreshold = 0.1f;
constexpr float stopDistance = 4.0f;
constexpr float stopDistance = 2.0f;
const Eigen::Vector3f targetPos = inCar ? carPosition : player->position;

View File

@ -113,6 +113,7 @@ namespace ZL
bool dialoguePlayedOffroad = false;
bool dialoguePlayedCrash = false;
bool dialoguePlayedDrivingGas1 = false;
bool dialogueDrivingGas1Finished = false;
bool dialoguePlayedGas1 = false;
bool dialoguePlayedGirlfriend1 = false;
bool dialoguePlayedPhone1 = false;
@ -145,6 +146,7 @@ namespace ZL
bool dialoguePlayedVillageRescue1 = false;
bool dialoguePlayedVillageIntro1 = false;
bool dialogueVillageIntro1Finished = false;
bool dialoguePlayedVillageIntro2 = false;
bool dialoguePlayedVillageFinal1 = false;
bool dialoguePlayedVillageFinal2 = false;