From 982bf9b1a1fa21ebad94deab0819b5b5f313d298 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Tue, 27 Dec 2016 17:15:20 -0600 Subject: [PATCH] Fix species radiation multipliers (#1325) Fixes radiation so species' radiation_mod values are actually applied. Refactored radiation application to use proc apply_radiation() instead of directly modifying the variable. --- code/game/dna/dna_modifier.dm | 2 +- code/game/machinery/adv_med.dm | 2 +- code/game/machinery/suit_storage_unit.dm | 4 ++-- code/game/objects/items/devices/PDA/PDA.dm | 4 ++-- code/modules/mob/living/carbon/alien/life.dm | 6 +++--- code/modules/mob/living/carbon/brain/life.dm | 16 ++++++++-------- code/modules/mob/living/carbon/diona_base.dm | 6 ++++-- .../mob/living/carbon/human/human_damage.dm | 5 +++++ code/modules/mob/living/carbon/human/life.dm | 16 ++++++++-------- .../carbon/human/species/station/station.dm | 11 ++++++----- code/modules/mob/living/damage_procs.dm | 8 +++++++- code/modules/mob/living/living.dm | 2 +- code/modules/mob/living/living_defines.dm | 2 ++ code/modules/mob/mob_defines.dm | 1 - .../Chemistry-Reagents-Food-Drinks.dm | 2 +- .../Chemistry-Reagents-Medicine.dm | 4 ++-- .../Chemistry-Reagents-Other.dm | 2 +- .../artifact/effects/unknown_effect_heal.dm | 2 +- code/modules/virus2/disease2.dm | 2 +- 19 files changed, 56 insertions(+), 41 deletions(-) diff --git a/code/game/dna/dna_modifier.dm b/code/game/dna/dna_modifier.dm index 66c42edbec7..c4180f55a28 100644 --- a/code/game/dna/dna_modifier.dm +++ b/code/game/dna/dna_modifier.dm @@ -386,7 +386,7 @@ occupantData["uniqueEnzymes"] = connected.occupant.dna.unique_enzymes occupantData["uniqueIdentity"] = connected.occupant.dna.uni_identity occupantData["structuralEnzymes"] = connected.occupant.dna.struc_enzymes - occupantData["radiationLevel"] = connected.occupant.radiation + occupantData["radiationLevel"] = connected.occupant.total_radiation data["occupant"] = occupantData; data["isBeakerLoaded"] = connected.beaker ? 1 : 0 diff --git a/code/game/machinery/adv_med.dm b/code/game/machinery/adv_med.dm index 8643b8c4b1d..4bfeb102cda 100644 --- a/code/game/machinery/adv_med.dm +++ b/code/game/machinery/adv_med.dm @@ -317,7 +317,7 @@ "fireloss" = H.getFireLoss(), "oxyloss" = H.getOxyLoss(), "toxloss" = H.getToxLoss(), - "rads" = H.radiation, + "rads" = H.total_radiation, "cloneloss" = H.getCloneLoss(), "brainloss" = H.getBrainLoss(), "paralysis" = H.paralysis, diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 31a1b4044ba..c0d63e60ad0 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -330,7 +330,7 @@ for(i=0,i<4,i++) sleep(50) if(src.OCCUPANT) - OCCUPANT.radiation += 50 + OCCUPANT.apply_radiation(50) if (!OCCUPANT.is_diona()) if(src.issuperUV) var/burndamage = rand(28,35) @@ -661,7 +661,7 @@ departments = list("Wizardry") species = list("Human","Tajara","Skrell","Unathi") can_repair = 1 - + /obj/machinery/suit_cycler/captain name = "Captain suit cycler" model_text = "Captain" diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index 6c6a1223c2b..3733bec1546 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -1276,8 +1276,8 @@ var/global/list/obj/item/device/pda/PDAs = list() O.show_message("\The [user] has analyzed [C]'s radiation levels!", 1) user.show_message("Analyzing Results for [C]:") - if(C.radiation) - user.show_message("Radiation Level: [C.radiation]") + if(C.total_radiation) + user.show_message("Radiation Level: [C.total_radiation]") else user.show_message("No radiation detected.") diff --git a/code/modules/mob/living/carbon/alien/life.dm b/code/modules/mob/living/carbon/alien/life.dm index 29c6b72d99f..8873e804de9 100644 --- a/code/modules/mob/living/carbon/alien/life.dm +++ b/code/modules/mob/living/carbon/alien/life.dm @@ -26,11 +26,11 @@ // Currently both Dionaea and larvae like to eat radiation, so I'm defining the // rad absorbtion here. This will need to be changed if other baby aliens are added. - if(!radiation) + if(!total_radiation) return - var/rads = radiation/25 - radiation -= rads + var/rads = total_radiation/25 + apply_radiation(rads*-1) nutrition += rads heal_overall_damage(rads,rads) adjustOxyLoss(-(rads)) diff --git a/code/modules/mob/living/carbon/brain/life.dm b/code/modules/mob/living/carbon/brain/life.dm index 9f3f3e54565..c9f87091c2f 100644 --- a/code/modules/mob/living/carbon/brain/life.dm +++ b/code/modules/mob/living/carbon/brain/life.dm @@ -2,26 +2,26 @@ return /mob/living/carbon/brain/handle_mutations_and_radiation() - if (radiation) - if (radiation > 100) - radiation = 100 + if (total_radiation) + if (total_radiation > 100) + total_radiation = 100 if(!container)//If it's not in an MMI src << "\red You feel weak." else//Fluff-wise, since the brain can't detect anything itself, the MMI handles thing like that src << "\red STATUS: CRITICAL AMOUNTS OF RADIATION DETECTED." - switch(radiation) + switch(total_radiation) if(1 to 49) - radiation-- + apply_radiation(-1) if(prob(25)) adjustToxLoss(1) updatehealth() if(50 to 74) - radiation -= 2 + apply_radiation(-2) adjustToxLoss(1) if(prob(5)) - radiation -= 5 + apply_radiation(-5) if(!container) src << "\red You feel weak." else @@ -29,7 +29,7 @@ updatehealth() if(75 to 100) - radiation -= 3 + apply_radiation(-3) adjustToxLoss(3) updatehealth() diff --git a/code/modules/mob/living/carbon/diona_base.dm b/code/modules/mob/living/carbon/diona_base.dm index 51203359426..2472951d52f 100644 --- a/code/modules/mob/living/carbon/diona_base.dm +++ b/code/modules/mob/living/carbon/diona_base.dm @@ -55,6 +55,8 @@ var/list/diona_banned_languages = list( //Converts radiation to stored energy if its needed, and gives messages related to radiation //Rads can be used to heal in place of light energy, that is handled in the regular regeneration proc + var/radiation = total_radiation + if (radiation && DS.stored_energy < (DS.max_energy * 0.8))//Radiation can provide energy in place of light radiation -= 2 DS.stored_energy += 2 @@ -116,10 +118,10 @@ var/list/diona_banned_languages = list( //Most medicines don't work on diona, but physical treatment for external wounds helps a little, //and some alternative things that are toxic to other life, such as radium and mutagen, will benefit diona /mob/living/carbon/proc/diona_handle_regeneration(var/datum/dionastats/DS) - if ((DS.stored_energy < 1 && !radiation))//we need energy or radiation to heal + if ((DS.stored_energy < 1 && !total_radiation))//we need energy or radiation to heal return - radiation = max(radiation, 0) + var/radiation = max(total_radiation, 0) var/value //A little variable we'll reuse to optimise diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm index e3fba24bf9f..57afcac3db7 100644 --- a/code/modules/mob/living/carbon/human/human_damage.dm +++ b/code/modules/mob/living/carbon/human/human_damage.dm @@ -401,3 +401,8 @@ This function restores all organs. updatehealth() BITSET(hud_updateflag, HEALTH_HUD) return 1 + +/mob/living/carbon/human/apply_radiation(var/rads) + if (species && rads > 0) + rads = rads * species.radiation_mod + ..(rads) \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index ecfd0b4ae39..7f8d3cec9ef 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -281,24 +281,24 @@ speech_problem_flag = 1 gene.OnMobLife(src) - radiation = Clamp(radiation,0,100) + total_radiation = Clamp(total_radiation,0,100) // #TODO-MERGE: Check vaurca and IPC radiation management - if (radiation) + if (total_radiation) //var/obj/item/organ/diona/nutrients/rad_organ = locate() in internal_organs if(src.is_diona()) diona_handle_regeneration(get_dionastats()) else var/damage = 0 - radiation -= 1 * RADIATION_SPEED_COEFFICIENT + total_radiation -= 1 * RADIATION_SPEED_COEFFICIENT if(prob(25)) damage = 1 - if (radiation > 50) + if (total_radiation > 50) damage = 1 - radiation -= 1 * RADIATION_SPEED_COEFFICIENT + total_radiation -= 1 * RADIATION_SPEED_COEFFICIENT if(prob(5) && prob(100 * RADIATION_SPEED_COEFFICIENT)) - radiation -= 5 * RADIATION_SPEED_COEFFICIENT + src.apply_radiation(-5 * RADIATION_SPEED_COEFFICIENT) src << "You feel weak." Weaken(3) if(!lying) @@ -310,8 +310,8 @@ f_style = "Shaved" update_hair() - if (radiation > 75) - radiation -= 1 * RADIATION_SPEED_COEFFICIENT + if (total_radiation > 75) + src.apply_radiation(-1 * RADIATION_SPEED_COEFFICIENT) damage = 3 if(prob(5)) take_overall_damage(0, 5 * RADIATION_SPEED_COEFFICIENT, used_weapon = "Radiation Burns") diff --git a/code/modules/mob/living/carbon/human/species/station/station.dm b/code/modules/mob/living/carbon/human/species/station/station.dm index 65703a5a9c5..461ed2f1def 100644 --- a/code/modules/mob/living/carbon/human/species/station/station.dm +++ b/code/modules/mob/living/carbon/human/species/station/station.dm @@ -275,13 +275,13 @@ var/remainder = cost * sprint_cost_factor - if (H.radiation) - if (H.radiation > (cost*0.5))//Radiation counts as double energy - H.radiation -= cost*0.5 + if (H.total_radiation) + if (H.total_radiation > (cost*0.5))//Radiation counts as double energy + H.apply_radiation(cost*(-0.5)) return 1 else - remainder = cost - (H.radiation*2) - H.radiation = 0 + remainder = cost - (H.total_radiation*2) + H.total_radiation = 0 if (DS.stored_energy > remainder) DS.stored_energy -= remainder @@ -343,6 +343,7 @@ num_alternate_languages = 2 secondary_langs = list("Encoded Audio Language") ethanol_resistance = -1//Can't get drunk + radiation_mod = 0 // not affected by radiation eyes = "blank_eyes" // #TODO-MERGE: Check for balance and self-repair. If self-repair is a thing, RIP balance. diff --git a/code/modules/mob/living/damage_procs.dm b/code/modules/mob/living/damage_procs.dm index e4188474df4..84414c15f00 100644 --- a/code/modules/mob/living/damage_procs.dm +++ b/code/modules/mob/living/damage_procs.dm @@ -54,7 +54,7 @@ adjustHalLoss(effect) //Changed this to use the wrapper function, it shouldn't directly alter the value if(IRRADIATE) var/rad_protection = check_protection ? getarmor(null, "rad")/100 : 0 - radiation += max((1-rad_protection)*effect/(blocked+1),0)//Rads auto check armor + apply_radiation(max((1-rad_protection)*effect/(blocked+1),0))//Rads auto check armor if(STUTTER) if(status_flags & CANSTUN) // stun is usually associated with stutter stuttering = max(stuttering,(effect/(blocked+1))) @@ -81,3 +81,9 @@ if(agony) apply_effect(agony, AGONY, blocked) if(incinerate) apply_effect(incinerate, INCINERATE, blocked) return 1 + +// overridden by human +/mob/living/proc/apply_radiation(var/rads) + total_radiation += rads + if (total_radiation < 0) + total_radiation = 0 \ No newline at end of file diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 0872fd8ba00..cf80d65f456 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -442,7 +442,7 @@ default behaviour is: SetWeakened(0) // shut down ongoing problems - radiation = 0 + total_radiation = 0 nutrition = 400 bodytemperature = T20C sdisabilities = 0 diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 1625d85b629..ddd0a306899 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -67,3 +67,5 @@ var/exhaust_threshold = 50 var/move_delay_mod = 0//Added to move delay, used for calculating movement speeds. Provides a centralised value for modifiers to alter + + var/total_radiation // DON'T MODIFY THIS DIRECTLY. USE apply_radiation()! diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index fdc6f346355..24d100b9c67 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -159,7 +159,6 @@ var/can_pull_mobs = MOB_PULL_LARGER // Whether or not the mob can pull other mobs. var/datum/dna/dna = null//Carbon - var/radiation = 0.0//Carbon var/list/mutations = list() //Carbon -- Doohl //see: setup.dm for list of mutations diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Food-Drinks.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Food-Drinks.dm index 5c98ec182f4..b1d029d0f08 100644 --- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Food-Drinks.dm +++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Food-Drinks.dm @@ -1223,7 +1223,7 @@ /datum/reagent/ethanol/vodka/affect_ingest(var/mob/living/carbon/M, var/alien, var/removed) ..() - M.apply_effect(max(M.radiation - 1 * removed, 0), IRRADIATE, check_protection = 0) + M.apply_effect(max(M.total_radiation - 1 * removed, 0), IRRADIATE, check_protection = 0) /datum/reagent/ethanol/whiskey name = "Whiskey" diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm index 187d226a3eb..3025970af0e 100644 --- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm +++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm @@ -391,7 +391,7 @@ scannable = 1 /datum/reagent/hyronalin/affect_blood(var/mob/living/carbon/M, var/alien, var/removed) - M.radiation = max(M.radiation - 30 * removed, 0) + M.apply_radiation(-30 * removed) /datum/reagent/arithrazine name = "Arithrazine" @@ -404,7 +404,7 @@ scannable = 1 /datum/reagent/arithrazine/affect_blood(var/mob/living/carbon/M, var/alien, var/removed) - M.radiation = max(M.radiation - 70 * removed, 0) + M.apply_radiation(-70 * removed) M.adjustToxLoss(-10 * removed) if(prob(60)) M.take_organ_damage(4 * removed, 0) diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Other.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Other.dm index 152d2f2a984..47e2047c768 100644 --- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Other.dm +++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Other.dm @@ -122,7 +122,7 @@ /datum/reagent/adminordrazine/affect_blood(var/mob/living/carbon/M, var/alien, var/removed) M.setCloneLoss(0) M.setOxyLoss(0) - M.radiation = 0 + M.total_radiation = 0 M.heal_organ_damage(5,5) M.adjustToxLoss(-5) M.hallucination = 0 diff --git a/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_heal.dm b/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_heal.dm index 5a6e8a46dbd..899694b1594 100644 --- a/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_heal.dm +++ b/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_heal.dm @@ -20,7 +20,7 @@ H.vessel.add_reagent("blood",5) H.nutrition += 50 * weakness H.adjustBrainLoss(-25 * weakness) - H.radiation -= min(H.radiation, 25 * weakness) + H.apply_radiation(-1*min(H.total_radiation, 25 * weakness)) H.bodytemperature = initial(H.bodytemperature) spawn(1) H.fixblood() diff --git a/code/modules/virus2/disease2.dm b/code/modules/virus2/disease2.dm index 81a57dd3008..456901893c4 100644 --- a/code/modules/virus2/disease2.dm +++ b/code/modules/virus2/disease2.dm @@ -75,7 +75,7 @@ cure(mob) return - if(mob.radiation > 50) + if(mob.total_radiation > 50) if(prob(1)) majormutate()