-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Prevent safecracking attempt while wearing earbuds #37528
Prevent safecracking attempt while wearing earbuds #37528
Conversation
To increase realism and game consistency regarding partial deafness Partially fixes CleverRaven#36013 Disallows an attempt at safecracking while player has `effect_earphones`. Due to a loophole caused by mp3 player activation being instantaneous, it is still possible to begin safecracking immediately after putting on the mp3 player (but not after 1 turn has passed with the mp3 active).
With the logic to prevent safecracking with `effect_earphones`, there was an edge case immediately after activating them mp3 player, still allowing a safecrack attempt to be made. Fixes CleverRaven#36013 Turning an mp3 player on or off now takes 1 second, where before it took 0 time. This allows `effect_earphones` to become active before the next action, preventing a safecracking attempt. Unfortunately, it leaves a second edge case when the mp3 player turns off (which also takes only 1 second); there, for some reason I can't determine, the `effect_earphones` status remains alive for a further second. As a side note, this 1-turn delay on activation, and 2-turn delay on deactivation has been clearly visible in-game in the experimental branch for quite some time, using the DeadPeople tileset. You may have noticed after turning on an mp3 player that it takes 1 further second for the icon to appear above your avatar, and that after turning it off, 2 seconds must elapse before the icon disappears. Now, because of the 1-second (de-)activation time, turning it on gives the icon right away, but turning it off still takes 1 more second.
By making the mp3 player take 2 seconds to turn off, the avatar status indicator is correctly updated, and earphone effect is correctly refreshed, allowing a safecrack attempt immediately after turning off the mp3 player. Increasing the mp3 turn-on time to 2 seconds for symmetry.
Alright, I pushed one last change, increasing the mp3 on/off time to 2 seconds. This makes the status indicator above your player update correctly after deactivating the mp3 player, and allows a safecrack attempt immediately afterward (as it should). 2 seconds to turn an mp3 player on or off seems pretty generous, even if you assume you're keeping the ear buds in all the time. Heck, I'll spend 5 minutes just trying to figure out what to listen to. |
Summary
SUMMARY: Bugfixes "Prevent safecracking attempt while wearing earbuds"
Purpose of change
Fixes #36013
Describe the solution
My solution is two-fold:
effect_earphones
in the safe-cracking functioniexamine::safe
; if so deny the attempt with a message: "You can't crack a safe with earbuds on!"Describe alternatives you've considered
I considered leaving mp3 activation time alone, but that would leave a loophole allowing the safecracking attempt to begin immediately after starting the mp3 player. Causing it to take 1 second solved the loophole while also being more realistic.
While I was at it, I considered adding logic to check for for
p.worn_with_flag( "PARTIAL_DEAF" )
but those appear to be fairly rare specialty items that filter loud sounds rather than muting them entirely. Anyway it's outside the scope of this bugfix.Testing
Tested in a debug world - got lucky and found a private resort with a couple of safes to test on:
Additional context
The mp3 player's 1-turn delay on activation, and 2-turn delay on deactivation has been clearly visible in-game in the experimental branch for quite some time, using the DeadPeople tileset. You may have noticed after turning on an mp3 player that it takes 1 further second for the icon to appear above your avatar, and that after turning it off, 2 seconds must elapse before the icon disappears.
Now, because of the 1-second (de-)activation time, turning it on gives the icon right away, but turning it off still takes 1 more second before the icon goes away (and you can attempt the safe crack again - hence the extra "Wait 1 second" step above).