Skip to content

Commit

Permalink
Replacing species mod getters with damage modifier list/getter.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Oct 9, 2023
1 parent 91e70d6 commit 184489f
Show file tree
Hide file tree
Showing 32 changed files with 101 additions and 106 deletions.
2 changes: 1 addition & 1 deletion code/_helpers/medical_scans.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
scan["burn"] = H.get_damage(/decl/damage_handler/burn)
scan["toxin"] = H.get_damage(/decl/damage_handler/organ)
scan["oxygen"] = H.get_damage(/decl/damage_handler/suffocation)
scan["radiation"] = H.radiation
scan["radiation"] = H.get_damage(/decl/damage_handler/radiation)
scan["genetic"] = H.get_damage(/decl/damage_handler/genetic)
scan["paralysis"] = GET_STATUS(H, STAT_PARA)
scan["immune_system"] = H.get_immunity()
Expand Down
10 changes: 6 additions & 4 deletions code/datums/damage/damage_radiation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
name = "radiation"
category_type = /decl/damage_handler/radiation


/decl/damage_handler/radiation/apply_damage_to_mob(var/mob/living/target, var/damage, var/def_zone, var/damage_flags = 0, var/used_weapon, var/silent = FALSE)
target.apply_radiation(target)
return TRUE
. = ..()
if(. && iscarbon(target) && !target.isSynthetic())
var/mob/living/carbon/target_carbon = target
if(!target_carbon.ignore_rads)
target.take_damage(0.25 * damage * target.get_damage_modifier(category_type), /decl/damage_handler/burn)

/decl/damage_handler/radiation/get_armor_key(var/damage_flags)
return ARMOR_RAD
return ARMOR_RAD
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/scanners/health.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
dat += "Body temperature: [H.bodytemperature-T0C]°C ([H.bodytemperature*1.8-459.67]°F)"

// Radiation.
switch(H.radiation)
switch(H.get_damage(/decl/damage_handler/radiation))
if(-INFINITY to 0)
dat += "No radiation detected."
if(1 to 30)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/integrated_electronics/subtypes/input.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
set_pin_data(IC_OUTPUT, 8, H.get_pulse_as_number())
set_pin_data(IC_OUTPUT, 9, H.get_blood_oxygenation())
set_pin_data(IC_OUTPUT, 10, damage_to_severity(H.get_shock()))
set_pin_data(IC_OUTPUT, 11, H.radiation)
set_pin_data(IC_OUTPUT, 11, H.get_damage(/decl/damage_handler/radiation))

push_data()
activate_pin(2)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/materials/_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ INITIALIZE_IMMEDIATE(/obj/effect/gas_overlay)
M.add_chemical_effect(CE_TOXIN, toxicity)
var/dam = (toxicity * removed)
if(toxicity_targets_organ && ishuman(M))
var/organ_damage = dam * M.get_toxin_resistance()
var/organ_damage = dam * M.get_damage_modifier(/decl/damage_handler/organ)
if(organ_damage > 0)
var/mob/living/carbon/human/H = M
var/obj/item/organ/internal/I = GET_INTERNAL_ORGAN(H, toxicity_targets_organ)
Expand Down
7 changes: 4 additions & 3 deletions code/modules/mob/living/carbon/alien/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

/mob/living/carbon/alien/handle_mutations_and_radiation()
..()
if(radiation)
var/rads = radiation/25
radiation -= rads
var/rads = get_damage(/decl/damage_handler/radiation)
if(rads)
rads /= 25
adjust_nutrition(rads)
heal_damage(rads, /decl/damage_handler/radiation)
heal_damage(rads, /decl/damage_handler/brute)
heal_damage(rads, /decl/damage_handler/burn)
heal_damage(rads, /decl/damage_handler/suffocation)
Expand Down
11 changes: 6 additions & 5 deletions code/modules/mob/living/carbon/brain/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@

/mob/living/carbon/brain/handle_mutations_and_radiation()
..()
var/radiation = get_damage(/decl/damage_handler/radiation)
if (radiation)
if (radiation > 100)
radiation = 100
set_damage(100, /decl/damage_handler/radiation)
if(!container)//If it's not in an MMI
to_chat(src, "<span class='notice'>You feel weak.</span>")
else//Fluff-wise, since the brain can't detect anything itself, the MMI handles thing like that
to_chat(src, "<span class='warning'>STATUS: CRITICAL AMOUNTS OF RADIATION DETECTED.</span>")
switch(radiation)
if(1 to 49)
radiation--
heal_damage(1, /decl/damage_handler/radiation)
if(prob(25))
take_damage(1, /decl/damage_handler/organ)
updatehealth()

