Merge pull request #10127 from Nyksia/species-cleanup

Species cleanup
This commit is contained in:
Novacat
2021-04-10 23:04:07 -04:00
committed by GitHub
6 changed files with 35 additions and 169 deletions
+1 -1
View File
@@ -243,7 +243,7 @@
H.custom_exclaim = dna.custom_exclaim
H.species.blood_color = dna.blood_color
var/datum/species/S = H.species
S.produceCopy(dna.base_species,dna.species_traits,src)
S.produceCopy(dna.species_traits,src)
// VOREStation Edit End
H.force_update_organs() //VOREStation Add - Gotta do this too
@@ -114,12 +114,7 @@
pref.dirty_synth = 0
var/datum/species/S = character.species
var/SB
if(S.selects_bodytype)
SB = pref.custom_base ? pref.custom_base : "Human"
else
SB = S.name
var/datum/species/new_S = S.produceCopy(SB, pref.pos_traits + pref.neu_traits + pref.neg_traits, character)
var/datum/species/new_S = S.produceCopy(pref.pos_traits + pref.neu_traits + pref.neg_traits, character, pref.custom_base)
//Any additional non-trait settings can be applied here
new_S.blood_color = pref.blood_color
@@ -42,32 +42,49 @@
nif.nifsofts = nifsofts
else
..()
/datum/species/proc/produceCopy(var/datum/species/to_copy,var/list/traits,var/mob/living/carbon/human/H)
ASSERT(to_copy)
/datum/species/proc/produceCopy(var/list/traits,var/mob/living/carbon/human/H, var/custom_base)
var/datum/species/S
//If species allows custom base, and custom base is set, apply it, otherwise use default.
if(selects_bodytype && custom_base)
S = GLOB.all_species[custom_base]
else
S = GLOB.all_species[src.name]
ASSERT(S)
ASSERT(istype(H))
var/datum/species/new_copy = new S.type()
if(ispath(to_copy))
to_copy = "[initial(to_copy.name)]"
if(istext(to_copy))
to_copy = GLOB.all_species[to_copy]
for(var/i in S.vars) //Thorough copy of species.
if(new_copy.vars[i] != S.vars[i])
//Skipping lists because they may contain more lists, copy those manually.
//Also ignoring type var since it's read-only and will runtime.
if(islist(vars[i]))
continue
new_copy.vars[i] = S.vars[i]
var/datum/species/new_copy = new to_copy.type()
for(var/organ in to_copy.has_limbs)
var/list/organ_data = to_copy.has_limbs[organ]
for(var/organ in S.has_limbs) //Copy important organ data generated by species.
var/list/organ_data = S.has_limbs[organ]
new_copy.has_limbs[organ] = organ_data.Copy()
new_copy.traits = traits
//If you had traits, apply them
if(new_copy.traits)
for(var/trait in new_copy.traits)
var/datum/trait/T = all_traits[trait]
T.apply(new_copy,H)
T.apply(new_copy, H)
//Set up a mob
H.species = new_copy
H.icon_state = new_copy.get_bodytype()
if(new_copy.holder_type)
H.holder_type = new_copy.holder_type
if(H.dna)
H.dna.ready_dna(H)
return new_copy
return new_copy
/datum/species/get_bodytype()
return base_species
@@ -445,55 +445,6 @@
//End of fruit gland code.
/datum/species/alraune/produceCopy(var/datum/species/to_copy,var/list/traits,var/mob/living/carbon/human/H)
ASSERT(to_copy)
ASSERT(istype(H))
if(ispath(to_copy))
to_copy = "[initial(to_copy.name)]"
if(istext(to_copy))
to_copy = GLOB.all_species[to_copy]
var/datum/species/alraune/new_copy = new()
//Initials so it works with a simple path passed, or an instance
new_copy.base_species = to_copy.name
new_copy.icobase = to_copy.icobase
new_copy.deform = to_copy.deform
new_copy.tail = to_copy.tail
new_copy.tail_animation = to_copy.tail_animation
new_copy.icobase_tail = to_copy.icobase_tail
new_copy.color_mult = to_copy.color_mult
new_copy.primitive_form = to_copy.primitive_form
new_copy.appearance_flags = to_copy.appearance_flags
new_copy.flesh_color = to_copy.flesh_color
new_copy.base_color = to_copy.base_color
new_copy.blood_mask = to_copy.blood_mask
new_copy.damage_mask = to_copy.damage_mask
new_copy.damage_overlays = to_copy.damage_overlays
new_copy.traits = traits
//If you had traits, apply them
if(new_copy.traits)
for(var/trait in new_copy.traits)
var/datum/trait/T = all_traits[trait]
T.apply(new_copy,H)
//Set up a mob
H.species = new_copy
H.icon_state = lowertext(new_copy.get_bodytype())
if(new_copy.holder_type)
H.holder_type = new_copy.holder_type
if(H.dna)
H.dna.ready_dna(H)
return new_copy
/datum/species/alraune/get_bodytype()
return base_species
/datum/species/alraune/get_race_key()
var/datum/species/real = GLOB.all_species[base_species]
return real.race_key
@@ -42,61 +42,14 @@
BP_R_FOOT = list("path" = /obj/item/organ/external/foot/right, "descriptor" = "right foot")
)
/datum/species/custom/get_bodytype()
return base_species
/datum/species/custom/get_race_key()
var/datum/species/real = GLOB.all_species[base_species]
return real.race_key
/datum/species/custom/produceCopy(var/datum/species/to_copy,var/list/traits,var/mob/living/carbon/human/H)
ASSERT(to_copy)
ASSERT(istype(H))
if(ispath(to_copy))
to_copy = "[initial(to_copy.name)]"
if(istext(to_copy))
to_copy = GLOB.all_species[to_copy]
var/datum/species/custom/new_copy = new()
//Initials so it works with a simple path passed, or an instance
new_copy.base_species = to_copy.name
new_copy.icobase = to_copy.icobase
new_copy.deform = to_copy.deform
new_copy.tail = to_copy.tail
new_copy.tail_animation = to_copy.tail_animation
new_copy.icobase_tail = to_copy.icobase_tail
new_copy.color_mult = to_copy.color_mult
new_copy.primitive_form = to_copy.primitive_form
new_copy.appearance_flags = to_copy.appearance_flags
new_copy.flesh_color = to_copy.flesh_color
new_copy.base_color = to_copy.base_color
new_copy.blood_mask = to_copy.blood_mask
new_copy.damage_mask = to_copy.damage_mask
new_copy.damage_overlays = to_copy.damage_overlays
new_copy.traits = traits
new_copy.move_trail = move_trail
new_copy.has_floating_eyes = has_floating_eyes
//If you had traits, apply them
if(new_copy.traits)
for(var/trait in new_copy.traits)
var/datum/trait/T = all_traits[trait]
T.apply(new_copy,H)
//Set up a mob
H.species = new_copy
H.maxHealth = new_copy.total_health
H.hunger_rate = new_copy.hunger_factor
if(new_copy.holder_type)
H.holder_type = new_copy.holder_type
if(H.dna)
H.dna.ready_dna(H)
return new_copy
/datum/species/custom/produceCopy(var/list/traits,var/mob/living/carbon/human/H)
. = ..()
H.maxHealth = H.species.total_health
H.hunger_rate = H.species.hunger_factor
// Stub species overrides for shoving trait abilities into
@@ -291,56 +291,6 @@
// HUD update time
update_xenochimera_hud(H, danger, feral_state)
/datum/species/xenochimera/produceCopy(var/datum/species/to_copy,var/list/traits,var/mob/living/carbon/human/H)
ASSERT(to_copy)
ASSERT(istype(H))
if(ispath(to_copy))
to_copy = "[initial(to_copy.name)]"
if(istext(to_copy))
to_copy = GLOB.all_species[to_copy]
var/datum/species/xenochimera/new_copy = new()
//Initials so it works with a simple path passed, or an instance
new_copy.base_species = to_copy.name
new_copy.icobase = to_copy.icobase
new_copy.deform = to_copy.deform
new_copy.tail = to_copy.tail
new_copy.tail_animation = to_copy.tail_animation
new_copy.icobase_tail = to_copy.icobase_tail
new_copy.color_mult = to_copy.color_mult
new_copy.primitive_form = to_copy.primitive_form
new_copy.appearance_flags = to_copy.appearance_flags
new_copy.flesh_color = to_copy.flesh_color
new_copy.base_color = to_copy.base_color
new_copy.blood_mask = to_copy.blood_mask
new_copy.damage_mask = to_copy.damage_mask
new_copy.damage_overlays = to_copy.damage_overlays
new_copy.traits = traits
//If you had traits, apply them
if(new_copy.traits)
for(var/trait in new_copy.traits)
var/datum/trait/T = all_traits[trait]
T.apply(new_copy,H)
//Set up a mob
H.species = new_copy
H.icon_state = lowertext(new_copy.get_bodytype())
if(new_copy.holder_type)
H.holder_type = new_copy.holder_type
if(H.dna)
H.dna.ready_dna(H)
return new_copy
/datum/species/xenochimera/get_bodytype()
return base_species
/datum/species/xenochimera/get_race_key()
var/datum/species/real = GLOB.all_species[base_species]
return real.race_key