Skip to content

Commit

Permalink
Language refactor & Blindness stuffs (#893)
Browse files Browse the repository at this point in the history
* base stuff

* tweaks to sign language not understood

* stop hearing sign language

* remove low memoery mode

* fix compile error

* fix null lang

* fix random language setting

* fixes

* fix, this should be null not zero

* fix zebra table css

* language pref

* Add Spacer

* remove ssd indicator, touch up examine

* adjust age positioning in examine

* fixup species data usage

* Partially hear people talking while unconscious

* blindness

* HOLY FUCK

* fuck

* fixes

* more fixes

* this probably fixes it...?

* WORK!!!!

* this probably needs infinity too

* OOGA BOOGA PASS UNIT TESTS

* fixes stuff

* fix holopad range

* fix this probably

* before_speaking & say mod fixes

* good enough

* fix auto punctuation pref

* dont modify payroll announcements

* cleanup sign language saymod

* cleaner

* tanks are bulky
  • Loading branch information
Kapu1178 authored Mar 26, 2024
1 parent 8b05775 commit be98ab4
Show file tree
Hide file tree
Showing 137 changed files with 1,443 additions and 987 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/DNA.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ GLOBAL_LIST_INIT(organ_process_order, list(
ORGAN_SLOT_XENO_EGGSAC,
ORGAN_SLOT_BRAIN))

#define SPECIES_DATA_PERKS 1
#define SPECIES_DATA_LANGUAGES 2

// Defines for used in creating "perks" for the species preference pages.
/// A key that designates UI icon displayed on the perk.
#define SPECIES_PERK_ICON "ui_icon"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@
#define HEARING_SPEAKER 2
#define HEARING_LANGUAGE 3
#define HEARING_RAW_MESSAGE 4
/* #define HEARING_RADIO_FREQ 5
#define HEARING_RADIO_FREQ 5
#define HEARING_SPANS 6
#define HEARING_MESSAGE_MODE 7 */
#define HEARING_MESSAGE_MODE 7
#define HEARING_SOUND_LOC 8
#define HEARING_MESSAGE_RANGE 9

/// Same as the above but RAW_MESSAGE will be replaced with the mob's interpretation of the message.
#define COMSIG_LIVING_HEAR_POST_TRANSLATION "living_hear_after_translate"

///called when the movable is added to a disposal holder object for disposal movement: (obj/structure/disposalholder/holder, obj/machinery/disposal/source)
#define COMSIG_MOVABLE_DISPOSING "movable_disposing"
Expand Down
11 changes: 6 additions & 5 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@
#define COMPONENT_UPPERCASE_SPEECH (1<<0)
// used to access COMSIG_MOB_SAY argslist
#define SPEECH_MESSAGE 1
// #define SPEECH_BUBBLE_TYPE 2
#define SPEECH_BUBBLE_TYPE 2
#define SPEECH_SPANS 3
// #define SPEECH_SANITIZE 4
#define SPEECH_SANITIZE 4
#define SPEECH_LANGUAGE 5
/* #define SPEECH_IGNORE_SPAM 6
#define SPEECH_FORCED 7 */
#define SPEECH_RANGE 8
#define SPEECH_IGNORE_SPAM 6
#define SPEECH_FORCED 7
#define SPEECH_FILTERPROOF 8
#define SPEECH_RANGE 9

///from /mob/say_dead(): (mob/speaker, message)
#define COMSIG_MOB_DEADSAY "mob_deadsay"
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/dcs/signals/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@

///called from base of /obj/item/radio/proc/set_frequency(): (list/args)
#define COMSIG_RADIO_NEW_FREQUENCY "radio_new_frequency"
///called during SSpacketnets/proc/ImmediateSubspaceVocalSend(): (message, freq_num)
#define COMSIG_RADIO_NEW_MESSAGE "radio_new_message"
///called during SSpacketnets/proc/ImmediateSubspaceVocalSend(): (speaker, message, freq_num, data)
#define COMSIG_RADIO_RECEIVE "radio_receive"
// /obj/item/pen signals

///called after rotation in /obj/item/pen/attack_self(): (rotation, mob/living/carbon/user)
#define COMSIG_PEN_ROTATED "pen_rotated"

Expand Down
15 changes: 11 additions & 4 deletions code/__DEFINES/language.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#define NO_STUTTER 1
#define TONGUELESS_SPEECH 2
#define LANGUAGE_HIDE_ICON_IF_UNDERSTOOD 4
#define LANGUAGE_HIDE_ICON_IF_NOT_UNDERSTOOD 8
#define NO_STUTTER (1<<0)
#define TONGUELESS_SPEECH (1<<1)
#define LANGUAGE_HIDE_ICON_IF_UNDERSTOOD (1<<2)
#define LANGUAGE_HIDE_ICON_IF_NOT_UNDERSTOOD (1<<3)
#define LANGUAGE_CAN_WHISPER (1<<4)
#define LANGUAGE_SELECTABLE_SPEAK (1<<5)
#define LANGUAGE_SELECTABLE_UNDERSTAND (1<<6)
#define LANGUAGE_OVERRIDE_SAY_MOD (1<<7)

// LANGUAGE SOURCE DEFINES
#define LANGUAGE_ALL "all" // For use in full removal only.
Expand All @@ -22,3 +26,6 @@
#define LANGUAGE_SOFTWARE "software"
#define LANGUAGE_STONER "stoner"
#define LANGUAGE_VOICECHANGE "voicechange"

#define LANGUAGE_UNDERSTAND (1<<0)
#define LANGUAGE_SPEAK (1<<1)
4 changes: 4 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -814,3 +814,7 @@ GLOBAL_LIST_INIT(voice_type2sound_ref, voice_type2sound)
#define MOB_ATTACKEDBY_FAIL 0
#define MOB_ATTACKEDBY_SUCCESS 1
#define MOB_ATTACKEDBY_NO_DAMAGE 2

#define BLIND_NOT_BLIND 0
#define BLIND_PHYSICAL 1
#define BLIND_SLEEPING 2
8 changes: 7 additions & 1 deletion code/__DEFINES/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@

#define MODE_CUSTOM_SAY_ERASE_INPUT "erase_input"

#define MODE_NO_QUOTE "no_quote"

//Spans. Robot speech, italics, etc. Applied in compose_message().
#define SPAN_ROBOT "robot"
#define SPAN_YELL "yell"
Expand All @@ -74,7 +76,11 @@
#define REDUCE_RANGE (1<<1)
#define NOPASS (1<<2)

//Eavesdropping
/// Range to hear normal messages
#define MESSAGE_RANGE 7
/// Range to hear whispers normally
#define WHISPER_RANGE 1
/// Additional range to partially hear whispers
#define EAVESDROP_EXTRA_RANGE 1 //how much past the specified message_range does the message get starred, whispering only

/// How close intercoms can be for radio code use
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/spaceman_dmm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
/world/Del()
var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL")
if (debug_server)
call(debug_server, "auxtools_shutdown")()
call_ext(debug_server, "auxtools_shutdown")()
. = ..()
6 changes: 2 additions & 4 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_NO_PAINSHOCK "no_painshock"
/// Does not get addicted
#define TRAIT_NO_ADDICTION "no_addiction"
/// Makes whispers clearly heard from seven tiles away, the full hearing range
#define TRAIT_GOOD_HEARING "good_hearing"

// Stops the mob from slipping on water, or banana peels, or pretty much anything that doesn't have [GALOSHES_DONT_HELP] set
#define TRAIT_NO_SLIP_WATER "NO_SLIP_WATER"
Expand Down Expand Up @@ -357,10 +359,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_TUMOR_SUPPRESSED "brain_tumor_suppressed"
/// overrides the update_fire proc to always add fire (for lava)
#define TRAIT_PERMANENTLY_ONFIRE "permanently_onfire"
/// Galactic Common Sign Language
#define TRAIT_SIGN_LANG "sign_language"
/// This mob is able to use sign language over the radio.
#define TRAIT_CAN_SIGN_ON_COMMS "can_sign_on_comms"
/// nobody can use martial arts on this mob
#define TRAIT_MARTIAL_ARTS_IMMUNE "martial_arts_immune"
/// You've been cursed with a living duffelbag, and can't have more added
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/~pariah_defines/jobs.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define SEC_RESTRICTED_QUIRKS "Blind" = TRUE, "Brain Tumor" = TRUE, "Deaf" = TRUE, "Paraplegic" = TRUE, "Mute" = TRUE, "Foreigner" = TRUE, "Pacifist" = TRUE, "Chunky Fingers" = TRUE
#define HEAD_RESTRICTED_QUIRKS "Blind" = TRUE, "Deaf" = TRUE, "Mute" = TRUE, "Foreigner" = TRUE, "Chunky Fingers" = TRUE
#define SEC_RESTRICTED_QUIRKS "Blind" = TRUE, "Brain Tumor" = TRUE, "Deaf" = TRUE, "Paraplegic" = TRUE, "Mute" = TRUE, "Pacifist" = TRUE, "Chunky Fingers" = TRUE
#define HEAD_RESTRICTED_QUIRKS "Blind" = TRUE, "Deaf" = TRUE, "Mute" = TRUE, "Chunky Fingers" = TRUE
#define TECH_RESTRICTED_QUIRKS "Chunky Fingers" = TRUE
14 changes: 14 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@

init_blood_types()

init_language_datums()

/// Inits the crafting recipe list, sorting crafting recipe requirements in the process.
/proc/init_crafting_recipes(list/crafting_recipes)
for(var/path in subtypesof(/datum/crafting_recipe))
Expand Down Expand Up @@ -251,3 +253,15 @@ GLOBAL_LIST_INIT(magnet_error_codes, list(
if(isabstract(path))
continue
GLOB.blood_datums[path] = new path()

/proc/init_language_datums()
for(var/datum/language/language as anything in subtypesof(/datum/language))
if(isabstract(language) || !initial(language.key))
continue

var/datum/language/instance = new language
GLOB.all_languages += instance
GLOB.language_datum_instances[language] = instance

if(instance.flags & (LANGUAGE_SELECTABLE_SPEAK | LANGUAGE_SELECTABLE_UNDERSTAND))
GLOB.preference_language_types += language
3 changes: 3 additions & 0 deletions code/_globalvars/lists/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ GLOBAL_LIST_EMPTY(current_observers_list)
///underages who have been reported to security for trying to buy things they shouldn't, so they can't spam
GLOBAL_LIST_EMPTY(narcd_underages)

#define GET_LANGUAGE_DATUM(lang) (istype(lang, /datum/language) ? lang : GLOB.language_datum_instances[lang])

GLOBAL_LIST_EMPTY(language_datum_instances)
GLOBAL_LIST_EMPTY(all_languages)
GLOBAL_LIST_EMPTY(preference_language_types)

GLOBAL_LIST_EMPTY(sentient_disease_instances)

Expand Down
1 change: 0 additions & 1 deletion code/_globalvars/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_NICE_SHOT" = TRAIT_NICE_SHOT,
"TRAIT_TUMOR_SUPPRESSION" = TRAIT_TUMOR_SUPPRESSED,
"TRAIT_PERMANENTLY_ONFIRE" = TRAIT_PERMANENTLY_ONFIRE,
"TRAIT_SIGN_LANG" = TRAIT_SIGN_LANG,
"TRAIT_UNDERWATER_BASKETWEAVING_KNOWLEDGE" = TRAIT_UNDERWATER_BASKETWEAVING_KNOWLEDGE,
"TRAIT_WINE_TASTER" = TRAIT_WINE_TASTER,
"TRAIT_BONSAI" = TRAIT_BONSAI,
Expand Down
5 changes: 5 additions & 0 deletions code/_onclick/hud/fullscreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
layer = BLIND_LAYER
plane = FULLSCREEN_PLANE

/atom/movable/screen/fullscreen/blind/blinder
icon_state = "blackerimageoverlay"
layer = BLIND_LAYER + 0.01
plane = FULLSCREEN_PLANE

/atom/movable/screen/fullscreen/curse
icon_state = "curse"
layer = CURSE_LAYER
Expand Down
1 change: 1 addition & 0 deletions code/controllers/subsystem/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ SUBSYSTEM_DEF(economy)
"Attention staff of [station_name()], you have received payment for this period. You may withdraw funds from your nearest ATM.",
"Station Announcement",
"Staff Update",
do_not_modify = TRUE,
)

//price_update() This doesn't need to fire every 5 minutes. The only current use is market crash, which handles it on its own.
Expand Down
18 changes: 0 additions & 18 deletions code/controllers/subsystem/language.dm

This file was deleted.

35 changes: 3 additions & 32 deletions code/controllers/subsystem/packetnets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,35 +195,6 @@ SUBSYSTEM_DEF(packets)

cost_radios = MC_AVERAGE(cost_radios, TICK_DELTA_TO_MS(cached_cost))
resumed = FALSE
// stage = SSPACKETS_TABLETS

// if(stage == SSPACKETS_TABLETS)
// timer = TICK_USAGE_REAL
// if(!resumed)
// cached_cost = 0
// last_processed_tablet_message_packets = 0

// var/datum/signal/subspace/messaging/tablet_msg/packet
// while(length(current_tablet_messages))
// packet = current_tablet_messages[1]
// current_tablet_messages.Cut(1,2)
// queued_tablet_messages -= packet

// if (!packet.logged) // Can only go through if a message server logs it
// continue

// for (var/obj/item/modular_computer/comp in packet.data["targets"])
// var/obj/item/computer_hardware/hard_drive/drive = comp.all_components[MC_HDD]
// for(var/datum/computer_file/program/messenger/app in drive.stored_files)
// app.receive_message(packet)

// cached_cost += TICK_USAGE_REAL - timer
// last_processed_tablet_message_packets++
// if(MC_TICK_CHECK)
// return

// cost_tablets = MC_AVERAGE(cost_tablets, TICK_DELTA_TO_MS(cached_cost))
// resumed = FALSE
stage = SSPACKETS_SUBSPACE_VOCAL

if(stage == SSPACKETS_SUBSPACE_VOCAL)
Expand Down Expand Up @@ -405,17 +376,17 @@ SUBSYSTEM_DEF(packets)
var/rendered = virt.compose_message(virt, language, message, frequency, spans)

for(var/obj/item/radio/radio as anything in receive)
SEND_SIGNAL(radio, COMSIG_RADIO_RECEIVE, virt.source, message, frequency)
SEND_SIGNAL(radio, COMSIG_RADIO_RECEIVE, virt.source, message, frequency, data)
for(var/atom/movable/hearer as anything in receive[radio])
if(!hearer)
stack_trace("null found in the hearers list returned by the spatial grid. this is bad")
continue

hearer.Hear(rendered, virt, language, message, frequency, spans, message_mods, sound_loc = radio.speaker_location())
hearer.Hear(rendered, virt, language, message, frequency, spans, message_mods, sound_loc = radio.speaker_location(), message_range = INFINITY)

// Let the global hearers (ghosts, etc) hear this message
for(var/atom/movable/hearer as anything in globally_receiving)
hearer.Hear(rendered, virt, language, message, frequency, spans, message_mods)
hearer.Hear(rendered, virt, language, message, frequency, spans, message_mods, message_range = INFINITY)

// This following recording is intended for research and feedback in the use of department radio channels
if(length(receive))
Expand Down
3 changes: 3 additions & 0 deletions code/datums/brain_damage/hypnosis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@
new /datum/hallucination/chat(owner, TRUE, FALSE, span_hypnophrase("[hypnotic_phrase]"))

/datum/brain_trauma/hypnosis/handle_hearing(datum/source, list/hearing_args)
var/datum/language/L = hearing_args[HEARING_LANGUAGE]
if(istype(L, /datum/language/visual) || !L?.can_receive_language(owner))
return
hearing_args[HEARING_RAW_MESSAGE] = target_phrase.Replace(hearing_args[HEARING_RAW_MESSAGE], span_hypnophrase("$1"))
2 changes: 1 addition & 1 deletion code/datums/brain_damage/imaginary_friend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

friend_talk(message)

/mob/camera/imaginary_friend/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods = list(), atom/sound_loc)
/mob/camera/imaginary_friend/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods = list(), atom/sound_loc, message_range)
if (client?.prefs.read_preference(/datum/preference/toggle/enable_runechat) && (client.prefs.read_preference(/datum/preference/toggle/enable_runechat_non_mobs) || ismob(speaker)))
create_chat_message(speaker, message_language, raw_message, spans, sound_loc = sound_loc)
to_chat(src, compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mods))
Expand Down
5 changes: 5 additions & 0 deletions code/datums/brain_damage/mild.dm
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@
/datum/brain_trauma/mild/mind_echo/handle_hearing(datum/source, list/hearing_args)
if(owner == hearing_args[HEARING_SPEAKER])
return

