Skip to content

Commit

Permalink
Merge pull request #15 from Stutternov/Statpack
Browse files Browse the repository at this point in the history
Statpack Port
  • Loading branch information
GeneralPantsuIsBadAtCoding authored Jul 31, 2024
2 parents b314f7c + 99e86c7 commit ae4bddf
Show file tree
Hide file tree
Showing 31 changed files with 248 additions and 1 deletion.
6 changes: 6 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
if(patron.preference_accessible)
GLOB.preference_patrons[path] = patron

// Ported fom Lethalstone
for (var/path in subtypesof(/datum/statpack))
var/datum/statpack/statpack = new path()
GLOB.statpacks[path] = statpack
sortList(GLOB.statpacks, GLOBAL_PROC_REF(cmp_text_dsc))

//creates every subtype of prototype (excluding prototype) and adds it to list L.
//if no list/L is provided, one is created.
/proc/init_subtypes(prototype, list/L)
Expand Down
31 changes: 31 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ GLOBAL_LIST_EMPTY(chosen_names)
var/slot_randomized //keeps track of round-to-round randomization of the character slot, prevents overwriting
var/real_name //our character's name
var/gender = MALE //gender of character (well duh)
var/datum/statpack/statpack = new /datum/statpack/wildcard/fated // LETHALSTONE EDIT: the statpack we're giving our char instead of racial bonuses
var/age = AGE_ADULT //age of character
var/origin = "Default"
var/underwear = "Nude" //underwear type
Expand Down Expand Up @@ -330,6 +331,9 @@ GLOBAL_LIST_EMPTY(chosen_names)

dat += "<BR>"
dat += "<b>Race:</b> <a href='?_src_=prefs;preference=species;task=input'>[pref_species.name]</a>[spec_check(user) ? "" : " (!)"]<BR>"

// LETHALSTONE EDIT BEGIN: add statpack selection
dat += "<b>Statpack:</b> <a href='?_src_=prefs;preference=statpack;task=input'>[statpack.name]</a><BR>"
// dat += "<a href='?_src_=prefs;preference=species;task=random'>Random Species</A> "
// dat += "<a href='?_src_=prefs;preference=toggle_random;random_type=[RANDOM_SPECIES]'>Always Random Species: [(randomise[RANDOM_SPECIES]) ? "Yes" : "No"]</A><br>"

Expand Down Expand Up @@ -1482,9 +1486,34 @@ Slots: [job.spawn_positions]</span>
hairs = pref_species.get_hairc_list()
hair_color = hairs[pick(hairs)]
facial_hair_color = hair_color
// LETHALSTONE EDIT: let players know what this shit does stats-wise
switch (age)
if (AGE_ADULT)
to_chat(user, "You preside in your 'prime', whatever this may be, and gain no bonus nor endure any penalty for your time spent alive.")
if (AGE_MIDDLEAGED)
to_chat(user, "Muscles ache and joints begin to slow as Aeon's grasp begins to settle upon your shoulders. (-1 SPD, +1 END)")
if (AGE_OLD)
to_chat(user, "In a place as lethal as Engima, the elderly are all but marvels... or beneficiaries of the habitually privileged. (-1 STR, -2 SPE, -1 PER, -2 CON, +2 INT)")
// LETHALSTONE EDIT END
ResetJobs()
to_chat(user, "<font color='red'>Classes reset.</font>")

// LETHALSTONE EDIT: add statpack selection
if ("statpack")
var/list/statpacks_available = list()
for (var/path as anything in GLOB.statpacks)
var/datum/statpack/statpack = GLOB.statpacks[path]
if (!statpack.name)
continue
statpacks_available[statpack.name] = statpack

var/statpack_input = input(user, "Choose your character's statpack", "Statpack") as null|anything in statpacks_available
if (statpack_input)
var/datum/statpack/statpack_chosen = statpacks_available[statpack_input]
statpack = statpack_chosen
to_chat(user, "<font color='purple'>[statpack.name]</font>")
to_chat(user, "<font color='purple'>[statpack.description_string()]</font>")

if("faith")
var/list/faiths_named = list()
for(var/path as anything in GLOB.preference_faiths)
Expand Down Expand Up @@ -2090,6 +2119,8 @@ Slots: [job.spawn_positions]</span>

