Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Extremely Fast Quirk Changes #148

Merged
merged 7 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__DEFINES/~doppler_defines/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#define TRAIT_LEFT_HANDED "left_handed"
/// Trait for people with the cybernetic quirk
#define TRAIT_PERMITTED_CYBERNETIC "permitted_cybernetic"
/// No step on glass
#define TRAIT_HARD_SOLES "hard_soles"

////
// Jobs
Expand Down
4 changes: 4 additions & 0 deletions code/datums/components/caltrop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
return

if (!(flags & CALTROP_BYPASS_SHOES))
// NOVA EDIT ADDITION BEGIN - Hardened Soles Quirk
carpotoxin marked this conversation as resolved.
Show resolved Hide resolved
if(HAS_TRAIT(digitigrade_fan, TRAIT_HARD_SOLES))
return
// NOVA EDIT ADDITION END
if ((digitigrade_fan.wear_suit?.body_parts_covered | digitigrade_fan.w_uniform?.body_parts_covered | digitigrade_fan.shoes?.body_parts_covered) & FEET)
return

Expand Down
10 changes: 10 additions & 0 deletions modular_doppler/modular_quirks/hardened_soles/hardened_soles.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

/datum/quirk/hard_soles
name = "Hardened Soles"
desc = "You're used to walking barefoot, and won't receive the negative effects of doing so."
value = 2
mob_trait = TRAIT_HARD_SOLES
gain_text = span_notice("The ground doesn't feel so rough on your feet anymore.")
lose_text = span_danger("You start feeling the ridges and imperfections on the ground.")
medical_record_text = "Patient's feet are more resilient against traction."
icon = FA_ICON_PERSON_RUNNING
132 changes: 0 additions & 132 deletions modular_doppler/modular_quirks/linguist/linguist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,135 +7,3 @@
lose_text = span_danger("Your grasp of the finer points of Draconic idioms fades away.")
medical_record_text = "Patient demonstrates a high brain plasticity in regards to language learning."
icon = FA_ICON_BOOK_ATLAS

/datum/quirk/night_vision
name = "Night Vision"
desc = "You can see slightly more clearly in full darkness than most people."
icon = FA_ICON_MOON
value = 4
mob_trait = TRAIT_NIGHT_VISION
gain_text = span_notice("The shadows seem a little less dark.")
lose_text = span_danger("Everything seems a little darker.")
medical_record_text = "Patient's eyes show above-average acclimation to darkness."
mail_goodies = list(
/obj/item/flashlight/flashdark,
/obj/item/food/grown/mushroom/glowshroom/shadowshroom,
/obj/item/skillchip/light_remover,
)

/datum/quirk/night_vision/add(client/client_source)
refresh_quirk_holder_eyes()

/datum/quirk/night_vision/remove()
refresh_quirk_holder_eyes()

/datum/quirk/night_vision/proc/refresh_quirk_holder_eyes()
var/mob/living/carbon/human/human_quirk_holder = quirk_holder
var/obj/item/organ/internal/eyes/eyes = human_quirk_holder.get_organ_by_type(/obj/item/organ/internal/eyes)
if(!eyes)
return
// We've either added or removed TRAIT_NIGHT_VISION before calling this proc. Just refresh the eyes.
eyes.refresh()

// This NV quirk variant applies color_offsets night vision to a mob based on its chosen eye color.
// Some eye colors will produce very slightly stronger mechanical night vision effects just by virtue of their RGB values being scaled higher (typically lighter colours).

/datum/quirk/night_vision
desc = "You can see a little better in darkness than most ordinary humanoids. If your eyes are naturally more sensitive to light through other means (such as being photophobic or a mothperson), this effect is significantly stronger."
medical_record_text = "Patient's visual sensory organs demonstrate non-standard performance in low-light conditions."
var/nv_color = null /// Holds the player's selected night vision colour
var/list/nv_color_cutoffs = null /// Contains the color_cutoffs applied to the user's eyes w/ our custom hue (once built)

/datum/quirk/night_vision/add_unique(client/client_source)
. = ..()
nv_color = client_source?.prefs.read_preference(/datum/preference/color/nv_color)
if (isnull(nv_color))
var/mob/living/carbon/human/human_holder = quirk_holder
nv_color = process_chat_color(human_holder.eye_color_left)
nv_color_cutoffs = calculate_color_cutoffs(nv_color)
refresh_quirk_holder_eyes() // make double triple dog sure we apply the overlay

/// Calculate eye organ color_cutoffs used in tinted night vision with a supplied hexcode colour, clamping and scaling appropriately.
/datum/quirk/night_vision/proc/calculate_color_cutoffs(color)
var/mob/living/carbon/human/target = quirk_holder

// if we have more sensitive eyes, increase the power
var/obj/item/organ/internal/eyes/target_eyes = target.get_organ_slot(ORGAN_SLOT_EYES)
if (!istype(target_eyes))
return
var/infravision_multiplier = max(0, (-(target_eyes.flash_protect) * DOPPLER_NIGHT_VISION_SENSITIVITY_MULT)) + 1

