From e43d43f16ccd5fed5dbc455ba8c3ffe074d2e210 Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Fri, 25 Jun 2021 21:33:38 -0400 Subject: [PATCH] Traits sort better --- code/__defines/misc.dm | 6 ++- code/_helpers/global_lists_vr.dm | 20 +++++++--- .../station/protean_vr/protean_powers.dm | 8 ++-- .../species/station/traits_vr/negative.dm | 16 ++++---- .../species/station/traits_vr/neutral.dm | 38 +++++++++++-------- .../species/station/traits_vr/positive.dm | 10 ++--- .../human/species/station/traits_vr/trait.dm | 11 +++--- 7 files changed, 65 insertions(+), 44 deletions(-) diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 9e198dabefd..a1d7592cd75 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -467,4 +467,8 @@ GLOBAL_LIST_INIT(all_volume_channels, list( #define DOCK_ATTEMPT_TIMEOUT 200 //how long in ticks we wait before assuming the docking controller is broken or blown up. #define SMES_TGUI_INPUT 1 -#define SMES_TGUI_OUTPUT 2 \ No newline at end of file +#define SMES_TGUI_OUTPUT 2 + +#define TRAIT_SORT_NORMAL 1 +#define TRAIT_SORT_BODYTYPE 2 +#define TRAIT_SORT_SPECIES 3 diff --git a/code/_helpers/global_lists_vr.dm b/code/_helpers/global_lists_vr.dm index 4df7afe9b44..16622d1ee6a 100644 --- a/code/_helpers/global_lists_vr.dm +++ b/code/_helpers/global_lists_vr.dm @@ -509,19 +509,27 @@ var/global/list/remainless_species = list(SPECIES_PROMETHEAN, var/datum/trait/instance = new path() if(!instance.name) continue //A prototype or something - var/category = instance.category var/cost = instance.cost traits_costs[path] = cost all_traits[path] = instance + + // Shakey shakey shake + sortTim(all_traits, /proc/cmp_trait_datums_name, associative = TRUE) + + // Split 'em up + for(var/traitpath in all_traits) + var/datum/trait/T = all_traits[traitpath] + var/category = T.category switch(category) if(-INFINITY to -0.1) - negative_traits[path] = instance + negative_traits[traitpath] = T if(0) - neutral_traits[path] = instance - if(!(instance.custom_only)) - everyone_traits[path] = instance + neutral_traits[traitpath] = T + if(!(T.custom_only)) + everyone_traits[traitpath] = T if(0.1 to INFINITY) - positive_traits[path] = instance + positive_traits[traitpath] = T + // Weaver recipe stuff paths = typesof(/datum/weaver_recipe/structure) - /datum/weaver_recipe/structure diff --git a/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_powers.dm b/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_powers.dm index 948d45d19ca..2a36151f125 100644 --- a/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_powers.dm +++ b/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_powers.dm @@ -22,7 +22,7 @@ to_chat(src,"You don't have a working refactory module!") return - var/choice = input(src,"Pick the bodypart to change:", "Refactor - One Bodypart") as null|anything in species.has_limbs + var/choice = tgui_input_list(src,"Pick the bodypart to change:", "Refactor - One Bodypart", species.has_limbs) if(!choice) return @@ -68,7 +68,7 @@ usable_manufacturers[company] = M if(!usable_manufacturers.len) return - var/manu_choice = input(src, "Which manufacturer do you wish to mimic for this limb?", "Manufacturer for [choice]") as null|anything in usable_manufacturers + var/manu_choice = tgui_input_list(src, "Which manufacturer do you wish to mimic for this limb?", "Manufacturer for [choice]", usable_manufacturers) if(!manu_choice) return //Changed mind @@ -125,7 +125,7 @@ usable_manufacturers[company] = M if(!usable_manufacturers.len) return - var/manu_choice = input(src, "Which manufacturer do you wish to mimic?", "Manufacturer") as null|anything in usable_manufacturers + var/manu_choice = tgui_input_list(src, "Which manufacturer do you wish to mimic?", "Manufacturer", usable_manufacturers) if(!manu_choice) return //Changed mind @@ -272,7 +272,7 @@ to_chat(src,"You must be awake and standing to perform this action!") return - var/new_species = input("Please select a species to emulate.", "Shapeshifter Body") as null|anything in GLOB.playable_species + var/new_species = tgui_input_list(usr, "Please select a species to emulate.", "Shapeshifter Body", GLOB.playable_species) if(new_species) impersonate_bodytype = new_species species?.base_species = new_species // Really though you better have a species diff --git a/code/modules/mob/living/carbon/human/species/station/traits_vr/negative.dm b/code/modules/mob/living/carbon/human/species/station/traits_vr/negative.dm index e7537dcd523..244a00b53a6 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits_vr/negative.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits_vr/negative.dm @@ -8,7 +8,7 @@ var_changes = list("slowdown" = 0.5) /datum/trait/negative/speed_slow_plus - name = "Major Slowdown" + name = "Slowdown, Major" desc = "Allows you to move MUCH slower on average than baseline." cost = -3 var_changes = list("slowdown" = 1.0) @@ -20,7 +20,7 @@ var_changes = list("item_slowdown_mod" = 1.5) /datum/trait/negative/weakling_plus - name = "Major Weakling" + name = "Weakling, Major" desc = "Allows you to carry heavy equipment with much more slowdown." cost = -2 var_changes = list("item_slowdown_mod" = 2.0) @@ -36,7 +36,7 @@ H.setMaxHealth(S.total_health) /datum/trait/negative/endurance_very_low - name = "Extremely Low Endurance" + name = "Low Endurance, Major" desc = "Reduces your maximum total hitpoints to 50." cost = -3 //Teshari HP. This makes the person a lot more suseptable to getting stunned, killed, etc. var_changes = list("total_health" = 50) @@ -46,7 +46,7 @@ H.setMaxHealth(S.total_health) /datum/trait/negative/minor_brute_weak - name = "Minor Brute Weakness" + name = "Brute Weakness, Minor" desc = "Increases damage from brute damage sources by 15%" cost = -1 var_changes = list("brute_mod" = 1.15) @@ -58,13 +58,13 @@ var_changes = list("brute_mod" = 1.25) /datum/trait/negative/brute_weak_plus - name = "Major Brute Weakness" + name = "Brute Weakness, Major" desc = "Increases damage from brute damage sources by 50%" cost = -3 var_changes = list("brute_mod" = 1.5) /datum/trait/negative/minor_burn_weak - name = "Minor Burn Weakness" + name = "Burn Weakness, Minor" desc = "Increases damage from burn damage sources by 15%" cost = -1 var_changes = list("burn_mod" = 1.15) @@ -76,7 +76,7 @@ var_changes = list("burn_mod" = 1.25) /datum/trait/negative/burn_weak_plus - name = "Major Burn Weakness" + name = "Burn Weakness, Major" desc = "Increases damage from burn damage sources by 50%" cost = -3 var_changes = list("burn_mod" = 1.5) @@ -88,7 +88,7 @@ var_changes = list("siemens_coefficient" = 1.5) //This makes you a lot weaker to tasers. /datum/trait/negative/conductive_plus - name = "Major Conductive" + name = "Conductive, Major" desc = "Increases your susceptibility to electric shocks by 100%" cost = -1 var_changes = list("siemens_coefficient" = 2.0) //This makes you extremely weak to tasers. diff --git a/code/modules/mob/living/carbon/human/species/station/traits_vr/neutral.dm b/code/modules/mob/living/carbon/human/species/station/traits_vr/neutral.dm index ccf4d9614f0..3c298700801 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits_vr/neutral.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits_vr/neutral.dm @@ -1,35 +1,35 @@ /datum/trait/neutral /datum/trait/neutral/metabolism_up - name = "Fast Metabolism" + name = "Metabolism, Fast" desc = "You process ingested and injected reagents faster, but get hungry faster (Teshari speed)." cost = 0 var_changes = list("metabolic_rate" = 1.2, "hunger_factor" = 0.2, "metabolism" = 0.06) // +20% rate and 4x hunger (Teshari level) excludes = list(/datum/trait/neutral/metabolism_down, /datum/trait/neutral/metabolism_apex) /datum/trait/neutral/metabolism_down - name = "Slow Metabolism" + name = "Metabolism, Slow" desc = "You process ingested and injected reagents slower, but get hungry slower." cost = 0 var_changes = list("metabolic_rate" = 0.8, "hunger_factor" = 0.04, "metabolism" = 0.0012) // -20% of default. excludes = list(/datum/trait/neutral/metabolism_up, /datum/trait/neutral/metabolism_apex) /datum/trait/neutral/metabolism_apex - name = "Apex Metabolism" + name = "Metabolism, Apex" desc = "Finally a proper excuse for your predatory actions. Essentially doubles the fast trait rates. Good for characters with big appetites." cost = 0 var_changes = list("metabolic_rate" = 1.4, "hunger_factor" = 0.4, "metabolism" = 0.012) // +40% rate and 8x hunger (Double Teshari) excludes = list(/datum/trait/neutral/metabolism_up, /datum/trait/neutral/metabolism_down) /datum/trait/neutral/coldadapt - name = "Cold-Adapted" + name = "Temp. Adapted, Cold" desc = "You are able to withstand much colder temperatures than other species, and can even be comfortable in extremely cold environments. You are also more vulnerable to hot environments, and have a lower body temperature as a consequence of these adaptations." cost = 0 var_changes = list("cold_level_1" = 200, "cold_level_2" = 150, "cold_level_3" = 90, "breath_cold_level_1" = 180, "breath_cold_level_2" = 100, "breath_cold_level_3" = 60, "cold_discomfort_level" = 210, "heat_level_1" = 330, "heat_level_2" = 380, "heat_level_3" = 700, "breath_heat_level_1" = 360, "breath_heat_level_2" = 400, "breath_heat_level_3" = 850, "heat_discomfort_level" = 295, "body_temperature" = 290) excludes = list(/datum/trait/neutral/hotadapt) /datum/trait/neutral/hotadapt - name = "Heat-Adapted" + name = "Temp. Adapted, Heat" desc = "You are able to withstand much hotter temperatures than other species, and can even be comfortable in extremely hot environments. You are also more vulnerable to cold environments, and have a higher body temperature as a consequence of these adaptations." cost = 0 var_changes = list("heat_level_1" = 420, "heat_level_2" = 460, "heat_level_3" = 1100, "breath_heat_level_1" = 440, "breath_heat_level_2" = 510, "breath_heat_level_3" = 1500, "heat_discomfort_level" = 390, "cold_level_1" = 280, "cold_level_2" = 220, "cold_level_3" = 140, "breath_cold_level_1" = 260, "breath_cold_level_2" = 240, "breath_cold_level_3" = 120, "cold_discomfort_level" = 280, "body_temperature" = 330) @@ -62,7 +62,7 @@ excludes = list(/datum/trait/neutral/autohiss_unathi) /datum/trait/neutral/bloodsucker - name = "Bloodsucker (Obligate)" + name = "Bloodsucker, Obligate" desc = "Makes you unable to gain nutrition from anything but blood. To compenstate, you get fangs that can be used to drain blood from prey." cost = 0 custom_only = FALSE @@ -249,21 +249,21 @@ // Spicy Food Traits, from negative to positive. /datum/trait/neutral/spice_intolerance_extreme - name = "Extreme Spice Intolerance" + name = "Spice Intolerance, Extreme" desc = "Spicy (and chilly) peppers are three times as strong. (This does not affect pepperspray.)" cost = 0 custom_only = FALSE var_changes = list("spice_mod" = 3) // 300% as effective if spice_mod is set to 1. If it's not 1 in species.dm, update this! /datum/trait/neutral/spice_intolerance_basic - name = "Heavy Spice Intolerance" + name = "Spice Intolerance, Heavy" desc = "Spicy (and chilly) peppers are twice as strong. (This does not affect pepperspray.)" cost = 0 custom_only = FALSE var_changes = list("spice_mod" = 2) // 200% as effective if spice_mod is set to 1. If it's not 1 in species.dm, update this! /datum/trait/neutral/spice_intolerance_slight - name = "Slight Spice Intolerance" + name = "Spice Intolerance, Slight" desc = "You have a slight struggle with spicy foods. Spicy (and chilly) peppers are one and a half times stronger. (This does not affect pepperspray.)" cost = 0 custom_only = FALSE @@ -277,14 +277,14 @@ var_changes = list("spice_mod" = 0.75) // 75% as effective if spice_mod is set to 1. If it's not 1 in species.dm, update this! /datum/trait/neutral/spice_tolerance_advanced - name = "Strong Spice Tolerance" + name = "Spice Tolerance, Strong" desc = "Spicy (and chilly) peppers are only half as strong. (This does not affect pepperspray.)" cost = 0 custom_only = FALSE var_changes = list("spice_mod" = 0.5) // 50% as effective if spice_mod is set to 1. If it's not 1 in species.dm, update this! /datum/trait/neutral/spice_immunity - name = "Extreme Spice Tolerance" + name = "Spice Tolerance, Extreme" desc = "Spicy (and chilly) peppers are basically ineffective! (This does not affect pepperspray.)" cost = 0 custom_only = FALSE @@ -365,6 +365,7 @@ /datum/trait/neutral/taller name = "Tall" desc = "Your body is taller than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_y" = 1.09) @@ -375,8 +376,9 @@ H.update_transform() /datum/trait/neutral/tall - name = "Slightly Tall" + name = "Tall, Minor" desc = "Your body is a bit taller than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_y" = 1.05) @@ -387,8 +389,9 @@ H.update_transform() /datum/trait/neutral/short - name = "Slightly Short" + name = "Short, Minor" desc = "Your body is a bit shorter than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_y" = 0.95) @@ -401,6 +404,7 @@ /datum/trait/neutral/shorter name = "Short" desc = "Your body is shorter than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_y" = 0.915) @@ -411,8 +415,9 @@ H.update_transform() /datum/trait/neutral/obese - name = "Very Bulky" + name = "Bulky, Major" desc = "Your body is much wider than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_x" = 1.095) @@ -425,6 +430,7 @@ /datum/trait/neutral/fat name = "Bulky" desc = "Your body is wider than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_x" = 1.054) @@ -437,6 +443,7 @@ /datum/trait/neutral/thin name = "Thin" desc = "Your body is thinner than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_x" = 0.945) @@ -447,8 +454,9 @@ H.update_transform() /datum/trait/neutral/thinner - name = "Very Thin" + name = "Thin, Major" desc = "Your body is much thinner than average." + sort = TRAIT_SORT_BODYTYPE cost = 0 custom_only = FALSE var_changes = list("icon_scale_x" = 0.905) diff --git a/code/modules/mob/living/carbon/human/species/station/traits_vr/positive.dm b/code/modules/mob/living/carbon/human/species/station/traits_vr/positive.dm index 20a0653c220..0298f370df2 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits_vr/positive.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits_vr/positive.dm @@ -14,7 +14,7 @@ var_changes = list("item_slowdown_mod" = 0.5) /datum/trait/positive/hardy_plus - name = "Major Hardy" + name = "Hardy, Major" desc = "Allows you to carry heavy equipment with almost no slowdown." cost = 2 var_changes = list("item_slowdown_mod" = 0.25) @@ -36,7 +36,7 @@ var_changes = list("siemens_coefficient" = 0.9) /datum/trait/positive/nonconductive_plus - name = "Major Non-Conductive" + name = "Non-Conductive, Major" desc = "Decreases your susceptibility to electric shocks by a 25% amount." cost = 2 //Let us not forget this effects tasers! var_changes = list("siemens_coefficient" = 0.75) @@ -48,7 +48,7 @@ var_changes = list("darksight" = 5, "flash_mod" = 1.1) /datum/trait/positive/darksight_plus - name = "Darksight (Major)" + name = "Darksight, Major" desc = "Allows you to see in the dark for the whole screen." cost = 2 var_changes = list("darksight" = 8, "flash_mod" = 1.2) @@ -72,7 +72,7 @@ var_changes = list("unarmed_types" = list(/datum/unarmed_attack/stomp, /datum/unarmed_attack/kick, /datum/unarmed_attack/punch, /datum/unarmed_attack/bite/sharp/numbing)) /datum/trait/positive/minor_brute_resist - name = "Minor Brute Resist" + name = "Brute Resist, Minor" desc = "Adds 15% resistance to brute damage sources." cost = 2 var_changes = list("brute_mod" = 0.85) @@ -85,7 +85,7 @@ excludes = list(/datum/trait/positive/minor_burn_resist,/datum/trait/positive/burn_resist) /datum/trait/positive/minor_burn_resist - name = "Minor Burn Resist" + name = "Burn Resist, Minor" desc = "Adds 15% resistance to burn damage sources." cost = 2 var_changes = list("burn_mod" = 0.85) diff --git a/code/modules/mob/living/carbon/human/species/station/traits_vr/trait.dm b/code/modules/mob/living/carbon/human/species/station/traits_vr/trait.dm index d01d016b2c0..91bf5fafeae 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits_vr/trait.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits_vr/trait.dm @@ -3,13 +3,14 @@ var/desc = "Contact a developer if you see this trait." var/cost = 0 - var/category = 0 // What category this trait is. -1 is Negative, 0 is Neutral, 1 is Positive - var/list/var_changes // A list to apply to the custom species vars. - var/list/excludes // Store a list of paths of traits to exclude, but done automatically if they change the same vars. + var/sort = TRAIT_SORT_NORMAL // Sort order, 1 before 2 before 3 etc. Alphabetical is used for same-group traits. + var/category = 0 // What category this trait is. -1 is Negative, 0 is Neutral, 1 is Positive + var/list/var_changes // A list to apply to the custom species vars. + var/list/excludes // Store a list of paths of traits to exclude, but done automatically if they change the same vars. var/can_take = ORGANICS|SYNTHETICS // Can freaking synths use those. - var/list/banned_species // A list of species that can't take this trait + var/list/banned_species // A list of species that can't take this trait var/list/allowed_species // VORESTATION EDIT:chomp port. A list of species that CAN take this trait, use this if only a few species can use it. -shark - var/custom_only = TRUE // Trait only available for custom species + var/custom_only = TRUE // Trait only available for custom species //Proc can be overridden lower to include special changes, make sure to call up though for the vars changes /datum/trait/proc/apply(var/datum/species/S,var/mob/living/carbon/human/H)