if(50 to 74)
radiation -= 2
heal_damage(2, /decl/damage_handler/radiation)
take_damage(1, /decl/damage_handler/organ)
if(prob(5))
radiation -= 5
heal_damage(5, /decl/damage_handler/radiation)
if(!container)
to_chat(src, "<span class='warning'>You feel weak.</span>")
else
to_chat(src, "<span class='warning'>STATUS: DANGEROUS LEVELS OF RADIATION DETECTED.</span>")
updatehealth()

if(75 to 100)
radiation -= 3
heal_damage(3, /decl/damage_handler/radiation)
take_damage(3, /decl/damage_handler/organ)


Expand Down
13 changes: 0 additions & 13 deletions code/modules/mob/living/carbon/damage_procs.dm

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
var/heal = amount < 0
amount = abs(amount)
if(!heal)
amount *= target.get_toxin_resistance()
amount *= target.get_damage_modifier(/decl/damage_handler/organ)
var/antitox = GET_CHEMICAL_EFFECT(target, CE_ANTITOX)
if(antitox)
amount *= 1 - antitox * 0.25
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@
vomit_score += I.damage
else if (should_have_organ(tag))
vomit_score += 45
if(has_chemical_effect(CE_TOXIN, 1) || radiation)
if(has_chemical_effect(CE_TOXIN, 1) || get_damage(/decl/damage_handler/radiation))
vomit_score += 0.5 * get_damage(/decl/damage_handler/organ)
if(has_chemical_effect(CE_ALCOHOL_TOXIC, 1))
vomit_score += 10 * GET_CHEMICAL_EFFECT(src, CE_ALCOHOL_TOXIC)
Expand Down
13 changes: 6 additions & 7 deletions code/modules/mob/living/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
/mob/living/proc/handle_mutations_and_radiation()
SHOULD_CALL_PARENT(TRUE)

radiation = clamp(radiation,0,500)
var/radiation = clamp(get_damage(/decl/damage_handler/radiation), 0, 500)
var/decl/species/my_species = get_species()
var/decl/bodytype/my_bodytype = get_bodytype()
if(my_species && my_bodytype && (my_bodytype.appearance_flags & RADIATION_GLOWS))
Expand All @@ -97,16 +97,16 @@
return

var/damage = 0
radiation -= 1 * RADIATION_SPEED_COEFFICIENT
heal_damage(1 * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/radiation)
if(prob(25))
damage = 2

if (radiation > 50)
damage = 2
radiation -= 2 * RADIATION_SPEED_COEFFICIENT
heal_damage(2 * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/radiation)
if(!isSynthetic())
if(prob(5) && prob(100 * RADIATION_SPEED_COEFFICIENT))
radiation -= 5 * RADIATION_SPEED_COEFFICIENT
heal_damage(5 * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/radiation)
to_chat(src, "<span class='warning'>You feel weak.</span>")
SET_STATUS_MAX(src, STAT_WEAK, 3)
if(!lying)
Expand All @@ -116,7 +116,7 @@

if (radiation > 75)
damage = 3
radiation -= 3 * RADIATION_SPEED_COEFFICIENT
heal_damage(3 * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/radiation)
if(!isSynthetic())
if(prob(5))
take_damage(5 * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/burn, used_weapon = "Radiation Burns")
Expand All @@ -126,9 +126,8 @@
emote("gasp")
if(radiation > 150)
damage = 8
radiation -= 4 * RADIATION_SPEED_COEFFICIENT
heal_damage(4 * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/radiation)

damage = FLOOR(damage * (my_species ? my_species.get_radiation_mod(src) : 1))
if(damage)
take_damage(damage * RADIATION_SPEED_COEFFICIENT, /decl/damage_handler/organ)
immunity = max(0, immunity - damage * 15 * RADIATION_SPEED_COEFFICIENT)
Expand Down
7 changes: 2 additions & 5 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,14 @@ default behaviour is:
clear_damage(/decl/damage_handler/organ)
clear_damage(/decl/damage_handler/suffocation)
clear_damage(/decl/damage_handler/genetic)
clear_damage(/decl/damage_handler/radiation)

set_brain_damage(0)
set_status(STAT_PARA, 0)
set_status(STAT_STUN, 0)
set_status(STAT_WEAK, 0)

