In-game item management/storage

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • In-game item management/storage

      How do you figure a game like Skyrim keeps track of all the items throughout the entire game? I can go into a house, knock everything off of the kitchen table, spend the next 40 hours playing the game, and go back in the house to see everything exactly where it landed after my roid rage - and I think that's awesome. Is there some kind of mini database that they implement or something? I'm sorry if this has been asked before, I tried searching but didn't find anything.

      I'm sure it's probably a blatantly obvious thing, but I'm a newb so have some mercy. :D
    • You may have heard about Skyrim/Fallout etc having issues with massive save files, I am assuming that they are literally saving the state of every single object/npc (at least the information that matters that is).
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • There are a LOT of ways to handle this. In general, you have a static world that never changes (towns, trees, rocks, etc.) which makes up a huge part of your world. Then you have a set of dynamic objects that all have the ability to change, but even those have pieces of static data.

      For example, let's say I cast whirlwind inside a house. What actually happened? A bunch of positions got changed, but nothing else. You still have a list of objects in that room, they just have different positions. If you eat a piece of bread, all you do is remove that object from the object list and don't save it out. If you have a magic staff with charges, you need to save out those charges, but probably not the model / texture info.

      This gets much more complex with streaming worlds. You effectively have an intermediate file (or set of files) that is written to disk as you travel away from a place. All that data is written out because you can't keep 16 square miles in memory. If you turn around and head back, it streams back in. NPCs are spun up and put on their schedules, scattered objects are put in their rightful place, etc.

      In my own engine, I save actors by component. Each component can be marked as "saved", as can the actor. When I save the game, I loop through all the actors. If the actor is marked as saved, I loop through all components and save any that are marked as saved. This is usually stuff like the StatisticComponent and the TransformComponent. I don't bother saving things like the RenderComponent because that's all static data.

      Each actor has a template, which is the data file used to create the initial version of the actor. When I load the game, I go through each actor that was saved. I first load the template file for that actor and load every component that's not marked as saved. Then I go through the components that were saved and load them. Poof! The actor is back in business.

      My save/load system does a bunch of other stuff as well, but this is the core of the actor section.

      -Rez
    • Sorry for the late resply. Thanks for the response guys! I think I might have been over-thinking it: I was thinking maybe there's a separate file that's saved that keeps track of all that stuff. >< I need to go over all the saving stuff again, kind of glossed over it!

      mholley519: Yeah I remember all that; I never personally experienced it with Skyrim, but a little with Oblivion and a lot with Morrowind :). I poked around online and, whew, there are definitely some large save files!

      rez: Your example really helped me get my head in the right place! So when I get out into the streamed world part of Skyrim, if I suddenly decide to be a minimalist and drop 90% of my inventory, all of those objects have to be written somewhere once I move a certain distance away? What would happen when I save the game, are these separate files opened up and added to the rest of the saved stuff?

      You make it all sound so simple! It makes total sense the way you do it. So the components that weren't saved, are they just set up with their defaults?
    • They are almost certainly streaming level data from a HD save file.

      I've never used the Skyrim engine before (they have a fairly complete editor if you want to play with it) but I suspect the engine divides the "world" into sublevels.

      You know how in first-person shooters there are frequently long hallways or gates that take a while to open? Well this is a smoke&mirror technique used by level designers to
      a) cull unnecessary stuff that doesn't need to be rendered/updated and
      b) if a level and all of its reference assets take more space than is available in ram (as is frequently the case on the 360 and PS3) then you have to load and unload data as you need it. This is lovingly called "streaming." The first layer of organization is frequently the "Sublevel". As you move about the Level you'll stream in and out Sublevels from memory as you enter and leave them. Usually, there isn't enough memory to hold an entire Sublevel in memory (hi-res textures and audio take a lot of space) and as you navigate a Sublevel assets are streamed on the fly. Have you ever noticed in an Unreal3 game how as you get closer/father from a wall how the textures get higher/lower quality? That's streaming.

      Anyways, Skyrim almost certainly has object data associated with whatever they use as Sublevels within the engine. As they move about the map and Sublevel data is streamed in, object data is certainly streamed in as well.


      And now for the first edition of "Electrohamster's Tales from the Pixel Mines"

      Streaming level data is a trick that allows game designers to create levels that require more memory than is available on the target platform(s). This, however introduces numerous technical complications that sometimes aren't always obvious until something breaks in-game.
      I was working on a title once that required streaming Sublevels because of memory limitations and was responsible for some streaming related technical work on the XBox-360. After implementation, I sent a build to QA for verification. Data can only be streamed so fast because of disk limitations and I was concerned the 360 might not perform as well as my desktop PC.
      There are several tell-tale signs that you have a streaming issue. One of these signs is when expected events, such as audio playback, have noticeable delays. QA shortly sent back my build labeled as FAILED for reason, "Begin Level 1. Player soon falls through level into nowhere." Apparently a level designer used a long hallway as a transition point between 2 Sublevels. Because of memory limitations on the 360, a player could run to the end of the hall before the next Sublevel was loaded into RAM, resulting in him "falling" through the map into nowhere. I don't recall if the level designer fixed this by re-balancing the Sublevel divisions or making the hallway longer.