Tumbleweed | Doors::AnyClickSpecial closed value 2 - lock loop

Started by Nahuel, Fri 09/09/2022 16:32:17

Previous topic - Next topic

Nahuel

Hello guys, I was testing a few things, I'm trying to get some kind of door lock when closed like no door handle from one side.

I think I misunderstood the documentation or there's a bug for Doors:AnyClickSpecial

When using the function for Door interaction and checked the closevalue=2 and I assumed that status would be re-locked (when closed - after being closed), not Locked Forever.
If this is the case, then I was wrong, and all is good and working as expected.

BUT if that is not the case, I think there's an issue, because:
- I get the message "It is locked" when I use Open Door
- And when using the inventory key: "the door is now it's unlocked"
- Again I use Open Door => "It is locked"

Code: ags
function room_FirstLoad()
{
  Doors.SetDoorState(10, 2);
  Doors.InitObject(10, oDoor.ID);
}

function hDoor_AnyClick()
{
  if ( Doors.AnyClickSpecial(10, oDoor.ID, 313, 165, eDirectionUp, 1, 210, 145, eDirectionUp, null, null, 3, 2) == 0 ) Verbs.Unhandled();
}



In any case, one message is incorrect, either it's re-locked forever, either is locked and can be unlocked.

AGS Editor .NET (Build 3.5.1.21)
v3.5.1, September 2022


Ref
Code: ags
/***********************************************************************
 * AnyClickSpecial(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, AudioClip *opensound, AudioClip *closesound, int key, int closevalue)
 * This function extends AnyClick with the following parameters:
 * 
 *   opensound: custom sound to be played, when the door is being opend 
 *   closesound: custom sound to be played, when the door is being closed 
 *   key: the id of the inventory item, that can unlock the door, -1 masterkey, -2 if the door cannot be unlocked 
 *   closevalue: default 0 (closed), but you can also set 2 (locked). 
 ***********************************************************************/
Life isn't a game. Let's develop a life-like-game.

Nahuel

Okay I think I got it, there's an issue here

Code: ags
   else if (Verbs.UsedAction(eGA_UseInv) && key >= 0) {
  ...
       else if (Doors.GetDoorState(door_id) == 2 ) {
          if (verbsData.unlockDoorSound != null) chan = verbsData.unlockDoorSound.Play();
          if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringUnlock])) player.Say(verbsData.door_strings[eDoorStringUnlock]);
          Doors.SetDoorState(door_id, closevalue);


which should be changed closevalue to 0 because otherwise the door was unlocked and relocked in a loop.

Code: ags
  else if (Verbs.UsedAction(eGA_UseInv) && key >= 0) {
          ...
          else if (Doors.GetDoorState(door_id) == 2 ) {
          if (verbsData.unlockDoorSound != null) chan = verbsData.unlockDoorSound.Play();
          if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringUnlock])) player.Say(verbsData.door_strings[eDoorStringUnlock]);
          Doors.SetDoorState(door_id, 0);
Life isn't a game. Let's develop a life-like-game.

eri0o

Hey, I don't understand much of thee door stuff in Tumbleweed, so for the time being I opened an issue for the developer and will wait an answer.

SMF spam blocked by CleanTalk