Skip to content

Commit

Permalink
Refactors Dance Machine + deletes a bunch of sound files (tgstation#3…
Browse files Browse the repository at this point in the history
…6815)

* Refactors Dance Machine

* Removes sound from netherworld

* Fixes icons

* More fixes

* QDEL_LIST

* Sanity check

* Matches delimiter to README

* qdel_list

* Fixes disco version of machine
  • Loading branch information
KorPhaeron authored and vuonojenmustaturska committed Apr 1, 2018
1 parent 8c3804d commit 4471461
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 111 deletions.
2 changes: 1 addition & 1 deletion _maps/shuttles/emergency_discoinferno.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
/turf/open/floor/mineral/plasma,
/area/shuttle/escape)
"v" = (
/obj/machinery/disco/indestructible,
/obj/machinery/jukebox/disco/indestructible,
/turf/open/floor/light/colour_cycle,
/area/shuttle/escape)
"w" = (
Expand Down
186 changes: 77 additions & 109 deletions code/game/machinery/dance_machine.dm
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
// DISCO DANCE MACHINE - For admin, engineering and shuttle memes/abuse.

/obj/machinery/disco
name = "radiant dance machine mark IV"
desc = "The first three prototypes were discontinued after mass casualty incidents."
icon = 'icons/obj/lighting.dmi'
icon_state = "disco0"
anchored = FALSE
/obj/machinery/jukebox
name = "jukebox"
desc = "A classic music player.."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "jukebox"
anchored = TRUE
verb_say = "states"
density = TRUE
req_access = list(ACCESS_ENGINE)
req_access = list(ACCESS_BAR)
var/active = FALSE
var/list/rangers = list()
var/charge = 35
var/stop = 0
var/list/songs = list()
var/datum/track/selection = null

/obj/machinery/jukebox/disco
name = "radiant dance machine mark IV"
desc = "The first three prototypes were discontinued after mass casualty incidents."
icon_state = "disco"
req_access = list(ACCESS_ENGINE)
anchored = FALSE
var/list/spotlights = list()
var/list/sparkles = list()
var/static/list/songs = list(
new /datum/track("Engineering's Basic Beat", 'sound/misc/disco.ogg', 600, 5),
new /datum/track("Engineering's Domination Dance", 'sound/misc/e1m1.ogg', 950, 6),
new /datum/track("Engineering's Superiority Shimmy", 'sound/misc/paradox.ogg', 2400, 4),
new /datum/track("Engineering's Ultimate High-Energy Hustle", 'sound/misc/boogie2.ogg', 1770, 5),
)
var/datum/track/selection = null

/obj/machinery/disco/indestructible
/obj/machinery/jukebox/disco/indestructible
name = "radiant dance machine mark V"
desc = "Now redesigned with data gathered from the extensive disco and plasma research."
req_access = null
Expand All @@ -36,37 +35,34 @@
var/song_path = null
var/song_length = 0
var/song_beat = 0
var/GBP_required = 0

/datum/track/New(name, path, length, beat)
song_name = name
song_path = path
song_length = length
song_beat = beat

/obj/machinery/disco/proc/add_track(file, name, length, beat)
var/sound/S = file
if(!istype(S))
return
if(!name)
name = "[file]"
if(!beat)
beat = 5
if(!length)
length = 2400 //Unless there's a way to discern via BYOND.
var/datum/track/T = new /datum/track(name, file, length, beat)
songs += T

/obj/machinery/disco/Initialize()
/obj/machinery/jukebox/Initialize()
. = ..()
selection = songs[1]
var/list/tracks = flist("config/jukebox_music/sounds/")

for(var/S in tracks)
var/datum/track/T = new()
T.song_path = file("config/jukebox_music/sounds/[S]")
var/list/L = splittext(S,"+")
T.song_name = L[1]
T.song_length = text2num(L[2])
T.song_beat = text2num(L[3])
songs |= T

if(songs.len)
selection = pick(songs)

/obj/machinery/disco/Destroy()
/obj/machinery/jukebox/Destroy()
dance_over()
return ..()

/obj/machinery/disco/attackby(obj/item/O, mob/user, params)
/obj/machinery/jukebox/attackby(obj/item/O, mob/user, params)
if(!active && !(flags_1 & NODECONSTRUCT_1))
if(istype(O, /obj/item/wrench))
if(!anchored && !isinspace())
Expand All @@ -79,49 +75,40 @@
return
return ..()

/obj/machinery/disco/update_icon()
/obj/machinery/jukebox/update_icon()
if(active)
icon_state = "disco1"
icon_state = "[initial(icon_state)]-active"
else
icon_state = "disco0"
..()

icon_state = "[initial(icon_state)]"

/obj/machinery/disco/ui_interact(mob/user)
/obj/machinery/jukebox/ui_interact(mob/user)
. = ..()
if (!anchored)
to_chat(user,"<span class='warning'>This device must be anchored by a wrench!</span>")
return
if(!allowed(user))
to_chat(user,"<span class='warning'>Error: Access Denied - Message: Only the engineering department can be trusted with this kind of power.</span>")
to_chat(user,"<span class='warning'>Error: Access Denied.</span>")
user.playsound_local(src,'sound/misc/compiler-failure.ogg', 25, 1)
return
if(!Adjacent(user) && !isAI(user))
return
if(!songs.len)
to_chat(user,"<span class='warning'>Error: No music tracks have been authorized for your station. Petition Central Command to resolve this issue.</span>")
playsound(src,'sound/misc/compiler-failure.ogg', 25, 1)
return
var/list/dat = list()
dat +="<div class='statusDisplay' style='text-align:center'>"
dat += "<b><A href='?src=[REF(src)];action=toggle'>[!active ? "BREAK IT DOWN" : "SHUT IT DOWN"]<b></A><br>"
dat += "</div><br>"
dat += "<A href='?src=[REF(src)];action=select'> Select Track</A><br>"
dat += "Track Selected: [selection.song_name]<br>"
dat += "Track Length: [DisplayTimeText(selection.song_length)]<br><br>"
dat += "<br>DJ's Soundboard:<b><br>"
dat +="<div class='statusDisplay'><div style='text-align:center'>"
dat += "<A href='?src=[REF(src)];action=horn'>Air Horn</A> "
dat += "<A href='?src=[REF(src)];action=alert'>Station Alert</A> "
dat += "<A href='?src=[REF(src)];action=siren'>Warning Siren</A> "
dat += "<A href='?src=[REF(src)];action=honk'>Honk</A><br>"
dat += "<A href='?src=[REF(src)];action=pump'>Shotgun Pump</A>"
dat += "<A href='?src=[REF(src)];action=pop'>Gunshot</A>"
dat += "<A href='?src=[REF(src)];action=saber'>Esword</A>"
dat += "<A href='?src=[REF(src)];action=harm'>Harm Alarm</A>"
dat += "<A href='?src=[REF(src)];action=yeehaw'>Yeehaw</A>"
var/datum/browser/popup = new(user, "vending", "Radiance Dance Machine - Mark IV", 400, 350)
var/datum/browser/popup = new(user, "vending", "[name]", 400, 350)
popup.set_content(dat.Join())
popup.open()


/obj/machinery/disco/Topic(href, href_list)
/obj/machinery/jukebox/Topic(href, href_list)
if(..())
return
add_fingerprint(usr)
Expand All @@ -134,11 +121,8 @@
to_chat(usr, "<span class='warning'>Error: The device is still resetting from the last activation, it will be ready again in [DisplayTimeText(stop-world.time)].</span>")
playsound(src, 'sound/misc/compiler-failure.ogg', 50, 1)
return
active = TRUE
update_icon()
dance_setup()
activate_music()
START_PROCESSING(SSobj, src)
lights_spin()
updateUsrDialog()
else if(active)
stop = 0
Expand All @@ -156,34 +140,19 @@
return
selection = available[selected]
updateUsrDialog()
if("horn")
deejay('sound/items/airhorn2.ogg')
if("alert")
deejay('sound/misc/notice1.ogg')
if("siren")
deejay('sound/machines/engine_alert1.ogg')
if("honk")
deejay('sound/items/bikehorn.ogg')
if("pump")
deejay('sound/weapons/shotgunpump.ogg')
if("pop")
deejay('sound/weapons/gunshot3.ogg')
if("saber")
deejay('sound/weapons/saberon.ogg')
if("harm")
deejay('sound/ai/harmalarm.ogg')
if("yeehaw")
deejay('sound/misc/Yeehaw.ogg')

/obj/machinery/disco/proc/deejay(var/S)
if (QDELETED(src) || !active || charge < 5)
to_chat(usr, "<span class='warning'>The device is not able to play more DJ sounds at this time.</span>")
return
charge -= 5
playsound(src, S,300,1)

/obj/machinery/disco/proc/dance_setup()
/obj/machinery/jukebox/proc/activate_music()
active = TRUE
update_icon()
START_PROCESSING(SSobj, src)
stop = world.time + selection.song_length

/obj/machinery/jukebox/disco/activate_music()
..()
dance_setup()
lights_spin()

/obj/machinery/jukebox/disco/proc/dance_setup()
var/turf/cen = get_turf(src)
FOR_DVIEW(var/turf/t, 3, get_turf(src),INVISIBILITY_LIGHTING)
if(t.x == cen.x && t.y > cen.y)
Expand Down Expand Up @@ -245,14 +214,14 @@
continue
FOR_DVIEW_END

/obj/machinery/disco/proc/hierofunk()
/obj/machinery/jukebox/disco/proc/hierofunk()
for(var/i in 1 to 10)
spawn_atom_to_turf(/obj/effect/temp_visual/hierophant/telegraph/edge, src, 1, FALSE)
sleep(5)

#define DISCO_INFENO_RANGE (rand(85, 115)*0.01)

/obj/machinery/disco/proc/lights_spin()
/obj/machinery/jukebox/disco/proc/lights_spin()
for(var/i in 1 to 25)
if(QDELETED(src) || !active)
return
Expand Down Expand Up @@ -330,7 +299,7 @@

#undef DISCO_INFENO_RANGE

/obj/machinery/disco/proc/dance(var/mob/living/M) //Show your moves
/obj/machinery/jukebox/disco/proc/dance(var/mob/living/M) //Show your moves
set waitfor = FALSE
switch(rand(0,9))
if(0 to 1)
Expand All @@ -342,7 +311,7 @@
if(7 to 9)
dance5(M)

/obj/machinery/disco/proc/dance2(var/mob/living/M)
/obj/machinery/jukebox/disco/proc/dance2(var/mob/living/M)
for(var/i = 1, i < 10, i++)
for(var/d in list(NORTH,SOUTH,EAST,WEST,EAST,SOUTH,NORTH,SOUTH,EAST,WEST,EAST,SOUTH))
M.setDir(d)
Expand All @@ -351,7 +320,7 @@
sleep(1)
sleep(20)

/obj/machinery/disco/proc/dance3(var/mob/living/M)
/obj/machinery/jukebox/disco/proc/dance3(var/mob/living/M)
var/matrix/initial_matrix = matrix(M.transform)
for (var/i in 1 to 75)
if (!M)
Expand Down Expand Up @@ -399,7 +368,7 @@
M.lying_fix()


/obj/machinery/disco/proc/dance4(var/mob/living/M)
/obj/machinery/jukebox/disco/proc/dance4(var/mob/living/M)
var/speed = rand(1,3)
set waitfor = 0
var/time = 30
Expand All @@ -411,7 +380,7 @@
NS.lay_down(TRUE) //specifically excludes silicons to prevent pAI chat spam
time--

/obj/machinery/disco/proc/dance5(var/mob/living/M)
/obj/machinery/jukebox/disco/proc/dance5(var/mob/living/M)
animate(M, transform = matrix(180, MATRIX_ROTATE), time = 1, loop = 0)
var/matrix/initial_matrix = matrix(M.transform)
for (var/i in 1 to 60)
Expand Down Expand Up @@ -446,30 +415,23 @@
sleep(1)
M.lying_fix()



/mob/living/proc/lying_fix()
animate(src, transform = null, time = 1, loop = 0)
lying_prev = 0

/obj/machinery/disco/proc/dance_over()
for(var/obj/item/device/flashlight/spotlight/SL in spotlights)
qdel(SL)
spotlights.Cut()
for(var/obj/effect/overlay/sparkles/SP in sparkles)
qdel(SP)
sparkles.Cut()
/obj/machinery/jukebox/proc/dance_over()
for(var/mob/living/L in rangers)
if(!L || !L.client)
continue
L.stop_sound_channel(CHANNEL_JUKEBOX)
rangers = list()

/obj/machinery/jukebox/disco/dance_over()
..()
QDEL_LIST(spotlights)
QDEL_LIST(sparkles)


/obj/machinery/disco/process()
if(charge<35)
charge += 1
/obj/machinery/jukebox/process()
if(world.time < stop && active)
var/sound/song_played = sound(selection.song_path)

Expand All @@ -479,8 +441,6 @@
if(!(M in rangers))
rangers[M] = TRUE
M.playsound_local(get_turf(M), null, 100, channel = CHANNEL_JUKEBOX, S = song_played)
if(prob(5+(allowed(M)*4)) && M.canmove)
dance(M)
for(var/mob/L in rangers)
if(get_dist(src,L) > 10)
rangers -= L
Expand All @@ -492,5 +452,13 @@
STOP_PROCESSING(SSobj, src)
dance_over()
playsound(src,'sound/machines/terminal_off.ogg',50,1)
icon_state = "disco0"
update_icon()
stop = world.time + 100


/obj/machinery/jukebox/disco/process()
. = ..()
if(active)
for(var/mob/M in rangers)
if(prob(5+(allowed(M)*4)) && M.canmove)
dance(M)
Loading

0 comments on commit 4471461

Please sign in to comment.