Tape Recorder Buffs (#8740)

This commit is contained in:
Geeves
2020-04-28 15:24:43 +02:00
committed by GitHub
parent 2f2b49fc54
commit 9fb9d24e57
3 changed files with 199 additions and 168 deletions
+183 -159
View File
@@ -3,82 +3,82 @@
desc = "A device that can record up to an hour of dialogue and play it back. It automatically translates the content in playback."
icon_state = "taperecorderidle"
item_state = "analyzer"
w_class = 2.0
w_class = ITEMSIZE_SMALL
matter = list(DEFAULT_WALL_MATERIAL = 60, MATERIAL_GLASS = 30)
var/emagged = 0.0
var/recording = 0.0
var/playing = 0.0
var/timerecorded = 0.0
var/playsleepseconds = 0.0
var/list/storedinfo = new/list()
var/list/timestamp = new/list()
var/canprint = 1
var/emagged = FALSE
var/recording = FALSE
var/playing = FALSE
var/time_recorded = 0
var/play_sleep_seconds = 0
var/list/stored_info = list() // TOOK OUT NEW THING
var/list/timestamp = list()
var/can_print = TRUE
var/obj/item/computer_hardware/hard_drive/portable/portable_drive
flags = CONDUCT
throwforce = 2
throw_speed = 4
throw_range = 20
/obj/item/device/taperecorder/New()
..()
/obj/item/device/taperecorder/Initialize()
. = ..()
listening_objects += src
portable_drive = new /obj/item/computer_hardware/hard_drive/portable(src)
/obj/item/device/taperecorder/Destroy()
listening_objects -= src
return ..()
/obj/item/device/taperecorder/hear_talk(mob/living/M as mob, msg, var/verb="says", datum/language/speaking=null)
/obj/item/device/taperecorder/hear_talk(mob/living/M, msg, var/verb = "says", datum/language/speaking = null)
if(isanimal(M))
if(!M.universal_speak)
return
if(recording)
timestamp += timerecorded
timestamp += time_recorded
if(speaking)
if(!speaking.machine_understands)
msg = speaking.scramble(msg)
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] [M.name] [speaking.format_message_plain(msg, verb)]"
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] [M.name] [speaking.format_message_plain(msg, verb)]"
else
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] [M.name] [verb], \"[msg]\""
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] [M.name] [verb], \"[msg]\""
/obj/item/device/taperecorder/see_emote(mob/M as mob, text, var/emote_type)
/obj/item/device/taperecorder/see_emote(mob/M, text, var/emote_type)
if(emote_type != 2) //only hearable emotes
return
if(recording)
timestamp += timerecorded
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] [strip_html_properly(text)]"
timestamp += time_recorded
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] [strip_html_properly(text)]"
/obj/item/device/taperecorder/show_message(msg, type, alt, alt_type)
var/recordedtext
if (msg && type == 2) //must be hearable
if(msg && type == 2) //must be hearable
recordedtext = msg
else if (alt && alt_type == 2)
else if(alt && alt_type == 2)
recordedtext = alt
else
return
if(recording)
timestamp += timerecorded
storedinfo += "*\[[time2text(timerecorded*10,"mm:ss")]\] *[strip_html_properly(recordedtext)]*" //"*" at front as a marker
timestamp += time_recorded
stored_info += "*\[[time2text(time_recorded*10,"mm:ss")]\] *[strip_html_properly(recordedtext)]*" //"*" at front as a marker
/obj/item/device/taperecorder/emag_act(var/remaining_charges, var/mob/user)
if(emagged == 0)
emagged = 1
recording = 0
to_chat(user, "<span class='warning'>PZZTTPFFFT</span>")
icon_state = "taperecorderidle"
return 1
else
to_chat(user, "<span class='warning'>It is already emagged!</span>")
/obj/item/device/taperecorder/emag_act(var/remaining_charges, mob/user)
if(emagged)
to_chat(user, SPAN_WARNING("It is already emagged!"))
return FALSE
emagged = TRUE
recording = FALSE
to_chat(user, SPAN_NOTICE("PZZTTPFFFT"))
icon_state = "taperecorderidle"
return TRUE
/obj/item/device/taperecorder/proc/explode()
var/turf/T = get_turf(loc)
if(ismob(loc))
var/mob/M = loc
to_chat(M, "<span class='danger'>\The [src] explodes!</span>")
visible_message(SPAN_DANGER("\The [src] explodes!"))
if(T)
T.hotspot_expose(700,125)
T.hotspot_expose(700, 125)
explosion(T, -1, -1, 0, 4)
qdel(src)
return
@@ -87,207 +87,231 @@
set name = "Start Recording"
set category = "Object"
if(usr.stat)
if(use_check_and_message(usr))
return
if(emagged == 1)
to_chat(usr, "<span class='warning'>The tape recorder makes a scratchy noise.</span>")
if(emagged)
to_chat(usr, SPAN_WARNING("The tape recorder makes a scratchy noise."))
return
icon_state = "taperecorderrecording"
if(timerecorded < 3600 && playing == 0)
to_chat(usr, "<span class='notice'>Recording started.</span>")
recording = 1
timestamp+= timerecorded
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] Recording started."
for(timerecorded, timerecorded<3600)
if(recording == 0)
if(time_recorded < 3600 && !playing)
to_chat(usr, SPAN_NOTICE("Recording started."))
recording = TRUE
timestamp += time_recorded
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] Recording started."
for(time_recorded, time_recorded < 3600)
if(!recording)
break
timerecorded++
time_recorded++
sleep(10)
recording = 0
recording = FALSE
icon_state = "taperecorderidle"
return
else
to_chat(usr, "<span class='notice'>Either your tape recorder's memory is full, or it is currently playing back its memory.</span>")
to_chat(usr, SPAN_NOTICE("Either your tape recorder's memory is full, or it is currently playing back its memory."))
/obj/item/device/taperecorder/verb/stop()
set name = "Stop"
set name = "Stop Recording"
set category = "Object"
if(usr.stat)
if(use_check_and_message(usr))
return
if(emagged == 1)
to_chat(usr, "<span class='warning'>The tape recorder makes a scratchy noise.</span>")
return
if(recording == 1)
recording = 0
timestamp+= timerecorded
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] Recording stopped."
to_chat(usr, "<span class='notice'>Recording stopped.</span>")
icon_state = "taperecorderidle"
return
else if(playing == 1)
playing = 0
var/turf/T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: Playback stopped.</font>")
icon_state = "taperecorderidle"
if(emagged)
to_chat(usr, SPAN_WARNING("The tape recorder makes a scratchy noise."))
return
if(recording)
recording = FALSE
timestamp += time_recorded
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] Recording stopped."
to_chat(usr, SPAN_NOTICE("Recording stopped."))
icon_state = "taperecorderidle"
return
else if(playing)
playing = FALSE
audible_message("<font color=Maroon><B>Tape Recorder</B>: Playback stopped.</font>", hearing_distance = 3)
icon_state = "taperecorderidle"
return
/obj/item/device/taperecorder/verb/clear_memory()
set name = "Clear Memory"
set category = "Object"
if(usr.stat)
if(use_check_and_message(usr))
return
if(emagged == 1)
to_chat(usr, "<span class='warning'>The tape recorder makes a scratchy noise.</span>")
if(emagged)
to_chat(usr, SPAN_WARNING("The tape recorder makes a scratchy noise."))
return
if(recording == 1 || playing == 1)
to_chat(usr, "<span class='notice'>You can't clear the memory while playing or recording!</span>")
if(recording || playing)
to_chat(usr, SPAN_WARNING("You can't clear the memory while playing or recording!"))
return
else
if(storedinfo) storedinfo.Cut()
if(timestamp) timestamp.Cut()
timerecorded = 0
to_chat(usr, "<span class='notice'>Memory cleared.</span>")
if(stored_info)
stored_info.Cut()
if(timestamp)
timestamp.Cut()
time_recorded = 0
to_chat(usr, SPAN_NOTICE("Memory cleared."))
return
/obj/item/device/taperecorder/verb/playback_memory()
set name = "Playback Memory"
set category = "Object"
if(usr.stat)
if(use_check_and_message(usr))
return
if(emagged == 1)
to_chat(usr, "<span class='warning'>The tape recorder makes a scratchy noise.</span>")
if(emagged)
to_chat(usr, SPAN_WARNING("The tape recorder makes a scratchy noise."))
return
if(recording == 1)
to_chat(usr, "<span class='notice'>You can't playback when recording!</span>")
if(recording)
to_chat(usr, SPAN_WARNING("You can't playback when recording!"))
return
if(playing == 1)
to_chat(usr, "<span class='notice'>You're already playing!</span>")
if(playing)
to_chat(usr, SPAN_WARNING("You're already playing!"))
return
playing = 1
playing = TRUE
icon_state = "taperecorderplaying"
to_chat(usr, "<span class='notice'>Playing started.</span>")
for(var/i=1,timerecorded<3600,sleep(10 * (playsleepseconds) ))
if(playing == 0)
to_chat(usr, SPAN_NOTICE("Playing started."))
for(var/i = 1, time_recorded < 3600, sleep(10 * play_sleep_seconds))
if(!playing)
break
if(storedinfo.len < i)
if(stored_info.len < i)
break
var/turf/T = get_turf(src)
var/playedmessage = storedinfo[i]
if (findtextEx(playedmessage,"*",1,2)) //remove marker for action sounds
playedmessage = copytext(playedmessage,2)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: [playedmessage]</font>")
if(storedinfo.len < i+1)
playsleepseconds = 1
var/playedmessage = stored_info[i]
if(findtextEx(playedmessage, "*" , 1, 2)) //remove marker for action sounds
playedmessage = copytext(playedmessage, 2)
audible_message("<font color=Maroon><B>Tape Recorder</B>: [playedmessage]</font>", hearing_distance = 3)
if(stored_info.len < i + 1)
play_sleep_seconds = 1
sleep(10)
T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: End of recording.</font>")
audible_message("<font color=Maroon><B>Tape Recorder</B>: End of recording.</font>", hearing_distance = 3)
else
playsleepseconds = timestamp[i+1] - timestamp[i]
if(playsleepseconds > 14)
play_sleep_seconds = timestamp[i + 1] - timestamp[i]
if(play_sleep_seconds > 14)
sleep(10)
T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: Skipping [playsleepseconds] seconds of silence</font>")
playsleepseconds = 1
audible_message("<font color=Maroon><B>Tape Recorder</B>: Skipping [play_sleep_seconds] seconds of silence.</font>", hearing_distance = 3)
play_sleep_seconds = 1
i++
icon_state = "taperecorderidle"
playing = 0
if(emagged == 1.0)
var/turf/T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: This tape recorder will self-destruct in... Five.</font>")
playing = FALSE
if(emagged)
audible_message("<font color=Maroon><B>Tape Recorder</B>: This tape recorder will self-destruct in... Five.</font>", hearing_distance = 3)
sleep(10)
T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: Four.</font>")
audible_message("<font color=Maroon><B>Tape Recorder</B>: Four.</font>", hearing_distance = 3)
sleep(10)
T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: Three.</font>")
audible_message("<font color=Maroon><B>Tape Recorder</B>: Three.</font>", hearing_distance = 3)
sleep(10)
T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: Two.</font>")
audible_message("<font color=Maroon><B>Tape Recorder</B>: Two.</font>", hearing_distance = 3)
sleep(10)
T = get_turf(src)
T.audible_message("<font color=Maroon><B>Tape Recorder</B>: One.</font>")
audible_message("<font color=Maroon><B>Tape Recorder</B>: One.</font>", hearing_distance = 3)
sleep(10)
explode()
/obj/item/device/taperecorder/verb/print_transcript()
set name = "Print Transcript"
set category = "Object"
if(usr.stat)
if(use_check_and_message(usr))
return
if(emagged == 1)
to_chat(usr, "<span class='warning'>The tape recorder makes a scratchy noise.</span>")
if(emagged)
to_chat(usr, SPAN_WARNING("The tape recorder makes a scratchy noise."))
return
if(!canprint)
to_chat(usr, "<span class='notice'>The recorder can't print that fast!</span>")
if(!can_print)
to_chat(usr, SPAN_WARNING("The recorder can't print that fast!"))
return
if(recording == 1 || playing == 1)
to_chat(usr, "<span class='notice'>You can't print the transcript while playing or recording!</span>")
if(recording || playing)
to_chat(usr, SPAN_WARNING("You can't print the transcript while playing or recording!"))
return
to_chat(usr, "<span class='notice'>Transcript printed.</span>")
to_chat(usr, SPAN_NOTICE("Transcript printed."))
var/obj/item/paper/P = new /obj/item/paper(get_turf(src))
var/t1 = "<B>Transcript:</B><BR><BR>"
for(var/i=1,storedinfo.len >= i,i++)
var/printedmessage = storedinfo[i]
if (findtextEx(printedmessage,"*",1,2)) //replace action sounds
printedmessage = "\[[time2text(timestamp[i]*10,"mm:ss")]\] (Unrecognized sound)"
t1 += "[printedmessage]<BR>"
for(var/i = 1, stored_info.len >= i, i++)
var/printed_message = stored_info[i]
if(findtextEx(printed_message,"*", 1, 2))
printed_message = "\[[time2text(timestamp[i]*10,"mm:ss")]\] (Unrecognized sound)"
t1 += "[printed_message]<BR>"
P.info = t1
P.name = "Transcript"
usr.put_in_hands(P)
canprint = 0
sleep(300)
canprint = 1
can_print = FALSE
addtimer(CALLBACK(src, .proc/toggle_can_print), 300)
can_print = TRUE
/obj/item/device/taperecorder/proc/toggle_can_print()
can_print = !can_print
/obj/item/device/taperecorder/verb/eject_usb()
set name = "Eject Portable Storage"
set category = "Object"
if(use_check_and_message(usr))
return
if(!portable_drive)
to_chat(usr, SPAN_WARNING("There is no portable drive connected to \the [src]."))
return
var/datum/computer_file/data/F = new /datum/computer_file/data(portable_drive)
F.filename = "[capitalize_first_letters(src.name)] Digital Transcript ([worldtime2text()] - [time2text(world.time, "Month DD")])"
F.filetype = "TXT"
var/file_data = "<B>Transcript:</B><BR>"
for(var/i = 1, stored_info.len >= i, i++)
var/printed_message = stored_info[i]
if(findtextEx(printed_message,"*", 1, 2))
printed_message = "\[[time2text(timestamp[i]*10,"mm:ss")]\] (Unrecognized sound)"
file_data += "[printed_message]<BR>"
F.stored_data = file_data
portable_drive.store_file(F)
to_chat(usr, SPAN_NOTICE("You eject the portable drive."))
usr.put_in_hands(portable_drive)
portable_drive = null
/obj/item/device/taperecorder/attack_self(mob/user)
if(recording == 0 && playing == 0)
if(usr.stat)
if(!recording && !playing)
if(use_check_and_message(usr))
return
if(emagged == 1)
to_chat(usr, "<span class='warning'>The tape recorder makes a scratchy noise.</span>")
if(emagged)
to_chat(usr, SPAN_WARNING("The tape recorder makes a scratchy noise."))
return
icon_state = "taperecorderrecording"
if(timerecorded < 3600 && playing == 0)
to_chat(usr, "<span class='notice'>Recording started.</span>")
recording = 1
timestamp+= timerecorded
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] Recording started."
for(timerecorded, timerecorded<3600)
if(recording == 0)
if(time_recorded < 3600 && !playing)
to_chat(usr, SPAN_NOTICE("Recording started."))
recording = TRUE
timestamp += time_recorded
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] Recording started."
for(time_recorded, time_recorded < 3600)
if(!recording)
break
timerecorded++
time_recorded++
sleep(10)
recording = 0
recording = FALSE
icon_state = "taperecorderidle"
return
else
to_chat(usr, "<span class='warning'>Either your tape recorder's memory is full, or it is currently playing back its memory.</span>")
to_chat(usr, SPAN_WARNING("Either your tape recorder's memory is full, or it is currently playing back its memory."))
else
if(usr.stat)
to_chat(usr, "Not when you're incapacitated.")
if(use_check_and_message(usr))
return
if(recording == 1)
recording = 0
timestamp+= timerecorded
storedinfo += "\[[time2text(timerecorded*10,"mm:ss")]\] Recording stopped."
to_chat(usr, "<span class='notice'>Recording stopped.</span>")
if(recording)
recording = FALSE
timestamp += time_recorded
stored_info += "\[[time2text(time_recorded*10,"mm:ss")]\] Recording stopped."
to_chat(usr, SPAN_NOTICE("Recording stopped."))
icon_state = "taperecorderidle"
return
else if(playing == 1)
playing = 0
var/turf/T = get_turf(src)
for(var/mob/O in hearers(world.view-1, T))
O.show_message("<font color=Maroon><B>Tape Recorder</B>: Playback stopped.</font>",2)
else if(playing)
playing = FALSE
audible_message("<font color=Maroon><B>Tape Recorder</B>: Playback stopped.</font>", hearing_distance = 3)
icon_state = "taperecorderidle"
return
else
to_chat(usr, "<span class='warning'>Stop what?</span>")
/obj/item/device/taperecorder/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/computer_hardware/hard_drive/portable))
if(portable_drive)
to_chat(user, SPAN_WARNING("\The [src] already has a portable drive!"))
return
user.drop_from_inventory(W, src)
portable_drive = W
else
..()