Files
Bubberstation/code/__HELPERS/duplicating.dm
Time-Green 095f7e3b70 Death of mutant bodyparts AND external organs (#85137)
## About The Pull Request

Removes mutant bodyparts and external organs from the game completely
Digitgrade behaviour was mutant bodypart for no reason

Cat ears now work with the bodyparts overlay system, same as all the
other external organs (since all their behaviour is now just on /organ

It doesn't remove all the /external types, but moves all behaviour to
/organ. I'll follow up with a PR wiping all the /external organ types,
but it's just conflict heaven so not this PR

I've also streamlined a lot of duplicate/weird species regeneration code

Melbert did the same PR as well but due to a lack of time (?) I have
absorbed his PR to double nuke mutant bodyparts

## Why It's Good For The Game
Frees us from the chain of unmodular code, and kills my greatest nemesis
(after the shuttle meteor murder bug)

## Changelog
🆑 Time-Green and MrMelbert
Refactor: External organ behaviour has been moved to /organ, ears now
use the same system as the other organs
Refactor: Mutant bodyparts are dead! This likely does not mean much to
the average person but it's very dear to me
code: Improves digitgrade handling in preference code
/🆑

I have absorbed #85126, using Melberts code to improve and add some
missing changes. Mainly improving the functioning of preferences and
digitgrade legs. I didn't take over the hairstyle improvements.

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2024-08-20 16:33:34 +02:00

96 lines
2.7 KiB
Plaintext

///List of all vars that will not be copied over when using duplicate_object()
GLOBAL_LIST_INIT(duplicate_forbidden_vars, list(
"AIStatus",
"actions",
"active_hud_list",
"_active_timers",
"appearance",
"area",
"atmos_adjacent_turfs",
"bodyparts",
"ckey",
"client_mobs_in_contents",
"_listen_lookup",
"computer_id",
"contents",
"cooldowns",
"_datum_components",
"group",
"hand_bodyparts",
"held_items",
"hud_list",
"implants",
"important_recursive_contents",
"organs",
"organs_slot",
"key",
"lastKnownIP",
"loc",
"locs",
"managed_overlays",
"managed_vis_overlays",
"overlays",
"overlays_standing",
"parent",
"parent_type",
"power_supply",
"quirks",
"reagents",
"_signal_procs",
"stat",
"status_effects",
"_status_traits",
"tag",
"tgui_shared_states",
"type",
"update_on_z",
"vars",
"verbs",
"x", "y", "z",
))
GLOBAL_PROTECT(duplicate_forbidden_vars)
/**
* # duplicate_object
*
* Makes a copy of an item and transfers most vars over, barring GLOB.duplicate_forbidden_vars
* Args:
* original - Atom being duplicated
* spawning_location - Turf where the duplicated atom will be spawned at.
*/
/proc/duplicate_object(atom/original, turf/spawning_location)
RETURN_TYPE(original.type)
if(!original)
return
var/atom/made_copy = new original.type(spawning_location)
for(var/atom_vars in original.vars - GLOB.duplicate_forbidden_vars)
if(islist(original.vars[atom_vars]))
var/list/var_list = original.vars[atom_vars]
made_copy.vars[atom_vars] = var_list.Copy()
continue
else if(istype(original.vars[atom_vars], /datum) || ismob(original.vars[atom_vars]))
continue // this would reference the original's object, that will break when it is used or deleted.
made_copy.vars[atom_vars] = original.vars[atom_vars]
if(isliving(made_copy))
if(iscarbon(made_copy))
var/mob/living/carbon/original_carbon = original
var/mob/living/carbon/copied_carbon = made_copy
//transfer DNA over (also body features), then update skin color.
original_carbon.dna.copy_dna(copied_carbon.dna)
copied_carbon.updateappearance(mutcolor_update = TRUE)
var/mob/living/original_living = original
var/mob/living/copied_living = made_copy
//transfer implants, we do this so the original's implants being removed won't destroy ours.
for(var/obj/item/implant/original_implants as anything in original_living.implants)
var/obj/item/implant/copied_implant = new original_implants.type
copied_implant.implant(made_copy, silent = TRUE, force = TRUE)
//transfer quirks, we do this because transfering the original's quirks keeps the 'owner' as the original.
for(var/datum/quirk/original_quirks as anything in original_living.quirks)
copied_living.add_quirk(original_quirks.type)
return made_copy