[MIRROR] Boss music stops on mob death [MDB IGNORE] (#22896)

* Boss music stops on mob death (#77335)

## About The Pull Request

Listens for the death of people fighting w/ boss music and kicks them
out early if they die, which stops the music from playing to them.

## Why It's Good For The Game

You won't have to listen to boss music of something that just killed
you.

## Changelog

🆑
fix: Boss music cuts out when you die.
/🆑

* Boss music stops on mob death

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-08-05 21:48:06 -04:00
committed by GitHub
co-authored by John Willard
parent 445ded933c
commit e2418dad90
+8
View File
@@ -52,9 +52,16 @@
return
players_listening_refs += new_ref
RegisterSignal(new_target, COMSIG_LIVING_DEATH, PROC_REF(on_mob_death))
music_callbacks += addtimer(CALLBACK(src, PROC_REF(clear_target), new_ref), track_duration, TIMER_STOPPABLE)
new_target.playsound_local(new_target, boss_track, 200, FALSE, channel = CHANNEL_BOSS_MUSIC, pressure_affected = FALSE, use_reverb = FALSE)
///Called when a mob listening to boss music dies- ends their music early.
/datum/component/boss_music/proc/on_mob_death(mob/living/source)
SIGNAL_HANDLER
var/datum/weakref/player_ref = WEAKREF(source)
clear_target(player_ref)
///Removes `old_target` from the list of players listening, and stops their music if it is still playing.
///This allows them to have music played again if they re-enter combat with this fauna.
/datum/component/boss_music/proc/clear_target(datum/weakref/old_ref)
@@ -62,4 +69,5 @@
var/mob/old_target = old_ref?.resolve()
if(old_target)
UnregisterSignal(old_target, COMSIG_LIVING_DEATH)
old_target.stop_sound_channel(CHANNEL_BOSS_MUSIC)