Fixing minor bugs, some renaming
This commit is contained in:
1 parent
f3cafd2bf7
commit
63bf981e21
12 files changed
+3186
-1940
No files matched your search
@@ -194,6 +194,59 @@ int main()
|
||||
return fail("Hostile NPC did not return home after losing its target");
|
||||
}
|
||||
|
||||
auto blocker = std::make_shared<FRG::CharacterState>();
|
||||
blocker->enabled = true;
|
||||
blocker->hp = 50.f;
|
||||
blocker->position = {0.8f, 0.f, 0.f};
|
||||
state.npcs["blocker"] = blocker;
|
||||
hostileNpc.position = Eigen::Vector3f::Zero();
|
||||
hostileNpc.homePosition = {5.f, 0.f, 0.f};
|
||||
hostileNpc.attackTargetId = "player";
|
||||
hostileNpc.requestedWalkTarget = playerOne->position;
|
||||
hostileNpc.walkTarget = playerOne->position;
|
||||
hostileNpc.pathWaypoints = {playerOne->position};
|
||||
hostileNpc.currentWaypointIndex = 0;
|
||||
hostileNpc.movementBlockedTicks = 0;
|
||||
playerOne->enabled = true;
|
||||
playerOne->hp = 75.f;
|
||||
playerOne->position = {4.f, 0.f, 0.f};
|
||||
playerTwo->enabled = true;
|
||||
playerTwo->hp = 75.f;
|
||||
playerTwo->position = {2.f, 0.f, 0.f};
|
||||
|
||||
bool blockedRetryRequested = false;
|
||||
for (int tick = 0; tick < 10 && !blockedRetryRequested; ++tick) {
|
||||
const FRG::LocationSimulationEvents events =
|
||||
state.update(100, combatPlayers, false);
|
||||
for (const auto& event : events.characters) {
|
||||
if (event.characterId == "npc" &&
|
||||
event.events.forceNavigationReplan) {
|
||||
blockedRetryRequested = true;
|
||||
if (!state.replanCharacter(
|
||||
"npc", combatPlayers,
|
||||
event.events.blockingCharacterId)) {
|
||||
return fail("Blocked NPC replan was rejected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!blockedRetryRequested ||
|
||||
hostileNpc.attackTargetId != "player2" ||
|
||||
(hostileNpc.requestedWalkTarget - playerTwo->position).norm() >
|
||||
FRG::CharacterState::kWalkThreshold) {
|
||||
return fail("Blocked NPC did not switch to the nearest player");
|
||||
}
|
||||
|
||||
playerOne->enabled = false;
|
||||
playerTwo->enabled = false;
|
||||
if (!state.replanCharacter("npc", combatPlayers, "blocker") ||
|
||||
!hostileNpc.attackTargetId.empty() ||
|
||||
hostileNpc.battle_state != 0 ||
|
||||
(hostileNpc.requestedWalkTarget - hostileNpc.homePosition).norm() >
|
||||
FRG::CharacterState::kWalkThreshold) {
|
||||
return fail("Blocked NPC did not return home without an eligible target");
|
||||
}
|
||||
|
||||
FRG::CampaignConfig battleZone;
|
||||
battleZone.id = "battle_zone";
|
||||
battleZone.questsPath = "resources/config/quests_battle_zone.json";
|
||||
|
||||
Reference in new issue
Block a user