cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
681 stars 267 forks source link

Items with lockpicking quality are not used first when trying to open locked metal doors #5028

Closed Unrepentant-Atheist closed 2 months ago

Unrepentant-Atheist commented 2 months ago

Describe the bug

If you have an improvised lockpick, a crowbar and a toolbox in your inventory and try to open a closed metal door.

It first tries the crowbar, if you drop the crowbar and try again, it'll use the toolbox (probably due to prying? quality?).

If you then drop the toolbox it'll correctly use the improvised lockpic to open the closed metal door.

Steps To Reproduce

  1. Have lockpick, crowbar and toolbox in invetory
  2. Try open metal door
  3. Fail
  4. ???
  5. Don't profit

Screenshots

No response

Versions and configuration

Additional context

No response

remmark99 commented 2 months ago

This is my first time checking the games code, but I think that happens because metal door has examine action set as "locked_object" which first tries to use prying tool, and only then a lockpicking one, instead of "locked_object_pickable" which goes for lockpicking first: (https://github.com/cataclysmbnteam/Cataclysm-BN/blob/f5a0677b9d94c40ed9d17f299f8e531973a462cf/data/json/furniture_and_terrain/terrain-doors.json#L2313)](https://github.com/cataclysmbnteam/Cataclysm-BN/blob/f5a0677b9d94c40ed9d17f299f8e531973a462cf/data/json/furniture_and_terrain/terrain-doors.json#L2322C1-L2322C39) The fix would probably to simply change this line to "locked_object_pickable", but I guess prying is usually faster and more convenient and that's why it's set this way. Tho I do remember that you sometimes get to pick what you want to do with a door.

RoyalFox2140 commented 2 months ago

And another part of this issue, it should not allow you to use worn hairpins and fancy hairpins for lockpicking. If an item with tool qualities is worn as clothing and not inside a holster/toolbelt it should disallow using it in situations where it may get destroyed.

chaosvolt commented 2 months ago

If no one tackles this I might mess with it, possibly alongside making locked display cases pickable, tomorrow.

chaosvolt commented 2 months ago

Okay so I found a problem here: locked_object_pickable flat-out doesn't even allow you to use a prying tool at all, if you drop your lockpick I found that doors set to use that examine object leave you pining for

Re-reading the OP tells me that locked doors as they are now still freely use lockpicks OR crowbars, which is entirely as expected. I misread this at first and mistakenly assumed that only one tool was being permitted. So the root issue here is the code doesn't give you any sane way to prioritize which tool to use.

I'd close this as invalid except there is a legit flaw in the logic for it. If you have a prying tool, but it lacks the quality to actually work on the door you're targeting, it isn't smart enough to skip the futile attempts to pry and instead go straight to lockpicking: image

chaosvolt commented 2 months ago

So, I see three potential fixes here:

  1. Just swap it so the player will try to lockpick a door first, pry it open second. That would avoid this fuckery I encountered of "having a crowbar prevents you from even attempting" very elegantly but I dunno if players will be okay with that or not.
  2. Have it still try to pry first, but first check that the pry attempt would fail outright due to lack of quality, skip trying to pry outright if so, then come BACK to a pry attempt anyway after checking for lockpicks just so that we can still print the "your tool sucks too much bro"
  3. Since the above method would already require duplicating crowbar iuse code in the examine action to actually work (or moving parts of the iuse to a "calculate if you can do X" function that both can cite), an even more complicated but potentially ideal solution would be to create a function that determines whether lockpicking or prying currently has the highest success rate (automatically putting prying in last place if the best tool can't pry the targeted door) then automatically make you do the most successful action.
Unrepentant-Atheist commented 2 months ago

I'd go with 1., probably performance-wise the best option. And lockpicks are dime-a-dozen and crafted quickly. And high-end lockpicks, reinforced are often mid to late game, and don't break that quick.

The other options seem to be extra code and checks and probably a miniscule performance hit.

chaosvolt commented 2 months ago

Another idea that came up was making it favor prying if you're standing up and lockpicking if you're crouching, which would also be fairly easy to add in and of itself but run into the issue of whether I'd still want to bother trying to make it automatically skip prying if it'd be softlocked by prying difficulty, vs. just trying to explain to the player to crouch if they want to lockpick first...