feat: Random npc walkabouts

This commit is contained in:
2025-10-05 15:32:57 +01:00
parent 8f148b6894
commit 394366480b
3 changed files with 8 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
#include "game/npc.h"
#include "game/world.h"
#include "core/types.h"
#include "core/math.h"
#include <stdio.h>
@@ -10,8 +11,8 @@ void updateNPC(F32 delta, NPC *npc, World *world) {
npc->waitTime+=delta;
if(npc->waitTime > npc->maxWaitTime) {
npc->mode = NPC_ACTION_WALKING;
U32 next = npc->targetNavNode == 100 ? 20 : 100;
npc->targetNavNode = next; // TODO RANDOM
// TODO change targets to poi's rather than just random nodes
npc->targetNavNode = Random_U32(&world->random, 0, world->navMesh->nodeCount);
printf("Starting to nav path\n");
npc->path = Nav_Path(world->navMesh, npc->currentNavNode, npc->targetNavNode);
printf("done\n");
@@ -26,7 +27,7 @@ void updateNPC(F32 delta, NPC *npc, World *world) {
if(npc->path.nodeCount == npc->pathIndex+1){
printf("Finished! so I'm waiting\n");
npc->mode = NPC_ACTION_WAITING;
npc->maxWaitTime = 20; // TODO RANDOM
npc->maxWaitTime = Random_F32(&world->random, 10, 40);
npc->waitTime = 0;
npc->pathIndex = 0;
return;