Area-based Jukebox

A jukebox which alters the ambient sound in the current area and plays it with 100% probability.
Leaving the area stops the ambient sound.
Entering the area resumes playing the ambient sound.
This commit is contained in:
PsiOmega
2014-10-29 00:14:20 +01:00
parent fd0ab349bd
commit 9adb94ff55
7 changed files with 251 additions and 7 deletions

View File

@@ -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"

View File

@@ -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*/

View File

@@ -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

View File

@@ -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 << "<span class='warning'>You must secure \the [src] first.</span>"
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("<span class='danger'>\the [src] blows apart!</span>", 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("<span class='warning'>[user] has [anchored ? "un" : ""]secured \the [src].</span>", "<span class='notice'>You [anchored ? "un" : ""]secure \the [src].</span>")
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("<span class='danger'>\the [src] makes a fizzling sound.</span>")
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()

View File

@@ -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("<span class='info'>\icon[icon] [message]</span>", 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

BIN
icons/obj/jukebox.dmi Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -0,0 +1,19 @@
<!--
Title: Jukebox UI
Used In File(s): \code\game\machinery\jukebox.dm
-->
<H3><span class="white">Current track:</span> <span class="average">{{:data.current_track}}</span></H3>
<div>
{{:helper.link('Play' , 'play', {'play' : 1}, data.playing == 1 ? 'disabled' : null, null)}}
{{:helper.link('Stop' , 'stop', {'stop' : 1}, data.playing == 0 ? 'disabled' : null, null)}}
</div>
<H3><span class="white">Available tracks:</span></H3>
<div class="itemContent">
{{for data.tracks}}
<div class="item">
{{:helper.link( value.track, 'gear', {'change_track' : 1, 'title' : value.track}, value.track == data.current_track ? 'disabled' : null, null)}}
</div>
{{/for}}
</div>