mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 16:44:43 +01:00
[MIRROR] Refactors quirk code. (#6303)
* Refactors quirk code. * Update neutral.dm * 0 * Update neutral.dm Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk> Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
@@ -13,7 +13,6 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
|
||||
|
||||
var/list/quirks = list() //Assoc. list of all roundstart quirk datum types; "name" = /path/
|
||||
var/list/quirk_points = list() //Assoc. list of quirk names and their "point cost"; positive numbers are good traits, and negative ones are bad
|
||||
var/list/quirk_objects = list() //A list of all quirk objects in the game, since some may process
|
||||
var/list/quirk_blacklist = list() //A list of quirks that can not be used with each other. Format: list(quirk1,quirk2),list(quirk3,quirk4)
|
||||
///An assoc list of quirks that can be obtained as a hardcore character, and their hardcore value.
|
||||
var/list/hardcore_quirks = list()
|
||||
@@ -36,23 +35,27 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
|
||||
// Sort by Positive, Negative, Neutral; and then by name
|
||||
var/list/quirk_list = sortList(subtypesof(/datum/quirk), /proc/cmp_quirk_asc)
|
||||
|
||||
for(var/V in quirk_list)
|
||||
var/datum/quirk/T = V
|
||||
quirks[initial(T.name)] = T
|
||||
quirk_points[initial(T.name)] = initial(T.value)
|
||||
for(var/type in quirk_list)
|
||||
var/datum/quirk/quirk_type = type
|
||||
|
||||
var/hardcore_value = initial(T.hardcore_value)
|
||||
if(initial(quirk_type.abstract_parent_type) == type)
|
||||
continue
|
||||
|
||||
quirks[initial(quirk_type.name)] = quirk_type
|
||||
quirk_points[initial(quirk_type.name)] = initial(quirk_type.value)
|
||||
|
||||
var/hardcore_value = initial(quirk_type.hardcore_value)
|
||||
|
||||
if(!hardcore_value)
|
||||
continue
|
||||
hardcore_quirks[T] += hardcore_value
|
||||
hardcore_quirks[quirk_type] += hardcore_value
|
||||
|
||||
/datum/controller/subsystem/processing/quirks/proc/AssignQuirks(mob/living/user, client/cli, spawn_effects)
|
||||
/datum/controller/subsystem/processing/quirks/proc/AssignQuirks(mob/living/user, client/cli)
|
||||
var/badquirk = FALSE
|
||||
for(var/V in cli.prefs.all_quirks)
|
||||
var/datum/quirk/Q = quirks[V]
|
||||
if(Q)
|
||||
user.add_quirk(Q, spawn_effects)
|
||||
user.add_quirk(Q)
|
||||
else
|
||||
stack_trace("Invalid quirk \"[V]\" in client [cli.ckey] preferences")
|
||||
cli.prefs.all_quirks -= V
|
||||
@@ -65,8 +68,8 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
|
||||
human.hardcore_survival_score = cli.prefs.hardcore_survival_score //Only do this if we actually asign quirks, to prevent sillicons etc from getting the points.
|
||||
|
||||
// Assign wayfinding pinpointer granting quirk if they're new
|
||||
if(cli.get_exp_living(TRUE) < EXP_ASSIGN_WAYFINDER && !user.has_quirk(/datum/quirk/needswayfinder))
|
||||
user.add_quirk(/datum/quirk/needswayfinder, TRUE)
|
||||
if(cli.get_exp_living(TRUE) < EXP_ASSIGN_WAYFINDER && !user.has_quirk(/datum/quirk/item_quirk/needswayfinder))
|
||||
user.add_quirk(/datum/quirk/item_quirk/needswayfinder)
|
||||
|
||||
|
||||
// SKYRAT EDIT ADDITION START - Customization (food prefs)
|
||||
@@ -86,7 +89,7 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
|
||||
*Randomises the quirks for a specified mob
|
||||
*/
|
||||
/datum/controller/subsystem/processing/quirks/proc/randomise_quirks(mob/living/user)
|
||||
var/bonus_quirks = max((length(user.roundstart_quirks) + rand(-RANDOM_QUIRK_BONUS, RANDOM_QUIRK_BONUS)), MINIMUM_RANDOM_QUIRKS)
|
||||
var/bonus_quirks = max((length(user.quirks) + rand(-RANDOM_QUIRK_BONUS, RANDOM_QUIRK_BONUS)), MINIMUM_RANDOM_QUIRKS)
|
||||
var/added_quirk_count = 0 //How many we've added
|
||||
var/list/quirks_to_add = list() //Quirks we're adding
|
||||
var/good_count = 0 //Maximum of 6 good perks
|
||||
@@ -136,14 +139,14 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
|
||||
score += quirk_points[quirk]
|
||||
quirks_to_add += quirk
|
||||
|
||||
for(var/datum/quirk/quirk as anything in user.roundstart_quirks)
|
||||
for(var/datum/quirk/quirk as anything in user.quirks)
|
||||
if(quirk.name in quirks_to_add) //Don't delete ones we keep
|
||||
quirks_to_add -= quirk.name //Already there, no need to add.
|
||||
continue
|
||||
user.remove_quirk(quirk.type) //these quirks are objects
|
||||
|
||||
for(var/datum/quirk/quirk as anything in quirks_to_add)
|
||||
user.add_quirk(quirks[quirk], spawn_effects = TRUE)//these are typepaths converted from string
|
||||
user.add_quirk(quirks[quirk]) //these are typepaths converted from string
|
||||
|
||||
#undef RANDOM_QUIRK_BONUS
|
||||
#undef MINIMUM_RANDOM_QUIRKS
|
||||
|
||||
Reference in New Issue
Block a user