Large, complex rooms/hallways, party of player-characters

I’m trying to convert some old-school Dungeons & Dragons adventures, that are mostly puzzle-solving and very light on combat, to IF.

One problem I’m running into is that there are large, complex rooms and hallways where each 10x10 ft section (5x5 ft section?) of the floor and walls needs to be treated separately for searching or otherwise interacting with (pits, traps, etc). Any recommendations on how to best do this?

To make things more complicated, I am implementing a party of player-characters with the help of the old extension Protagonists by Kevin Norris. Each player-character is located in a different grid cell on the map, for a given room or hallway, so making each of these grid-cells different “rooms” in Inform will further complicate things since the other PCs will not be in the current “room”.

Has anyone else (foolishly) attempted anything like this in IF?

Hmm. My first advice would be to try to redesign things so they fit more closely into the typical Inform 7 paradigm–but that probably wouldn’t be as much fun.

Some of what you’re doing sounds kind of like some stuff I did in Terminator, where the playing space was a big grid. I used a different extension, Multiple Actors by Daniel Stelzer, to allow for commands like “all robots, go north.” You probably don’t want to do that, but if you want to look at the grid movement/visibility stuff, check out chapters 4-6. There’s a lot of complicated code in there because the default is that things in the grid can only see nearby things, and there’s some code to deal with obstructed vision too.

But… probably a better way is to implement the different sections as separate rooms, and make them intervisible by adding their contents to scope (and including some kind of description of their contents after the description of the room you’re currently in). You automatically won’t be able to interact with stuff in different rooms when the action requires touching the thing; you can write a rule for reaching inside to print a nice message about this. Section 3.4 of the Recipe Book, “Continuous Spaces and the Outdoors,” has some stuff about this; I borrowed a bit of code from “Carnivale.”

[code]Big Room North is a room. “You are at the north end of a big room.” The printed name of Big Room North is “North End of Big Room”.
Big Room South is south of Big Room North. “You are at the south end of a big room.” The printed name of BIg Room South is “South End of Big Room”.

A thing can be large or small. A thing is usually large.

After looking in Big Room North when a large thing is in Big Room South:
say “To the south you can see [a list of large things in Big Room South].”

After looking in Big Room South when a large thing is in Big Room North:
say “To the north you can see [a list of large things in Big Room North].”

After deciding the scope of a person (called protag) when the location of protag is Big Room North:
repeat with item running through large things in Big Room South:
place item in scope.
After deciding the scope of a person (called protag) when the location of protag is Big Room South:
repeat with item running through large things in Big Room North:
place item in scope.

A switch is fixed in place in Big Room North. A lever is fixed in place in Big Room South. A jewel is in Big Room North. It is small. A gem is in Big Room South. It is small.

Report going from Big Room North to Big Room South when a small thing is in Big Room South: say “As you move south, you see [a list of small things in Big room South] there.”

Report going from Big Room South to Big Room North when a small thing is in Big Room North: say “As you move north, you see [a list of small things in Big room North] there.”

Rule for reaching inside Big Room South when the location of the person asked is Big Room North:
say “[The person asked] will have to move to the south end of the room to try that.”;
deny access.
Rule for reaching inside Big Room North when the location of the person asked is Big Room South:
say “[The person asked] will have to move to the north end of the room to try that.”;
deny access.

Grunk is a person in Big Room North. Persuasion rule: Persuasion succeeds.

Test me with “Grunk, go south/grunk, x lever/grunk, x switch/grunk, take gem/grunk, drop gem/Grunk, take switch/Grunk, take lever/x switch/x lever/take switch/take lever/x gem/x jewel/south/x switch/x lever/take switch/take lever/x gem/x jewel”.[/code]

And note that you can command Grunk when you can see him, even though you can’t touch him; and he can pick up the gem even though you can’t see it, because he can see it.

Also note that the code is really repetitive, which is bad. If you’re going to do this you’re going to want some kind of way of automating which rooms can be seen from which other rooms in which directions. I think you might want to do this with a table–unfortunately you can’t make a three-place relation between two rooms and a direction, which would be ideal.

EDIT: fixed the deciding the scope rules so they apply to Grunk too.

Hmmm… could this be generalized by making a physical room or hallway a region, and then looping through all other Inform rooms in the same immediate region and add them to scope for visibility? I’d like to avoid coding all kinds of special case code which would be tedious and fragile, if the entire story consists of this approach of “physical rooms and hallways are regions, and 10x10’ areas within them are each rooms”.

It’s perfectly OK that by default you can’t manipulate a thing if you’re not in the same Inform room. That’s what I’d want – you have to actually be standing next to it to reach it.

That’d be one way to do it. Another way might be just to define a relation between rooms (which would let you do things like have an L-shaped “room” where you could see both legs if you were standing at the corner, but you can’t see one room from another). The reason I was concerned about having a three-place relation was that you’ll need to say things like “To the south you can see…”; but you can do that by finding the best route from the location to the room you’re describing. (However, you might want to watch out for the case where you have two rooms that are both to the north–you don’t want two separate sentences saying “To the north you can see…”)

Another option: make a series of rooms using backdrops for big items that are visible in different connected rooms, marking them as “not scenery” so they show up in every room they are in.

[code]Sphinx’s Feet is a room. “You are near the Sphinx’s paws. The bulk of the statue continues north.”

Sphinx’s Flank is a room. “The underbelly of the Sphinx curves above, its front to the south, and its tail to the north.” It is north of Sphinx’s Feet.

Sphinx’s Hindquarters is a room. “You are treated to an unusual view of the Sphinx’s hindquarters. The bulk of the structure stretches to the south.” It is north of Sphinx’s Flank.

The sphinx is a backdrop. “The majesty of the Sphinx’s head towers above, perhaps observing you.”. The description is “Is it human or feline? You figure it won’t give up its riddles so easily.” It is not scenery. Understand “sphinx” and “sphinx’s head” as the sphinx. The sphinx is in Sphinx’s Feet, Sphinx’s Flank, and Sphinx’s hindquarters.
[/code]