Drinks can now carry diseases, Wipe down your glasses with rags bartenders! (#52421)

* Drinks can now infect you, Wipe down your glasses with rags bartenders!

* Apply suggestions from code review

Co-authored-by: Rohesie <rohesie@gmail.com>

* Update code/datums/components/infective.dm

Co-authored-by: Rohesie <rohesie@gmail.com>

* Update code/datums/components/infective.dm

Co-authored-by: Rohesie <rohesie@gmail.com>

Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
Couls
2020-07-29 21:08:10 -03:00
committed by GitHub
co-authored by Rohesie
parent b3fd17ab69
commit 27838579e3
4 changed files with 41 additions and 2 deletions
+6
View File
@@ -627,6 +627,12 @@
///from base of obj/item/reagent_containers/food/snacks/attack(): (mob/living/eater, mob/feeder)
#define COMSIG_FOOD_EATEN "food_eaten"
//Drink
///from base of obj/item/reagent_containers/food/drinks/attack(): (mob/living/M, mob/user)
#define COMSIG_DRINK_DRANK "drink_drank"
///from base of obj/item/reagent_containers/glass/attack(): (mob/M, mob/user)
#define COMSIG_GLASS_DRANK "glass_drank"
//Gibs
///from base of /obj/effect/decal/cleanable/blood/gibs/streak(): (list/directions, list/diseases)
+11 -1
View File
@@ -1,5 +1,4 @@
/datum/component/infective
dupe_mode = COMPONENT_DUPE_ALLOWED
var/list/datum/disease/diseases //make sure these are the static, non-processing versions!
var/expire_time
var/required_clean_types = CLEAN_TYPE_DISEASE
@@ -26,6 +25,10 @@
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/try_infect_equipped)
if(istype(parent, /obj/item/reagent_containers/food/snacks))
RegisterSignal(parent, COMSIG_FOOD_EATEN, .proc/try_infect_eat)
else if(istype(parent, /obj/item/reagent_containers/food/drinks))
RegisterSignal(parent, COMSIG_DRINK_DRANK, .proc/try_infect_drink)
else if(istype(parent, /obj/item/reagent_containers/glass))
RegisterSignal(parent, COMSIG_GLASS_DRANK, .proc/try_infect_drink)
else if(istype(parent, /obj/effect/decal/cleanable/blood/gibs))
RegisterSignal(parent, COMSIG_GIBS_STREAK, .proc/try_infect_streak)
@@ -34,6 +37,13 @@
eater.ForceContractDisease(V)
try_infect(feeder, BODY_ZONE_L_ARM)
/datum/component/infective/proc/try_infect_drink(datum/source, mob/living/drinker, mob/living/feeder)
for(var/disease in diseases)
drinker.ForceContractDisease(disease)
var/appendage_zone = feeder.held_items.Find(source)
appendage_zone = appendage_zone == 0 ? BODY_ZONE_CHEST : appendage_zone % 2 ? BODY_ZONE_R_ARM : BODY_ZONE_L_ARM
try_infect(feeder, appendage_zone)
/datum/component/infective/proc/clean(datum/source, clean_types)
if(clean_types & required_clean_types)
qdel(src)
+12 -1
View File
@@ -44,12 +44,23 @@
M.visible_message("<span class='danger'>[user] fed [M] the contents of [src].</span>", \
"<span class='userdanger'>[user] fed you the contents of [src].</span>")
log_combat(user, M, "fed", reagents.log_list())
SEND_SIGNAL(src, COMSIG_DRINK_DRANK, M, user)
var/fraction = min(gulp_size/reagents.total_volume, 1)
checkLiked(fraction, M)
reagents.expose(M, INGEST, fraction)
reagents.trans_to(M, gulp_size, transfered_by = user)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), TRUE)
if(iscarbon(M))
var/mob/living/carbon/carbon_drinker = M
var/list/diseases = carbon_drinker.get_static_viruses()
if(LAZYLEN(diseases))
var/list/datum/disease/diseases_to_add = list()
for(var/d in diseases)
var/datum/disease/malady = d
if(malady.spread_flags & DISEASE_SPREAD_CONTACT_FLUIDS)
diseases_to_add += malady
if(LAZYLEN(diseases_to_add))
AddComponent(/datum/component/infective, diseases_to_add)
return TRUE
/*
@@ -48,8 +48,20 @@
log_combat(user, M, "fed", reagents.log_list())
else
to_chat(user, "<span class='notice'>You swallow a gulp of [src].</span>")
SEND_SIGNAL(src, COMSIG_GLASS_DRANK, M, user)
addtimer(CALLBACK(reagents, /datum/reagents.proc/trans_to, M, 5, TRUE, TRUE, FALSE, user, FALSE, INGEST), 5)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), TRUE)
if(iscarbon(M))
var/mob/living/carbon/carbon_drinker = M
var/list/diseases = carbon_drinker.get_static_viruses()
if(LAZYLEN(diseases))
var/list/datum/disease/diseases_to_add = list()
for(var/d in diseases)
var/datum/disease/malady = d
if(malady.spread_flags & DISEASE_SPREAD_CONTACT_FLUIDS)
diseases_to_add += malady
if(LAZYLEN(diseases_to_add))
AddComponent(/datum/component/infective, diseases_to_add)
/obj/item/reagent_containers/glass/afterattack(obj/target, mob/user, proximity)
. = ..()