Adds Jukebox hacking!

Ported from Vorestation.
This commit is contained in:
Spades
2016-08-23 14:48:15 -04:00
parent 729956de19
commit 5cf098d980
5 changed files with 120 additions and 4 deletions
+66
View File
@@ -0,0 +1,66 @@
/datum/wires/jukebox
random = 1
holder_type = /obj/machinery/media/jukebox
wire_count = 7
var/const/WIRE_POWER = 1
var/const/WIRE_HACK = 2
var/const/WIRE_SPEEDUP = 4
var/const/WIRE_SPEEDDOWN = 8
var/const/WIRE_REVERSE = 16
var/const/WIRE_NOTHING1 = 32
var/const/WIRE_NOTHING2 = 64
/datum/wires/jukebox/CanUse(var/mob/living/L)
var/obj/machinery/media/jukebox/A = holder
if(A.panel_open)
return 1
return 0
// Show the status of lights as a hint to the current state
/datum/wires/jukebox/GetInteractWindow()
var/obj/machinery/media/jukebox/A = holder
. += ..()
. += "<BR>The power light is [(A.stat & (BROKEN|NOPOWER)) ? "off" : "on"].<BR>"
. += "The parental guidance light is [A.hacked ? "off" : "on"].<BR>"
. += "The data light is [IsIndexCut(WIRE_REVERSE) ? "hauntingly dark" : "glowing sloftly"].<BR>"
// Give a hint as to what each wire does
/datum/wires/jukebox/UpdatePulsed(var/index)
var/obj/machinery/media/jukebox/A = holder
switch(index)
if(WIRE_POWER)
holder.visible_message("<span class='notice'>\icon[holder] The power light flickers.</span>")
A.shock(usr, 90)
if(WIRE_HACK)
holder.visible_message("<span class='notice'>\icon[holder] The parental guidance light flickers.</span>")
if(WIRE_REVERSE)
holder.visible_message("<span class='notice'>\icon[holder] The data light blinks ominously.</span>")
if(WIRE_SPEEDUP)
holder.visible_message("<span class='notice'>\icon[holder] The speakers squeaks.</span>")
if(WIRE_SPEEDDOWN)
holder.visible_message("<span class='notice'>\icon[holder] The speakers rumble.</span>")
else
A.shock(usr, 10) // The nothing wires give a chance to shock just for fun
/datum/wires/jukebox/UpdateCut(var/index, var/mended)
var/obj/machinery/media/jukebox/A = holder
switch(index)
if(WIRE_POWER)
// TODO - Actually make machine electrified or something.
A.shock(usr, 90)
if(WIRE_HACK)
if(mended)
A.set_hacked(0)
else
A.set_hacked(1)
if(WIRE_SPEEDUP, WIRE_SPEEDDOWN, WIRE_REVERSE)
var/newfreq = IsIndexCut(WIRE_REVERSE) ? -1 : 1;
if (IsIndexCut(WIRE_SPEEDUP))
newfreq *= 2
if (IsIndexCut(WIRE_SPEEDDOWN))
newfreq *= 0.5
A.freq = newfreq
+53 -4
View File
@@ -1,5 +1,3 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32
datum/track
var/title
var/sound
@@ -23,6 +21,11 @@ datum/track/New(var/title_name, var/audio)
var/playing = 0
// Vars for hacking
var/datum/wires/jukebox/wires = null
var/hacked = 0 // Whether to show the hidden songs or not
var/freq = 0
var/datum/track/current_track
var/list/datum/track/tracks = list(
new/datum/track("Beyond", 'sound/ambience/ambispace.ogg'),
@@ -36,6 +39,14 @@ datum/track/New(var/title_name, var/audio)
new/datum/track("Trai`Tor", 'sound/music/traitor.ogg'),
)
// Only visible if hacked
var/list/datum/track/secret_tracks = list(
//new/datum/track("Bandit Radio", 'sound/music/bandit_radio.ogg'), // Waiting on email from GSC World about the copyright status of this.
new/datum/track("Space Asshole", 'sound/music/space_asshole.ogg'),
new/datum/track("Thunderdome", 'sound/music/THUNDERDOME.ogg'),
new/datum/track("Russkiy rep Diskoteka", 'sound/music/russianrapdisco.ogg')
)
/obj/machinery/media/jukebox/New()
..()
circuit = new circuit(src)
@@ -44,11 +55,41 @@ datum/track/New(var/title_name, var/audio)
component_parts += new /obj/item/weapon/stock_parts/console_screen(src)
component_parts += new /obj/item/stack/cable_coil(src, 5)
RefreshParts()
wires = new/datum/wires/jukebox(src)
/obj/machinery/media/jukebox/Destroy()
StopPlaying()
qdel(wires)
wires = null
..()
/obj/machinery/media/jukebox/proc/set_hacked(var/newhacked)
if (hacked == newhacked) return
hacked = newhacked
if (hacked)
tracks.Add(secret_tracks)
else
tracks.Remove(secret_tracks)
updateDialog()
/obj/machinery/media/jukebox/attackby(obj/item/W as obj, mob/user as mob)
src.add_fingerprint(user)
if(default_deconstruction_screwdriver(user, W))
return
if(default_deconstruction_crowbar(user, W))
return
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
return ..()
/obj/machinery/media/jukebox/power_change()
if(!powered(power_channel) || !anchored)
stat |= NOPOWER
@@ -73,6 +114,8 @@ datum/track/New(var/title_name, var/audio)
overlays += "[state_base]-emagged"
else
overlays += "[state_base]-running"
if (panel_open)
overlays += "panel_open"
/obj/machinery/media/jukebox/Topic(href, href_list)
if(..() || !(Adjacent(usr) || istype(usr, /mob/living/silicon)))
@@ -213,11 +256,17 @@ datum/track/New(var/title_name, var/audio)
return
var/area/main_area = get_area(src)
main_area.forced_ambience = list(current_track.sound)
if(freq)
var/sound/new_song = sound(current_track.sound, channel = 1, repeat = 1, volume = 25)
new_song.frequency = freq
main_area.forced_ambience = list(new_song)
else
main_area.forced_ambience = list(current_track.sound)
for(var/mob/living/M in mobs_in_area(main_area))
if(M.mind)
main_area.play_ambience(M)
playing = 1
update_use_power(2)
update_icon()
update_icon()
+1
View File
@@ -250,6 +250,7 @@
#include "code\datums\wires\autolathe.dm"
#include "code\datums\wires\camera.dm"
#include "code\datums\wires\explosive.dm"
#include "code\datums\wires\jukebox.dm"
#include "code\datums\wires\particle_accelerator.dm"
#include "code\datums\wires\radio.dm"
#include "code\datums\wires\robot.dm"
Binary file not shown.
Binary file not shown.