var/list/new_rgb_cutoffs = new /list(3)
for(var/i in 1 to 3)
var/base_color = hex2num(copytext(color, (i*2), (i*2)+2)) //convert their supplied hex colour value to RGB
var/adjusted_color = max(((base_color / 255) * (DOPPLER_NIGHT_VISION_POWER_MAX * infravision_multiplier)), (DOPPLER_NIGHT_VISION_POWER_MIN * infravision_multiplier)) //linear convert their eye color into a color_cutoff range, ensuring it is clamped
new_rgb_cutoffs[i] = adjusted_color

return new_rgb_cutoffs

/datum/quirk_constant_data/night_vision
associated_typepath = /datum/quirk/night_vision
customization_options = list(/datum/preference/color/nv_color)

// Client preference for night vision colour
/datum/preference/color/nv_color
savefile_key = "nv_color"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED

/datum/preference/color/nv_color/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return "Night Vision" in preferences.all_quirks

/datum/preference/color/nv_color/apply_to_human(mob/living/carbon/human/target, value)
return

// run the Blessed Runechat Proc since it does most of what we want regarding luminance clamping anyway. could it be better? probably. is it more work? yes, it's a LOT of work.
/datum/preference/color/nv_color/deserialize(input, datum/preferences/preferences)
return process_chat_color(sanitize_hexcolor(input))

/datum/preference/color/nv_color/serialize(input)
return process_chat_color(sanitize_hexcolor(input))

/datum/preference/color/nv_color/create_default_value()
return process_chat_color("#[random_color()]")

/datum/quirk/photophobia
desc = "Bright lights are uncomfortable and upsetting to you for whatever reason. Your eyes are also more sensitive to light in general. This shares a unique interaction with Night Vision."
/// how much of a flash_protect deficit the quirk inflicts
var/severity = 1

/datum/quirk/photophobia/add_unique(client/client_source)
var/sensitivity = client_source?.prefs.read_preference(/datum/preference/choiced/photophobia_severity)
switch (sensitivity)
if ("Hypersensitive")
severity = 2
if ("Sensitive")
severity = 1
var/obj/item/organ/internal/eyes/holder_eyes = quirk_holder.get_organ_slot(ORGAN_SLOT_EYES)
restore_eyes(holder_eyes) // add_unique() happens after add() so we need to jank reset this to ensure sensitivity is properly applied at roundstart
check_eyes(holder_eyes)

/datum/quirk_constant_data/photophobia
associated_typepath = /datum/quirk/photophobia
customization_options = list(/datum/preference/choiced/photophobia_severity)

/datum/preference/choiced/photophobia_severity
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "photophobia_severity"
savefile_identifier = PREFERENCE_CHARACTER

/datum/preference/choiced/photophobia_severity/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return "Photophobia" in preferences.all_quirks

/datum/preference/choiced/photophobia_severity/init_possible_values()
var/list/values = list("Sensitive", "Hypersensitive")
return values

/datum/preference/choiced/photophobia_severity/apply_to_human(mob/living/carbon/human/target, value)
return
131 changes: 131 additions & 0 deletions modular_doppler/modular_quirks/night_vision/night_vision.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/datum/quirk/night_vision
name = "Night Vision"
desc = "You can see slightly more clearly in full darkness than most people."
icon = FA_ICON_MOON
value = 4
mob_trait = TRAIT_NIGHT_VISION
gain_text = span_notice("The shadows seem a little less dark.")
lose_text = span_danger("Everything seems a little darker.")
medical_record_text = "Patient's eyes show above-average acclimation to darkness."
mail_goodies = list(
/obj/item/flashlight/flashdark,
/obj/item/food/grown/mushroom/glowshroom/shadowshroom,
/obj/item/skillchip/light_remover,
)

/datum/quirk/night_vision/add(client/client_source)
refresh_quirk_holder_eyes()

/datum/quirk/night_vision/remove()
refresh_quirk_holder_eyes()

/datum/quirk/night_vision/proc/refresh_quirk_holder_eyes()
var/mob/living/carbon/human/human_quirk_holder = quirk_holder
var/obj/item/organ/internal/eyes/eyes = human_quirk_holder.get_organ_by_type(/obj/item/organ/internal/eyes)
if(!eyes)
return
// We've either added or removed TRAIT_NIGHT_VISION before calling this proc. Just refresh the eyes.
eyes.refresh()

// This NV quirk variant applies color_offsets night vision to a mob based on its chosen eye color.
// Some eye colors will produce very slightly stronger mechanical night vision effects just by virtue of their RGB values being scaled higher (typically lighter colours).

/datum/quirk/night_vision
desc = "You can see a little better in darkness than most ordinary humanoids. If your eyes are naturally more sensitive to light through other means (such as being photophobic or a mothperson), this effect is significantly stronger."
medical_record_text = "Patient's visual sensory organs demonstrate non-standard performance in low-light conditions."
var/nv_color = null /// Holds the player's selected night vision colour
var/list/nv_color_cutoffs = null /// Contains the color_cutoffs applied to the user's eyes w/ our custom hue (once built)

