this post was submitted on 28 Jul 2024
24 points (96.2% liked)

Game Development

2814 readers
1 users here now

Welcome to the game development community! This is a place to talk about and post anything related to the field of game development.

Community Wiki

founded 2 years ago
MODERATORS
 

For context, I am using the bevy engine.

I know that you aren't supposed to store stuff that might contain a lot of information, such as dialogue, NPCs and skills.

I already found a library that helps me store dialogue (bevy_yarnspinner), but I've yet to find such a library for other ressources.

So I was wondering, usually in RPGs, where and how are stats, skills, NPCs (including enemies) and maps are stored? And how does leveling up work?

top 4 comments
sorted by: hot top controversial new old
[–] [email protected] 10 points 4 months ago
[–] Sarazil 8 points 4 months ago

From my limited experience, NPCs come in two varieties, persistent, and instanced. An instanced NPC is a bandit on the street who, if you kill, will drop loot, and then never affect the game ever again. They appear and disappear as easily as a glitchy texture. A persistent NPC, you will probably want to track more of, but even then, you don't have to track everything.

A shopkeeper, you may generate their shop inventory when the player loads the area, but then clear it when the player leaves the town, or a certain amount of in-game time has passed. Same with aggression responses, you could have a list of NPCs who are unhappy with the player, and after a while, they're removed from that list. No need to store the NPCs dynamic opinion on each NPC, just that they are unhappy and when from. When you load the area, you check that table, and the NPC reacts accordingly.

Maps, you'd want to do region by region too. Of course you'll need your data files, terrain, navigation maps or whatever you need, but for the most part, you can choose to only store changes. This means you don't store the whole region in a file, only which containers have been looted, what persistent NPCs have been altered (enraged, seduced, quest actions completed) and such like.

Player stats... yeah, surely you need to just store those in the save file and assign them to the player object. Level up, when you reach the level up conditions, you get to improve. How that works is entirely down to you, the dev. Don't be afraid to play around and see what works.

I'm sure there will be other people with far better advice, but this should help guide you in the right direction.

[–] Astrimedes 3 points 4 months ago* (last edited 4 months ago)

In general you want to put things like item statistics, level up experience point thresholds, and any other "pure data" into some kind of text file or database, and then read it into the memory on load or when you need it.

Look into exporting and importing JSON objects, and write 'types' in your code that are read in from JSON files. Then when the game or level loads, you read in all of the item statistics, for example.

[–] [email protected] 1 points 4 months ago

Hot take: just use code.

Most data that you would store in some kind of encoding would be better as code. Code is fast, compact, versatile and easier to work with than a text, or even a binary encoding.

If the problem is that the data is large, and that would slow down the initial load, you can split it in dynamic linked modules, and lazy load them as needed