Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old January 30, 2020, 04:45   #1
eastwind
Apprentice
 
Join Date: Dec 2019
Location: Mexico, undisclosed location
Posts: 79
eastwind is on a distinguished road
locked doors?

I was messing around with the town a little bit, and I wanted to add some extra non-shop buildings, with doors, that the player couldn't open. Just for color, to make it look like there were some homes in the town or whatever.

How do I lock a door against the player? I called square_set_door_lock() and gave it a high power, and stepped through the code for that routine and it did it's thing. The lock doesn't show up for the player (because that's the way the trap is defined) but it also doesn't stop the player from opening the door.

Are doors now lockable only against monsters?

Also, I thought I remembered seeing a shockbolt tile of a door with a chain and lock across it, and I can't find that tile anymore either.

Time to punt on this? I can always make the extra buildings doorless, but that's less flavorful.
eastwind is offline   Reply With Quote
Old January 30, 2020, 08:08   #2
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,185
wobbly is on a distinguished road
In cmd-cave.c

Code:
/**
 * Determine if a given grid may be "opened"
 */
static bool do_cmd_open_test(struct loc grid)
{
	/* Must have knowledge */
	if (!square_isknown(cave, grid)) {
		msg("You see nothing there.");
		return false;
	}

	/* Must be a closed door */
	if (!square_iscloseddoor(cave, grid)) {
		msgt(MSG_NOTHING_TO_OPEN, "You see nothing there to open.");
		return false;
	}

	return (true);
}
I'd add an extra check for permalocked door, though you'd have to add the relevant bit in cave-square.c & the routine to set a permalocked door.

Another way you can do it would be to make lock values > x unpickable. Anyway you can look through the door opening code in cmd-cave.c & see if there's anything you are comfortable changing.
wobbly is offline   Reply With Quote
Old January 30, 2020, 09:54   #3
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,185
wobbly is on a distinguished road
A bit hack-ish, but you can just bar lock picking on dlvl 0
wobbly is offline   Reply With Quote
Old January 30, 2020, 21:32   #4
eastwind
Apprentice
 
Join Date: Dec 2019
Location: Mexico, undisclosed location
Posts: 79
eastwind is on a distinguished road
Ok, yeah, thanks, I can make a code change to do it for sure. I was setting power=99 for the lock trap, so I could test for that, or depth==0 as you say, either one.

I was trying to figure out if there was (already) a 'standard' way to do it and follow that, so if not, then inventing a way is no prob.

Thanks

Code:
	/* For newtown, don't allow breaking in buildings there for color */
	if (player->depth == 0) {
		msg("The door is securely locked against adventuresome burglers.");
		return false;
	}

Last edited by eastwind; January 30, 2020 at 21:51.
eastwind is offline   Reply With Quote
Old January 30, 2020, 23:54   #5
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,596
Donated: $40
Pete Mack is on a distinguished road
Don't use depth == 0, because it will screw things up if a mage casts create doors. They will be stuck inside, and in principle can permanently close off a store entrance. (Doors created in town are permanent.)
Pete Mack is offline   Reply With Quote
Old January 31, 2020, 03:41   #6
eastwind
Apprentice
 
Join Date: Dec 2019
Location: Mexico, undisclosed location
Posts: 79
eastwind is on a distinguished road
Ok, so I looked at the caller, do_cmd_open_aux(), set a breakpoint in it, and discovered that trying to move onto the door one time actually rolls 100 times for lock picking. Given that do_cmd_open_aux() enforces a minimum 2% chance of success on each roll, any character with any level of lockpicking skill will succeed against any lock with any power 87% of the time. 1-(.98^100).

When I comment out the minimum 2% enforcement line, I get
"you failed to pick the lock" (100x).

So I could put a specific check in do_cmd_open_aux() for depth == 0 *and* power > 90, and set the power of the doors I make > 90 and then if a wizard creates another door it won't have power > 90 (I assume) and so that new door will be openable.

if ((player->depth == 0) && (j > 90)) {
/* print special you-fail message */
}

and if I put this before j is changed from power to difficulty, it should work, but will print the special you-fail message 100 times each time they try.

IMHO 100 rolls is too many to give on one player try.
eastwind is offline   Reply With Quote
Old January 31, 2020, 03:53   #7
eastwind
Apprentice
 
Join Date: Dec 2019
Location: Mexico, undisclosed location
Posts: 79
eastwind is on a distinguished road
if ((player->depth == 0) && (j > 90))
{
msgt(MSG_LOCKPICK_FAIL, "The town resident has securely locked his home's door against adventurous burglers.");
return(false);
}

I learned returning false makes it not keep trying, so you only get the message once. This has to go above

/* Extract the difficulty XXX XXX XXX */
j = i - (j * 4);

/* Always have a small chance of success */
if (j < 2) j = 2;
eastwind is offline   Reply With Quote
Old January 31, 2020, 04:59   #8
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 9,002
Derakon is on a distinguished road
The 100 attempts is presumably due to auto-repeating safe commands. You'd get fewer repetitions if there was an enemy moving around in your vision, or you were poisoned, or there was something else going on to disturb you. Each attempt still takes a turn.
Derakon is offline   Reply With Quote
Old January 31, 2020, 05:27   #9
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,596
Donated: $40
Pete Mack is on a distinguished road
Just realized I was wrong. The doors in "create doors" are always unlocked, so just banning lock-picking is OK, so long as unlocked doors still open.
Pete Mack is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Doors Mark Vanilla 16 February 15, 2014 22:45
secret doors quarague Vanilla 31 June 3, 2013 11:01
Doors of Doom GrimBob Development 10 September 5, 2011 02:23
Angband doors Timo Pietilš Vanilla 24 September 15, 2010 18:25
[S] [spoiler] Locked chest? Fuma Variants 6 August 18, 2007 22:47


All times are GMT +1. The time now is 11:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.