2 characters play through 2 games in one environment

Hi. I’m a short time reader, first time seeker of wisdom.

I’m learning Inform and trying to work out broadly what would be the best approach to deliver a game idea I have. I don’t know all the mechanisms there are (far from it) so you might come up with a whole one I don’t even know of yet.

In the game, you start as character A and play through the game in a particular environment. If you get through that, I want to give you the opportunity to go back and play character B in the same situation, and thus which in story terms occurs over the same period of time as character A’s adventures.

I understand I can handle the character switch with the viewpoint character mechanism and a bunch of alternatives in programming where necessary. It also looked to me that the main way you would handle the resetting of the props on the playfield (which will be slightly different for character B) would be via the scene mechanism. So each character’s game would be a scene, with everything and everyone moved into place when the scene begins.

What I can’t work out is - how do I ‘flush’ the game’s memory when you switch from character A to B or vice versa? For instance, won’t things like handled flags persist from scene to scene? I can get my head around manually resetting stuff I programmed myself at scene change, but things like ‘handled’ are built into Inform.

Just on the ‘handled’ topic, does inform keep track of this flag separately for different persons?

So I’m looking for the equivalent of a game baseline initialisation routine for both characters, followed by the execution of the specific playfield setup for either character, A or B, every time you start a game with a new character. Thanks for any help.

I had a similar situation in a project I worked on, and the way I dealt with it was to avoid initializing things with declarative phrases.

e.g. instead of saying “The croquet ball is in the Game Room,” I’d say:

A scene can be episodic. Playing As A is an episodic scene. Playing As A begins when play begins. Playing As B is an episodic scene. Playing As B begins when Playing As A ends.

When an episodic scene begins:
    Now the croquet ball is in the Game Room.

That will take care of most circumstances. You may also have to add a few lines like “now everything is not handled,” but don’t feel intimidated - you can always fix problems like that one at a time.

You may have to avoid tricks like blanking out table rows or saying “[one of]…[stopping],” since those can’t be reset.

This technique can be partially automated by giving each of your items an initial location property and then repeating through all of them to set/reset the initial state:

[code]A thing has an object [or a room] called the starting location.

When an episodic scene begins:
Repeat with item running through things:
now the item is in the starting location of the item.[/code]


Thanks a lot Erik. That’s good stuff to get me thinking.

I wonder if it’s possible to do an actual restart and use a different character? You might be able to place a flag in a file on the player’s computer reflecting whether the game’s been finished or not; if so, allow the player to choose which character to use. That way, if the player wanted to take a break, he could always come back and still have access to the feature without doing another playthrough.

Heh, Gravel, I was just now drawing up a flowchart along those lines.

I think with a few Rules etc. that set things up for one character or the other initially, this might be the easiest way to go.

This discussion might be helpful. I think you could add an option to the Table of Final Player Options that allowed you to restart as the new character – “Would you like to UNDO, RESTART, RESTORE a saved game, QUIT, try some AMUSING things, or play again as EDWARD?” – presumably if the player chooses EDWARD then you have to have a whole routine that resets the game, sets a “playing-as-Edward” flag, does whatever else you need, and then you use “resume the story.” I haven’t tried “resume the story” yet so I’m not sure if this would work.

To let the player play as Edward when the game starts up, I think I would probably just use a password.

From experience, I can tell you that “resume the story” is marred with a couple of complications.

For one thing, there’s a timing situation. I don’t remember the details, but it has to do with turn sequence - I don’t think “resume the story” starts a new turn in the way you would always desire.

For another thing, it does not reset the game world in any way, so it has no advantage over a normal scene change.

Depending on how you plan on running the quest, there need not be a “reset”.

For example, if the game is small enough, you can have two rooms (Desert1 and Desert2) which are identically named to the player and having the second player in the second, non-connected game world “faking it”.

If you need it to be reset, then don’t put starting locations for any object or npc which can be moved. Then just have a “when play begins” which describes where all the objects are using a subroutine.

To re-place:
  now the sword is in the living room;
  now the lantern is in the living room;
  now the nasty-knife is in the attic;

When play begins:

Player2 is a scene. Player2 begins when Player1 ends. When player2 begins: replace.

Of course, every object could have a room called starting-location. During re-place now every thing is in its starting location.

Well, the advantage I was thinking of is that you can do it after the player finishes the game/story. But you could also accomplish that by faking the ending, I suppose. (That is, instead of ending the story finally, go to a scene during which the player is asked to Restart, Restore, play as Edward, etc.)