Hello, this might be a super easy question or a super difficult one but I was wondering if there was a way to set up a game where the player can choose to explore the story as either Person A or Person B at the start of the programme.
My concept is a ghost story where the player can chose to be either Person A or Person B. The story will be slightly different depending on which person they choose and they will (hopefully) come to discover the ghost haunting them was the unchosen player character.
I know how to have a person within the game follow the player which might end up being easier than what I want to do, but I was wondering if anyone knew if my idea is possible and had any clue as to how the code for it might work.
I just wrote a game with multiple PCs, and the game switched between them over time rather than the player choosing. I did learn some lessons from doing this incorrectly.
First, location and scenery may be perceived differently by the different characters, or you may want items or NPCs available to Person A that aren’t available to Person B. It is a big mistake to do what I did and code one location in which you have to change descriptions for each PC. The biggest problem I had was with going back and changing all the descriptions, responses of NPCs, etc for each new PC.
So if I were to do it again, I would essentially code two separate games using scenes, and direct the player to scene 1 or 2 depending on which character they chose. It sounds like more work, but I think it would be less work than the way I did it, which was basically finding every single description and action and putting conditions in for each PC.
This is kinda what I was thinking too. It’s not so much that you’re doing twice the work. Having two choices for player character means writing two different experiences, which effectively requires two games.
It may also depend on what complex entities you’re adding to the game (if any) that interact with both characters.
Let’s say there’s a forest, and that both PCs will be going in the forest. If we stop there, it’s easy to create two discrete forests with two different description sets, if you want to do it that way.
Now say there’s an elf wandering the forest. It has mechanics for how and where and when it moves. And when a PC meets it, and they can talk to it. At this point, the elf and its mechanics (and geography) are common to both PCs, but the conversation content won’t be. So this is where you have to start making slightly heavier decisions.
If you’ve made two forests, you now need to account for / program for the elf’s movements in either forest. This may not require much programming, but it is something. If you’ve made one forest, your elf movement programming will stand for either PC.
The conversation will be unaffected, whether you made one or two forests, because it will tend to be instantly funnelled by the moment in which conversation’s initiated. If character A is talking, we go down this conversation tree. If character B is, we go down this other one.
So in the longer view, making a game like this requires a bit of extra planning. You have to have an idea about what things (like my elf) are going to be in it, and consider the work involved in creating duplicate things/systems versus the work involved in creating flexible single entities (e.g. an elf that will work for both players in a single geography). Or as Amanda described it, loading each object with two descriptions. The solution may even involve a bit of both approaches. And it’ll depend on what your brain prefers, too.
This would be the point where I would implement a description object for a thing, instead of deferring to a string. That way I could key a description object as “player character A only”, “player character B only”, or “both player characters”, and have the game pick one, based on which character has focus.
Also, maybe track seen/known stats for each player character, per game thing.
However, that’s my Java programmer side talking about an ideal situation. I think I might know how this would be done in TADS 3 Adv3Lite, but it’s not useful for someone using Inform 7, I think.
EDIT: This is basically the “if-statement in each description for each player” problem that Amanda was talking about, now that I think about it.
Actually, you pretty much do all the same things in Inform, just with Inform’s syntax.
In simple cases, and with only two characters, you can use one if statement in a say phrase:
Carry out cheating:
say "[if the player is Harriet]You wouldn't dare![otherwise]Hm... you do like being tricky, but no, you don't like to be a cheater."
In more complex cases where it’s too icky (or impossible) to nest multiple conditions within a say phrase, you ‘nest’ the whole say phrase (which is sort of like making it an object in java), then you can stuff in as many conditions as you want:
There is a room called Edge Park. The printed name is "The Edge of the Park".
The description of Edge Park is "[Edge_Park_desc]."
To say Edge_Park_desc:
if the player is Harriet, say "You're at the south edge of the park. It's super hot today and the sun is pouring down on the grass and the flowerbeds[sick tree desc].[paragraph break]From here, paths lead north, east and west through the park, and to the south is the picnic area where mum and dad will set up lunch later";
if the player is Demi, say "This is the south edge of the park. The sky is blue and bright today, and the air is warm[sick tree desc].[paragraph break]Paths lead north, east and west, and to the south is the picnic area";
if the turn count is 1 and given_intro is 0 and player is Harriet:
say ".[paragraph break](If this is your first time playing Six, type HELP to learn some very helpful stuff)";
These examples are from my game Six, which has two PCs who play one after the other, all in the same geography and with the same NPCs, but with different prose all the way and some different mechanics. If you want to see the source, it’s in the right Download pane on the IFDB page: Six - Details
This is now 12-years-ago source (in my brain: yikes, doesn’t feel like it) but the overall design of dealing with two PCs / same environment is solid. If you search it for the phrase ‘player is Harriet’, it comes up 483 times.