var/datum/language/L = hearing_args[HEARING_LANGUAGE]
if(istype(L, /datum/language/visual) || !L?.can_receive_language(owner) || !owner.has_language(L))
return

if(hear_dejavu.len >= 5)
if(prob(25))
var/deja_vu = pick_n_take(hear_dejavu)
Expand Down
5 changes: 4 additions & 1 deletion code/datums/brain_damage/phobia.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@
return

/datum/brain_trauma/mild/phobia/handle_hearing(datum/source, list/hearing_args)
if(!owner.can_hear() || !COOLDOWN_FINISHED(src, scare_cooldown)) //words can't trigger you if you can't hear them *taps head*
var/datum/language/L = hearing_args[HEARING_LANGUAGE]
if(!L?.can_receive_language(owner) || !owner.has_language(L))
return
if(!COOLDOWN_FINISHED(src, scare_cooldown)) //words can't trigger you if you can't hear them *taps head*
return
if(HAS_TRAIT(owner, TRAIT_FEARLESS))
return
Expand Down
6 changes: 4 additions & 2 deletions code/datums/brain_damage/severe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,13 @@
owner.remove_status_effect(/datum/status_effect/trance)

/datum/brain_trauma/severe/hypnotic_trigger/handle_hearing(datum/source, list/hearing_args)
if(!owner.can_hear())
return
if(owner == hearing_args[HEARING_SPEAKER])
return

