Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TG Mirror] Fixes magic mirrors not being able to change your race (?) #153

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -524,25 +524,31 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())
/mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE)
if(QDELETED(src))
CRASH("You're trying to change your species post deletion, this is a recipe for madness")
if(mrace && has_dna())
var/datum/species/new_race
if(ispath(mrace))
new_race = new mrace
else if(istype(mrace))
new_race = mrace
else
return
death_sound = new_race.death_sound
if(isnull(mrace))
CRASH("set_species called without a species to set to")
if(!has_dna())
return

var/datum/species/new_race
if(ispath(mrace))
new_race = new mrace
else if(istype(mrace))
if(QDELING(mrace))
CRASH("someone is calling set_species() and is passing it a qdeling species datum, this is VERY bad, stop it")
new_race = mrace
else
CRASH("set_species called with an invalid mrace [mrace]")

var/datum/species/old_species = dna.species
dna.species = new_race
death_sound = new_race.death_sound

if (old_species.properly_gained)
old_species.on_species_loss(src, new_race, pref_load)
var/datum/species/old_species = dna.species
dna.species = new_race

dna.species.on_species_gain(src, old_species, pref_load)
log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]")
if (old_species.properly_gained)
old_species.on_species_loss(src, new_race, pref_load)

dna.species.on_species_gain(src, old_species, pref_load)
log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]")
*/
//SKYRAT EDIT REMOVAL END

Expand Down
10 changes: 5 additions & 5 deletions code/game/objects/structures/mirror.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror/broken, 28)
var/racechoice = tgui_input_list(race_changer, "What are we again?", "Race change", selectable_races)
if(isnull(racechoice))
return TRUE
if(!selectable_races[racechoice])
return TRUE


var/datum/species/newrace = new selectable_races[racechoice]
var/new_race_path = selectable_races[racechoice]
if(!ispath(new_race_path, /datum/species))
return TRUE

var/datum/species/newrace = new new_race_path()
var/attributes_desc = newrace.get_physical_attributes()
qdel(newrace)

var/answer = tgui_alert(race_changer, attributes_desc, "Become a [newrace]?", list("Yes", "No"))
if(answer != "Yes")
qdel(newrace)
change_race(race_changer) // try again
return

Expand Down
72 changes: 40 additions & 32 deletions modular_skyrat/modules/customization/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -189,46 +189,54 @@ GLOBAL_LIST_EMPTY(total_uf_len_by_block)
/mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, list/override_features, list/override_mutantparts, list/override_markings, retain_features = FALSE, retain_mutantparts = FALSE)
if(QDELETED(src))
CRASH("You're trying to change your species post deletion, this is a recipe for madness")
if(mrace && has_dna())
var/datum/species/new_race
if(ispath(mrace))
new_race = new mrace
else if(istype(mrace))
new_race = mrace
else
return
death_sound = new_race.death_sound
var/datum/species/old_species = dna.species
dna.species = new_race
if(isnull(mrace))
CRASH("set_species called without a species to set to")
if(!has_dna())
return

var/datum/species/new_race
if(ispath(mrace))
new_race = new mrace
else if(istype(mrace))
if(QDELING(mrace))
CRASH("someone is calling set_species() and is passing it a qdeling species datum, this is VERY bad, stop it")
new_race = mrace
else
CRASH("set_species called with an invalid mrace [mrace]")

death_sound = new_race.death_sound

var/datum/species/old_species = dna.species
dna.species = new_race

if (old_species.properly_gained)
old_species.on_species_loss(src, new_race, pref_load)
if (old_species.properly_gained)
old_species.on_species_loss(src, new_race, pref_load)

//BODYPARTS AND FEATURES - We need to instantiate the list with compatible mutant parts so we don't break things
//BODYPARTS AND FEATURES - We need to instantiate the list with compatible mutant parts so we don't break things

if(override_mutantparts && override_mutantparts.len)
for(var/feature in dna.mutant_bodyparts)
override_mutantparts[feature] = dna.mutant_bodyparts[feature]
dna.mutant_bodyparts = override_mutantparts
if(override_mutantparts && override_mutantparts.len)
for(var/feature in dna.mutant_bodyparts)
override_mutantparts[feature] = dna.mutant_bodyparts[feature]
dna.mutant_bodyparts = override_mutantparts

if(override_markings && override_markings.len)
for(var/feature in dna.body_markings)
override_markings[feature] = dna.body_markings[feature]
dna.body_markings = override_markings
if(override_markings && override_markings.len)
for(var/feature in dna.body_markings)
override_markings[feature] = dna.body_markings[feature]
dna.body_markings = override_markings

if(override_features && override_features.len)
for(var/feature in dna.features)
override_features[feature] = dna.features[feature]
dna.features = override_features
//END OF BODYPARTS AND FEATURES
if(override_features && override_features.len)
for(var/feature in dna.features)
override_features[feature] = dna.features[feature]
dna.features = override_features
//END OF BODYPARTS AND FEATURES

apply_customizable_dna_features_to_species()
dna.unique_features = dna.generate_unique_features()
apply_customizable_dna_features_to_species()
dna.unique_features = dna.generate_unique_features()

dna.update_body_size()
dna.update_body_size()

dna.species.on_species_gain(src, old_species, pref_load)
log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]")
dna.species.on_species_gain(src, old_species, pref_load)
log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]")


/mob/living/carbon/proc/apply_customizable_dna_features_to_species()
Expand Down
Loading