Adds a bunch of looping audio to computers, grav-gen and telecomms. (#54324)

This commit is contained in:
Qustinnus
2020-10-12 22:37:56 +02:00
committed by GitHub
parent 0ef4856b19
commit 1df07cbae1
22 changed files with 70 additions and 5 deletions

View File

@@ -18,8 +18,12 @@
var/list/atom/output_atoms var/list/atom/output_atoms
var/mid_sounds var/mid_sounds
var/mid_length var/mid_length
///Override for volume of start sound
var/start_volume
var/start_sound var/start_sound
var/start_length var/start_length
///Override for volume of end sound
var/end_volume
var/end_sound var/end_sound
var/chance var/chance
var/volume = 100 var/volume = 100
@@ -28,7 +32,6 @@
var/direct var/direct
var/extra_range = 0 var/extra_range = 0
var/falloff var/falloff
var/timerid var/timerid
/datum/looping_sound/New(list/_output_atoms=list(), start_immediately=FALSE, _direct=FALSE) /datum/looping_sound/New(list/_output_atoms=list(), start_immediately=FALSE, _direct=FALSE)
@@ -72,12 +75,12 @@
if(!timerid) if(!timerid)
timerid = addtimer(CALLBACK(src, .proc/sound_loop, world.time), mid_length, TIMER_CLIENT_TIME | TIMER_STOPPABLE | TIMER_LOOP) timerid = addtimer(CALLBACK(src, .proc/sound_loop, world.time), mid_length, TIMER_CLIENT_TIME | TIMER_STOPPABLE | TIMER_LOOP)
/datum/looping_sound/proc/play(soundfile) /datum/looping_sound/proc/play(soundfile, volume_override)
var/list/atoms_cache = output_atoms var/list/atoms_cache = output_atoms
var/sound/S = sound(soundfile) var/sound/S = sound(soundfile)
if(direct) if(direct)
S.channel = SSsounds.random_available_channel() S.channel = SSsounds.random_available_channel()
S.volume = volume S.volume = volume_override || volume //Use volume as fallback if theres no override
for(var/i in 1 to atoms_cache.len) for(var/i in 1 to atoms_cache.len)
var/atom/thing = atoms_cache[i] var/atom/thing = atoms_cache[i]
if(direct) if(direct)
@@ -93,10 +96,10 @@
/datum/looping_sound/proc/on_start() /datum/looping_sound/proc/on_start()
var/start_wait = 0 var/start_wait = 0
if(start_sound) if(start_sound)
play(start_sound) play(start_sound, start_volume)
start_wait = start_length start_wait = start_length
addtimer(CALLBACK(src, .proc/sound_loop), start_wait, TIMER_CLIENT_TIME) addtimer(CALLBACK(src, .proc/sound_loop), start_wait, TIMER_CLIENT_TIME)
/datum/looping_sound/proc/on_stop() /datum/looping_sound/proc/on_stop()
if(end_sound) if(end_sound)
play(end_sound) play(end_sound, end_volume)

View File

@@ -71,3 +71,28 @@
mid_sounds = list('sound/machines/roulettejackpot.ogg') mid_sounds = list('sound/machines/roulettejackpot.ogg')
volume = 85 volume = 85
vary = TRUE vary = TRUE
/datum/looping_sound/server
mid_sounds = list('sound/machines/tcomms/tcomms_mid1.ogg'=1,'sound/machines/tcomms/tcomms_mid2.ogg'=1,'sound/machines/tcomms/tcomms_mid3.ogg'=1,'sound/machines/tcomms/tcomms_mid4.ogg'=1,\
'sound/machines/tcomms/tcomms_mid5.ogg'=1,'sound/machines/tcomms/tcomms_mid6.ogg'=1,'sound/machines/tcomms/tcomms_mid7.ogg'=1)
mid_length = 1.8 SECONDS
extra_range = -4.5
volume = 50
/datum/looping_sound/computer
start_sound = 'sound/machines/computer/computer_start.ogg'
start_length = 7.2 SECONDS
start_volume = 10
mid_sounds = list('sound/machines/computer/computer_mid1.ogg'=1, 'sound/machines/computer/computer_mid2.ogg'=1)
mid_length = 1.8 SECONDS
end_sound = 'sound/machines/computer/computer_end.ogg'
end_volume = 10
volume = 3
extra_range = -5.5
/datum/looping_sound/gravgen
mid_sounds = list('sound/machines/gravgen/gravgen_mid1.ogg'=1,'sound/machines/gravgen/gravgen_mid2.ogg'=1,'sound/machines/gravgen/gravgen_mid3.ogg'=1,'sound/machines/gravgen/gravgen_mid4.ogg'=1,)
mid_length = 1.8 SECONDS
extra_range = 10
volume = 70

View File

@@ -14,12 +14,19 @@
var/icon_screen = "generic" var/icon_screen = "generic"
var/time_to_screwdrive = 20 var/time_to_screwdrive = 20
var/authenticated = 0 var/authenticated = 0
///Looping audio for when the computer is on
var/datum/looping_sound/computer/soundloop
/obj/machinery/computer/Initialize(mapload, obj/item/circuitboard/C) /obj/machinery/computer/Initialize(mapload, obj/item/circuitboard/C)
. = ..() . = ..()
soundloop = new(list(src))
power_change() power_change()
/obj/machinery/computer/Destroy()
. = ..()
QDEL_NULL(soundloop)
/obj/machinery/computer/process() /obj/machinery/computer/process()
if(machine_stat & (NOPOWER|BROKEN)) if(machine_stat & (NOPOWER|BROKEN))
return FALSE return FALSE
@@ -44,8 +51,10 @@
/obj/machinery/computer/power_change() /obj/machinery/computer/power_change()
. = ..() . = ..()
if(machine_stat & NOPOWER) if(machine_stat & NOPOWER)
soundloop.stop()
set_light(0) set_light(0)
else else
soundloop.start()
set_light(brightness_on) set_light(brightness_on)
/obj/machinery/computer/screwdriver_act(mob/living/user, obj/item/I) /obj/machinery/computer/screwdriver_act(mob/living/user, obj/item/I)

View File

@@ -31,6 +31,8 @@ GLOBAL_LIST_EMPTY(telecomms_list)
var/long_range_link = FALSE // Can you link it across Z levels or on the otherside of the map? (Relay & Hub) var/long_range_link = FALSE // Can you link it across Z levels or on the otherside of the map? (Relay & Hub)
var/hide = FALSE // Is it a hidden machine? var/hide = FALSE // Is it a hidden machine?
///Looping sounds for any servers
var/datum/looping_sound/server/soundloop
/obj/machinery/telecomms/proc/relay_information(datum/signal/subspace/signal, filter, copysig, amount = 20) /obj/machinery/telecomms/proc/relay_information(datum/signal/subspace/signal, filter, copysig, amount = 20)
// relay signal to all linked machinery that are of type [filter]. If signal has been sent [amount] times, stop sending // relay signal to all linked machinery that are of type [filter]. If signal has been sent [amount] times, stop sending
@@ -82,6 +84,7 @@ GLOBAL_LIST_EMPTY(telecomms_list)
/obj/machinery/telecomms/Initialize(mapload) /obj/machinery/telecomms/Initialize(mapload)
. = ..() . = ..()
soundloop = new(list(src), on)
GLOB.telecomms_list += src GLOB.telecomms_list += src
if(mapload && autolinkers.len) if(mapload && autolinkers.len)
return INITIALIZE_HINT_LATELOAD return INITIALIZE_HINT_LATELOAD
@@ -93,6 +96,7 @@ GLOBAL_LIST_EMPTY(telecomms_list)
/obj/machinery/telecomms/Destroy() /obj/machinery/telecomms/Destroy()
GLOB.telecomms_list -= src GLOB.telecomms_list -= src
QDEL_NULL(soundloop)
for(var/obj/machinery/telecomms/comm in GLOB.telecomms_list) for(var/obj/machinery/telecomms/comm in GLOB.telecomms_list)
comm.links -= src comm.links -= src
links = list() links = list()
@@ -127,10 +131,13 @@ GLOBAL_LIST_EMPTY(telecomms_list)
if(toggled) if(toggled)
if(machine_stat & (BROKEN|NOPOWER|EMPED)) // if powered, on. if not powered, off. if too damaged, off if(machine_stat & (BROKEN|NOPOWER|EMPED)) // if powered, on. if not powered, off. if too damaged, off
on = FALSE on = FALSE
soundloop.stop()
else else
on = TRUE on = TRUE
soundloop.start()
else else
on = FALSE on = FALSE
soundloop.stop()
/obj/machinery/telecomms/process(delta_time) /obj/machinery/telecomms/process(delta_time)
update_power() update_power()

View File

@@ -20,6 +20,10 @@
var/last_battery_percent = 0 // Used for deciding if battery percentage has chandged var/last_battery_percent = 0 // Used for deciding if battery percentage has chandged
var/last_world_time = "00:00" var/last_world_time = "00:00"
var/list/last_header_icons var/list/last_header_icons
///Looping sound for when the computer is on
var/datum/looping_sound/computer/soundloop
///Whether or not this modular computer uses the looping sound
var/looping_sound = TRUE
var/base_active_power_usage = 50 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too. var/base_active_power_usage = 50 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
var/base_idle_power_usage = 5 // Power usage when the computer is idle and screen is off (currently only applies to laptops) var/base_idle_power_usage = 5 // Power usage when the computer is idle and screen is off (currently only applies to laptops)
@@ -56,11 +60,14 @@
physical = src physical = src
comp_light_color = "#FFFFFF" comp_light_color = "#FFFFFF"
idle_threads = list() idle_threads = list()
if(looping_sound)
soundloop = new(list(src), enabled)
update_icon() update_icon()
/obj/item/modular_computer/Destroy() /obj/item/modular_computer/Destroy()
kill_program(forced = TRUE) kill_program(forced = TRUE)
STOP_PROCESSING(SSobj, src) STOP_PROCESSING(SSobj, src)
QDEL_NULL(soundloop)
for(var/H in all_components) for(var/H in all_components)
var/obj/item/computer_hardware/CH = all_components[H] var/obj/item/computer_hardware/CH = all_components[H]
if(CH.holder == src) if(CH.holder == src)
@@ -207,6 +214,8 @@
to_chat(user, "<span class='notice'>You send an activation signal to \the [src], turning it on.</span>") to_chat(user, "<span class='notice'>You send an activation signal to \the [src], turning it on.</span>")
else else
to_chat(user, "<span class='notice'>You press the power button and start up \the [src].</span>") to_chat(user, "<span class='notice'>You press the power button and start up \the [src].</span>")
if(looping_sound)
soundloop.start()
enabled = 1 enabled = 1
update_icon() update_icon()
ui_interact(user) ui_interact(user)
@@ -343,6 +352,8 @@
for(var/datum/computer_file/program/P in idle_threads) for(var/datum/computer_file/program/P in idle_threads)
P.kill_program(forced = TRUE) P.kill_program(forced = TRUE)
idle_threads.Remove(P) idle_threads.Remove(P)
if(looping_sound)
soundloop.stop()
if(loud) if(loud)
physical.visible_message("<span class='notice'>\The [src] shuts down.</span>") physical.visible_message("<span class='notice'>\The [src] shuts down.</span>")
enabled = 0 enabled = 0

View File

@@ -14,6 +14,7 @@
slot_flags = ITEM_SLOT_ID | ITEM_SLOT_BELT slot_flags = ITEM_SLOT_ID | ITEM_SLOT_BELT
has_light = TRUE //LED flashlight! has_light = TRUE //LED flashlight!
comp_light_luminosity = 2.3 //Same as the PDA comp_light_luminosity = 2.3 //Same as the PDA
looping_sound = FALSE
var/has_variants = TRUE var/has_variants = TRUE
var/finish_color = null var/finish_color = null

View File

@@ -27,6 +27,12 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
use_power = NO_POWER_USE use_power = NO_POWER_USE
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
var/sprite_number = 0 var/sprite_number = 0
///Audio for when the gravgen is on
var/datum/looping_sound/gravgen/soundloop
/obj/machinery/gravity_generator/main/Initialize()
. = ..()
soundloop = new(list(src), TRUE)
/obj/machinery/gravity_generator/safe_throw_at(atom/target, range, speed, mob/thrower, spin = TRUE, diagonals_first = FALSE, datum/callback/callback, force = MOVE_FORCE_STRONG, gentle = FALSE) /obj/machinery/gravity_generator/safe_throw_at(atom/target, range, speed, mob/thrower, spin = TRUE, diagonals_first = FALSE, datum/callback/callback, force = MOVE_FORCE_STRONG, gentle = FALSE)
return FALSE return FALSE
@@ -65,6 +71,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
if(main_part) if(main_part)
qdel(main_part) qdel(main_part)
set_broken() set_broken()
QDEL_NULL(soundloop)
return ..() return ..()
// //
@@ -282,11 +289,13 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
var/alert = FALSE var/alert = FALSE
if(SSticker.IsRoundInProgress()) if(SSticker.IsRoundInProgress())
if(on) // If we turned on and the game is live. if(on) // If we turned on and the game is live.
soundloop.start()
if(gravity_in_level() == FALSE) if(gravity_in_level() == FALSE)
alert = TRUE alert = TRUE
investigate_log("was brought online and is now producing gravity for this level.", INVESTIGATE_GRAVITY) investigate_log("was brought online and is now producing gravity for this level.", INVESTIGATE_GRAVITY)
message_admins("The gravity generator was brought online [ADMIN_VERBOSEJMP(src)]") message_admins("The gravity generator was brought online [ADMIN_VERBOSEJMP(src)]")
else else
soundloop.stop()
if(gravity_in_level() == TRUE) if(gravity_in_level() == TRUE)
alert = TRUE alert = TRUE
investigate_log("was brought offline and there is now no gravity for this level.", INVESTIGATE_GRAVITY) investigate_log("was brought offline and there is now no gravity for this level.", INVESTIGATE_GRAVITY)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.