/datum/quirk/night_vision/add_unique(client/client_source)
. = ..()
nv_color = client_source?.prefs.read_preference(/datum/preference/color/nv_color)
if (isnull(nv_color))
var/mob/living/carbon/human/human_holder = quirk_holder
nv_color = process_chat_color(human_holder.eye_color_left)
nv_color_cutoffs = calculate_color_cutoffs(nv_color)
refresh_quirk_holder_eyes() // make double triple dog sure we apply the overlay

/// Calculate eye organ color_cutoffs used in tinted night vision with a supplied hexcode colour, clamping and scaling appropriately.
/datum/quirk/night_vision/proc/calculate_color_cutoffs(color)
var/mob/living/carbon/human/target = quirk_holder

// if we have more sensitive eyes, increase the power
var/obj/item/organ/internal/eyes/target_eyes = target.get_organ_slot(ORGAN_SLOT_EYES)
if (!istype(target_eyes))
return
var/infravision_multiplier = max(0, (-(target_eyes.flash_protect) * DOPPLER_NIGHT_VISION_SENSITIVITY_MULT)) + 1

var/list/new_rgb_cutoffs = new /list(3)
for(var/i in 1 to 3)
var/base_color = hex2num(copytext(color, (i*2), (i*2)+2)) //convert their supplied hex colour value to RGB
var/adjusted_color = max(((base_color / 255) * (DOPPLER_NIGHT_VISION_POWER_MAX * infravision_multiplier)), (DOPPLER_NIGHT_VISION_POWER_MIN * infravision_multiplier)) //linear convert their eye color into a color_cutoff range, ensuring it is clamped
new_rgb_cutoffs[i] = adjusted_color

return new_rgb_cutoffs

/datum/quirk_constant_data/night_vision
associated_typepath = /datum/quirk/night_vision
customization_options = list(/datum/preference/color/nv_color)

// Client preference for night vision colour
/datum/preference/color/nv_color
savefile_key = "nv_color"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED

/datum/preference/color/nv_color/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return "Night Vision" in preferences.all_quirks

/datum/preference/color/nv_color/apply_to_human(mob/living/carbon/human/target, value)
return

// run the Blessed Runechat Proc since it does most of what we want regarding luminance clamping anyway. could it be better? probably. is it more work? yes, it's a LOT of work.
/datum/preference/color/nv_color/deserialize(input, datum/preferences/preferences)
return process_chat_color(sanitize_hexcolor(input))

/datum/preference/color/nv_color/serialize(input)
return process_chat_color(sanitize_hexcolor(input))

/datum/preference/color/nv_color/create_default_value()
return process_chat_color("#[random_color()]")

/datum/quirk/photophobia
desc = "Bright lights are uncomfortable and upsetting to you for whatever reason. Your eyes are also more sensitive to light in general. This shares a unique interaction with Night Vision."
/// how much of a flash_protect deficit the quirk inflicts
var/severity = 1

/datum/quirk/photophobia/add_unique(client/client_source)
var/sensitivity = client_source?.prefs.read_preference(/datum/preference/choiced/photophobia_severity)
switch (sensitivity)
if ("Hypersensitive")
severity = 2
if ("Sensitive")
severity = 1
var/obj/item/organ/internal/eyes/holder_eyes = quirk_holder.get_organ_slot(ORGAN_SLOT_EYES)
restore_eyes(holder_eyes) // add_unique() happens after add() so we need to jank reset this to ensure sensitivity is properly applied at roundstart
check_eyes(holder_eyes)

/datum/quirk_constant_data/photophobia
associated_typepath = /datum/quirk/photophobia
customization_options = list(/datum/preference/choiced/photophobia_severity)

/datum/preference/choiced/photophobia_severity
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "photophobia_severity"
savefile_identifier = PREFERENCE_CHARACTER

/datum/preference/choiced/photophobia_severity/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return "Photophobia" in preferences.all_quirks

/datum/preference/choiced/photophobia_severity/init_possible_values()
var/list/values = list("Sensitive", "Hypersensitive")
return values

/datum/preference/choiced/photophobia_severity/apply_to_human(mob/living/carbon/human/target, value)
return
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6863,8 +6863,10 @@
#include "modular_doppler\modular_mood\code\mood_events\hotspring.dm"
#include "modular_doppler\modular_mood\code\mood_events\race_drink.dm"
#include "modular_doppler\modular_quirks\excitable\excitable.dm"
#include "modular_doppler\modular_quirks\hardened_soles\hardened_soles.dm"
#include "modular_doppler\modular_quirks\left_handed\left_handed.dm"
#include "modular_doppler\modular_quirks\linguist\linguist.dm"
#include "modular_doppler\modular_quirks\night_vision\night_vision.dm"
#include "modular_doppler\modular_quirks\overwrites\musician.dm"
#include "modular_doppler\modular_quirks\paycheck_rations\code\quirk.dm"
#include "modular_doppler\modular_quirks\paycheck_rations\code\rationpacks.dm"
Expand Down
Loading