Working on hostile NPCs, fixing darklands mode for battle zone

This commit is contained in:
Vladislav Khorev committed 2026-11-07 00:03:03 +06:00
1 parent 2e6b93f3ac
commit f4bd3b6bed
24 files changed
+23930 -1457

No files matched your search

+46
View File
@@ -148,6 +148,52 @@ int main()
return fail("Disabled player interacted with location entities");
}
auto& hostileNpc = *state.npcs.at("npc");
hostileNpc.enabled = true;
hostileNpc.canAttack = true;
hostileNpc.hp = hostileNpc.initialHp = 75.f;
hostileNpc.position = Eigen::Vector3f::Zero();
hostileNpc.homePosition = {5.f, 0.f, 0.f};
hostileNpc.stopInPlace();
auto playerOne = std::make_shared<FRG::CharacterState>();
playerOne->configureAsPlayer();
playerOne->enabled = true;
playerOne->position = {3.f, 0.f, 0.f};
auto playerTwo = std::make_shared<FRG::CharacterState>();
playerTwo->configureAsPlayer();
playerTwo->enabled = true;
playerTwo->position = {2.f, 0.f, 0.f};
FRG::PlayerStateMap combatPlayers{
{"player", playerOne}, {"player2", playerTwo}};
state.update(100, combatPlayers, false);
if (hostileNpc.attackTargetId != "player2") {
return fail("Hostile NPC did not select the nearest player");
}
playerOne->position = {1.f, 0.f, 0.f};
playerTwo->position = {4.f, 0.f, 0.f};
state.update(100, combatPlayers, false);
if (hostileNpc.attackTargetId != "player2") {
return fail("Hostile NPC did not retain its living target lock");
}
playerTwo->hp = 0.f;
state.update(100, combatPlayers, false);
if (hostileNpc.attackTargetId != "player") {
return fail("Hostile NPC did not acquire a replacement after target death");
}
playerOne->enabled = false;
state.update(100, combatPlayers, false);
if (!hostileNpc.attackTargetId.empty() ||
hostileNpc.battle_state != 0 ||
(hostileNpc.requestedWalkTarget - hostileNpc.homePosition).norm() >
FRG::CharacterState::kWalkThreshold) {
return fail("Hostile NPC did not return home after losing its target");
}
FRG::CampaignConfig battleZone;
battleZone.id = "battle_zone";
battleZone.questsPath = "resources/config/quests_battle_zone.json";