February 25, 2011

Information Management

Hey, all! I just have a quick update on what's going on over this weekend. My apologies for being light on the posts; as I mentioned previously, I'm being slammed by some heavy coursework between now and Thursday. After bouncing some ideas off my older brother, I believe I have the solution to my dialogue woes. Note: this post is about the nuts and bolts underlying the game. No pretty screenshots here! If that's not your cup of tea, you might want to stop reading before you fall asleep.

Basically, this dialogue-box situation is little more than an information management problem. All I really needed to do was to simplify it and whittle it down to its bare bones. When the player talks to an NPC, a dialogue box should appear that says something appropriate for the circumstances. As it turns out, those circumstances are:

  • Which character is talking
  • What objective the player is currently on
  • What level the player is currently on
Those are the three major variables that need to be accounted for. And the best way to do this -- at least at this point -- is through a pseudo-three-dimensional spreadsheet using arrays. Here's the basic funcionality.
  • Each level in the game is assigned a number. When the player enters the level, a variable is switched to reflect which level the player is currently on.
  • The objectives within each level are linear. As you complete each objective within a level, it unlocks the next objective. Therefore, there is a variable that tracks the number of objectives completed within each level.
  • Each NPC (that talks) is also assigned a number. When the player speaks to that NPC, that NPC's number gets dropped into a variable to reflect which NPC is currently talking.
So the pseudocode would be:
  1. Player presses "x" on an NPC, which starts the dialogue box opening event.
  2. Variable global.current_npc = [current NPC's index number]
  3. Check the dialogue library where the following variables coincide: current_level, objectives_completed, npc_index
Think of it as a three-dimensional space, with the level number on the X axis, NPC index on the Z axis, and the number of completed objectives on the Y axis. All throughout this space are points representing the particular chunk of dialogue needed for any particular point in the game. All I needed to do was to build a system that simply goes into that three-dimensional space and points at the correct point. Easy!

No comments:

Post a Comment