Skip to content

Commit

Permalink
Adds Quirk Customization: Take 2 (#10357)
Browse files Browse the repository at this point in the history
* Adds Quirk Customization: Take 2

* Properly implement. I think.
  • Loading branch information
Absolucy authored Dec 28, 2023
1 parent bd877f6 commit d267c63
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 15 deletions.
8 changes: 7 additions & 1 deletion SQL/beestation_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ CREATE TABLE IF NOT EXISTS `SS13_characters` (
`joblessrole` TINYINT(4) UNSIGNED,
`job_preferences` MEDIUMTEXT COLLATE 'utf8mb4_general_ci',
`all_quirks` MEDIUMTEXT COLLATE 'utf8mb4_general_ci',
`quirk_prosthetic_limb_location` VARCHAR(64) COLLATE 'utf8mb4_general_ci',
`quirk_phobia` VARCHAR(64) COLLATE 'utf8mb4_general_ci',
`quirk_multilingual_language` VARCHAR(64) COLLATE 'utf8mb4_general_ci',
`quirk_smoker_cigarettes` VARCHAR(64) COLLATE 'utf8mb4_general_ci',
`quirk_junkie_drug` VARCHAR(64) COLLATE 'utf8mb4_general_ci',
`quirk_alcohol_type` VARCHAR(64) COLLATE 'utf8mb4_general_ci',
`equipped_gear` MEDIUMTEXT COLLATE 'utf8mb4_general_ci',
`role_preferences` MEDIUMTEXT COLLATE 'utf8mb4_general_ci',
`randomize` MEDIUMTEXT COLLATE 'utf8mb4_general_ci',
Expand Down Expand Up @@ -491,7 +497,7 @@ CREATE TABLE IF NOT EXISTS `SS13_schema_revision` (
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`major`,`minor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (7, 0);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (7, 2);



Expand Down
22 changes: 19 additions & 3 deletions SQL/database_changelog.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.

The latest database version is 7.1; The query to update the schema revision table is:
The latest database version is 7.2; The query to update the schema revision table is:

INSERT INTO `schema_revision` (`major`, `minor`) VALUES (7, 1);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (7, 2);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (7, 1);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (7, 2);

In any query remember to add a prefix to the table names if you use one.


-----------------------------------------------------

-----------------------------------------------------

Version 7.2, 20 December 2023, by that0neperson and Absolucy
Added customization for quirks.

ALTER TABLE `SS13_characters`
ADD COLUMN IF NOT EXISTS `quirk_prosthetic_limb_location` VARCHAR(64) COLLATE 'utf8mb4_general_ci' AFTER `all_quirks`,
ADD COLUMN IF NOT EXISTS `quirk_phobia` VARCHAR(64) COLLATE 'utf8mb4_general_ci' AFTER `quirk_prosthetic_limb_location`,
ADD COLUMN IF NOT EXISTS `quirk_multilingual_language` VARCHAR(64) COLLATE 'utf8mb4_general_ci' AFTER `quirk_phobia`,
ADD COLUMN IF NOT EXISTS `quirk_smoker_cigarettes` VARCHAR(64) COLLATE 'utf8mb4_general_ci' AFTER `quirk_multilingual_language` ,
ADD COLUMN IF NOT EXISTS `quirk_junkie_drug` VARCHAR(64) COLLATE 'utf8mb4_general_ci' AFTER `quirk_smoker_cigarettes`,
ADD COLUMN IF NOT EXISTS `quirk_alcohol_type` VARCHAR(64) COLLATE 'utf8mb4_general_ci' AFTER `quirk_junkie_drug`;

-----------------------------------------------------

-----------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2299,12 +2299,19 @@
#include "code\modules\client\preferences\entries\character\jobless_role.dm"
#include "code\modules\client\preferences\entries\character\names.dm"
#include "code\modules\client\preferences\entries\character\pda.dm"
#include "code\modules\client\preferences\entries\character\quirks.dm"
#include "code\modules\client\preferences\entries\character\random.dm"
#include "code\modules\client\preferences\entries\character\security_department.dm"
#include "code\modules\client\preferences\entries\character\skin_tone.dm"
#include "code\modules\client\preferences\entries\character\species.dm"
#include "code\modules\client\preferences\entries\character\underwear_color.dm"
#include "code\modules\client\preferences\entries\character\uplink_location.dm"
#include "code\modules\client\preferences\entries\character\quirks\alcoholic.dm"
#include "code\modules\client\preferences\entries\character\quirks\junkie.dm"
#include "code\modules\client\preferences\entries\character\quirks\multilingual.dm"
#include "code\modules\client\preferences\entries\character\quirks\phobia.dm"
#include "code\modules\client\preferences\entries\character\quirks\prosthetic.dm"
#include "code\modules\client\preferences\entries\character\quirks\smoker.dm"
#include "code\modules\client\preferences\entries\character\species_features\apid.dm"
#include "code\modules\client\preferences\entries\character\species_features\basic.dm"
#include "code\modules\client\preferences\entries\character\species_features\ethereal.dm"
Expand Down
17 changes: 17 additions & 0 deletions code/__DEFINES/language.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@
#define LANGUAGE_MULTILINGUAL "multilingual"
#define LANGUAGE_EMP "emp"
#define LANGUAGE_HOLOPARA "holoparasite"

// Languages available from Multilingual
GLOBAL_LIST_INIT(multilingual_language_list, typecacheof(list(
/datum/language/apidite,
/datum/language/beachbum,
/datum/language/buzzwords,
/datum/language/calcic,
/datum/language/draconic,
/datum/language/moffic,
/datum/language/monkey,
/datum/language/piratespeak,
/datum/language/shadowtongue,
/datum/language/slime,
/datum/language/sylvan,
/datum/language/terrum,
/datum/language/uncommon
)))
20 changes: 20 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@
#define TRAUMA_RESILIENCE_MAGIC 4 //! Curable only with magic
#define TRAUMA_RESILIENCE_ABSOLUTE 5 //! This is here to stay

GLOBAL_LIST_INIT(available_random_trauma_list, list(
"spiders" = 5,
"space" = 2,
"security" = 5,
"clowns" = 5,
"greytide" = 5,
"lizards" = 5,
"skeletons" = 5,
"snakes" = 5,
"robots" = 4,
"doctors" = 4,
"authority" = 5,
"the supernatural" = 5,
"aliens" = 5,
"strangers" = 5,
"birds" = 5,
"falling" = 5,
"anime" = 5
))

/// This trauma cannot be cured through "special" means, such as nanites or viruses.
#define TRAUMA_SPECIAL_CURE_PROOF (1<<0)
/// This trauma transfers on cloning.
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* make sure you add an update to the schema_version stable in the db changelog
*/
#define DB_MINOR_VERSION 1
#define DB_MINOR_VERSION 2


//! ## Timing subsystem
Expand Down
28 changes: 28 additions & 0 deletions code/_globalvars/lists/flavor_misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,31 @@ GLOBAL_LIST_INIT(pAI_faces_icons, list(
"Sunglasses" = image(icon = 'icons/obj/aicards.dmi', icon_state = "pai-sunglasses"),
"What" = image(icon = 'icons/obj/aicards.dmi', icon_state = "pai-what"),
))

GLOBAL_LIST_INIT(smoker_cigarettes, list(
/obj/item/storage/fancy/cigarettes,
/obj/item/storage/fancy/cigarettes/cigpack_midori,
/obj/item/storage/fancy/cigarettes/cigpack_uplift,
/obj/item/storage/fancy/cigarettes/cigpack_robust,
/obj/item/storage/fancy/cigarettes/cigpack_robustgold,
/obj/item/storage/fancy/cigarettes/cigpack_carp
))

GLOBAL_LIST_INIT(alcoholic_bottles, list(
/obj/item/reagent_containers/food/drinks/bottle/ale,
/obj/item/reagent_containers/food/drinks/bottle/beer,
/obj/item/reagent_containers/food/drinks/bottle/gin,
/obj/item/reagent_containers/food/drinks/bottle/whiskey,
/obj/item/reagent_containers/food/drinks/bottle/vodka,
/obj/item/reagent_containers/food/drinks/bottle/rum,
/obj/item/reagent_containers/food/drinks/bottle/applejack
))

GLOBAL_LIST_INIT(junkie_drugs, list(
/datum/reagent/drug/crank,
/datum/reagent/drug/krokodil,
/datum/reagent/medicine/morphine,
/datum/reagent/drug/happiness,
/datum/reagent/drug/methamphetamine,
/datum/reagent/drug/ketamine
))
5 changes: 2 additions & 3 deletions code/controllers/subsystem/traumas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ SUBSYSTEM_DEF(traumas)

/datum/controller/subsystem/traumas/Initialize()
//phobia types is to pull from randomly for brain traumas, e.g. conspiracies is for special assignment only
//defined in __DEFINES/mobs.dm
//5 is the default weight, lower it for more punishing phobias
phobia_types = sort_list(list("spiders" = 5, "space" = 2, "security" = 5, "clowns" = 5, "greytide" = 5, "lizards" = 5,
"skeletons" = 5, "snakes" = 5, "robots" = 4, "doctors" = 4, "authority" = 5, "the supernatural" = 5,
"aliens" = 5, "strangers" = 5, "birds" = 5, "falling" = 5, "anime" = 5))
phobia_types = sort_list(GLOB.available_random_trauma_list)

phobia_words = list(
"spiders" = strings(PHOBIA_FILE, "spiders"),
Expand Down
8 changes: 7 additions & 1 deletion code/datums/traits/_quirk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
var/icon
var/value = 0
var/list/restricted_mobtypes = list(/mob/living/carbon/human) //specifies valid mobtypes, have a good reason to change this
var/list/restricted_species //specifies valid species, use /datum/species/
var/list/restricted_species //specifies valid species, use /datum/species/
var/species_whitelist = TRUE //whether restricted_species is a whitelist or a blacklist
var/gain_text
var/lose_text
Expand Down Expand Up @@ -134,6 +134,12 @@
return "None"
return dat.Join("<br>")

/datum/quirk/proc/read_choice_preference(path)
var/client/qclient = GLOB.directory[ckey(quirk_holder.key)]
var/pref = qclient?.prefs.read_character_preference(path)
if(pref != "Random")
return pref

/*
Commented version of Nearsighted to help you add your own quirks
Expand Down
14 changes: 9 additions & 5 deletions code/datums/traits/negative_quirk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
if(is_species(H, /datum/species/moth) && prob(50))
heirloom_type = /obj/item/flashlight/lantern/heirloom_moth
else
//surely there is a better way to do this
switch(quirk_holder.assigned_role)
//Service jobs
if(JOB_NAME_CLOWN)
Expand Down Expand Up @@ -427,7 +426,7 @@
var/slot_string = "limb"

/datum/quirk/prosthetic_limb/on_spawn()
var/limb_slot = pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)
var/limb_slot = read_choice_preference(/datum/preference/choiced/quirk/prosthetic_limb_location) || pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) // default to random
var/mob/living/carbon/human/H = quirk_target
var/obj/item/bodypart/old_part = H.get_bodypart(limb_slot)
var/obj/item/bodypart/prosthetic
Expand Down Expand Up @@ -542,6 +541,7 @@

/datum/quirk/junkie/on_spawn()
var/mob/living/carbon/human/H = quirk_target
reagent_type = reagent_type || read_choice_preference(/datum/preference/choiced/quirk/junkie_drug)
if (!reagent_type)
reagent_type = pick(drug_list)
reagent_instance = new reagent_type()
Expand Down Expand Up @@ -603,7 +603,9 @@
process = TRUE

/datum/quirk/junkie/smoker/on_spawn()
drug_container_type = pick(/obj/item/storage/fancy/cigarettes,
drug_container_type = read_choice_preference(/datum/preference/choiced/quirk/smoker_cigarettes)
if(!drug_container_type)
drug_container_type = pick(/obj/item/storage/fancy/cigarettes,
/obj/item/storage/fancy/cigarettes/cigpack_midori,
/obj/item/storage/fancy/cigarettes/cigpack_uplift,
/obj/item/storage/fancy/cigarettes/cigpack_robust,
Expand Down Expand Up @@ -648,7 +650,9 @@
var/obj/item/reagent_containers/food/drinks/bottle/drink_instance

/datum/quirk/alcoholic/on_spawn()
drink_instance = pick(drink_types)
drink_instance = read_choice_preference(/datum/preference/choiced/quirk/alcohol_type)
if(!drink_instance)
drink_instance = pick(drink_types)
drink_instance = new drink_instance()
var/list/slots = list("in your backpack" = ITEM_SLOT_BACKPACK)
var/mob/living/carbon/human/H = quirk_target
Expand Down Expand Up @@ -709,7 +713,7 @@
var/trauma

/datum/quirk/trauma/add()
trauma = new trauma_type
trauma = new trauma_type(read_choice_preference(/datum/preference/choiced/quirk/phobia))
var/mob/living/carbon/human/H = quirk_target
H.gain_trauma(trauma, TRAUMA_RESILIENCE_ABSOLUTE)

Expand Down
3 changes: 2 additions & 1 deletion code/datums/traits/positive_quirk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
//Credit To Yowii/Yoworii/Yorii for a much more streamlined method of language library building

/datum/quirk/multilingual/add()
if(!known_language)
known_language = read_choice_preference(/datum/preference/choiced/quirk/multilingual_language)
if(!known_language) // default to random
set_up_language()
var/datum/language_holder/LH = quirk_holder.get_language_holder()
LH.grant_language(known_language, TRUE, TRUE, LANGUAGE_MULTILINGUAL)
Expand Down
32 changes: 32 additions & 0 deletions code/modules/client/preferences/entries/character/quirks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/datum/preference/choiced/quirk
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
preference_type = PREFERENCE_CHARACTER
can_randomize = TRUE
abstract_type = /datum/preference/choiced/quirk
/// typepath of the quirk to be checked for (exact)
var/required_quirk

/datum/preference/choiced/quirk/deserialize(input, datum/preferences/preferences)
// stupid, but if you have a better solution, then go ahead and write it
var/input_path = text2path(input)
if(ispath(input_path))
return ..(input_path, preferences)
else
return ..(input, preferences)

/datum/preference/choiced/quirk/create_default_value()
return "Random"

/datum/preference/choiced/quirk/apply_to_human(mob/living/carbon/human/target, value)
return

/datum/preference/choiced/quirk/is_accessible(datum/preferences/preferences, ignore_page = FALSE)
if (!..())
return FALSE
var/datum/quirk/quirk = required_quirk
if(initial(quirk.name) in preferences.all_quirks)
return TRUE
return FALSE

/datum/preference/choiced/quirk/init_possible_values()
return list("Random")
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/datum/preference/choiced/quirk/alcohol_type
db_key = "quirk_alcohol_type"
required_quirk = /datum/quirk/alcoholic

/datum/preference/choiced/quirk/alcohol_type/init_possible_values()
return ..() + GLOB.alcoholic_bottles

/datum/preference/choiced/quirk/alcohol_type/compile_constant_data()
var/list/data = ..()
var/list/clean_names = list("Random" = "Random")
for(var/obj/item/reagent_containers/food/drinks/bottle/S as() in GLOB.alcoholic_bottles)
clean_names[S] = initial(S.name)
data[CHOICED_PREFERENCE_DISPLAY_NAMES] = clean_names
return data
14 changes: 14 additions & 0 deletions code/modules/client/preferences/entries/character/quirks/junkie.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/datum/preference/choiced/quirk/junkie_drug
db_key = "quirk_junkie_drug"
required_quirk = /datum/quirk/junkie

/datum/preference/choiced/quirk/junkie_drug/init_possible_values()
return ..() + GLOB.junkie_drugs

/datum/preference/choiced/quirk/junkie_drug/compile_constant_data()
var/list/data = ..()
var/list/clean_names = list("Random" = "Random")
for(var/datum/reagent/drug/D as() in GLOB.junkie_drugs)
clean_names[D] = initial(D.name)
data[CHOICED_PREFERENCE_DISPLAY_NAMES] = clean_names
return data
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/datum/preference/choiced/quirk/multilingual_language
db_key = "quirk_multilingual_language"
required_quirk = /datum/quirk/multilingual

/datum/preference/choiced/quirk/multilingual_language/init_possible_values()
return ..() + assoc_to_keys(GLOB.multilingual_language_list)

/datum/preference/choiced/quirk/multilingual_language/compile_constant_data()
var/list/data = ..()
var/list/clean_names = list("Random" = "Random")
for(var/datum/language/L as() in GLOB.multilingual_language_list)
clean_names[L] = initial(L.name)

data[CHOICED_PREFERENCE_DISPLAY_NAMES] = clean_names

return data
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/datum/preference/choiced/quirk/phobia
db_key = "quirk_phobia"
required_quirk = /datum/quirk/trauma

/datum/preference/choiced/quirk/phobia/init_possible_values()
return ..() + assoc_to_keys(GLOB.available_random_trauma_list)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/datum/preference/choiced/quirk/prosthetic_limb_location
db_key = "quirk_prosthetic_limb_location"
required_quirk = /datum/quirk/prosthetic_limb

/datum/preference/choiced/quirk/prosthetic_limb_location/init_possible_values()
return ..() + list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)

/datum/preference/choiced/quirk/prosthetic_limb_location/compile_constant_data()
var/list/data = ..()

data[CHOICED_PREFERENCE_DISPLAY_NAMES] = list(
"Random" = "Random",
BODY_ZONE_L_ARM = "Left Arm",
BODY_ZONE_R_ARM = "Right Arm",
BODY_ZONE_L_LEG = "Left Leg",
BODY_ZONE_R_LEG = "Right Leg",
)

return data
16 changes: 16 additions & 0 deletions code/modules/client/preferences/entries/character/quirks/smoker.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/datum/preference/choiced/quirk/smoker_cigarettes
db_key = "quirk_smoker_cigarettes"
required_quirk = /datum/quirk/junkie/smoker

/datum/preference/choiced/quirk/smoker_cigarettes/init_possible_values()
return ..() + GLOB.smoker_cigarettes

/datum/preference/choiced/quirk/smoker_cigarettes/compile_constant_data()
var/list/data = ..()
var/list/clean_names = list("Random" = "Random")
for(var/obj/item/storage/fancy/cigarettes/S as() in GLOB.smoker_cigarettes)
clean_names[S] = initial(S.name)

data[CHOICED_PREFERENCE_DISPLAY_NAMES] = clean_names

return data
Loading

0 comments on commit d267c63

Please sign in to comment.