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>
This commit is contained in:
Springf
2023-02-07 13:50:37 -06:00
committed by GitHub
co-authored by Henri215 Ryan
parent fba3664c5a
commit 9504e00ba2
3 changed files with 44 additions and 36 deletions
+3
View File
@@ -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
+39
View File
@@ -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
@@ -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, "<span class='notice'>We begin to heal rapidly.</span>")
if(recent_uses > 1)
if(user.has_status_effect(STATUS_EFFECT_FLESHMEND))
to_chat(user, "<span class='warning'>Our healing's effectiveness is reduced \
by quick repeated use!</span>")
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)