views:

129

answers:

5

Hi,

I made already a few simple games: enter a level, get up to the end, continue to the next level.
But I'm still wondering how "real" game developers create games with a story.

Here are a few things what a story game has (and where I'm wondering about how they make it) :

  • A sequence of places the player have to visit and do there that, that and that.
  • The first time you see a guy, he says just hello. After a few hours game progress, he gives you a hint to go to a specific place.
  • The first time you walk over a bridge nothing happens, a second time: the bridge falls and you will enter a new location under the bridge.
  • The first time you enter a new location, you will get a lot of information from e.g. villagers, etc. Next time nothing happens

The last points are a bit three times the same.
But, I don't think they have a save-file with a lot of booleans and integers for holding things like:

  • Player did the first time ....
  • Player enters the tenth time that location
  • Player talked for the ###th time to that person
  • etc

When I talk about story games, I'm thinking to:

  • The Legend of Zelda (all games of the serie)
  • Okami

And this are a few examples of level-in-level-out games:

  • Mario
  • Braid
  • Crayon Physics

Thanks

+1  A: 

I think you'll find it varies from genre to genre but while playing it's probably just held in a data structure in memory and when saved it's persisted into the save file (just look at the size of some save files for various games, I've seen multi MB save files).

Lazarus
+4  A: 

Normally these games use a collection of flags to govern behaviour of particular characters and set pieces. This works out to be very similar (often directly equivalent) to a finite state machine, which is a slightly more general and powerful approach to the problem.

  • A FSM tracks the "progress" of a particular quest - what switches are thrown, what conversations are held, etc
  • Each NPC has a FSM to track the "information state of that NPC - each state correlates to a particular phase within the NPC's arc in the game, usually ending in a random-quote state.
  • A saved game could, as one example, track the state of every object in the game universe.

The important part is to design not only the states but also the transitions so that they are as easy to hook up as possible.

Mike Burton
At what point would using an FSM become too unwieldy? I would think that, if your objects have a multitude of properties, there may be a point where you'd end up with too many states to deal with easily.
JAB
There are ways to break down individual behaviours so that that's less of a problem. For example, in a conversation model where you have several lines of inquiry, you might have several state machines which are mostly independent tracking each particular line. Obviously you have to balance the complexity of the model (ability to interplay between plotlines, for example, requires more complex state machines) with the complexity of the technical solution. FSMs are better for governing high-level behaviours, however. They're fine for stories, quests, conversations, but not AI in general.
Mike Burton
+1  A: 

I've never worked on anything like that, but I would assume that the the general approach is to load / save / query a "GameState" structure which holds all the necessary info for the game to perform the appropriate actions.

e.g.

if(GameState.Player.Karma < 0 && GameState.NPCs.BillyTheInnocentLamb.KilledByPlayer)
{
    GameState.NPCs.FredTheShephard.HatesPlayer == true;
}

Now do it a million times and you've got yourself an RPG.

C.McAtackney
`GameState.NPCs.BillyTheInnocentLamb.Killer.equals(GameState.Player)` would make more sense to me, unless you don't want to have inter-NPC relationships and so don't care who killed the lamb if it wasn't the player.
JAB
@JAB: Someone can be killed only once. And it would be the player in this example. So I don't see what the problem is.
Martijn Courteaux
A: 

If you can manage to have a look at Oblivion (fantastic game!) you can try and use their Construction Set that allows you to completely personalise the game by building additional maps quests etc.

By using it you will see that the mechanism is essentially what the others have said: for instance you have several sentences a NPC can say, and it will say one or the other depending on certain conditions. For instance whether you're good or evil, how good you are at convincing him of something or how good you are at bribing him, particular items that you have/have not, but even things like the time of the day!

As you can see any of these thing can be easily expressed with a value (e.g. good/bad can be a value between 0 and 100, same for your bribing skill etc) and then it's just a matter of having lots of ifs :)

nico
A: 

"But, I don't think they have a save-file with a lot of booleans and integers for holding things"

I think they do. :)

Sometimes there might be a formal structure to it: for example, it may be a list of named counters and flags that can be queried from the game's scripting language and which might correspond directly to entries in the design document. The game can increment the counters and flip the flags in response to in-game events and query those flags and counters when deciding which actions to perform, and the whole lot can be easily saved out in a compact format.

Kylotan