diff --git a/Content.Server/Nuke/NukeComponent.cs b/Content.Server/Nuke/NukeComponent.cs index 1f9d3b99f6..503a50758e 100644 --- a/Content.Server/Nuke/NukeComponent.cs +++ b/Content.Server/Nuke/NukeComponent.cs @@ -54,6 +54,11 @@ namespace Content.Server.Nuke [DataField("alertLevelOnActivate")] public string AlertLevelOnActivate = default!; [DataField("alertLevelOnDeactivate")] public string AlertLevelOnDeactivate = default!; + /// + /// This is stored so we can do a funny by making 0 shift the last played note up by 12 semitones (octave) + /// + public int LastPlayedKeypadSemitones = 0; + [DataField("keypadPressSound")] public SoundSpecifier KeypadPressSound = new SoundPathSpecifier("/Audio/Machines/Nuke/general_beep.ogg"); diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index a59a5bccc6..6f08aed792 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -173,7 +173,7 @@ namespace Content.Server.Nuke private void OnKeypadButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadMessage args) { - PlaySound(uid, component.KeypadPressSound, 0.125f, component); + PlayNukeKeypadSound(uid, args.Value, component); if (component.Status != NukeStatus.AWAIT_CODE) return; @@ -358,6 +358,37 @@ namespace Content.Server.Nuke ui.SetState(state); } + private void PlayNukeKeypadSound(EntityUid uid, int number, NukeComponent? component = null) + { + if (!Resolve(uid, ref component)) + return; + + // This is a C mixolydian blues scale. + // 1 2 3 C D Eb + // 4 5 6 E F F# + // 7 8 9 G A Bb + var semitoneShift = number switch + { + 1 => 0, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => 5, + 6 => 6, + 7 => 7, + 8 => 9, + 9 => 10, + 0 => component.LastPlayedKeypadSemitones + 12, + _ => 0 + }; + + // Don't double-dip on the octave shifting + component.LastPlayedKeypadSemitones = number == 0 ? component.LastPlayedKeypadSemitones : semitoneShift; + + SoundSystem.Play(component.KeypadPressSound.GetSound(), Filter.Pvs(uid), + AudioHelpers.ShiftSemitone(semitoneShift).WithVolume(-5f)); + } + private void PlaySound(EntityUid uid, SoundSpecifier sound, float varyPitch = 0f, NukeComponent? component = null) { diff --git a/Resources/Audio/Machines/Nuke/general_beep.ogg b/Resources/Audio/Machines/Nuke/general_beep.ogg index c149eb300a..a8d2e34b49 100644 Binary files a/Resources/Audio/Machines/Nuke/general_beep.ogg and b/Resources/Audio/Machines/Nuke/general_beep.ogg differ