// shut down ongoing problems
radiation = 0
bodytemperature = get_species()?.body_temperature || initial(bodytemperature)
sdisabilities = 0
disabilities = 0
Expand Down Expand Up @@ -1050,10 +1051,6 @@ default behaviour is:
/mob/living/proc/apply_fall_damage(var/turf/landing)
take_damage(rand(max(1, CEILING(mob_size * 0.33)), max(1, CEILING(mob_size * 0.66))), /decl/damage_handler/brute)

/mob/living/proc/get_toxin_resistance()
var/decl/species/species = get_species()
return isnull(species) ? 1 : species.toxins_mod

/mob/living/proc/get_metabolizing_reagent_holders(var/include_contact = FALSE)
for(var/datum/reagents/adding in list(reagents, get_ingested_reagents(), get_inhaled_reagents()))
LAZYDISTINCTADD(., adding)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/living_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
return FALSE

/mob/living/proc/get_damage_modifier(var/damage_type)
return 1
var/decl/species/my_species = get_species()
return my_species ? my_species.get_damage_modifier(src, damage_type) : 1

// Special procs; not handled by damage system above.
// Primarily used by humans.
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
apply_effect(agony_amount/10, STUTTER)
apply_effect(agony_amount/10, EYE_BLUR)

/mob/living/proc/apply_radiation(var/damage)
radiation = max(0, radiation + damage)

/mob/living/proc/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, def_zone = null)
return 0 //only carbon liveforms have this proc

Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@
var/list/mutations = list() // TODO: Lazylist this var.
//see: setup.dm for list of mutations

var/radiation = 0.0//Carbon

var/voice_name = "unidentifiable voice"

var/faction = MOB_FACTION_NEUTRAL //Used for checking whether hostile simple animals will attack you, possibly more stuff later
Expand Down
4 changes: 2 additions & 2 deletions code/modules/organs/external/_external_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
if(A)
B = A.brute_mult
if(!BP_IS_PROSTHETIC(src))
B *= species.get_brute_mod(owner)
B *= species.get_damage_modifier(owner, /decl/damage_handler/brute)
var/blunt = !(damage_flags & DAM_EDGE|DAM_SHARP)
if(blunt && BP_IS_BRITTLE(src))
B *= 1.5
Expand All @@ -345,7 +345,7 @@
if(A)
B = A.burn_mult
if(!BP_IS_PROSTHETIC(src))
B *= species.get_burn_mod(owner)
B *= species.get_damage_modifier(owner, /decl/damage_handler/burn)
if(BP_IS_CRYSTAL(src))
B *= 0.1
return B
Expand Down
2 changes: 1 addition & 1 deletion code/modules/organs/internal/_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
if(!damage_threshold_count || !damage_threshold_value || BP_IS_PROSTHETIC(src))
return FALSE
// Our owner is under stress.
if(owner.get_blood_oxygenation() < BLOOD_VOLUME_SAFE || GET_CHEMICAL_EFFECT(owner, CE_TOXIN) || owner.radiation || owner.is_asystole())
if(owner.get_blood_oxygenation() < BLOOD_VOLUME_SAFE || GET_CHEMICAL_EFFECT(owner, CE_TOXIN) || owner.get_damage(/decl/damage_handler/radiation) || owner.is_asystole())
return FALSE
// If we haven't hit the regeneration cutoff point, heal.
if(min_regeneration_cutoff_threshold && !past_damage_threshold(min_regeneration_cutoff_threshold))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chems/chems_medicines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
uid = "chem_antirads"

/decl/material/liquid/antirads/affect_blood(var/mob/living/M, var/removed, var/datum/reagents/holder)
M.radiation = max(M.radiation - 30 * removed, 0)
M.heal_damage(30 * removed, /decl/damage_handler/radiation)

/decl/material/liquid/brute_meds
name = "styptic powder"
Expand Down
13 changes: 13 additions & 0 deletions code/modules/species/outsider/random.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,24 @@

//Combat stats
MULT_BY_RANDOM_COEF(total_health, 0.8, 1.2)

var/brute_mod = 1
MULT_BY_RANDOM_COEF(brute_mod, 0.5, 1.5)
var/burn_mod = 1
MULT_BY_RANDOM_COEF(burn_mod, 0.8, 1.2)
var/oxy_mod = 1
MULT_BY_RANDOM_COEF(oxy_mod, 0.5, 1.5)
var/toxins_mod = 1
MULT_BY_RANDOM_COEF(toxins_mod, 0, 2)
var/radiation_mod = 1
MULT_BY_RANDOM_COEF(radiation_mod, 0, 2)
damage_modifiers = list(
/decl/damage_handler/burn = burn_mod,
/decl/damage_handler/brute = brute_mod,
/decl/damage_handler/organ = toxins_mod,
/decl/damage_handler/radiation = radiation_mod,
/decl/damage_handler/suffocation = oxy_mod
)

