Keeping track of "quests"

Started by , Sun 23/03/2008 14:50:17

Previous topic - Next topic

Ghost

This is more of a general question, but basic scripting is involved, so I hope this is the right place to post.

I am trying to find a way to keep track of my game puzzles in a more comfortable way.

It's like this:

A puzzle or "situation"  can be either
* unknown to the player
* known but unsolved
* solved

For example, "Unlock the chest with the big shiny key":
Unknown: The player doesn't know that she will need to unlock the chest at all, and will only comment upon the chest in a generic way: "It's just some old, bulky chest."
Known/Unsolved: The player has learned that something interesting is in the chest, but she has no means to unlock it/hasn't tried to unlock it. Comments on the chest are now more specific: "Without a proper key I can't get this thing open!"
Solved: The player has unlocked the chest and retrieved an important item. Now a new puzzle will "open" up.

I imagine setting up some sort of struct for all puzzles will be the best way, but I am very, very unsure how to implement something like that. I can describe what I need though:
Puzzles should have a name for easy reference.
They should be able to set their state, and objects/hotspots/characters should be able to read the state of puzzles related to them (to allow for specific messages when interacting with them, for example, or to add dialog options and the like).
Plus, if one entry could hold "links" to puzzles that will be triggered (activated) by solving it, this would be a neat bonus.

Let me add that I know my way around the engine and general scripting quite okay, it's just that this problem seems to involve some of the more obscure features, and I would be very glad if someone could point me into the right direction.

Khris

How about a struct:
Code: ags
struct str_puzzle {
  int State;            // 0 = unknown, 1 = known, 2 = solved
  String Name = "";
  int link[10];
}

miguel

The current game I'm working on uses loads of 'Global Ints' and 'If' statments just because I can't work out structures, as soon as I finish it I will learn to code structs before I start anything!
Sometimes it gets really confusing and frustrating, like if I want to check past events and how NPC's relate to them in dialogs!
Working on a RON game!!!!!

DoorKnobHandle

#3
Quote from: KhrisMUC on Sun 23/03/2008 14:59:47
How about a struct:
Code: ags
struct str_puzzle {
  int State;            // 0 = unknown, 1 = known, 2 = solved
  String Name = "";
  int link[10];
}


This is what I'd do, but please, please replace that int with an enumeration... :)

Like this:

Code: ags

enum PuzzleState
{
      Unknown,
      Known,
      Solved
};

struct Puzzle
{
      String Name;
      PuzzleState State;
      [...]
};


Essentially the same, but enumerations are so much easier to read. Now you could access the property like this:

Code: ags

Puzzle main_quest;

[...]

if ( main_quest.State == SOLVED )
      QuitGame ( false );

Ghost

#4
Kris, dhk, this really seems simple enough. I was thinking I'd have to mess around with defines and such. Thanks!

But I'll still have to open all the "links" manually then, yes?

[edit]
No wait, I can write a function to do that each time a puzzle is unlocked/solved...

twin-moon

Quote from: dkh on Sun 23/03/2008 15:27:29
This is what I'd do, but please, please replace that int with an enumeration... :)

Just saying thanks to dhk for answering a question about creating your own keywords I was about to post.
                                    The Grey Zone

SMF spam blocked by CleanTalk