From 9504e00ba280d6ee391719dd0e9ea380d19890ed Mon Sep 17 00:00:00 2001 From: Springf <10732668+SpringSkipper@users.noreply.github.com> Date: Tue, 7 Feb 2023 14:50:37 -0500 Subject: [PATCH] Refactor Fleshmend into a Status Effect (#20031) * Fleshmend Refactor * Reworked buff to match existing code in effect * Clean up formatting Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> * Syntax and formatting updates as per comment suggestions * Update code/datums/status_effects/buffs.dm Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> * Clean up array code Cleaned up some array code, changed a segment where an array was manipulated while iterating through it to instead collect expired instances and remove them after. --------- Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> --- code/__DEFINES/status_effects.dm | 3 ++ code/datums/status_effects/buffs.dm | 39 +++++++++++++++++++ .../changeling/powers/fleshmend.dm | 38 +----------------- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/code/__DEFINES/status_effects.dm b/code/__DEFINES/status_effects.dm index d2cc3abef75..bf1947250a1 100644 --- a/code/__DEFINES/status_effects.dm +++ b/code/__DEFINES/status_effects.dm @@ -39,6 +39,9 @@ #define STATUS_EFFECT_DASH /datum/status_effect/dash // Grants the ability to dash, expiring after a few secodns +/// Rapid burn/brute/oxy/blood healing from the cling ability +#define STATUS_EFFECT_FLESHMEND /datum/status_effect/fleshmend + #define STATUS_EFFECT_SPEEDLEGS /datum/status_effect/speedlegs //Handles cling speed boost and chemical cost. #define STATUS_EFFECT_PANACEA /datum/status_effect/panacea diff --git a/code/datums/status_effects/buffs.dm b/code/datums/status_effects/buffs.dm index aead3e01d90..3bd9cb64598 100644 --- a/code/datums/status_effects/buffs.dm +++ b/code/datums/status_effects/buffs.dm @@ -359,6 +359,45 @@ /datum/status_effect/regenerative_core/on_remove() REMOVE_TRAIT(owner, TRAIT_IGNOREDAMAGESLOWDOWN, id) +/datum/status_effect/fleshmend + duration = -1 + status_type = STATUS_EFFECT_REFRESH + tick_interval = 1 SECONDS + alert_type = null + /// This diminishes the healing of fleshmend the higher it is. + var/tolerance = 1 + var/instance_duration = 10 // in ticks + /// a list of integers, one for each remaining instance of fleshmend. + var/list/active_instances = list() + var/ticks = 0 + +/datum/status_effect/fleshmend/on_apply() + tolerance += 1 + active_instances += instance_duration + return TRUE + +/datum/status_effect/fleshmend/refresh() + tolerance += 1 + active_instances += instance_duration + ..() + +/datum/status_effect/fleshmend/tick() + if(length(active_instances) >= 1) + var/heal_amount = 10 * length(active_instances) / tolerance + var/blood_restore = 30 * length(active_instances) + owner.heal_overall_damage(heal_amount, heal_amount, updating_health = FALSE) + owner.adjustOxyLoss(-heal_amount, FALSE) + owner.blood_volume = min(owner.blood_volume + blood_restore, BLOOD_VOLUME_NORMAL) + owner.updatehealth() + var/list/expired_instances = list() + for(var/i in 1 to length(active_instances)) + active_instances[i]-- + if(active_instances[i] <= 0) + expired_instances += active_instances[i] + active_instances -= expired_instances + tolerance = max(tolerance - 0.05, 1) + if(tolerance <= 1 && length(active_instances) == 0) + qdel(src) /datum/status_effect/speedlegs duration = -1 diff --git a/code/modules/antagonists/changeling/powers/fleshmend.dm b/code/modules/antagonists/changeling/powers/fleshmend.dm index bec9e0820ae..c2aac09017a 100644 --- a/code/modules/antagonists/changeling/powers/fleshmend.dm +++ b/code/modules/antagonists/changeling/powers/fleshmend.dm @@ -7,48 +7,14 @@ dna_cost = 2 req_stat = UNCONSCIOUS power_type = CHANGELING_PURCHASABLE_POWER - var/recent_uses = 1 //The factor of which the healing should be divided by - var/healing_ticks = 10 - // The ideal total healing amount, - // divided by healing_ticks to get heal/tick - var/total_healing = 100 - -/datum/action/changeling/fleshmend/New() - ..() - START_PROCESSING(SSobj, src) - -/datum/action/changeling/fleshmend/Destroy() - STOP_PROCESSING(SSobj, src) - return ..() - -/datum/action/changeling/fleshmend/process() - if(recent_uses > 1) - recent_uses = max(1, recent_uses - (1 / healing_ticks)) //Starts healing you every second for 10 seconds. Can be used whilst unconscious. /datum/action/changeling/fleshmend/sting_action(mob/living/user) to_chat(user, "We begin to heal rapidly.") - if(recent_uses > 1) + if(user.has_status_effect(STATUS_EFFECT_FLESHMEND)) to_chat(user, "Our healing's effectiveness is reduced \ by quick repeated use!") - recent_uses++ - INVOKE_ASYNC(src, PROC_REF(fleshmend), user) + user.apply_status_effect(STATUS_EFFECT_FLESHMEND) SSblackbox.record_feedback("nested tally", "changeling_powers", 1, list("[name]")) return TRUE - -/datum/action/changeling/fleshmend/proc/fleshmend(mob/living/user) - - // The healing itself - doesn't heal toxin damage - // (that's anatomic panacea) and the effectiveness decreases with - // each use in a short timespan - for(var/i in 1 to healing_ticks) - if(user) - var/healpertick = -(total_healing / healing_ticks) - user.heal_overall_damage((-healpertick/recent_uses), (-healpertick/recent_uses), updating_health = FALSE) - user.adjustOxyLoss(healpertick/recent_uses, FALSE) - user.blood_volume = min(user.blood_volume + 30, BLOOD_VOLUME_NORMAL) - user.updatehealth() - else - break - sleep(10)