Files
VMSolidus 1a1a875bdb Revenge Of The Instruments (#22213)
Take 2

<img width="320" height="149" alt="image"
src="https://github.com/user-attachments/assets/21e45078-ef69-4b3c-8b50-208800b82558"
/>

It somehow got even worse over time.

<img width="311" height="164" alt="image"
src="https://github.com/user-attachments/assets/882d9a8e-16f1-4172-9c7b-f741d5bede8d"
/>

And now I have finished fixing it by hand and testing to verify that my
fixes work.


https://github.com/user-attachments/assets/0106593b-4b3f-4e7d-88f0-86c4b22571ff

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com>
2026-04-12 22:19:33 +00:00

82 lines
2.4 KiB
Plaintext

/datum/sound_player
var/range = 15
var/volume = 30
var/max_volume = 50
var/falloff = 2
var/apply_echo = 0
var/virtual_environment_selected = 0
var/env[23]
var/echo[18]
var/datum/weakref/wait = null
var/datum/synthesized_song/song
var/datum/instrument/instrument
var/obj/actual_instrument
var/datum/musical_event_manager/event_manager = new
var/list/datum/sound_token/instrument/tokens = list()
/datum/sound_player/New(datum/real_instrument/where, datum/instrument/what)
src.song = new (src, what)
src.actual_instrument = where
src.echo = GLOB.musical_config.echo_default.Copy()
src.env = GLOB.musical_config.env_default.Copy()
GLOB.instrument_synchronizer.register_global(src, .proc/check_wait)
/datum/sound_player/Destroy()
actual_instrument = null
instrument = null
QDEL_NULL(song)
QDEL_NULL(event_manager)
QDEL_LIST(tokens)
GLOB.instrument_synchronizer.unregister_global(src, .proc/check_wait)
wait = null
. = ..()
/datum/sound_player/proc/check_wait(obj/other)
if(wait && (other != actual_instrument))
var/mob/M = wait.resolve()
if(istype(M) && !shouldStopPlaying(M))
if(get_dist(get_turf(actual_instrument), get_turf(other)) <= 5 && !song.playing)
song.playing = TRUE
song.play_song(M)
wait = null //Either way clean it up
/datum/sound_player/proc/subscribe(datum/sound_token/instrument/newtoken)
if(!istype(newtoken))
CRASH("Non token type passed to subscribe function.")
tokens += newtoken
//Tell it of what we saw prior to it spawning
newtoken.PrivLocateListeners()
/datum/sound_player/proc/unsubscribe(datum/sound_token/instrument/oldtoken)
if(!istype(oldtoken))
CRASH("Non token type passed to unsubscribe function.")
tokens.Remove(oldtoken)
/datum/sound_player/proc/apply_modifications(sound/what, note_num, which_line, which_note) // You don't need to override this
what.volume = volume
what.falloff = falloff
if (GLOB.musical_config.env_settings_available)
what.environment = GLOB.musical_config.is_custom_env(src.virtual_environment_selected) ? src.env : src.virtual_environment_selected
if (src.apply_echo)
what.echo = src.echo
return
/datum/sound_player/proc/shouldStopPlaying(mob/user)
var/obj/structure/synthesized_instrument/S = actual_instrument
var/obj/item/synthesized_instrument/D = actual_instrument
if(istype(S))
return S.shouldStopPlaying(user)
if(istype(D))
return D.shouldStopPlaying(user)
return 1 //Well if you got this far you did something very wrong