Hey,
I'm trying to create a situation where if the player turns off the lights in a room, everything goes dark, and they become limited to certain actions. I've gotten the darkness sorted for the most part, but I'm having a few issues with the rest of it.
What I would like to happen is that the player becomes unable to move, and only able to use the "look at" and "use" interactions (I'm using a 9 verb MI template). I only want the player to be able to actually 'use' one hotspot - the light switch, and to receive a different message than normal when looking at other items.
For example, if the player tries to walk somewhere it might say "I don't want to wander around in the dark, I might bump into something.",
and if they look at an object/hotspot "I cant make out what that is from here.".
Most of this i can accomplish i think by checking the current background frame in the interaction function for each object/hotspot, thought this is a bit unwieldy, so I wonder if anyone has a neater way of achieving it. The main thing I can't seem to do at the moment is stop the player from being able to walk around still.
I've tried the freeze_player() function from the template, and also mouse.disablemode() to try and disable walking but to no avail.
Any help would be much appreciated, thanks :)
Use RemoveWalkableArea (with the id of the walkable area your player is standing in) to disable it and make the player not able to move.
Use RestoreWalkableArea to bring it back afterwards...
For the second question, you can create a global variable, name it LightIsOn or something similar. set it to true/false when turning it on/off and check the variables instead of the frames. It will make the code more readable...
A simple way of disabling walking would be to turn off the walkable area(s).
To disable certain actions, you could change the Action_Click function (GlobalScript.asc, line 100):
function Action_Click(GUIControl *control, MouseButton button) {
Action tempbutton = getButtonAction(control.ID);
Action t = tempbutton;
if (is_dark) {
if (t == eGA_Close || t == eGA_Open || t == eGA_PickUp || t == eGA_Pull ||
t == eGA_Push || t == eGA_UseInv || t == eGA_GiveTo) {
player.Say("Not in the dark.");
return;
}
}
SetAction(tempbutton);
}
Note that this will result in atypical behavior, i.e. a response by the player before the verb is used on a hotspot.
Thanks to both of you :) I think between the 2 methods I can make something work
Very quick question, am I likely to run into problems later on if I edit the Unhandled() function to give me different responses when i pass if a value of -1? This is what I've done currently to get new defaults when the room is dark, and it seems to work fine so far. It would let me use the same situation later in the game if I wanted too.
Shouldn't be a problem at all.