Files
Bubberstation/code/datums/quirks/_quirk.dm
SkyratBot 124ddd7cca [MIRROR] tgui Preferences Menu + total rewrite of the preferences backend (#8153)
* tgui Preferences Menu + total rewrite of the preferences backend

* nah, we dont need to ping those people

* trying to remove the funny stuff

* unmodularizing this

* prefs reset

* this may need to be reverted, who knows

* okay, this part

* perhaps

* EEEEEEEEE

* unsanitary

* E

* Stage 1 + loadout system

* more fixes

* E

* I mean, it launches?

* More fixes and reorganisation

* E

* customisation code is spaget.

* disable ERP prefs

* Update erp_preferences.dm

* Update erp_preferences.dm

* E

* Slowly getting there

* It may be time for help :)

* tri...colors... help

* preferences now pass preferences

* Update dna.dm

* Fuck this man

* missing savefile return, set_species works, removed dumb stuff from updateappearance

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8199

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8224

* https://github.com/tgstation/tgstation/pull/61519

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8278

* e

* le butonAZARAK HELLO

* hhh

* Proper recognition where it's due, MrMelbert!

* EEEE

* examine block

* Better gen hit sounds from whitedream

* final loadout touches, more bug fixes im sure to come

* i said there would be bugfixes

* Update LoadoutManager.js

* Missing preferences in the html menu

* LIVE TESTING PHASE BABY

* Update LoadoutManager.js

* EEE

* LAUNCH TEST FIRE

* Update job.dm

* Update new_player.dm

* 50gb DAY ONE PATCH

* EEE

* Update preferences.dm

* buggle fixes

* Update examine.dm

* >LOOC starts on

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: jjpark-kb <55967837+jjpark-kb@users.noreply.github.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
Co-authored-by: Azarak <azarak10@gmail.com>
2021-09-23 00:40:37 +01:00

216 lines
8.4 KiB
Plaintext