character.headshot_link = headshot_link

character.statpack = statpack

character.flavortext = flavortext

character.ooc_notes = ooc_notes
Expand Down
15 changes: 15 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
charflaw = GLOB.character_flaws[charflaw]
charflaw = new charflaw()

/datum/preferences/proc/_load_statpack(S)
var/statpack_type
S["statpack"] >> statpack_type
if (statpack_type)
statpack = new statpack_type()
else
statpack = pick(GLOB.statpacks)
statpack = GLOB.statpacks[statpack]
//statpack = new statpack

/datum/preferences/proc/_load_appearence(S)
S["real_name"] >> real_name
S["gender"] >> gender
Expand Down Expand Up @@ -384,6 +394,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car

_load_flaw(S)

// LETHALSTONE edit: jank-ass load our statpack choice
_load_statpack(S)

if(!S["features["mcolor"]"] || S["features["mcolor"]"] == "#000")
WRITE_FILE(S["features["mcolor"]"] , "#FFF")
if(!S["features["mcolor2"]"] || S["features["mcolor2"]"] == "#000")
Expand Down Expand Up @@ -565,6 +578,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car

WRITE_FILE(S["update_mutant_colors"] , update_mutant_colors)
WRITE_FILE(S["headshot_link"] , headshot_link)
WRITE_FILE(S["statpack"] , statpack.type)


return TRUE

Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@
/datum/rmb_intent/weak)

rot_type = /datum/component/rot/corpse

