diff --git a/baystation12.dme b/baystation12.dme index f17fd812b4..f77e38af3b 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -312,6 +312,7 @@ #include "code\game\machinery\holosign.dm" #include "code\game\machinery\igniter.dm" #include "code\game\machinery\iv_drip.dm" +#include "code\game\machinery\jukebox.dm" #include "code\game\machinery\lightswitch.dm" #include "code\game\machinery\machinery.dm" #include "code\game\machinery\magnet.dm" diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index 8085e9eb02..f48e04a371 100755 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -56,6 +56,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station var/list/all_doors = list() //Added by Strumpetplaya - Alarm Change - Contains a list of doors adjacent to this area var/air_doors_activated = 0 var/list/ambience = list('sound/ambience/ambigen1.ogg','sound/ambience/ambigen3.ogg','sound/ambience/ambigen4.ogg','sound/ambience/ambigen5.ogg','sound/ambience/ambigen6.ogg','sound/ambience/ambigen7.ogg','sound/ambience/ambigen8.ogg','sound/ambience/ambigen9.ogg','sound/ambience/ambigen10.ogg','sound/ambience/ambigen11.ogg','sound/ambience/ambigen12.ogg','sound/ambience/ambigen14.ogg') + var/sound/forced_ambience = null /*Adding a wizard area teleport list because motherfucking lag -- Urist*/ /*I am far too lazy to make it a proper list of areas so I'll just make it run the usual telepot routine at the start of the game*/ diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index bc45640522..8279cde6a4 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -282,10 +282,9 @@ master.used_environ += amount -/area/Entered(A) - var/musVolume = 25 - var/sound = 'sound/ambience/ambigen1.ogg' +var/list/mob/living/forced_ambiance_list = new +/area/Entered(A) if(!istype(A,/mob/living)) return var/mob/living/L = A @@ -300,18 +299,28 @@ L.make_floating(0) L.lastarea = newarea + play_ambience(L) +/area/proc/play_ambience(var/mob/living/L) // Ambience goes down here -- make sure to list each area seperately for ease of adding things in later, thanks! Note: areas adjacent to each other should have the same sounds to prevent cutoff when possible.- LastyScratch if(!(L && L.client && (L.client.prefs.toggles & SOUND_AMBIENCE))) return + // If we previously were in an area with force-played ambiance, stop it. + if(L in forced_ambiance_list) + L << sound(null, channel = 1) + forced_ambiance_list -= L + if(!L.client.ambience_playing) L.client.ambience_playing = 1 L << sound('sound/ambience/shipambience.ogg', repeat = 1, wait = 0, volume = 35, channel = 2) - if(src.ambience.len && prob(35)) - sound = pick(ambience) - - if(world.time > L.client.played + 600) + if(forced_ambience) + forced_ambiance_list += L + L << forced_ambience + else if(src.ambience.len && prob(35)) + if((world.time >= L.client.played + 600)) + var/musVolume = 25 + var/sound = pick(ambience) L << sound(sound, repeat = 0, wait = 0, volume = musVolume, channel = 1) L.client.played = world.time diff --git a/code/game/machinery/jukebox.dm b/code/game/machinery/jukebox.dm new file mode 100644 index 0000000000..4bca09fdcc --- /dev/null +++ b/code/game/machinery/jukebox.dm @@ -0,0 +1,207 @@ +//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32 + +datum/track + var/title + var/sound + +datum/track/New(var/title_name, var/audio) + title = title_name + sound = audio + +/obj/machinery/media/jukebox/ + name = "space jukebox" + icon = 'icons/obj/jukebox.dmi' + icon_state = "jukebox2-nopower" + var/state_base = "jukebox2" + anchored = 1 + density = 1 + power_channel = EQUIP + + var/playing = 0 + + var/datum/track/current_track + var/list/datum/track/tracks = list( + new/datum/track("Beyond", 'sound/ambience/ambispace.ogg'), + new/datum/track("Clouds of Fire", 'sound/music/clouds.s3m'), + new/datum/track("D`Bert", 'sound/music/title2.ogg'), + new/datum/track("D`Fort", 'sound/ambience/song_game.ogg'), + new/datum/track("Floating", 'sound/music/main.ogg'), + new/datum/track("Endless Space", 'sound/music/space.ogg'), + new/datum/track("Part A", 'sound/misc/TestLoop1.ogg'), + new/datum/track("Scratch", 'sound/music/title1.ogg'), + new/datum/track("Trai`Tor", 'sound/music/traitor.ogg'), + ) + +/obj/machinery/media/jukebox/Del() + StopPlaying() + +/obj/machinery/media/jukebox/power_change() + if(!powered(power_channel) || !anchored) + stat |= NOPOWER + else + stat &= ~NOPOWER + + if(stat & (NOPOWER|BROKEN) && playing) + StopPlaying() + update_icon() + +/obj/machinery/media/jukebox/update_icon() + overlays.Cut() + if(stat & (NOPOWER|BROKEN) || !anchored) + if(stat & BROKEN) + icon_state = "[state_base]-broken" + else + icon_state = "[state_base]-nopower" + return + icon_state = state_base + if(playing) + if(emagged) + overlays += "[state_base]-emagged" + else + overlays += "[state_base]-running" + +/obj/machinery/media/jukebox/Topic(href, href_list) + if(..() || !(Adjacent(usr) || istype(usr, /mob/living/silicon))) + return + + if(!anchored) + usr << "You must secure \the [src] first." + return + + if(stat & (NOPOWER|BROKEN)) + usr << "\the [src] doesn't appear to function." + return + + if(href_list["change_track"]) + for(var/datum/track/T in tracks) + if(T.title == href_list["title"]) + current_track = T + StartPlaying() + break + else if(href_list["stop"]) + StopPlaying() + else if(href_list["play"]) + if(emagged) + playsound(src.loc, 'sound/items/AirHorn.ogg', 100, 1) + for(var/mob/living/carbon/M in ohearers(6, src)) + if(istype(M, /mob/living/carbon/human)) + var/mob/living/carbon/human/H = M + if(istype(H.l_ear, /obj/item/clothing/ears/earmuffs) || istype(H.r_ear, /obj/item/clothing/ears/earmuffs)) + continue + M.sleeping = 0 + M.stuttering += 20 + M.ear_deaf += 30 + M.Weaken(3) + if(prob(30)) + M.Stun(10) + M.Paralyse(4) + else + M.make_jittery(500) + spawn(15) + explode() + else if(current_track == null) + usr << "No track selected." + else + StartPlaying() + + return 1 + +/obj/machinery/media/jukebox/interact(mob/user) + if(stat & (NOPOWER|BROKEN)) + usr << "\the [src] doesn't appear to function." + return + + ui_interact(user) + +/obj/machinery/media/jukebox/ui_interact(mob/user, ui_key = "jukebox", var/datum/nanoui/ui = null, var/force_open = 1) + var/title = "RetroBox - Space Style" + var/data[0] + + if(!(stat & (NOPOWER|BROKEN))) + data["current_track"] = current_track != null ? current_track.title : "" + data["playing"] = playing + + var/list/nano_tracks = new + for(var/datum/track/T in tracks) + nano_tracks[++nano_tracks.len] = list("track" = T.title) + + data["tracks"] = nano_tracks + + // update the ui if it exists, returns null if no ui is passed/found + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + if (!ui) + // the ui does not exist, so we'll create a new() one + // for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm + ui = new(user, src, ui_key, "jukebox.tmpl", title, 450, 600) + // when the ui is first opened this is the data it will use + ui.set_initial_data(data) + // open the new ui window + ui.open() + +/obj/machinery/media/jukebox/attack_ai(mob/user as mob) + return src.attack_hand(user) + +/obj/machinery/media/jukebox/attack_hand(var/mob/user as mob) + interact(user) + +/obj/machinery/media/jukebox/proc/explode() + walk_to(src,0) + src.visible_message("\the [src] blows apart!", 1) + + explosion(src.loc, 0, 0, 1, rand(1,2), 1) + + var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread + s.set_up(3, 1, src) + s.start() + + new /obj/effect/decal/cleanable/blood/oil(src.loc) + del(src) + +/obj/machinery/media/jukebox/attackby(obj/item/W as obj, mob/user as mob) + src.add_fingerprint(user) + + if(istype(W, /obj/item/weapon/wrench)) + if(playing) + StopPlaying() + user.visible_message("[user] has [anchored ? "un" : ""]secured \the [src].", "You [anchored ? "un" : ""]secure \the [src].") + anchored = !anchored + playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + power_change() + update_icon() + return + if(istype(W, /obj/item/weapon/card/emag)) + if(!emagged) + emagged = 1 + StopPlaying() + visible_message("\the [src] makes a fizzling sound.") + log_and_message_admins("emagged \the [src]") + update_icon() + return + + return ..() + +/obj/machinery/media/jukebox/proc/StopPlaying() + var/area/A = get_area(src) + // Always kill the current sound + for(var/mob/living/M in mobs_in_area(A)) + M << sound(null, channel = 1) + + A.forced_ambience = null + playing = 0 + update_icon() + + +/obj/machinery/media/jukebox/proc/StartPlaying() + StopPlaying() + if(!current_track) + return + + var/area/A = get_area(src) + A.forced_ambience = sound(current_track.sound, channel = 1, repeat = 1, volume = 25) + + for(var/mob/living/M in mobs_in_area(A)) + if(M.mind) + A.play_ambience(M) + + playing = 1 + update_icon() diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 51676ca04f..774e7afe1c 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -426,3 +426,10 @@ var/list/intents = list("help","disarm","grab","hurt") var/turf/targetturf = get_turf(M) if((targetturf.z == sourceturf.z)) M.show_message("\icon[icon] [message]", 1) + +/proc/mobs_in_area(var/area/A) + var/list/mobs = new + for(var/mob/living/M in mob_list) + if(get_area(M) == A) + mobs += M + return mobs diff --git a/icons/obj/jukebox.dmi b/icons/obj/jukebox.dmi new file mode 100644 index 0000000000..9109049704 Binary files /dev/null and b/icons/obj/jukebox.dmi differ diff --git a/nano/templates/jukebox.tmpl b/nano/templates/jukebox.tmpl new file mode 100644 index 0000000000..f7fac89ff9 --- /dev/null +++ b/nano/templates/jukebox.tmpl @@ -0,0 +1,19 @@ + + +