Skip to content

Commit

Permalink
Ghost listening device preference (#5219)
Browse files Browse the repository at this point in the history
# About the pull request
Ghosts can now toggle between hearing and not hearing listening devices.

## THIS DEFAULTS TO OFF

# Explain why it's good for the game
Bit of peace of mind, a lot of text can be duplicated by hearing
listening devices as a ghost.
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
add: Ghosts can now toggle hearing listening devices or not. This is
dependant on hearing radios and will not function to allow hearing
devices without also hearing radios.
/:cl:

---------

Co-authored-by: Drathek <[email protected]>
  • Loading branch information
realforest2001 and Drulikar committed Dec 21, 2023
1 parent c5dc4c5 commit 1f6e62a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/__game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ block( \
#define CHAT_FFATTACKLOGS (1<<11)
#define CHAT_GHOSTHIVEMIND (1<<12)
#define CHAT_NICHELOGS (1<<13)
#define CHAT_LISTENINGBUG (1<<14)

//toggles_ghost
#define GHOST_HEALTH_SCAN (1<<0)
Expand Down
7 changes: 5 additions & 2 deletions code/game/machinery/telecomms/broadcaster.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
vmask, vmessage, obj/item/device/radio/radio,
message, name, job, realname, vname,
data, compression, list/level, freq, verbage = "says",
datum/language/speaking = null, volume = RADIO_VOLUME_QUIET)
datum/language/speaking = null, volume = RADIO_VOLUME_QUIET, listening_device = FALSE)

/* ###### Prepare the radio connection ###### */
var/display_freq = freq
Expand Down Expand Up @@ -175,13 +175,16 @@
volume = RADIO_VOLUME_CRITICAL

for (var/mob/R in receive)
var/is_ghost = istype(R, /mob/dead/observer)
/* --- Loop through the receivers and categorize them --- */
if (R.client && !(R.client.prefs.toggles_chat & CHAT_RADIO)) //Adminning with 80 people on can be fun when you're trying to talk and all you can hear is radios.
continue
if(istype(R, /mob/new_player)) // we don't want new players to hear messages. rare but generates runtimes.
continue
// Ghosts hearing all radio chat don't want to hear syndicate intercepts, they're duplicates
if(data == 3 && istype(R, /mob/dead/observer) && R.client && (R.client.prefs.toggles_chat & CHAT_GHOSTRADIO))
if(data == 3 && is_ghost && R.client && (R.client.prefs.toggles_chat & CHAT_GHOSTRADIO))
continue
if(is_ghost && listening_device && !(R.client.prefs.toggles_chat & CHAT_LISTENINGBUG))
continue
// --- Check for compression ---
if(compression > 0)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/radio/listening_bugs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
var/processed_verb = "[SPAN_RED("\[LSTN [nametag]\]")] [verb]"
if(broadcasting)
if(get_dist(src, M) <= 7)
talk_into(M, msg,null,processed_verb,speaking)
talk_into(M, msg, null, processed_verb, speaking, listening_device = TRUE)

/obj/item/device/radio/listening_bug/afterattack(atom/target_atom, mob/user as mob, proximity)
if(!ready_to_disguise)
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
// If we were to send to a channel we don't have, drop it.
return null

/obj/item/device/radio/talk_into(mob/living/M as mob, message, channel, verb = "says", datum/language/speaking = null)
/obj/item/device/radio/talk_into(mob/living/M as mob, message, channel, verb = "says", datum/language/speaking = null, listening_device = FALSE)
if(!on) return // the device has to be on
// Fix for permacell radios, but kinda eh about actually fixing them.
if(!M || !message) return
Expand Down Expand Up @@ -297,11 +297,11 @@
if(use_volume)
Broadcast_Message(connection, M, voicemask, pick(M.speak_emote),
src, message, displayname, jobname, real_name, M.voice_name,
filter_type, 0, target_zs, connection.frequency, verb, speaking, volume)
filter_type, 0, target_zs, connection.frequency, verb, speaking, volume, listening_device)
else
Broadcast_Message(connection, M, voicemask, pick(M.speak_emote),
src, message, displayname, jobname, real_name, M.voice_name,
filter_type, 0, target_zs, connection.frequency, verb, speaking, RADIO_VOLUME_QUIET)
filter_type, 0, target_zs, connection.frequency, verb, speaking, RADIO_VOLUME_QUIET, listening_device)