var/datum/statpack/statpack = null // Lethalstone Port - statpacks for greater customization
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
)
specstats = list("strength" = 0, "perception" = 0, "intelligence" = -1, "constitution" = 1, "endurance" = 1, "speed" = 0, "fortune" = 0)
specstats_f = list("strength" = 0, "perception" = 0, "intelligence" = -1, "constitution" = 1, "endurance" = 1, "speed" = 0, "fortune" = 0)
race_bonus = list(STAT_ENDURANCE = 1)
enflamed_icon = "widefire"
attack_verb = "slash"
attack_sound = 'sound/blank.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = -1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_PERCEPTION = 1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
)
specstats = list("strength" = -2, "perception" = 1, "intelligence" = 0, "constitution" = -1, "endurance" = 1, "speed" = 2, "fortune" = 0)
specstats_f = list("strength" = -3, "perception" = 1, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 2, "fortune" = 0)
race_bonus = list(STAT_SPEED = 1, STAT_INTELLIGENCE = -1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = -1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_PERCEPTION = 1)
enflamed_icon = "widefire"
bodypart_features = list(
/datum/bodypart_feature/hair/head,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = -1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_STRENGTH = 1, STAT_ENDURANCE = -1)
enflamed_icon = "widefire"
attack_verb = "slash"
attack_sound = 'sound/blank.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
specstats = list("strength" = -1, "perception" = 1, "intelligence" = -2, "constitution" = -1, "endurance" = 1, "speed" = 2, "fortune" = 0)
specstats_f = list("strength" = -2, "perception" = 0, "intelligence" = 1, "constitution" = -1, "endurance" = 1, "speed" = 2, "fortune" = 0)
race_bonus = list(STAT_SPEED = 1, STAT_CONSTITUTION = -1)
enflamed_icon = "widefire"
attack_verb = "slash"
attack_sound = 'sound/blank.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
)
specstats = list("strength" = 1, "perception" = 1, "intelligence" = -2, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = 0, "perception" = 0, "intelligence" = 1, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_CONSTITUTION = 1)
enflamed_icon = "widefire"
attack_verb = "slash"
attack_sound = 'sound/blank.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
)
specstats = list("strength" = 1, "perception" = -2, "intelligence" = 1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0) //0 total
specstats_f = list("strength" = 1, "perception" = -2, "intelligence" = 1, "constitution" = 0, "endurance" = 0, "speed" = 0, "fortune" = 0) //0 total
race_bonus = list(STAT_INTELLIGENCE = 1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = -1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_SPEED = 1, STAT_INTELLIGENCE = -1)
enflamed_icon = "widefire"
attack_verb = "slash"
attack_sound = 'sound/blank.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = -1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_SPEED = 1, STAT_INTELLIGENCE = -1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = 1, "constitution" = -1, "endurance" = 0, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_INTELLIGENCE = 1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
)
specstats = list("strength" = 1, "perception" = -2, "intelligence" = 0, "constitution" = 2, "endurance" = 2, "speed" = -3, "fortune" = 0)
specstats_f = list("strength" = 1, "perception" = -2, "intelligence" = 0, "constitution" = 2, "endurance" = 1, "speed" = -2, "fortune" = 0)
race_bonus = list(STAT_CONSTITUTION = 1)
enflamed_icon = "widefire"
customizers = list(
/datum/customizer/organ/eyes/humanoid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
)
specstats = list("strength" = 0, "perception" = -1, "intelligence" = 1, "constitution" = -1, "endurance" = 1, "speed" = 2, "fortune" = 0)
specstats_f = list("strength" = 1, "perception" = -1, "intelligence" = 2, "constitution" = 0, "endurance" = 1, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_PERCEPTION = 1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
)
specstats = list("strength" = -2, "perception" = 1, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 2, "fortune" = 0)
specstats_f = list("strength" = -4, "perception" = 1, "intelligence" = 2, "constitution" = -2, "endurance" = 0, "speed" = 3, "fortune" = 0)
race_bonus = list(STAT_SPEED = 1, STAT_CONSTITUTION = -1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
)
specstats = list("strength" = -1, "perception" = 1, "intelligence" = -2, "constitution" = -1, "endurance" = 1, "speed" = 2, "fortune" = 0)
specstats_f = list("strength" = -2, "perception" = 0, "intelligence" = 1, "constitution" = -1, "endurance" = 1, "speed" = 2, "fortune" = 0)
race_bonus = list(STAT_SPEED = 1, STAT_INTELLIGENCE = -1)
enflamed_icon = "widefire"
attack_verb = "slash"
attack_sound = 'sound/blank.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = -1, "constitution" = 0, "endurance" = 1, "speed" = -1, "fortune" = 0)
specstats_f = list("strength" = -1, "perception" = 0, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 1, "fortune" = 0)
race_bonus = list(STAT_INTELLIGENCE = 1)
enflamed_icon = "widefire"
customizers = list(
/datum/customizer/organ/eyes/humanoid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = 2, "constitution" = -1, "endurance" = -1, "speed" = 1, "fortune" = 1)
specstats_f = list("strength" = 0, "perception" = 1, "intelligence" = 2, "constitution" = -1, "endurance" = -1, "speed" = 1, "fortune" = 1)
race_bonus = list(STAT_FORTUNE = 1, STAT_PERCEPTION = -1)
enflamed_icon = "widefire"
customizers = list(
/datum/customizer/organ/eyes/humanoid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = 1, "constitution" = -1, "endurance" = -1, "speed" = 1, "fortune" = -1)
specstats_f = list("strength" = -1, "perception" = 1, "intelligence" = 1, "constitution" = -2, "endurance" = 0, "speed" = 2, "fortune" = -1)
race_bonus = list(STAT_PERCEPTION = 1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
OFFSET_SHIRT_F = list(0,1), OFFSET_ARMOR_F = list(0,1), OFFSET_UNDIES_F = list(0,1))
specstats = list("strength" = 1, "perception" = -2, "intelligence" = -2, "constitution" = 2, "endurance" = 1, "speed" = 0, "fortune" = 0)
specstats_f = list("strength" = 1, "perception" = -1, "intelligence" = -2, "constitution" = 1, "endurance" = 2, "speed" = 0, "fortune" = -1)
race_bonus = list(STAT_STRENGTH = 1, STAT_INTELLIGENCE = -1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
)
specstats = list("strength" = 0, "perception" = 1, "intelligence" = 2, "constitution" = -1, "endurance" = 0, "speed" = 0, "fortune" = -1)
specstats_f = list("strength" = -1, "perception" = 1, "intelligence" = 2, "constitution" = -2, "endurance" = 1, "speed" = 1, "fortune" = -1)
race_bonus = list(STAT_INTELLIGENCE = 1)
enflamed_icon = "widefire"
organs = list(
ORGAN_SLOT_BRAIN = /obj/item/organ/brain,
Expand Down
23 changes: 22 additions & 1 deletion code/modules/mob/living/stats.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

#define STAT_STRENGTH "strength"
#define STAT_PERCEPTION "perception"
#define STAT_INTELLIGENCE "intelligence"
#define STAT_CONSTITUTION "constitution"
#define STAT_ENDURANCE "endurance"
#define STAT_SPEED "speed"
#define STAT_FORTUNE "fortune"

/mob/living
var/STASTR = 10
var/STAPER = 10
Expand Down Expand Up @@ -38,6 +46,8 @@
/datum/species
var/list/specstats = list("strength" = 0, "perception" = 0, "intelligence" = 0, "constitution" = 0, "endurance" = 0, "speed" = 0, "fortune" = 0)
var/list/specstats_f = list("strength" = 0, "perception" = 0, "intelligence" = 0, "constitution" = 0, "endurance" = 0, "speed" = 0, "fortune" = 0)
// Associative list of stat (STAT_STRENGTH, etc) bonuses used to differentiate each race. They should ALWAYS be positive.
var/list/race_bonus = list()

/mob/living/proc/roll_stats()
STASTR = 10
Expand All @@ -58,13 +68,24 @@
change_stat(S, 1)
if(ishuman(src))
var/mob/living/carbon/human/H = src

/* - Old way of handling race/gender stats, no longer used. See: Statpacks.
if(H.dna.species)
if(gender == FEMALE)
for(var/S in H.dna.species.specstats_f)
change_stat(S, H.dna.species.specstats_f[S])
else
for(var/S in H.dna.species.specstats)
change_stat(S, H.dna.species.specstats[S])
change_stat(S, H.dna.species.specstats[S])*/

if (H.statpack)
H.statpack.apply_to_human(H)
if (H.dna?.species) // LETHALSTONE EDIT: apply our race bonus, if we have one
var/datum/species/species = H.dna.species
if (species.race_bonus)
for (var/stat in species.race_bonus)
var/amt = species.race_bonus[stat]
H.change_stat(stat, amt)
switch(H.age)
if(AGE_MIDDLEAGED)
change_stat("speed", -1)
Expand Down
55 changes: 55 additions & 0 deletions modular_azurepeak/_statpacks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
GLOBAL_LIST_EMPTY(statpacks)

/datum/statpack
/// Name of the statpack
var/name
/// Flavor description of the statpack (don't include stat totals in this, we'll render them automatically)
var/desc
/// An associative list of only the stats we're altering. The value can also be a list to signify a range of values - maximum length of 2 for these.
var/stat_array = list()

/datum/statpack/proc/apply_to_human(mob/living/carbon/human/recipient)
if (recipient && recipient.mind)
for (var/stat in stat_array)
if (!islist(stat_array[stat]))
var/value = stat_array[stat]
recipient.change_stat(stat, value)
else
var/list/stat_range = stat_array[stat]
recipient.change_stat(stat, rand(stat_range[1], stat_range[2]))
return TRUE
return FALSE

/datum/statpack/proc/description_string()
return "[desc]<br> <i>[generate_modifier_string()]</i>"

/datum/statpack/proc/generate_modifier_string()
/// Generates a blurb string for use in preferences, programatically, based on our desc and stat alterations.
var/result
var/list/concat = list()
for (var/stat in stat_array)
if (!islist(stat_array[stat]))
var/value = stat_array[stat]
var/modifier = ""

if (value >= 1)
modifier = "+"

var/statlabel = uppertext(copytext(stat, 1, 4))
var/blockstring = "[modifier][value] [statlabel]"
concat += blockstring
else
var/list/stat_range = stat_array[stat]
var/list/chunk_string = list()
for (var/sub_range in stat_range)
var/modifier = ""
if (sub_range >= 1)
modifier = "+"

chunk_string += "<b>[modifier][sub_range]</b>"

var/statlabel = uppertext(copytext(stat, 1, 4))
concat += "[chunk_string.Join(" to ")] [statlabel]"

result = "([concat.Join(", ")])"
return result
Loading

0 comments on commit ae4bddf

Please sign in to comment.