Diet/Allergy Rework & Refactor Pt2 (#7940)

* Diet/Allergy Pt2

* couple more reaction types

* refactor and improve

* Update Chemistry-Reagents.dm
This commit is contained in:
Killian
2021-03-07 21:09:18 +00:00
committed by GitHub
parent 698d1035ab
commit 948d43afec
5 changed files with 43 additions and 26 deletions

View File

@@ -36,6 +36,16 @@
#define FUNGI 0x100 // Delicious shrooms.
#define COFFEE 0x200 // Mostly here for tajara.
#define GENERIC 0x400 // Catchall for stuff that doesn't fall into the groups above. You shouldn't be allergic to this type, ever.
#define SUGARS 0x800 // For unathi-like reactions
// Allergen reactions
#define AG_TOX_DMG 0x1 // the classic
#define AG_OXY_DMG 0x2 // intense airway reactions
#define AG_EMOTE 0x4 // general emote reactions based on affect type
#define AG_PAIN 0x8 // short-lived hurt
#define AG_WEAKEN 0x10 // too weak to move, oof
#define AG_BLURRY 0x20 // blurred vision!
#define AG_SLEEPY 0x40 // fatigue/exhaustion
// Species spawn flags
#define SPECIES_IS_WHITELISTED 0x1 // Must be whitelisted to play.

View File

@@ -51,9 +51,11 @@
var/hunger_factor = 0.05 // Multiplier for hunger.
var/active_regen_mult = 1 // Multiplier for 'Regenerate' power speed, in human_powers.dm
var/taste_sensitivity = TASTE_NORMAL // How sensitive the species is to minute tastes.
var/allergens = null // Things that will make this species very sick
var/allergen_severity = 0.5 // How bad are reactions to the allergen? This is raw toxin damage per metabolism tick, multiplied by the amount metabolized
var/taste_sensitivity = TASTE_NORMAL // How sensitive the species is to minute tastes.
var/allergens = null // Things that will make this species very sick
var/allergen_reaction = AG_TOX_DMG|AG_OXY_DMG|AG_EMOTE|AG_PAIN|AG_WEAKEN // What type of reactions will you have? These the 'main' options and are intended to approximate anaphylactic shock at high doses.
var/allergen_damage_severity = 1.2 // How bad are reactions to the allergen? Touch with extreme caution.
var/allergen_disable_severity = 3 // Whilst this determines how long nonlethal effects last and how common emotes are.
var/min_age = 17
var/max_age = 70

View File

@@ -25,6 +25,9 @@
var/affects_dead = 0 // Does this chem process inside a corpse?
var/affects_robots = 0 // Does this chem process inside a Synth?
var/allergen_type = GENERIC // What potential allergens does this contain?
var/allergen_factor = 1 // If the potential allergens are mixed and low-volume, they're a bit less dangerous. Needed for drinks because they're a single reagent compared to food which contains multiple seperate reagents.
var/cup_icon_state = null
var/cup_name = null
@@ -159,6 +162,26 @@
affect_touch(M, alien, removed)
if(overdose && (volume > overdose * M?.species.chemOD_threshold) && (active_metab.metabolism_class != CHEM_TOUCH && !can_overdose_touch))
overdose(M, alien, removed)
if(M.species.allergens & allergen_type) //uhoh, we can't handle this!
var/damage_severity = M.species.allergen_damage_severity*allergen_factor
var/disable_severity = M.species.allergen_disable_severity*allergen_factor
if(M.species.allergen_reaction & AG_TOX_DMG)
M.adjustToxLoss(damage_severity)
if(M.species.allergen_reaction & AG_OXY_DMG)
M.adjustOxyLoss(damage_severity)
if(prob(2.5*disable_severity))
M.emote(pick("cough","gasp","choke"))
if(M.species.allergen_reaction & AG_EMOTE)
if(prob(2.5*disable_severity)) //this has a higher base chance, but not *too* high
M.emote(pick("pale","shiver","twitch"))
if(M.species.allergen_reaction & AG_PAIN)
M.adjustHalLoss(disable_severity)
if(M.species.allergen_reaction & AG_WEAKEN)
M.Weaken(disable_severity)
if(M.species.allergen_reaction & AG_BLURRY)
M.eye_blurry = max(M.eye_blurry, disable_severity)
if(M.species.allergen_reaction & AG_SLEEPY)
M.drowsyness = max(M.drowsyness, disable_severity)
remove_self(removed)
return

View File

@@ -82,8 +82,6 @@
var/nutriment_factor = 0
var/strength = 10 // This is, essentially, units between stages - the lower, the stronger. Less fine tuning, more clarity.
var/allergen_type = GENERIC // What potential allergens does this contain?
var/allergen_factor = 0.5 // If the potential allergens are mixed and low-volume, they're a bit less dangerous. Needed for drinks because they're a single reagent compared to food which contains multiple seperate reagents.
var/toxicity = 1
var/druggy = 0
@@ -93,6 +91,7 @@
glass_name = "ethanol"
glass_desc = "A well-known alcohol with a variety of applications."
allergen_factor = 0.5 //simulates mixed drinks containing less of the allergen, as they have only a single actual reagent unlike food
/datum/reagent/ethanol/touch_mob(var/mob/living/L, var/amount)
if(istype(L))
@@ -141,13 +140,11 @@
if(halluci)
M.hallucination = max(M.hallucination, halluci*3)
if(M.species.allergens & allergen_type)
M.adjustToxLoss(((M.species.allergen_severity*allergen_factor)*4) * removed)
/datum/reagent/ethanol/affect_ingest(var/mob/living/carbon/M, var/alien, var/removed)
if(issmall(M)) removed *= 2
M.adjust_nutrition(nutriment_factor * removed)
if(!(M.species.allergens & allergen_type)) //assuming it doesn't cause a horrible reaction, we get the nutrition effects
M.adjust_nutrition(nutriment_factor * removed)
var/strength_mod = 1 * M.species.alcohol_mod
if(alien == IS_SKRELL)
strength_mod *= 5
@@ -188,9 +185,6 @@
if(halluci)
M.hallucination = max(M.hallucination, halluci)
if(M.species.allergens & allergen_type)
M.adjustToxLoss((M.species.allergen_severity*allergen_factor) * removed)
/datum/reagent/ethanol/touch_obj(var/obj/O)
if(istype(O, /obj/item/weapon/paper))

View File

@@ -9,7 +9,6 @@
metabolism = REM * 4
ingest_met = REM * 4
var/nutriment_factor = 30 // Per unit
var/allergen_type = GENERIC // What potential allergens does this contain?
var/injectable = 0
color = "#664330"
@@ -41,9 +40,6 @@
if(!injectable && alien != IS_SLIME)
M.adjustToxLoss(0.1 * removed)
return
if(M.species.allergens & allergen_type)
M.adjustToxLoss((M.species.allergen_severity*4) * removed)
return
affect_ingest(M, alien, removed)
..()
@@ -52,9 +48,7 @@
if(IS_DIONA) return
if(IS_UNATHI) removed *= 0.5
if(issmall(M)) removed *= 2 // Small bodymass, more effect from lower volume.
if(M.species.allergens & allergen_type) //uhoh, we can't digest this!
M.adjustToxLoss(M.species.allergen_severity * removed)
else //delicious
if(!(M.species.allergens & allergen_type)) //assuming it doesn't cause a horrible reaction, we'll be ok!
M.heal_organ_damage(0.5 * removed, 0)
M.adjust_nutrition(nutriment_factor * removed)
M.add_chemical_effect(CE_BLOODRESTORE, 4 * removed)
@@ -859,22 +853,16 @@
var/adj_sleepy = 0
var/adj_temp = 0
var/water_based = TRUE
var/allergen_type = GENERIC // What potential allergens does this contain?
var/allergen_factor = 1 // If the potential allergens are mixed and low-volume, they're a bit less dangerous. Needed for drinks because they're a single reagent compared to food which contains multiple seperate reagents.
/datum/reagent/drink/affect_blood(var/mob/living/carbon/M, var/alien, var/removed)
var/strength_mod = 1
if(alien == IS_SLIME && water_based)
strength_mod = 3
M.adjustToxLoss(removed * strength_mod) // Probably not a good idea; not very deadly though
if(M.species.allergens & allergen_type) // Unless you're allergic, in which case...
M.adjustToxLoss(((M.species.allergen_severity*allergen_factor)*2) * removed)
return
/datum/reagent/drink/affect_ingest(var/mob/living/carbon/M, var/alien, var/removed)
if(M.species.allergens & allergen_type)
M.adjustToxLoss((M.species.allergen_severity*allergen_factor) * removed)
else //delicious
if(!(M.species.allergens & allergen_type))
M.adjust_nutrition(nutrition * removed)
M.dizziness = max(0, M.dizziness + adj_dizzy)
M.drowsyness = max(0, M.drowsyness + adj_drowsy)