diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 045f9b74e3..d78cecf9b1 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -318,6 +318,9 @@ #define COMSIG_SPECIES_GAIN "species_gain" //from datum/species/on_species_gain(): (datum/species/new_species, datum/species/old_species) #define COMSIG_SPECIES_LOSS "species_loss" //from datum/species/on_species_loss(): (datum/species/lost_species) +// /datum/mutation signals +#define COMSIG_HUMAN_MUTATION_LOSS "human_mutation_loss" //from datum/mutation/human/on_losing(): (datum/mutation/human/lost_mutation) + /*******Component Specific Signals*******/ //Janitor #define COMSIG_TURF_IS_WET "check_turf_wet" //(): Returns bitflags of wet values. diff --git a/code/datums/elements/dwarfism.dm b/code/datums/elements/dwarfism.dm new file mode 100644 index 0000000000..fefbe4fbe7 --- /dev/null +++ b/code/datums/elements/dwarfism.dm @@ -0,0 +1,42 @@ +#define SHORT 4/5 +#define TALL 5/4 + +///Very similar to squish, but for dwarves and shorties +/datum/element/dwarfism + element_flags = ELEMENT_DETACH|ELEMENT_BESPOKE + id_arg_index = 2 + var/comsig + var/list/attached_targets = list() + +/datum/element/dwarfism/Attach(datum/target, comsig, comsig_target) + . = ..() + if(!isliving(target)) + return ELEMENT_INCOMPATIBLE + + src.comsig = comsig + + var/mob/living/L = target + if(L.lying != 0) + L.transform = L.transform.Scale(SHORT, 1) + else + L.transform = L.transform.Scale(1, SHORT) + attached_targets[target] = comsig_target + RegisterSignal(target, comsig, .proc/check_loss) //Second arg of the signal will be checked against the comsig_target. + +/datum/element/dwarfism/proc/check_loss(mob/living/L, comsig_target) + if(attached_targets[L] == comsig_target) + Detach(L) + +/datum/element/dwarfism/Detach(mob/living/L) + . = ..() + if(QDELETED(L)) + return + if(L.lying != 0) + L.transform = L.transform.Scale(TALL, 1) + else + L.transform = L.transform.Scale(1, TALL) + UnregisterSignal(L, comsig) + attached_targets -= L + +#undef SHORT +#undef TALL diff --git a/code/datums/mutations/_mutations.dm b/code/datums/mutations/_mutations.dm index 9edaa7605c..db739c5100 100644 --- a/code/datums/mutations/_mutations.dm +++ b/code/datums/mutations/_mutations.dm @@ -116,7 +116,8 @@ owner.apply_overlay(layer_used) if(power) owner.RemoveSpell(power) - qdel(src) + qdel(power) + SEND_SIGNAL(owner, COMSIG_HUMAN_MUTATION_LOSS, src) return 0 return 1 diff --git a/code/datums/mutations/body.dm b/code/datums/mutations/body.dm index 9f8c74e2db..7b438f44db 100644 --- a/code/datums/mutations/body.dm +++ b/code/datums/mutations/body.dm @@ -82,7 +82,7 @@ if(..()) return ADD_TRAIT(owner, TRAIT_DWARF, GENETIC_MUTATION) - owner.transform = owner.transform.Scale(1, 0.8) + AddElement(/datum/element/dwarfism, COMSIG_HUMAN_MUTATION_LOSS, src) passtable_on(owner, GENETIC_MUTATION) owner.visible_message("[owner] suddenly shrinks!", "Everything around you seems to grow..") diff --git a/code/modules/mob/living/carbon/human/species_types/dwarves.dm b/code/modules/mob/living/carbon/human/species_types/dwarves.dm index 8a1794a140..0a44891a70 100644 --- a/code/modules/mob/living/carbon/human/species_types/dwarves.dm +++ b/code/modules/mob/living/carbon/human/species_types/dwarves.dm @@ -33,12 +33,11 @@ GLOBAL_LIST_INIT(dwarf_last, world.file2list("strings/names/dwarf_last.txt")) // var/mob/living/carbon/human/H = C H.facial_hair_style = dwarf_hair H.update_hair() - H.transform = H.transform.Scale(1, 0.8) //We use scale, and yeah. Dwarves can become gnomes with DWARFISM. + AddElement(/datum/element/dwarfism, COMSIG_SPECIES_LOSS, src) RegisterSignal(C, COMSIG_MOB_SAY, .proc/handle_speech) //We register handle_speech is being used. /datum/species/dwarf/on_species_loss(mob/living/carbon/H, datum/species/new_species) . = ..() - H.transform = H.transform.Scale(1, 1.25) //And we undo it. UnregisterSignal(H, COMSIG_MOB_SAY) //We register handle_speech is not being used. //Dwarf Name stuff diff --git a/tgstation.dme b/tgstation.dme index a675b2620a..3a34d8bd2b 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -528,6 +528,7 @@ #include "code\datums\elements\cleaning.dm" #include "code\datums\elements\dusts_on_catatonia.dm" #include "code\datums\elements\dusts_on_leaving_area.dm" +#include "code\datums\elements\dwarfism.dm" #include "code\datums\elements\earhealing.dm" #include "code\datums\elements\firestacker.dm" #include "code\datums\elements\flavor_text.dm"