This repository was archived by the owner on May 22, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 457
Voice Announcement System for AIs and Captains #11548
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e31ec37
Voice Announcement System
monster860 217036e
Fixes shit the linter complained about
monster860 922a34e
Uses topic instead of JSON files
monster860 9c9155f
fixes alex's problems
monster860 1506dc0
use /dev/urandom on linux
monster860 7b8545e
GenerateToken
monster860 3c25f6c
update the config in theory
monster860 74ec94d
Allow downloading sounds via Get Server Logs
monster860 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| GLOBAL_LIST_EMPTY(voice_announce_list) | ||
|
|
||
| /datum/voice_announce | ||
| var/id | ||
| var/client/client | ||
| var/is_ai = FALSE | ||
| var/started_playing = FALSE | ||
| var/duration = 300 | ||
| var/canceled = FALSE | ||
| var/was_queried = FALSE | ||
|
|
||
| /datum/voice_announce/New(client/client) | ||
| . = ..() | ||
| src.client = client | ||
| id = "[client.ckey]_[GenerateToken()]" | ||
|
|
||
| /datum/voice_announce/Destroy() | ||
| GLOB.voice_announce_list -= id | ||
| . = ..() | ||
|
|
||
| /datum/voice_announce/proc/open() | ||
| if(SScommunications.last_voice_announce_open + 30 > world.time) | ||
| // Keep cheeky fucks from trying to waste resources by spamming the button | ||
| return | ||
| var/url_base = CONFIG_GET(string/voice_announce_url_base) | ||
| var/dir = CONFIG_GET(string/voice_announce_dir) | ||
| if(!url_base || !dir) | ||
| return | ||
|
|
||
| if(is_banned_from(client.ckey, "Voice Announcements")) | ||
| to_chat(client, "<span class='warning>You are banned from making voice announcements.</span>") | ||
| return | ||
|
|
||
| SScommunications.last_voice_announce_open = world.time | ||
|
|
||
| GLOB.voice_announce_list[id] = src | ||
| usr << link(url_base + "[CONFIG_GET(string/serversqlname)]/[id]") | ||
| addtimer(CALLBACK(src, .proc/timeout1), 15 SECONDS) | ||
| addtimer(CALLBACK(src, .proc/timeout2), 5 MINUTES) | ||
|
|
||
| /datum/voice_announce/proc/timeout1() | ||
| if(!was_queried && !started_playing) | ||
| qdel(src) | ||
|
|
||
| /datum/voice_announce/proc/timeout2() | ||
| if(!started_playing) | ||
| qdel(src) | ||
|
|
||
| /datum/voice_announce/Topic(href, href_list) | ||
| . = ..() | ||
| if(href_list["stop_announce"] && started_playing && !canceled && check_rights(NONE)) | ||
| SEND_SOUND(world, sound(null, channel = CHANNEL_VOICE_ANNOUNCE)) | ||
| canceled = TRUE | ||
| log_admin("[key_name(usr)] has canceled the voice announcement") | ||
| message_admins("[key_name_admin(usr)] has canceled the voice announcement") | ||
|
|
||
|
|
||
| /datum/voice_announce/proc/do_announce_sound(sound/sound1, sound/sound2, sounds_delay, z_level) | ||
| started_playing = TRUE | ||
| // Play for admins | ||
| for(var/mob/M in GLOB.player_list) | ||
| if(M.client && M.client.holder && M.can_hear() && (M.client.prefs.toggles & SOUND_ANNOUNCEMENTS)) | ||
| var/turf/T = get_turf(M) | ||
| if(T.z == z_level) | ||
| SEND_SOUND(M, sound1) | ||
| sleep(sounds_delay) | ||
| for(var/mob/M in GLOB.player_list) | ||
| if(M.client && M.client.holder && M.can_hear() && (M.client.prefs.toggles & SOUND_ANNOUNCEMENTS)) | ||
| var/turf/T = get_turf(M) | ||
| if(T.z == z_level) | ||
| SEND_SOUND(M, sound2) | ||
| sleep(30) | ||
| if(canceled) | ||
| return | ||
| // Play for everyone else | ||
| for(var/mob/M in GLOB.player_list) | ||
| if(M.client && !M.client.holder && M.can_hear() && (M.client.prefs.toggles & SOUND_ANNOUNCEMENTS)) | ||
| var/turf/T = get_turf(M) | ||
| if(T.z == z_level) | ||
| SEND_SOUND(M, sound1) | ||
| sleep(sounds_delay) | ||
| if(canceled) | ||
| return | ||
| for(var/mob/M in GLOB.player_list) | ||
| if(M.client && !M.client.holder && M.can_hear() && (M.client.prefs.toggles & SOUND_ANNOUNCEMENTS)) | ||
| var/turf/T = get_turf(M) | ||
| if(T.z == z_level) | ||
| SEND_SOUND(M, sound2) | ||
| sleep(duration) | ||
| qdel(src) | ||
|
|
||
| /datum/voice_announce/proc/check_valid() | ||
| if(client == null) | ||
| return FALSE | ||
| if(is_banned_from(client.ckey, "Voice Announcements")) | ||
| to_chat(client, "<span class='warning>You are banned from making voice announcements.</span>") | ||
| return FALSE | ||
| return TRUE | ||
|
|
||
| /datum/voice_announce/proc/announce(snd) | ||
| stack_trace("announce() is unimplemented") | ||
|
|
||
| /datum/voice_announce/proc/handle_announce(ogg_filename, base_filename, ip, duration) | ||
| src.duration = duration | ||
| GLOB.voice_announce_list -= id | ||
| var/ogg_file = file("[CONFIG_GET(string/voice_announce_dir)]/[ogg_filename]") | ||
| var/base_file = file("[CONFIG_GET(string/voice_announce_dir)]/[base_filename]") | ||
| if(check_valid()) | ||
| var/snd = fcopy_rsc(ogg_file) | ||
| fdel(ogg_file) | ||
| fcopy(base_file, "[GLOB.log_directory]/[base_filename]") | ||
| fdel(base_file) | ||
|
|
||
| log_admin("[key_name(client)] has made a voice announcement via [ip], saved to [base_filename]") | ||
| message_admins("[key_name_admin(client)] has made a voice announcement. ((<a href='?src=[REF(src)]&stop_announce=1'>CANCEL</a>))") | ||
|
|
||
| announce(snd) | ||
| else | ||
| fdel(ogg_file) | ||
| fdel(base_file) | ||
|
|
||
| /datum/voice_announce/ai | ||
| is_ai = TRUE | ||
|
|
||
| /datum/voice_announce/ai/check_valid() | ||
| if(!..()) | ||
| return FALSE | ||
| var/mob/living/silicon/ai/M = client.mob | ||
| if(!istype(M)) | ||
| return FALSE | ||
| if(GLOB.announcing_vox > world.time || M.control_disabled || M.incapacitated()) | ||
| return FALSE | ||
| return TRUE | ||
|
|
||
| /datum/voice_announce/ai/announce(snd) | ||
| set waitfor = 0 | ||
|
|
||
| GLOB.announcing_vox = world.time + 600 | ||
|
|
||
| var/turf/mob_turf = get_turf(client.mob) | ||
| var/z_level = mob_turf.z | ||
|
|
||
| var/sound/sound1 = sound('sound/vox/doop.ogg') | ||
| var/sound/sound2 = sound(snd, channel = CHANNEL_VOICE_ANNOUNCE, volume = 70) | ||
| do_announce_sound(sound1, sound2, 5, z_level) | ||
|
|
||
| /datum/voice_announce/command | ||
| var/obj/machinery/computer/communications/comms_console | ||
|
|
||
| /datum/voice_announce/command/New(client/client, obj/machinery/computer/communications/console) | ||
| . = ..() | ||
| comms_console = console | ||
|
|
||
| /datum/voice_announce/command/check_valid() | ||
| if(!..()) | ||
| return FALSE | ||
| var/mob/living/user = client.mob | ||
| if(!SScommunications.can_announce(user, issilicon(user))) | ||
| return FALSE | ||
| if(!istype(user) || !user.canUseTopic(comms_console, !issilicon(user))) | ||
| return FALSE | ||
| return TRUE | ||
|
|
||
| /datum/voice_announce/command/announce(snd) | ||
| set waitfor = 0 | ||
| var/turf/console_turf = get_turf(comms_console) | ||
| var/z_level = console_turf.z | ||
| SScommunications.nonsilicon_message_cooldown = world.time + 300 | ||
| var/mob/living/user = client.mob | ||
| deadchat_broadcast(" made a priority announcement from <span class='name'>[get_area_name(user, TRUE)]</span>.", "<span class='name'>[user.real_name]</span>", user) | ||
| var/sound/sound1 = sound('sound/misc/announce.ogg') | ||
| var/sound/sound2 = sound(snd, channel = CHANNEL_VOICE_ANNOUNCE, volume = 70) | ||
| do_announce_sound(sound1, sound2, 15, z_level) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an unreasonably long wait time IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure about having it played for everyone before admins get to hear the full message tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admins get to hear bad words before everyone else, hit cancel button, sure they'll get a message cut off halfway but whatever right?