/obj/item/device/radio/proc/get_target_zs(frequency)
var/turf/position = get_turf(src)
Expand Down
4 changes: 4 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ GLOBAL_LIST_INIT(bgstate_options, list(
dat += "<b>Ghost Ears:</b> <a href='?_src_=prefs;preference=ghost_ears'><b>[(toggles_chat & CHAT_GHOSTEARS) ? "All Speech" : "Nearest Creatures"]</b></a><br>"
dat += "<b>Ghost Sight:</b> <a href='?_src_=prefs;preference=ghost_sight'><b>[(toggles_chat & CHAT_GHOSTSIGHT) ? "All Emotes" : "Nearest Creatures"]</b></a><br>"
dat += "<b>Ghost Radio:</b> <a href='?_src_=prefs;preference=ghost_radio'><b>[(toggles_chat & CHAT_GHOSTRADIO) ? "All Chatter" : "Nearest Speakers"]</b></a><br>"
dat += "<b>Ghost Spy Radio:</b> <a href='?_src_=prefs;preference=ghost_spyradio'><b>[(toggles_chat & CHAT_LISTENINGBUG) ? "Hear" : "Silence"] listening devices</b></a><br>"
dat += "<b>Ghost Hivemind:</b> <a href='?_src_=prefs;preference=ghost_hivemind'><b>[(toggles_chat & CHAT_GHOSTHIVEMIND) ? "Show Hivemind" : "Hide Hivemind"]</b></a><br>"
dat += "<b>Abovehead Chat:</b> <a href='?_src_=prefs;preference=lang_chat_disabled'><b>[lang_chat_disabled ? "Hide" : "Show"]</b></a><br>"
dat += "<b>Abovehead Emotes:</b> <a href='?_src_=prefs;preference=langchat_emotes'><b>[(toggles_langchat & LANGCHAT_SEE_EMOTES) ? "Show" : "Hide"]</b></a><br>"
Expand Down Expand Up @@ -1832,6 +1833,9 @@ GLOBAL_LIST_INIT(bgstate_options, list(
if("ghost_radio")
toggles_chat ^= CHAT_GHOSTRADIO

if("ghost_spyradio")
toggles_chat ^= CHAT_LISTENINGBUG

if("ghost_hivemind")
toggles_chat ^= CHAT_GHOSTHIVEMIND

Expand Down
9 changes: 9 additions & 0 deletions code/modules/client/preferences_toggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@
to_chat(src,SPAN_BOLDNOTICE( "As a ghost, you will now [(prefs.toggles_chat & CHAT_GHOSTRADIO) ? "hear all radio chat in the world" : "only hear from nearby speakers"]."))
prefs.save_preferences()

/client/proc/toggle_ghost_spyradio()
set name = "Toggle GhostSpyRadio"
set category = "Preferences.Ghost"
set desc = "Toggle between hearing listening devices or not."
prefs.toggles_chat ^= CHAT_LISTENINGBUG
to_chat(src,SPAN_BOLDNOTICE( "As a ghost, you will [(prefs.toggles_chat & CHAT_LISTENINGBUG) ? "now" : "no longer"] hear listening devices as a ghost."))
prefs.save_preferences()

/client/proc/toggle_ghost_hud()
set name = "Toggle Ghost HUDs"
set category = "Preferences.Ghost"
Expand Down Expand Up @@ -757,6 +765,7 @@ GLOBAL_LIST_INIT(ghost_prefs_verbs, list(
/client/proc/toggle_ghost_ears,
/client/proc/toggle_ghost_sight,
/client/proc/toggle_ghost_radio,
/client/proc/toggle_ghost_spyradio,
/client/proc/toggle_ghost_hivemind,
/client/proc/deadchat,
/client/proc/toggle_ghost_hud,
Expand Down

0 comments on commit 1f6e62a

Please sign in to comment.