var/datum/language/L = hearing_args[HEARING_LANGUAGE]
if(istype(L, /datum/language/visual) || !L?.can_receive_language(owner) || !owner.has_language(L))
return

var/regex/reg = new("(\\b[REGEX_QUOTE(trigger_phrase)]\\b)","ig")

if(findtext(hearing_args[HEARING_RAW_MESSAGE], reg))
Expand Down
7 changes: 6 additions & 1 deletion code/datums/brain_damage/split_personality.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,13 @@
return //no random switching

/datum/brain_trauma/severe/split_personality/brainwashing/handle_hearing(datum/source, list/hearing_args)
if(HAS_TRAIT(owner, TRAIT_DEAF) || owner == hearing_args[HEARING_SPEAKER])
if(owner == hearing_args[HEARING_SPEAKER])
return

var/datum/language/L = hearing_args[HEARING_LANGUAGE]
if(istype(L, /datum/language/visual) || !L?.can_receive_language(owner) || !owner.has_language(L))
return

var/message = hearing_args[HEARING_RAW_MESSAGE]
if(findtext(message, codeword))
hearing_args[HEARING_RAW_MESSAGE] = replacetext(message, codeword, span_warning("[codeword]"))
Expand Down
8 changes: 3 additions & 5 deletions code/datums/chatmessage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,10 @@
LAZYADD(prefixes, "\icon[r_icon]")

