diff --git a/code/__DEFINES/instruments.dm b/code/__DEFINES/instruments.dm
index 3c414f87f43..64c77abc9fa 100644
--- a/code/__DEFINES/instruments.dm
+++ b/code/__DEFINES/instruments.dm
@@ -19,7 +19,7 @@
#define INSTRUMENT_EXP_FALLOFF_MAX 10
/// Minimum volume for when the sound is considered dead.
-#define INSTRUMENT_MIN_SUSTAIN_DROPOFF 0
+#define INSTRUMENT_MIN_SUSTAIN_DROPOFF 0.1
#define SUSTAIN_LINEAR 1
#define SUSTAIN_EXPONENTIAL 2
diff --git a/code/datums/action.dm b/code/datums/action.dm
index f8920c0dab9..9d1fa00901f 100644
--- a/code/datums/action.dm
+++ b/code/datums/action.dm
@@ -190,9 +190,6 @@
/datum/action/item_action/toggle_mister
name = "Toggle Mister"
-/datum/action/item_action/toggle_headphones
- name = "Toggle Headphones"
-
/datum/action/item_action/toggle_helmet_light
name = "Toggle Helmet Light"
@@ -237,12 +234,8 @@
desc = "Recall yourself, and anyone nearby, to an attuned hierophant beacon at any time.
Lines are a series of chords, separated by commas
If the beacon is still attached, will detach it."
button_icon_state = "vortex_recall"
-/datum/action/item_action/vortex_recall/IsAvailable()
- if(istype(target, /obj/item/hierophant_club))
- var/obj/item/hierophant_club/H = target
- if(H.teleporting)
- return 0
- return ..()
+/datum/action/item_action/change_headphones_song
+ name = "Change Headphones Song"
/datum/action/item_action/toggle
diff --git a/code/modules/clothing/ears/ears.dm b/code/modules/clothing/ears/ears.dm
index ea8f4198f50..d00751e2cfb 100644
--- a/code/modules/clothing/ears/ears.dm
+++ b/code/modules/clothing/ears/ears.dm
@@ -8,21 +8,3 @@
strip_delay = 15
put_on_delay = 25
resistance_flags = FLAMMABLE
-
-/obj/item/clothing/ears/headphones
- name = "headphones"
- desc = "Unce unce unce unce."
- var/on = 0
- icon_state = "headphones0"
- item_state = null
- actions_types = list(/datum/action/item_action/toggle_headphones)
-
-/obj/item/clothing/ears/headphones/attack_self(mob/user)
- on = !on
- icon_state = "headphones[on]"
-
- for(var/X in actions)
- var/datum/action/A = X
- A.UpdateButtonIcon()
-
- user.update_inv_ears()
diff --git a/code/modules/instruments/objs/items/_instrument.dm b/code/modules/instruments/objs/items/_instrument.dm
index d3cd686409f..936a9b4c85d 100644
--- a/code/modules/instruments/objs/items/_instrument.dm
+++ b/code/modules/instruments/objs/items/_instrument.dm
@@ -27,12 +27,6 @@
user.visible_message("[user] begins to play 'Gloomy Sunday'! It looks like [user.p_theyre()] trying to commit suicide!")
return BRUTELOSS
-/obj/item/instrument/attack_self(mob/user)
- if(!user.IsAdvancedToolUser())
- to_chat(user, "You don't have the dexterity to do this!")
- return TRUE
- interact(user)
-
/obj/item/instrument/attack_self(mob/user)
tgui_interact(user)
diff --git a/code/modules/instruments/objs/items/headphones.dm b/code/modules/instruments/objs/items/headphones.dm
new file mode 100644
index 00000000000..ef1a76bdc3b
--- /dev/null
+++ b/code/modules/instruments/objs/items/headphones.dm
@@ -0,0 +1,80 @@
+/obj/item/clothing/ears/headphones
+ name = "headphones"
+ desc = "Unce unce unce unce."
+ icon_state = "headphones0"
+ item_state = "headphones0"
+ actions_types = list(/datum/action/item_action/change_headphones_song)
+ var/datum/song/headphones/song
+
+/obj/item/clothing/ears/headphones/Initialize(mapload)
+ . = ..()
+ song = new(src, "piano") // Piano is the default instrument but all instruments are allowed
+ song.instrument_range = 0
+ song.allowed_instrument_ids = SSinstruments.synthesizer_instrument_ids
+ // To update the icon
+ RegisterSignal(src, COMSIG_SONG_START, .proc/start_playing)
+ RegisterSignal(src, COMSIG_SONG_END, .proc/stop_playing)
+
+/obj/item/clothing/ears/headphones/Destroy()
+ QDEL_NULL(song)
+ return ..()
+
+/obj/item/clothing/ears/headphones/attack_self(mob/user)
+ tgui_interact(user)
+
+/obj/item/clothing/ears/headphones/tgui_data(mob/user)
+ return song.tgui_data(user)
+
+/obj/item/clothing/ears/headphones/tgui_interact(mob/user)
+ if(should_stop_playing(user) || user.incapacitated())
+ return
+ song.tgui_interact(user)
+
+/obj/item/clothing/ears/headphones/tgui_act(action, params)
+ if(..())
+ return
+ return song.tgui_act(action, params)
+
+/obj/item/clothing/ears/headphones/update_icon()
+ var/mob/living/carbon/human/user = loc
+ if(istype(user))
+ user.update_action_buttons_icon()
+ user.update_inv_ears()
+ ..()
+
+/obj/item/clothing/ears/headphones/item_action_slot_check(slot)
+ if(slot == slot_l_ear || slot == slot_r_ear)
+ return TRUE
+
+/**
+ * Called by a component signal when our song starts playing.
+ */
+/obj/item/clothing/ears/headphones/proc/start_playing()
+ icon_state = item_state = "headphones1"
+ update_icon()
+
+/**
+ * Called by a component signal when our song stops playing.
+ */
+/obj/item/clothing/ears/headphones/proc/stop_playing()
+ icon_state = item_state = "headphones0"
+ update_icon()
+
+/**
+ * Whether the headphone's song should stop playing
+ *
+ * Arguments:
+ * * user - The user
+ */
+/obj/item/clothing/ears/headphones/proc/should_stop_playing(mob/living/carbon/human/user)
+ return !(src in user) || !istype(user) || !((src == user.l_ear) || (src == user.r_ear))
+
+// special subtype so it uses the correct item type
+/datum/song/headphones
+
+/datum/song/headphones/should_stop_playing(mob/user)
+ . = ..()
+ if(.)
+ return TRUE
+ var/obj/item/clothing/ears/headphones/I = parent
+ return I.should_stop_playing(user)
diff --git a/code/modules/instruments/objs/items/instruments.dm b/code/modules/instruments/objs/items/instruments.dm
index b411bc6c032..2426de9a5c9 100644
--- a/code/modules/instruments/objs/items/instruments.dm
+++ b/code/modules/instruments/objs/items/instruments.dm
@@ -39,7 +39,7 @@
icon_state = "guitar"
item_state = "guitar"
attack_verb = list("played metal on", "serenaded", "crashed", "smashed")
- hitsound = 'sound/weapons/stringsmash.ogg'
+ hitsound = 'sound/weapons/guitarslam.ogg'
allowed_instrument_ids = "guitar"
/obj/item/instrument/eguitar
diff --git a/code/modules/instruments/songs/_song.dm b/code/modules/instruments/songs/_song.dm
index 25d1d665417..142eab1fd2d 100644
--- a/code/modules/instruments/songs/_song.dm
+++ b/code/modules/instruments/songs/_song.dm
@@ -115,7 +115,7 @@
/// The kind of sustain we're using
var/sustain_mode = SUSTAIN_LINEAR
/// When a note is considered dead if it is below this in volume
- var/sustain_dropoff_volume = 0
+ var/sustain_dropoff_volume = INSTRUMENT_MIN_SUSTAIN_DROPOFF
/// Total duration of linear sustain for 100 volume note to get to SUSTAIN_DROPOFF
var/sustain_linear_duration = 5
/// Exponential sustain dropoff rate per decisecond
@@ -168,7 +168,9 @@
var/turf/source = get_turf(parent)
for(var/mob/M in GLOB.player_list)
var/dist = get_dist(M, source)
- if(dist > instrument_range)
+ if(dist > instrument_range) // Distance check
+ continue
+ if(!isInSight(M, source)) // Visibility check (direct line of sight)
continue
hearing_mobs[M] = dist
var/list/exited = old - hearing_mobs
@@ -251,7 +253,7 @@
* Processes our song.
*/
/datum/song/proc/process_song(wait)
- if(!length(compiled_chords) || should_stop_playing(user_playing))
+ if(!length(compiled_chords) || current_chord > length(compiled_chords) || should_stop_playing(user_playing))
stop_playing()
return
var/list/chord = compiled_chords[current_chord]
@@ -349,26 +351,29 @@
/**
* Setter for setting how low the volume has to get before a note is considered "dead" and dropped
*/
-/datum/song/proc/set_dropoff_volume(volume)
+/datum/song/proc/set_dropoff_volume(volume, no_refresh = FALSE)
sustain_dropoff_volume = clamp(volume, INSTRUMENT_MIN_SUSTAIN_DROPOFF, 100)
update_sustain()
- SStgui.update_uis(parent)
+ if(!no_refresh)
+ SStgui.update_uis(parent)
/**
* Setter for setting exponential falloff factor.
*/
-/datum/song/proc/set_exponential_drop_rate(drop)
+/datum/song/proc/set_exponential_drop_rate(drop, no_refresh = FALSE)
sustain_exponential_dropoff = clamp(drop, INSTRUMENT_EXP_FALLOFF_MIN, INSTRUMENT_EXP_FALLOFF_MAX)
update_sustain()
- SStgui.update_uis(parent)
+ if(!no_refresh)
+ SStgui.update_uis(parent)
/**
* Setter for setting linear falloff duration.
*/
-/datum/song/proc/set_linear_falloff_duration(duration)
+/datum/song/proc/set_linear_falloff_duration(duration, no_refresh = FALSE)
sustain_linear_duration = clamp(duration, 0.1, INSTRUMENT_MAX_TOTAL_SUSTAIN)
update_sustain()
- SStgui.update_uis(parent)
+ if(!no_refresh)
+ SStgui.update_uis(parent)
/datum/song/vv_edit_var(var_name, var_value)
. = ..()
diff --git a/code/modules/instruments/songs/_song_ui.dm b/code/modules/instruments/songs/_song_ui.dm
index f4b5c37ed69..cbd0f646f5c 100644
--- a/code/modules/instruments/songs/_song_ui.dm
+++ b/code/modules/instruments/songs/_song_ui.dm
@@ -52,12 +52,12 @@
ui.set_autoupdate(FALSE) // NO!!! Don't auto-update this!!
/datum/song/tgui_act(action, params)
+ . = TRUE
switch(action)
if("newsong")
lines = new()
tempo = sanitize_tempo(5) // default 120 BPM
name = ""
- return TRUE
if("import")
var/t = ""
do
@@ -71,20 +71,17 @@
break
while(length_char(t) > MUSIC_MAXLINES * MUSIC_MAXLINECHARS)
parse_song(t)
+ return FALSE
if("help")
help = !help
- return TRUE
if("edit")
editing = !editing
- return TRUE
if("repeat") //Changing this from a toggle to a number of repeats to avoid infinite loops.
if(playing)
return //So that people cant keep adding to repeat. If the do it intentionally, it could result in the server crashing.
repeat = clamp(round(text2num(params["new"])), 0, max_repeats)
- return TRUE
if("tempo")
tempo = sanitize_tempo(text2num(params["new"]))
- return TRUE
if("play")
INVOKE_ASYNC(src, .proc/start_playing, usr)
if("newline")
@@ -96,13 +93,11 @@
if(length(newline) > MUSIC_MAXLINECHARS)
newline = copytext(newline, 1, MUSIC_MAXLINECHARS)
lines.Add(newline)
- return TRUE
if("deleteline")
var/num = round(text2num(params["line"]))
if(num > length(lines) || num < 1)
return
lines.Cut(num, num + 1)
- return TRUE
if("modifyline")
var/num = round(text2num(params["line"]))
var/content = stripped_input(usr, "Enter your line: ", parent.name, lines[num], MUSIC_MAXLINECHARS)
@@ -111,20 +106,16 @@
if(num > length(lines) || num < 1)
return
lines[num] = content
- return TRUE
if("stop")
stop_playing()
if("setlinearfalloff")
- set_linear_falloff_duration(round(text2num(params["new"]) * 10, world.tick_lag))
- return TRUE
+ set_linear_falloff_duration(round(text2num(params["new"]) * 10, world.tick_lag), TRUE)
if("setexpfalloff")
- set_exponential_drop_rate(round(text2num(params["new"]), 0.00001))
- return TRUE
+ set_exponential_drop_rate(round(text2num(params["new"]), 0.00001), TRUE)
if("setvolume")
set_volume(round(text2num(params["new"]), 1))
if("setdropoffvolume")
- set_dropoff_volume(round(text2num(params["new"]), 0.01))
- return TRUE
+ set_dropoff_volume(round(text2num(params["new"]), 0.01), TRUE)
if("switchinstrument")
if(!length(allowed_instrument_ids))
return
@@ -136,20 +127,25 @@
var/datum/instrument/I = SSinstruments.get_instrument(i)
if(I && I.name == choice)
set_instrument(I)
- return TRUE
if("setnoteshift")
note_shift = clamp(round(text2num(params["new"])), note_shift_min, note_shift_max)
- return TRUE
if("setsustainmode")
var/static/list/sustain_modes
if(!length(sustain_modes))
sustain_modes = list("Linear" = SUSTAIN_LINEAR, "Exponential" = SUSTAIN_EXPONENTIAL)
var/choice = params["new"]
sustain_mode = sustain_modes[choice] || sustain_mode
- return TRUE
if("togglesustainhold")
full_sustain_held_note = !full_sustain_held_note
- return TRUE
+ if("reset")
+ var/default_instrument = allowed_instrument_ids[1]
+ if(using_instrument != SSinstruments.instrument_data[default_instrument])
+ set_instrument(default_instrument)
+ note_shift = initial(note_shift)
+ sustain_mode = initial(sustain_mode)
+ set_linear_falloff_duration(initial(sustain_linear_duration), TRUE)
+ set_exponential_drop_rate(initial(sustain_exponential_dropoff), TRUE)
+ set_dropoff_volume(initial(sustain_dropoff_volume), TRUE)
else
return FALSE
parent.add_fingerprint(usr)
@@ -160,6 +156,7 @@
/datum/song/proc/parse_song(text)
set waitfor = FALSE
//split into lines
+ stop_playing()
lines = splittext(text, "\n")
if(length(lines))
var/bpm_string = "BPM: "
diff --git a/icons/mob/inhands/clothing_lefthand.dmi b/icons/mob/inhands/clothing_lefthand.dmi
index 589135b8701..379c727930f 100644
Binary files a/icons/mob/inhands/clothing_lefthand.dmi and b/icons/mob/inhands/clothing_lefthand.dmi differ
diff --git a/icons/mob/inhands/clothing_righthand.dmi b/icons/mob/inhands/clothing_righthand.dmi
index 8fd5f7d71b8..a0857935693 100644
Binary files a/icons/mob/inhands/clothing_righthand.dmi and b/icons/mob/inhands/clothing_righthand.dmi differ
diff --git a/icons/mob/inhands/equipment/instruments_righthand.dmi b/icons/mob/inhands/equipment/instruments_righthand.dmi
index 9b97ac3c728..28085ff746d 100644
Binary files a/icons/mob/inhands/equipment/instruments_righthand.dmi and b/icons/mob/inhands/equipment/instruments_righthand.dmi differ
diff --git a/paradise.dme b/paradise.dme
index be798210f82..a46eeb48bed 100644
--- a/paradise.dme
+++ b/paradise.dme
@@ -1649,6 +1649,7 @@
#include "code\modules\instruments\piano.dm"
#include "code\modules\instruments\synth_tones.dm"
#include "code\modules\instruments\objs\items\_instrument.dm"
+#include "code\modules\instruments\objs\items\headphones.dm"
#include "code\modules\instruments\objs\items\instruments.dm"
#include "code\modules\instruments\objs\structures\_musician.dm"
#include "code\modules\instruments\objs\structures\piano.dm"
diff --git a/sound/weapons/guitarslam.ogg b/sound/weapons/guitarslam.ogg
new file mode 100644
index 00000000000..4fa53db9404
Binary files /dev/null and b/sound/weapons/guitarslam.ogg differ
diff --git a/tgui/packages/tgui/interfaces/Instrument.js b/tgui/packages/tgui/interfaces/Instrument.js
index e30ddae705f..a952923df9a 100644
--- a/tgui/packages/tgui/interfaces/Instrument.js
+++ b/tgui/packages/tgui/interfaces/Instrument.js
@@ -25,9 +25,15 @@ const InstrumentHelp = (properties, context) => {
return;
}
return (
- Making a Song
+ Lines are a series of chords, separated by commas
+
+ Every note in a chord will play together,
+ with the chord timed by the
+
+ Notes are played by the
+
+ By default, every note is
+
+
+ A
+ To make a chord be a different time, end it
+ with /x, where the chord length will be length defined by
+
+ Combined, an example line is: E-E4/4,F#/2,G#/8,B/8,E3-E4/4. +