Character death / reload to a certain point

My searching of the documentation has failed. Are you aware of any resources about character death and ways people have handled it in the past?

I figure the easiest way is to warn the player, “Hey, you can die and end the game in this next section. Be sure to save right here and don’t save again until we tell you you’re clear.” But, I wonder if there are any mechanical ways to do it so the player doesn’t have to worry about such things. Like, upon death it “undo’s” back to a certain marker in the story I’ve set. That sort of thing.

2 Likes

Well, in i7, you’re in complete control of the state of the game, you don’t have to use the ‘end the story finally’ construct. Is really easy to replace it with your own function to rewind rather than kill the player:

Instead of pulling the lever of death:
   say "You have died.";
   rewind the game from lever;

To rewind the game from lever:
   say "Let's rewind.";
   now the lever is off;
   now the player is in the Factory;
   now the player is carrying....
   try looking;
   etc....

sort of thing.

You could easily build a general function to handle all death states.

4 Likes

There were extensions to control when to save the game state for undos (so you could save the game state before the dangerous part, and undo would always bring the player back at that point instead of the last turn), but I don’t know if they still exist/work with the latest Inform. I’ve found this one, which seems to have been updated for 6M62:

I’ve also written an extension that makes it possible to save the game state to and restore it from an external file. I haven’t tested it extensively, so use at your own risk.

It’s basically the permadeath feature extracted from Kerkerkruip, so kudos to the original authors!

4 Likes

I modified Emily Short’s “Recorded Endings” extension to maintain certain world state through death/restart for Baker of Shireton.

It won’t work to restore everything without a lot of work, but I was able to do things like set variables and return an object to the player they’d already acquired with code like this (I may be fuzzy on the exact syntax, but…)

After attacking the ogre with the Ogresmiter Club:
     say "The narrator says, 'Oh, this might be bad... I knew that weapon name would prove a misnomer!'";
     record "Killed by an Ogre" as an ending;
     end the story saying "You were killed by the Ogre!".

When play begins:
     if Killed by an Ogre is a used ending:
     say "The narrator says, 'Oof, that ogre did you in last time. That wasn't fair at all since the club was called Ogresmiter for gosh sakes. Let me help you out...'";
     now the ogre is off-stage;
     now the player carries the Ogresmiter Club;
     now the player is in Ogre's Den.

So unless there are millions of variables and world-states this would be feasible, but previous replies that might let you hack an autosave/restore (or just don’t actually end the game) would probably work better.

The simplest is probably as you said - make sure to warn the player that they’re in danger beforehand. Remind them to save and about the UNDO function. If they don’t listen, that’s the player’s fault and a commonly-accepted pitfall in parser adventure.

2 Likes

This is a really good question, because it’s something I always vaguely wondered about, but I didn’t really attack it, as I never had a need to.

@Natrium729’s seems like the most general, if you can get it working, so I’d recommend it. But for a ham-and-egger approach, I offer this:

If you have the game divided into, say, 10 sections, you could create lists of items that the player had when they reached section 2, e.g.

section_2_start_room is a list of items variable.

after looking in section_2_start_room: now section_2_start_list is the list of items enclosed by the player.

As for dying, you could also create a fake "you have died" e.g.

say "* * You have died * *"
say "But you got to section [max-section], so if you want to start at the beginning of 1-[max-section], you may do so. Or type 0 to kill yourself off for good.";
now section-reload is true;

understand the command "[number]" as sectionreloading when section-reload is true.

carry out sectionreloading:
    if number understood is 0, end the story;
    (go back to start of section "number understood")

Some problems you’ll want to address are – when you rewind, do you want things to be exactly as they were? Or do you want to account for optional puzzles the player may’ve solved?

So obviously you might have to track a few other world variables, and you’d need to test things, too, but I think it would be doable. It’s easier if there’s no way back from, say, checkpoint 3 to checkpoint 2.

This is a way to do things by using fake-death. There’s another way where you can hack the final menu.

1 Like

Here’s something where you can cut and paste a bit of i6-based code to be able to tinker with things in case of death.

include basic screen effects by emily short.

r1 is a room. r2 is a room. r3 is a room.

Include (-

[ ASK_FINAL_QUESTION_R;
	print "^";
	(+ escape mode +) = false;
	while ((+ escape mode +) == false) {
		CarryOutActivity(DEALING_WITH_FINAL_QUESTION_ACT);
		DivideParagraphPoint();
	}
];

-) instead of "Ask The Final Question Rule" in "OrderOfPlay.i6t".

The escape mode is a truth state that varies.

To fully resume the story:
	resume the story;
	now escape mode is true;
	clear the screen;
	say paragraph break.

instead of attacking the player: end the story.

max-section is a number that varies. max-section is 10.
max-achieved-section is a number that varies. max-achieved-section is 1. [this is adjusted up as the player hits certain checkpoints]

Table of Final Question Options (continued)
final question wording	only if victorious	topic	final response rule	final response activity
"Go back to section 1-[max-section]"	false	"[number]"	epilogue rule	--

This is the epilogue rule:
	if number understood < 1 or number understood > 10:
		say "Invalid section.";
	if number understood > max-achieved-section:
		say "Oops! You can't get there yet.";
	if number understood is 1:
		move player to r1;
	else if number understood is 2:
		move player to r2;
	else if number understood is 3:
		move player to r3;
	fully resume the story;
	[reset variables as needed, which may be very tricky indeed];

Note you can change the topic to be just “go back” and then go back to the start of the previous section, without giving the player a choice.

1 Like

A third solution would be to create an outside data file that saved how many sections the character had gotten through, and then on startup allow the character to say “start at section (X).” This could be easily hackable if it just recorded the section, so maybe you could obfuscate it, e.g. by creating a number that mapped to it (for instance, (random 7-digit prime) * (random # from 1 to 100) + current section). Hackable enough if someone really wanted to, but at least people couldn’t do so on a whim and regret it later.

Hope these several posts in a row aren’t too much. Discourse told me to combine posts, but in this case I wanted to separate different ways to do things, as depending on what specifically you want to do, one choice may be better than others.

3 Likes

Thank you, all! This gives me boost up on figuring out how I’m going to handle this.