From ed08983b978eaf2c1d1aef975479e14415dcf116 Mon Sep 17 00:00:00 2001 From: DeltaFire Date: Sun, 1 Nov 2020 04:56:31 +0100 Subject: [PATCH] syscorruption framework Adds a framework for systems corruption instead of toxins damage for use in synthetic species. No ways to deal / heal it yet, nor effects, or actual uses. Soon. --- code/__DEFINES/combat.dm | 6 ++++ code/__DEFINES/traits.dm | 1 + code/_globalvars/traits.dm | 1 + .../modules/mob/living/carbon/damage_procs.dm | 6 ++-- code/modules/mob/living/damage_procs.dm | 33 ++++++++++++++++--- 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/combat.dm b/code/__DEFINES/combat.dm index 5f5a76b58d..7eebada734 100644 --- a/code/__DEFINES/combat.dm +++ b/code/__DEFINES/combat.dm @@ -11,6 +11,12 @@ #define STAMINA "stamina" #define BRAIN "brain" +//Toxins damage 'typeflag' - is this normal toxins damage or does it have to do with systems corruption (ROBOTIC_ORGANISM species trait) + +#define TOX_DEFAULT 1 //For normal toxins damage / healing (toxins, etc), adjustToxLoss() defaults to this +#define TOX_SYSCORRUPT 2 //For toxins damage causing adverse effects to robotic organisms, up to and including fatal corruption, or healing that damage +#define TOX_OMNI 3 //For tox damage / healing that affects both organics and robotic organisms. Used by very few things, e.g. aheals / by default setToxLoss() + //bitflag damage defines used for suicide_act #define BRUTELOSS (1<<0) #define FIRELOSS (1<<1) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 520f205381..0e433768eb 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -118,6 +118,7 @@ #define TRAIT_NOLIMBDISABLE "no_limb_disable" #define TRAIT_EASYLIMBDISABLE "easy_limb_disable" #define TRAIT_TOXINLOVER "toxinlover" +#define TRAIT_ROBOTICORGANISM "robotic_organism" #define TRAIT_NOBREATH "no_breath" #define TRAIT_ANTIMAGIC "anti_magic" #define TRAIT_HOLY "holy" diff --git a/code/_globalvars/traits.dm b/code/_globalvars/traits.dm index 605b20a4f3..f981ec3595 100644 --- a/code/_globalvars/traits.dm +++ b/code/_globalvars/traits.dm @@ -51,6 +51,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_NOLIMBDISABLE" = TRAIT_NOLIMBDISABLE, "TRAIT_EASYLIMBDISABLE" = TRAIT_EASYLIMBDISABLE, "TRAIT_TOXINLOVER" = TRAIT_TOXINLOVER, + "TRAIT_ROBOTICORGANISM" = TRAIT_ROBOTICORGANISM, "TRAIT_NOBREATH" = TRAIT_NOBREATH, "TRAIT_ANTIMAGIC" = TRAIT_ANTIMAGIC, "TRAIT_HOLY" = TRAIT_HOLY, diff --git a/code/modules/mob/living/carbon/damage_procs.dm b/code/modules/mob/living/carbon/damage_procs.dm index aad647e1f3..c0d7f89f59 100644 --- a/code/modules/mob/living/carbon/damage_procs.dm +++ b/code/modules/mob/living/carbon/damage_procs.dm @@ -85,8 +85,10 @@ heal_overall_damage(0, abs(amount), 0, FALSE, TRUE, updating_health) return amount -/mob/living/carbon/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE) - if(!forced && HAS_TRAIT(src, TRAIT_TOXINLOVER)) //damage becomes healing and healing becomes damage + +//God save me from spaghettifying this - Syscorrupt damage is not affected by toxlovers. +/mob/living/carbon/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE, toxins_type = TOX_DEFAULT) + if(!forced && HAS_TRAIT(src, TRAIT_TOXINLOVER) && toxins_type != TOX_SYSCORRUPT) //damage becomes healing and healing becomes damage amount = -amount if(amount > 0) blood_volume -= 3 * amount //5x was too much, this is punishing enough. diff --git a/code/modules/mob/living/damage_procs.dm b/code/modules/mob/living/damage_procs.dm index 47c9062148..afb6a584c6 100644 --- a/code/modules/mob/living/damage_procs.dm +++ b/code/modules/mob/living/damage_procs.dm @@ -168,20 +168,45 @@ updatehealth() return amount -/mob/living/proc/getToxLoss() - return toxloss +//By default, returns toxins damage no matter what kind of tox damage the target is using. +/mob/living/proc/getToxLoss(toxins_type = TOX_OMNI) + if(toxins_type == TOX_OMNI) + return toxloss -/mob/living/proc/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE) + var/affected_by = TOX_DEFAULT + if(HAS_TRAIT(src, TRAIT_ROBOTICORGANISM)) + affected_by = TOX_SYSCORRUPT + + if(toxins_type != affected_by) + return 0 + else + return toxloss + +/mob/living/proc/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE, toxins_type = TOX_DEFAULT) if(!forced && (status_flags & GODMODE)) return FALSE + var/affected_by = TOX_DEFAULT + if(HAS_TRAIT(src, TRAIT_ROBOTICORGANISM)) + affected_by = TOX_SYSCORRUPT + if(toxins_type != TOX_OMNI && toxins_type != affected_by) + return FALSE + toxloss = clamp((toxloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() return amount -/mob/living/proc/setToxLoss(amount, updating_health = TRUE, forced = FALSE) +//Defaults to omni here because setToxLoss is used by very few things that usually want to set all types +/mob/living/proc/setToxLoss(amount, updating_health = TRUE, forced = FALSE, toxins_type = TOX_OMNI) if(!forced && (status_flags & GODMODE)) return FALSE + + var/affected_by = TOX_DEFAULT + if(HAS_TRAIT(src, TRAIT_ROBOTICORGANISM)) + affected_by = TOX_SYSCORRUPT + if(toxins_type != TOX_OMNI && toxins_type != affected_by) + return FALSE + toxloss = amount if(updating_health) updatehealth()