Created
August 28, 2016 13:23
-
-
Save BlueNexus/8c61f1456ba025477203af590afa1927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id | |
/proc/initialize_chemical_reagents() | |
var/paths = typesof(/datum/reagent) - /datum/reagent | |
chemical_reagents_list = list() | |
for(var/path in paths) | |
var/datum/reagent/D = new path() | |
if(!D.name) | |
continue | |
chemical_reagents_list[D.id] = D | |
/datum/reagent | |
var/name = "Reagent" | |
var/id = "reagent" | |
var/description = "A non-descript chemical." | |
var/taste_description = "old rotten bandaids" | |
var/taste_mult = 1 //how this taste compares to others. Higher values means it is more noticable | |
var/datum/reagents/holder = null | |
var/reagent_state = SOLID | |
var/list/data = null | |
var/volume = 0 | |
var/metabolism = REM // This would be 0.2 normally | |
var/ingest_met = 0 | |
var/touch_met = 0 | |
var/dose = 0 | |
var/max_dose = 0 | |
var/overdose = 0 | |
var/scannable = 0 // Shows up on health analyzers. | |
var/color = "#000000" | |
var/color_weight = 1 | |
var/flags = 0 | |
var/glass_icon = DRINK_ICON_DEFAULT | |
var/glass_name = "something" | |
var/glass_desc = "It's a glass of... what, exactly?" | |
var/list/glass_special = null // null equivalent to list() | |
/datum/reagent/proc/remove_self(var/amount) // Shortcut | |
holder.remove_reagent(id, amount) | |
// This doesn't apply to skin contact - this is for, e.g. extinguishers and sprays. The difference is that reagent is not directly on the mob's skin - it might just be on their clothing. | |
/datum/reagent/proc/touch_mob(var/mob/M, var/amount) | |
return | |
/datum/reagent/proc/touch_obj(var/obj/O, var/amount) // Acid melting, cleaner cleaning, etc | |
return | |
/datum/reagent/proc/touch_turf(var/turf/T, var/amount) // Cleaner cleaning, lube lubbing, etc, all go here | |
return | |
/datum/reagent/proc/on_mob_life(var/mob/living/carbon/M, var/alien, var/location) // Currently, on_mob_life is called on carbons. Any interaction with non-carbon mobs (lube) will need to be done in touch_mob. | |
if(!istype(M)) | |
return | |
if(!(flags & AFFECTS_DEAD) && M.stat == DEAD) | |
return | |
if(overdose && (location != CHEM_TOUCH)) | |
var/overdose_threshold = overdose * (flags & IGNORE_MOB_SIZE? 1 : MOB_MEDIUM/M.mob_size) | |
if(volume > overdose_threshold) | |
overdose(M, alien) | |
//determine the metabolism rate | |
var/removed = metabolism | |
if(ingest_met && (location == CHEM_INGEST)) | |
removed = ingest_met | |
if(touch_met && (location == CHEM_TOUCH)) | |
removed = touch_met | |
var/mob/living/carbon/human/H = M | |
if(istype(H)) | |
removed *= H.species.metabolism_mod | |
removed = min(removed, volume) | |
//adjust effective amounts - removed, dose, and max_dose - for mob size | |
var/effective = removed | |
max_dose = max(volume, max_dose) | |
if(!(flags & IGNORE_MOB_SIZE) && location != CHEM_TOUCH) | |
effective *= (MOB_MEDIUM/M.mob_size) | |
max_dose *= (MOB_MEDIUM/M.mob_size) | |
dose = min(dose + effective, max_dose) | |
if(effective >= (metabolism * 0.1) || effective >= 0.1) // If there's too little chemical, don't affect the mob, just remove it | |
switch(location) | |
if(CHEM_BLOOD) | |
affect_blood(M, alien, effective) | |
if(CHEM_INGEST) | |
affect_ingest(M, alien, effective) | |
if(CHEM_TOUCH) | |
affect_touch(M, alien, effective) | |
remove_self(removed) | |
return | |
/datum/reagent/proc/affect_blood(var/mob/living/carbon/M, var/alien, var/removed) | |
return | |
/datum/reagent/proc/affect_ingest(var/mob/living/carbon/M, var/alien, var/removed) | |
affect_blood(M, alien, removed * 0.5) | |
return | |
/datum/reagent/proc/affect_touch(var/mob/living/carbon/M, var/alien, var/removed) | |
return | |
/datum/reagent/proc/overdose(var/mob/living/carbon/M, var/alien) // Overdose effect. Doesn't happen instantly. | |
M.adjustToxLoss(REM) | |
return | |
/datum/reagent/proc/initialize_data(var/newdata) // Called when the reagent is created. | |
if(!isnull(newdata)) | |
data = newdata | |
return | |
/datum/reagent/proc/mix_data(var/newdata, var/newamount) // You have a reagent with data, and new reagent with its own data get added, how do you deal with that? | |
return | |
/datum/reagent/proc/get_data() // Just in case you have a reagent that handles data differently. | |
if(data && istype(data, /list)) | |
return data.Copy() | |
else if(data) | |
return data | |
return null | |
/datum/reagent/Destroy() // This should only be called by the holder, so it's already handled clearing its references | |
..() | |
holder = null | |
/* DEPRECATED - TODO: REMOVE EVERYWHERE */ | |
/datum/reagent/proc/reaction_turf(var/turf/target) | |
touch_turf(target) | |
/datum/reagent/proc/reaction_obj(var/obj/target) | |
touch_obj(target) | |
/datum/reagent/proc/reaction_mob(var/mob/target) | |
touch_mob(target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment