In a traditional tabletop game, the Game Master or Game Mechanic is responsible for placing NPCs on the map, and the player doesn't have direct control over when and where they encounter them.
Here are a couple of ways you could implement NPC placement in the game:
Random placement: you could randomly place NPCs on the map at the start of the game or during certain events, such as when the player enters a new area or after a certain amount of time has passed.
Predetermined placement: you could have NPCs placed in specific locations on the map from the beginning of the game, and the player would encounter them as they explore the map.
Dynamic placement: you can mix both above mentioned, for instance, you could have some NPCs placed randomly, and others placed in specific locations based on the player's progress in the game or decisions they make.
For example, you could have a spawn_npcs() function that gets called when the player enters a new area or after a certain amount of time has passed. This function would be responsible for randomly spawning NPCs in the new area, while still keeping some NPCs in predetermined locations based on the player's progress in the game.
You can use this method to place them in the positions where they should be in the map, it's a very intuitive way, that allows you to see which NPCs are active and where they are in the game.
In a traditional tabletop game, the Game Master or Game Mechanic is responsible for placing NPCs on the map, and the player doesn't have direct control over when and where they encounter them.
Here are a couple of ways you could implement NPC placement in the game:
For example, you could have a
spawn_npcs()
function that gets called when the player enters a new area or after a certain amount of time has passed. This function would be responsible for randomly spawning NPCs in the new area, while still keeping some NPCs in predetermined locations based on the player's progress in the game.You can use this method to place them in the positions where they should be in the map, it's a very intuitive way, that allows you to see which NPCs are active and where they are in the game.