// Append language icon if the language uses one
var/datum/language/language_instance = GLOB.language_datum_instances[language]
if (language_instance?.display_icon(owner))
if (language?.display_icon(owner))
var/icon/language_icon = LAZYACCESS(language_icons, language)
if (isnull(language_icon))
language_icon = icon(language_instance.icon, icon_state = language_instance.icon_state)
language_icon = icon(language.icon, icon_state = language.icon_state)
language_icon.Scale(CHAT_MESSAGE_ICON_SIZE, CHAT_MESSAGE_ICON_SIZE)
LAZYSET(language_icons, language, language_icon)
LAZYADD(prefixes, "\icon[language_icon]")
Expand Down Expand Up @@ -293,8 +292,7 @@
if(runechat_flags & EMOTE_MESSAGE)
new /datum/chatmessage(raw_message, sound_loc || speaker, src, message_language, list("emote", "italics"))
else
new /datum/chatmessage(lang_treat(speaker, message_language, raw_message, spans, null, TRUE), sound_loc || speaker, src, message_language, spans)

new /datum/chatmessage(raw_message, sound_loc || speaker, src, message_language, spans)

// Tweak these defines to change the available color ranges
#define CM_COLOR_SAT_MIN 0.6
Expand Down
8 changes: 8 additions & 0 deletions code/datums/components/codeword_hearing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
/datum/component/codeword_hearing/proc/handle_hearing(datum/source, list/hearing_args)
SIGNAL_HANDLER

var/mob/living/mob_owner = parent
if(!istype(mob_owner))
return

var/datum/language/L = hearing_args[HEARING_LANGUAGE]
if(!L?.can_receive_language(mob_owner) || !mob_owner.has_language(L))
return

var/message = hearing_args[HEARING_RAW_MESSAGE]
message = replace_regex.Replace(message, "<span class='[span_class]'>$1</span>")
hearing_args[HEARING_RAW_MESSAGE] = message
Expand Down
Loading

0 comments on commit be98ab4

Please sign in to comment.