//every quirk in this folder should be coded around being applied on spawn
//these are NOT "mob quirks" like GOTTAGOFAST, but exist as a medium to apply them and other different effects
/datum/quirk
var/name = "Test Quirk"
var/desc = "This is a test quirk."
var/value = 0
var/human_only = TRUE
var/gain_text
var/lose_text
var/medical_record_text //This text will appear on medical records for the trait. Not yet implemented
var/mood_quirk = FALSE //if true, this quirk affects mood and is unavailable if moodlets are disabled
var/mob_trait //if applicable, apply and remove this mob trait
/// Amount of points this trait is worth towards the hardcore character mode; minus points implies a positive quirk, positive means its hard. This is used to pick the quirks assigned to a hardcore character. 0 means its not available to hardcore draws.
var/hardcore_value = 0
var/mob/living/quirk_holder
/// This quirk should START_PROCESSING when added and STOP_PROCESSING when removed.
var/processing_quirk = FALSE
/// When making an abstract quirk (in OOP terms), don't forget to set this var to the type path for that abstract quirk.
var/abstract_parent_type = /datum/quirk
/// The icon to show in the preferences menu.
/// This references a tgui icon, so it can be FontAwesome or a tgfont (with a tg- prefix).
var/icon = "bug" //SKYRAT EDIT CHANGE
/datum/quirk/Destroy()
if(quirk_holder)
remove_from_current_holder()
return ..()
/// Called when quirk_holder is qdeleting. Simply qdels this datum and lets Destroy() handle the rest.
/datum/quirk/proc/on_holder_qdeleting(mob/living/source, force)
SIGNAL_HANDLER
qdel(src)
/**
* Adds the quirk to a new quirk_holder.
*
* Performs logic to make sure new_holder is a valid holder of this quirk.
* Returns FALSEy if there was some kind of error. Returns TRUE otherwise.
* Arguments:
* * new_holder - The mob to add this quirk to.
* * quirk_transfer - If this is being added to the holder as part of a quirk transfer. Quirks can use this to decide not to spawn new items or apply any other one-time effects.
*/
/datum/quirk/proc/add_to_holder(mob/living/new_holder, quirk_transfer = FALSE)
if(!new_holder)
CRASH("Quirk attempted to be added to null mob.")
if(human_only && !ishuman(new_holder))
CRASH("Human only quirk attempted to be added to non-human mob.")
if(new_holder.has_quirk(type))
CRASH("Quirk attempted to be added to mob which already had this quirk.")
if(quirk_holder)
CRASH("Attempted to add quirk to a holder when it already has a holder.")
quirk_holder = new_holder
quirk_holder.quirks += src
if(mob_trait)
ADD_TRAIT(quirk_holder, mob_trait, QUIRK_TRAIT)
add()
if(processing_quirk)
START_PROCESSING(SSquirks, src)
if(!quirk_transfer)
if(gain_text)
to_chat(quirk_holder, gain_text)
add_unique()
if(quirk_holder.client)
post_add()
else
RegisterSignal(quirk_holder, COMSIG_MOB_LOGIN, .proc/on_quirk_holder_first_login)
RegisterSignal(quirk_holder, COMSIG_PARENT_QDELETING, .proc/on_holder_qdeleting)
return TRUE
/// Removes the quirk from the current quirk_holder.
/datum/quirk/proc/remove_from_current_holder(quirk_transfer = FALSE)
if(!quirk_holder)
CRASH("Attempted to remove quirk from the current holder when it has no current holder.")
UnregisterSignal(quirk_holder, list(COMSIG_MOB_LOGIN, COMSIG_PARENT_QDELETING))
quirk_holder.quirks -= src
if(!quirk_transfer && lose_text)
to_chat(quirk_holder, lose_text)
if(mob_trait)
REMOVE_TRAIT(quirk_holder, mob_trait, QUIRK_TRAIT)
if(processing_quirk)
STOP_PROCESSING(SSquirks, src)
remove()
quirk_holder = null
/**
* On client connection set quirk preferences.
*
* Run post_add to set the client preferences for the quirk.
* Clear the attached signal for login.
* Used when the quirk has been gained and no client is attached to the mob.
*/
/datum/quirk/proc/on_quirk_holder_first_login(mob/living/source)
SIGNAL_HANDLER
UnregisterSignal(source, COMSIG_MOB_LOGIN)
post_add()
/// Any effect that should be applied every single time the quirk is added to any mob, even when transferred.
/datum/quirk/proc/add()
/// Any effects from the proc that should not be done multiple times if the quirk is transferred between mobs. Put stuff like spawning items in here.
/datum/quirk/proc/add_unique()
/// Removal of any reversible effects added by the quirk.
/datum/quirk/proc/remove()
/// Any special effects or chat messages which should be applied. This proc is guaranteed to run if the mob has a client when the quirk is added. Otherwise, it runs once on the next COMSIG_MOB_LOGIN.
/datum/quirk/proc/post_add()
/// Subtype quirk that has some bonus logic to spawn items for the player.
/datum/quirk/item_quirk
/// Lazylist of strings describing where all the quirk items have been spawned.
var/list/where_items_spawned
/// If true, the backpack automatically opens on post_add(). Usually set to TRUE when an item is equipped inside the player's backpack.
var/open_backpack = FALSE
abstract_parent_type = /datum/quirk/item_quirk
/**
* Handles inserting an item in any of the valid slots provided, then allows for post_add notification.
*
* If no valid slot is available for an item, the item is left at the mob's feet.
* Arguments:
* * quirk_item - The item to give to the quirk holder. If the item is a path, the item will be spawned in first on the player's turf.
* * valid_slots - Assoc list of descriptive location strings to item slots that is fed into [/mob/living/carbon/proc/equip_in_one_of_slots]. list(LOCATION_BACKPACK = ITEM_SLOT_BACKPACK)
* * flavour_text - Optional flavour text to append to the where_items_spawned string after the item's location.
* * default_location - If the item isn't possible to equip in a valid slot, this is a description of where the item was spawned.
* * notify_player - If TRUE, adds strings to where_items_spawned list to be output to the player in [/datum/quirk/item_quirk/post_add()]
*/
/datum/quirk/item_quirk/proc/give_item_to_holder(quirk_item, list/valid_slots, flavour_text = null, default_location = "at your feet", notify_player = TRUE)
if(ispath(quirk_item))
quirk_item = new quirk_item(get_turf(quirk_holder))
var/mob/living/carbon/human/human_holder = quirk_holder
var/where = human_holder.equip_in_one_of_slots(quirk_item, valid_slots, qdel_on_fail = FALSE) || default_location
if(where == LOCATION_BACKPACK)
open_backpack = TRUE
if(notify_player)
LAZYADD(where_items_spawned, span_boldnotice("You have \a [quirk_item] [where]. [flavour_text]"))
/datum/quirk/item_quirk/post_add()
if(open_backpack)
var/mob/living/carbon/human/human_holder = quirk_holder
// post_add() can be called via delayed callback. Check they still have a backpack equipped before trying to open it.
if(human_holder.back)
SEND_SIGNAL(human_holder.back, COMSIG_TRY_STORAGE_SHOW, human_holder)
for(var/chat_string in where_items_spawned)
to_chat(quirk_holder, chat_string)
where_items_spawned = null
/**
* get_quirk_string() is used to get a printable string of all the quirk traits someone has for certain criteria
*
* Arguments:
* * Medical- If we want the long, fancy descriptions that show up in medical records, or if not, just the name
* * Category- Which types of quirks we want to print out. Defaults to everything
*/
/mob/living/proc/get_quirk_string(medical, category = CAT_QUIRK_ALL) //helper string. gets a string of all the quirks the mob has
var/list/dat = list()
switch(category)
if(CAT_QUIRK_ALL)
for(var/V in quirks)
var/datum/quirk/T = V
dat += medical ? T.medical_record_text : T.name
//Major Disabilities
if(CAT_QUIRK_MAJOR_DISABILITY)
for(var/V in quirks)
var/datum/quirk/T = V
if(T.value < -4)
dat += medical ? T.medical_record_text : T.name
//Minor Disabilities
if(CAT_QUIRK_MINOR_DISABILITY)
for(var/V in quirks)
var/datum/quirk/T = V
if(T.value >= -4 && T.value < 0)
dat += medical ? T.medical_record_text : T.name
//Neutral and Positive quirks
if(CAT_QUIRK_NOTES)
for(var/V in quirks)
var/datum/quirk/T = V
if(T.value > -1)
dat += medical ? T.medical_record_text : T.name
if(!dat.len)
return medical ? "No issues have been declared." : "None"
return medical ? dat.Join("<br>") : dat.Join(", ")
/mob/living/proc/cleanse_trait_datums() //removes all trait datums
for(var/V in quirks)
var/datum/quirk/T = V
qdel(T)
/mob/living/proc/transfer_trait_datums(mob/living/to_mob)
for(var/datum/quirk/quirk as anything in quirks)
quirk.remove_from_current_holder(quirk_transfer = TRUE)
quirk.add_to_holder(to_mob, quirk_transfer = TRUE)