Skip to content

Commit

Permalink
Refactor Restorative Metabolism
Browse files Browse the repository at this point in the history
Refactors code from Restorative Metabolism. Healing thresholds are now properly checked.
  • Loading branch information
LeDrascol committed Nov 4, 2024
1 parent 713c50e commit aa4cf2a
Showing 1 changed file with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#define RESTMETA_BRUTE_THRESHOLD 50
#define RESTMETA_BRUTE_AMOUNT -0.5
#define RESTMETA_BURN_THRESHOLD 50
#define RESTMETA_BURN_AMOUNT -0.25
#define RESTMETA_TOX_THRESHOLD 50
#define RESTMETA_TOX_AMOUNT -0.3

/datum/quirk/restorative_metabolism
name = "Restorative Metabolism"
desc = "Your body possesses a differentiated reconstructive ability, allowing you to slowly recover from injuries. Critical injuries, wounds, and genetic damage will still require medical attention."
desc = "Your body possesses a differentiated reconstructive ability, allowing you to slowly recover from light to moderate injuries. Critical injuries, wounds, and genetic damage will still require medical attention."
value = 10
quirk_flags = QUIRK_PROCESSES
gain_text = span_notice("You feel a surge of reconstructive vitality coursing through your body...")
Expand All @@ -11,12 +18,34 @@
icon = FA_ICON_NOTES_MEDICAL

/datum/quirk/restorative_metabolism/process(seconds_per_tick)
var/mob/living/carbon/human/H = quirk_holder

H.adjustBruteLoss(-0.5)
H.adjustFireLoss(-0.25)
if(H.getBruteLoss() > 0 && H.getFireLoss() <= 50 || H.getFireLoss() > 0 && H.getFireLoss() <= 50)
H.adjustBruteLoss(-0.5, forced = TRUE)
H.adjustFireLoss(-0.25, forced = TRUE)
else if (H.getToxLoss() <= 90)
H.adjustToxLoss(-0.3, forced = TRUE)
// Quirk holder must be injured
if(quirk_holder.health >= quirk_holder.maxHealth)
// Do nothing
return

// Define health needing updates
var/need_mob_update = FALSE

// Check brute threshold
if(quirk_holder.getBruteLoss() <= RESTMETA_BRUTE_THRESHOLD)
need_mob_update += quirk_holder.adjustBruteLoss(RESTMETA_BRUTE_AMOUNT, updating_health = FALSE)

// Check burn threshold
if(quirk_holder.getFireLoss() <= RESTMETA_BURN_THRESHOLD)
need_mob_update += quirk_holder.adjustFireLoss(RESTMETA_BURN_AMOUNT, updating_health = FALSE)

// Check tox threshold
if(quirk_holder.getToxLoss() <= RESTMETA_TOX_THRESHOLD)
need_mob_update += quirk_holder.adjustToxLoss(RESTMETA_TOX_AMOUNT, updating_health = FALSE, forced = TRUE)

// Check if healing will be applied
if(need_mob_update)
// Update health
quirk_holder.updatehealth()

#undef RESTMETA_BRUTE_THRESHOLD
#undef RESTMETA_BRUTE_AMOUNT
#undef RESTMETA_BURN_THRESHOLD
#undef RESTMETA_BURN_AMOUNT
#undef RESTMETA_TOX_THRESHOLD
#undef RESTMETA_TOX_AMOUNT

0 comments on commit aa4cf2a

Please sign in to comment.