diff --git a/code/modules/antagonists/changeling/powers/humanform.dm b/code/modules/antagonists/changeling/powers/humanform.dm index d4ae1ce2f5d..c5c81000e65 100644 --- a/code/modules/antagonists/changeling/powers/humanform.dm +++ b/code/modules/antagonists/changeling/powers/humanform.dm @@ -27,23 +27,35 @@ changeling.transform(user, chosen_prof) user.regenerate_icons() + // Delete ourselves when we're done. + qdel(src) return TRUE // Subtype used when a changeling uses lesser form. /datum/action/changeling/humanform/from_monkey desc = "We change back into a human. Costs 5 chemicals." -/datum/action/changeling/humanform/from_monkey/sting_action(mob/living/carbon/user) +/datum/action/changeling/humanform/from_monkey/Grant(mob/granted_to) . = ..() - if(!.) - return + RegisterSignal(granted_to, COMSIG_MONKEY_HUMANIZE, .proc/give_lesserform) - var/datum/antagonist/changeling/changeling = user.mind.has_antag_datum(/datum/antagonist/changeling) +/datum/action/changeling/humanform/from_monkey/Remove(mob/remove_from) + UnregisterSignal(remove_from, COMSIG_MONKEY_HUMANIZE) + return ..() + +/** + * Called on COMSIG_MONKEY_HUMANIZE + * Handles giving the new lesserform ability + * Removing ourselves is handled by parent already, so it's not needed here like it is on lesserform. + * + * Args: + * source - Monkey user who is now turning into a human + */ +/datum/action/changeling/humanform/from_monkey/proc/give_lesserform(mob/living/carbon/source) + SIGNAL_HANDLER + + var/datum/antagonist/changeling/changeling = source.mind.has_antag_datum(/datum/antagonist/changeling) var/datum/action/changeling/lesserform/monkey_form_ability = new() changeling.purchased_powers += monkey_form_ability - monkey_form_ability.Grant(user) - - // Delete ourselves when we're done. - qdel(src) - return TRUE + monkey_form_ability.Grant(source) diff --git a/code/modules/antagonists/changeling/powers/lesserform.dm b/code/modules/antagonists/changeling/powers/lesserform.dm index 6bb889a92c8..a843f031a59 100644 --- a/code/modules/antagonists/changeling/powers/lesserform.dm +++ b/code/modules/antagonists/changeling/powers/lesserform.dm @@ -7,31 +7,47 @@ dna_cost = 1 req_human = TRUE +/datum/action/changeling/lesserform/Grant(mob/granted_to) + . = ..() + RegisterSignal(granted_to, COMSIG_HUMAN_MONKEYIZE, .proc/swap_powers) + +/datum/action/changeling/lesserform/Remove(mob/remove_from) + UnregisterSignal(remove_from, COMSIG_HUMAN_MONKEYIZE) + return ..() + //Transform into a monkey. /datum/action/changeling/lesserform/sting_action(mob/living/carbon/human/user) if(!user || user.notransform) return FALSE - to_chat(user, span_warning("Our genes cry out!")) ..() - + to_chat(user, span_warning("Our genes cry out!")) user.monkeyize() + return TRUE + +/** + * Called on COMSIG_HUMAN_MONKEYIZE + * Handles giving the new human force ability and removing ourselves + * + * Args: + * source - Human user who is now turning into a monkey + */ +/datum/action/changeling/lesserform/proc/swap_powers(mob/living/carbon/source) + SIGNAL_HANDLER + + var/datum/antagonist/changeling/changeling = source.mind.has_antag_datum(/datum/antagonist/changeling) + // Drops all flesh disguise items after monkeyizing, because they don't drop automatically like real clothing. + for(var/slot in changeling.slot2type) + if(istype(source.vars[slot], changeling.slot2type[slot])) + qdel(source.vars[slot]) + for(var/datum/scar/iter_scar as anything in source.all_scars) + if(iter_scar.fake) + qdel(iter_scar) + source.regenerate_icons() - var/datum/antagonist/changeling/changeling = user.mind.has_antag_datum(/datum/antagonist/changeling) var/datum/action/changeling/humanform/from_monkey/human_form_ability = new() changeling.purchased_powers += human_form_ability changeling.purchased_powers -= src - - // Drops all flesh disguise items after monkeyizing, because they don't drop automatically like real clothing. - for(var/slot in changeling.slot2type) - if(istype(user.vars[slot], changeling.slot2type[slot])) - qdel(user.vars[slot]) - for(var/datum/scar/iter_scar as anything in user.all_scars) - if(iter_scar.fake) - qdel(iter_scar) - user.regenerate_icons() - - Remove(user) - human_form_ability.Grant(user) + human_form_ability.Grant(source) + Remove(source) qdel(src) - return TRUE