if(brute_mod < 1 && prob(40))
species_flags |= SPECIES_FLAG_NO_MINOR_CUT
Expand Down
12 changes: 7 additions & 5 deletions code/modules/species/outsider/starlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@
hunger_factor = 0
breath_type = null

burn_mod = 10
brute_mod = 0
oxy_mod = 0
toxins_mod = 0
radiation_mod = 0
damage_modifiers = list(
/decl/damage_handler/burn = 10,
/decl/damage_handler/brute = 0,
/decl/damage_handler/organ = 0,
/decl/damage_handler/radiation = 0,
/decl/damage_handler/suffocation = 0
)
species_flags = SPECIES_FLAG_NO_MINOR_CUT | SPECIES_FLAG_NO_SLIP | SPECIES_FLAG_NO_POISON | SPECIES_FLAG_NO_EMBED | SPECIES_FLAG_NO_TANGLE

/decl/species/starlight/blueforged/handle_death(var/mob/living/carbon/human/H)
Expand Down
20 changes: 10 additions & 10 deletions code/modules/species/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,11 @@ var/global/const/DEFAULT_SPECIES_HEALTH = 200
)

var/list/natural_armour_values // Armour values used if naked.
var/brute_mod = 1 // Physical damage multiplier.
var/burn_mod = 1 // Burn damage multiplier.
var/toxins_mod = 1 // Toxloss modifier
var/radiation_mod = 1 // Radiation modifier

var/oxy_mod = 1 // Oxyloss modifier
var/list/damage_modifiers // Various damage multipliers. Defaults to 1.
var/metabolism_mod = 1 // Reagent metabolism modifier
var/stun_mod = 1 // Stun period modifier.
var/paralysis_mod = 1 // Paralysis period modifier.
var/weaken_mod = 1 // Weaken period modifier.

var/vision_flags = SEE_SELF // Same flags as glasses.

// Death vars.
Expand Down Expand Up @@ -262,9 +256,9 @@ var/global/const/DEFAULT_SPECIES_HEALTH = 200
codex_traits += "<li>Has a plantlike physiology.</li>"

var/list/codex_damage_types = list(
"physical trauma" = brute_mod,
"burns" = burn_mod,
"lack of air" = oxy_mod,
"physical trauma" = get_damage_modifier(null, /decl/damage_handler/brute),
"burns" = get_damage_modifier(null, /decl/damage_handler/burn),
"lack of air" = get_damage_modifier(null, /decl/damage_handler/suffocation),
)
for(var/kind in codex_damage_types)
if(codex_damage_types[kind] > 1)
Expand Down Expand Up @@ -844,3 +838,9 @@ var/global/const/DEFAULT_SPECIES_HEALTH = 200
return heat_level_3
else
CRASH("get_species_temperature_threshold() called with invalid threshold value.")

/decl/species/proc/get_damage_modifier(var/mob/living/owner, var/damage_type)
if(damage_type in damage_modifiers)
. = damage_modifiers[damage_type]
if(owner?.isSynthetic() && damage_type == /decl/damage_handler/radiation)
. *= 0.5
9 changes: 0 additions & 9 deletions code/modules/species/species_getters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@
/decl/species/proc/get_footstep(var/mob/living/carbon/human/H, var/footstep_type)
return

/decl/species/proc/get_brute_mod(var/mob/living/carbon/human/H)
. = brute_mod

/decl/species/proc/get_burn_mod(var/mob/living/carbon/human/H)
. = burn_mod

/decl/species/proc/get_radiation_mod(var/mob/living/carbon/human/H)
. = (H && H.isSynthetic() ? 0.5 : radiation_mod)

/decl/species/proc/get_root_species_name(var/mob/living/carbon/human/H)
return name

Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/targeted/targeted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Targeted spells have two useful flags: INCLUDEUSER and SELECTABLE. These are exp
affecting.heal_damage(dam, dam, robo_repair = BP_IS_PROSTHETIC(affecting))
H.adjust_blood(amt_blood)
H.adjust_brain_damage(amt_brain)
H.radiation += min(H.radiation, amt_radiation)
H.take_damage(amt_radiation, /decl/damage_handler/radiation)

target.update_icon()
//disabling
Expand Down
Loading

0 comments on commit 184489f

Please sign in to comment.