Skip to content
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

Merged
merged 3 commits into from
Feb 1, 2020

Conversation

wapcaplet
Copy link
Contributor

Summary

SUMMARY: Bugfixes "Prevent safecracking attempt while wearing earbuds"

Purpose of change

Fixes #36013

Describe the solution

My solution is two-fold:

  • Change the mp3 player (de-)activation to take 1 second of time, instead of 0 seconds
  • Check if player has effect_earphones in the safe-cracking function iexamine::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:

  • Try to crack safe without any tools - "You mess with the dial for a little bit"
  • Spawn mp3 player and stethoscope
  • Examine safe: "Crack safe?" (OK)
  • Activate mp3 player
  • Examine safe: "You can't crack a safe with earbuds on!" (OK)
  • Deactivate mp3 player
  • Wait 1 second for mp3 player to turn off
  • Examine safe: "Crack safe?" (OK)

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).

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.
src/iuse.cpp Outdated Show resolved Hide resolved
@codemime codemime added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Mechanics: Character / Player Character / Player mechanics labels Jan 30, 2020
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.
@wapcaplet
Copy link
Contributor Author

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.

@ZhilkinSerg ZhilkinSerg merged commit 3f4c657 into CleverRaven:master Feb 1, 2020
@wapcaplet wapcaplet deleted the no-headphone-safecracking branch February 24, 2020 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Mechanics: Character / Player Character / Player mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can crack a safe with a stethoscope while simultaneously listening to an mp3 player
4 participants