How would I override "can see"?

I’m trying to have a situation where the player character is asleep (set with a property) and would be unaware of actions that they would normally be able to see. Rather than add an additional check for sleep to every use of can see in the library, how can I change “can see” so I can put the check in there? I already tried:

Visibility rule when not in darkness:
	If the actor is awake:
		There is sufficient light;
	There is insufficient light;

To be clear, you’re referring to actions by other people, which shouldn’t get reported? Maybe one way to do this would be to say “now the location is dark” at the moment when the player goes to sleep and “now the location is lighted” when they wake up. (I haven’t had time to test this, though.)

I thought of that… but then the other person wouldn’t be able to see either. I also need to handle situations where other people besides the player are asleep. Is it even possible to change how Inform handles “can see”?

Not easily. Visibility is handled at the I6 level for efficiency, so you’ll need to change that in I6 if you want a new system.

OK, it seems like you’re actually using the dark/lighted property of rooms independent of asleep/awake, so changing dark/lighted ad hoc wouldn’t help you.

If what you’re mostly concerned with is the game printing out action reports for NPC actions, then the visibility rules won’t help you. Those are concerned with whether the player can see well enough to do their own action, not with whether the player can see things at all in the relevant sense. “Player can see” basically refers to whether the object is in scope, which determines whether the parser can refer to it at all; once that’s taken care of, the visibility rules come in to determine whether there’s enough light to perform the action. (Roughly.)

What you’d need is probably tied up with this, from Writing with Inform §12.13: “Inform’s doctrine is that you witness an action if you can see any of the actor, the noun or the second noun at either the beginning or the end of the action; except that being able to see a backdrop does not count.” Which means that to get this to work directly, you’d have to stop the player from seeing the things when asleep–but this is really difficult to pull off. You can’t remove things from scope the way you can add them in, and you don’t want to get into the visibility rules at a low level.

A couple of things I thought of:

Definition: a person is NPC if it is not the player. First after an NPC person doing something when the player is asleep: rule succeeds.

Since “After” rules stop action processing right there, this would cut off any “after” or “report” rules for NPC action that might print something. If you had an instead or check rule for NPC action that printed something, then that wouldn’t get cut off, but I don’t think the standard check/instead rules for other actors print anything, and if you have a custom rule that does, you can always include a check there.

Another approach would be putting the player in an opaque container when they sleep, and whisking it away when they wake up–or putting them in another room when they sleep, and bringing them back when they wake up. You’d have to do some work to conceal that this was what was going on.

As for handling how other people are asleep–it depends on what they’re supposed to be doing. Usually it doesn’t even matter what other people can see. If you’ve got some rules where it does matter, maybe just put checks on their sleep state there?

Those simple solutions won’t work for my situation. The main thing is that I want alternative reports when the player is asleep - so he’s aware that something is happening, he just can’t see what. The player also has to be in scope for the npcs, since they react to his presence.
If it can be done with I6 hacks, I’m okay with that. It can’t be worse than replacing every instance of “can see” with “can see and is awake” in the standard rules, the various extensions I’m using, and my own code. ugh.

Could the NPCs not instead react to the presence of matt w’s opaque container?

Now that you mention it… I could just change the player’s viewpoint character, couldn’t I? And for NPCs I could switch them with a clone. It sounds like I need to figure out how to use relationships.

This doesn’t seem like it needs to be particularly complicated. Could you not do something like this?

After Gordon doing something in the presence of the player when the player is asleep:
	say "In your half-conscious state, you are dimly aware of Gordon in the room, fumbling around with something."

Two problems with that: One, the player should be aware of what is being done to them - like if Gordon is picking their pockets - but not who is doing it. I probably could do that by changing the print name of Gordon while the player is asleep though. The other is that my after rules change properties as well as output text, and there’s some complicated conditional trees. Yes, I could just move those into instead rules but then I still have to output text there - text which alternates depending on whether or not the player is awake.
I’m really liking the body swapping idea though and I’m looking into what I need to do to make it work.

It sounds like what you want is to change the messages printed when the player is asleep. In that case, instead of trying to hack the visibility code, I think it’d be much simpler just to change the messages to include a check for whether the player is asleep. Hacking the visibility code would leave you with the problem of how to report the actions that the player can’t see now–Inform will just let them pass silently when the player can’t see them, and you’d need a way to check for what’s going on around the player so you can print the report, and it seems like this would create a lot of grief over and above the difficulty of hacking the code. And, well, you need to write messages for all the things that go on when the player is asleep anyway, so it may not be that much additional work to hook them into the preexisting messages.

One thing that may be helpful here is the RESPONSES command. Type “responses all” and you should get the messages that are printed by every extension you have including the Standard Rules. (Assuming that the extensions you are using are in line with what’s recommended for the latest version of I7, which uses responses.) Then you can use the techniques described in the Adaptive Text and Responses chapter of the manual to change them, which again is something you’re going to need to do anyway. Or, as Mike was saying, if you have some sort of blanket case you might want to try to catch it in an After rule.

Worst comes to worst, ctrl-Fing for “can see” in every file won’t be as bad as trying to hack the I6 visibility routines… though it sounds like you’re over that anyway, and maybe the dummy player object would be less annoying.

Suggestion: Move the property changes to carry out rules if you can. The carry out rules are designed to add effects to actions without printing text, and then you can let an After rule stop whatever it prints without worrying about it messing up your Carry out rule (since that’s already taken care of). Although if the property change is too intertwined with the text that might not work, and also it has to be a specific action name (you can do “carry out taking” but not “carry out doing something”).

The problem with carry out is the same as the problem with instead: it’s not practical with how intertwined it all is. I’m going with the dummy player object, I think. That seems to be the most practical solution in my case.

Yay! The body swap is working, now I just have to change several instances of “the player” to the player character’s name so that NPCs can interact with his sleeping body. Yes, it’s a weird game.