0
\$\begingroup\$

I've been looking into making a small game where you would walk around and do puzzles (perhaps do some combat if I can get the basic framework going). So far, Googling for general game patterns used in these types of situations produces an event-oriented approach, I.e, send an event every time the player moves / tries to interact with anything / does anything potentially of interest. This makes sense. What doesn't make sense is the storage of items / game state. I found a similar question concerning textual RPGs, but all the techniques seem to be inflexible. Suppose that I have two areas, a forest and a city. In the city, Bob wants you to go into the forest and find an apple or two to satisfy his hunger. He gives you two different responses (the first time he asks you for the above favor, and any other time he sorrowfully reminds you that he's slowly starving while you're doodling around). Here is my thought process.

  1. Player enters area--load a Lua script pertaining to said area that registers necessary event hooks (hook like interact with bob)
  2. When the player talks to Bob, assign a "tag" to the player.

Here is the issue: What should the tag be? I can't just do "talked_with_bob" because there may be multiple Bobs in the game. I can't assign a tag within the script that says "talk_with_bob_at_the_city" because although there will be no map duplicates, what if the map names change? That would force me to go and reupdate my scripts. Almost done. I promise. Let's say that you do figure out your tag problem. You go into the forest, grab an apple, but as you were leaving you spot a chest. You open it, find some loot, and move on. My question is... should this also be tagged, and if so, how? A chest shouldn't magically refill every time you enter the map, so it must store its state somewhere, hence the tag idea, but then we're back to the problem of generating reliable names for the tag(s) and more importantly, constructing valid tag queries. As an aside, if I create a "tag" for every single event that has the possibility to be different, won't this grow huge, or should I not worry about memory constraints until it becomes a problem? The question I linked to above was the closest match to my query, but as you can see it doesn't entirely address it. I appreciate any insight

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I think this issue is about data persistence. The point is how to organize the game save data.

There is no one-size-fits-all solution to this. But in this special case you could try an object oriented approach. It's easier to expand.

For example, you don't need a "tag" named "talked_with_bob" in player's save data , but a variable named "is_talked" or "talked_times" in Bob's.

If there is more advanced requirements(record talk times by different place), you can define some data structure else for Bob. Such as a dictionary "talk_times_map", the place you talk for the key and the times for the value.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .