-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bionic fingerpick fix #39857
Bionic fingerpick fix #39857
Conversation
Also destroy PSEUDO items after use. Also remove unused consts.
…furniture Also added documentation.
Now it temporarily creates a copy of a fake bionic lockpicks item in player inventory, activates activity with this item, and immediately after that removes this item from inventory.
What happens if an activity using the fingerpick gets cancelled? It seems that the pseudo item would live in the player's inventory forever with the current code which could potentially cause issues. |
|
…em from player's inventory if activity is canceled mid-way
Added a special case if lockpicking activity is canceled mid-way: remove fake bionic lockpick. |
if( has_activity( ACT_LOCKPICK ) ) { | ||
std::vector<item *> bio_picklocks = g->u.items_with( []( const item & itm ) { | ||
return itm.typeId() == "pseudo_bio_picklock"; | ||
} ); | ||
if( !bio_picklocks.empty() ) { | ||
g->u.i_rem( bio_picklocks[0] ); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this still seems a little fragile as this wont be run if the activity is stopped using player_activity::set_to_null()
for example. I think we could instead set a variable on the activity to indicate that it is using the bionic lockpick. Then we could insert the pseudo item into the player's inventory on completion of the activity if that variable is set. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the activity is stopped using player_activity::set_to_null()
I didn't find any cases which could stop this activity by the means of set_to_null
. Could you please list any?
Then we could insert the pseudo item into the player's inventory on completion of the activity if that variable is set.
The item must be inserted prior to completion of activity, not after it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find any cases which could stop this activity by the means of set_to_null. Could you please list any?
It may very well be fine with the current code. When i said "fragile" i meant likely to break and cause bugs in the future if the code is changed.
The item must be inserted prior to completion of activity, not after it.
This behavior isn't set in stone, it could be changed. One way to do this would be to set the first member of player_activity::str_values
to bio_picklock
if using the fingerpick and check for that string before checking the targets
vector at the start of the finish function. If that string is present, the pseudo item could then be inserted into the players inventory and used instead of the first item_location
in the targets
vector. In my opinion, such an approach would be less prone to cause problems in the future.
Summary
SUMMARY: Bugfixes "Bionic fingerpick fix."
Purpose of change
Closes #39740 - Finger Pick CBM Stuck Picking Forever.
Describe the solution
Replaced creating a temporary item and then invoking it with creating a temporary item, placing it into player inventory, assigning activity with this item, and destroying this item immediately after use. Using bionic lockpick will always consume fixed 4 seconds and will always be successful.
Also cancel activity if lockpick item location is lost for some reason.
Also replaced hardcoded list of allowed terrain/furniture within lockpicking actor with check for a newly added
PICKABLE
flag. Added documentation for this flag.Also removed several unused
const
s fromactivity_handlers.cpp
andiexamine.cpp
.Describe alternatives you've considered
Directly use
invoke
method for a temporary created item - no luck.Testing
Debug-added bionic lockpicks CBM to my character. Activated it next to a locked gun safe. Spent 4 seconds, opened safe. Also tested mundane lockpicks on the locked gun safe - worked as intended.
Additional context
There is some strange reason activating the bionic fingerpick CBM and then selecting direction brings the bionic UI menu up front. You can activate the same CBM once again, and select direction once again. Lockpicking activity will occur only after you close the bionic UI menu. I couldn't get rid of this behavior, and I don't know if it's related to my changes.