From 2dde7e42d610fcfb243c34c64413e167a247212d Mon Sep 17 00:00:00 2001 From: Krausus Date: Mon, 4 May 2015 04:59:04 -0400 Subject: [PATCH] Fixes can code copy-pasta and minor drink bugs This fixes IPCs being able to drink from cans, being able to pour things into closed cans, and the IPC force-feeding-drink failure message going to the wrong person --- .../reagents/reagent_containers/food/cans.dm | 121 ++---------------- .../reagent_containers/food/drinks.dm | 9 +- 2 files changed, 22 insertions(+), 108 deletions(-) diff --git a/code/modules/reagents/reagent_containers/food/cans.dm b/code/modules/reagents/reagent_containers/food/cans.dm index cc265f9b1fe..04e0be6f9d4 100644 --- a/code/modules/reagents/reagent_containers/food/cans.dm +++ b/code/modules/reagents/reagent_containers/food/cans.dm @@ -1,11 +1,16 @@ /obj/item/weapon/reagent_containers/food/drinks/cans var canopened = 0 + New() + ..() + flags ^= OPENCONTAINER + attack_self(mob/user as mob) if (canopened == 0) playsound(src.loc,'sound/effects/canopen.ogg', rand(10,50), 1) user << "You open the drink with an audible pop!" canopened = 1 + flags |= OPENCONTAINER else return @@ -13,117 +18,19 @@ if (canopened == 0) user << "You need to open the drink!" return - var/datum/reagents/R = src.reagents - var/fillevel = gulp_size - - if(!R.total_volume || !R) - user << "\red None of [src] left, oh no!" - return 0 - - if(M == user) - M << "\blue You swallow a gulp of [src]." - if(reagents.total_volume) - reagents.trans_to_ingest(M, gulp_size) - reagents.reaction(M, INGEST) - spawn(5) - reagents.trans_to(M, gulp_size) - - playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1) - return 1 - else if( istype(M, /mob/living/carbon/human) ) - if (canopened == 0) - user << "You need to open the drink!" - return - - else if (canopened == 1) - for(var/mob/O in viewers(world.view, user)) - O.show_message("\red [user] attempts to feed [M] [src].", 1) - if(!do_mob(user, M)) return - for(var/mob/O in viewers(world.view, user)) - O.show_message("\red [user] feeds [M] [src].", 1) - - M.attack_log += text("\[[time_stamp()]\] Has been fed [src.name] by [user.name] ([user.ckey]) Reagents: [reagentlist(src)]") - user.attack_log += text("\[[time_stamp()]\] Fed [M.name] by [M.name] ([M.ckey]) Reagents: [reagentlist(src)]") - msg_admin_attack("[key_name(user)][isAntag(user) ? "(ANTAG)" : ""] fed [key_name(M)] with [src.name] Reagents: [reagentlist(src)] (INTENT: [uppertext(user.a_intent)]) (JMP)") - - if(reagents.total_volume) - reagents.trans_to_ingest(M, gulp_size) - - if(isrobot(user)) //Cyborg modules that include drinks automatically refill themselves, but drain the borg's cell - var/mob/living/silicon/robot/bro = user - bro.cell.use(30) - var/refill = R.get_master_reagent_id() - spawn(600) - R.add_reagent(refill, fillevel) - - playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1) - return 1 - - return 0 + return ..(M, user, def_zone) afterattack(obj/target, mob/user, proximity) if(!proximity) return - - if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us. - if (canopened == 0) - user << "You need to open the drink!" - return - - if(!target.reagents.total_volume) - user << "\red [target] is empty." - return - - if(reagents.total_volume >= reagents.maximum_volume) - user << "\red [src] is full." - return - - var/trans = target.reagents.trans_to(src, target:amount_per_transfer_from_this) - user << "\blue You fill [src] with [trans] units of the contents of [target]." - - - else if(target.is_open_container()) //Something like a glass. Player probably wants to transfer TO it. - if (canopened == 0) - user << "You need to open the drink!" - return - - if (istype(target, /obj/item/weapon/reagent_containers/food/drinks/cans)) - var/obj/item/weapon/reagent_containers/food/drinks/cans/cantarget = target - if(cantarget.canopened == 0) - user << "You need to open the drink you want to pour into!" - return - - if(!reagents.total_volume) - user << "\red [src] is empty." - return - - if(target.reagents.total_volume >= target.reagents.maximum_volume) - user << "\red [target] is full." - return - - - - var/datum/reagent/refill - var/datum/reagent/refillName - if(isrobot(user)) - refill = reagents.get_master_reagent_id() - refillName = reagents.get_master_reagent_name() - - var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this) - user << "\blue You transfer [trans] units of the solution to [target]." - - if(isrobot(user)) //Cyborg modules that include drinks automatically refill themselves, but drain the borg's cell - var/mob/living/silicon/robot/bro = user - var/chargeAmount = max(30,4*trans) - bro.cell.use(chargeAmount) - user << "Now synthesizing [trans] units of [refillName]..." - - - spawn(300) - reagents.add_reagent(refill, trans) - user << "Cyborg [src] refilled." - - return + if(istype(target, /obj/structure/reagent_dispensers) && (canopened == 0)) + user << "You need to open the drink!" + return + else if(target.is_open_container() && (canopened == 0)) + user << "You need to open the drink!" + return + else + return ..(target, user, proximity) /* examine() set src in view() diff --git a/code/modules/reagents/reagent_containers/food/drinks.dm b/code/modules/reagents/reagent_containers/food/drinks.dm index b2e6c9d7970..8034ef5a956 100644 --- a/code/modules/reagents/reagent_containers/food/drinks.dm +++ b/code/modules/reagents/reagent_containers/food/drinks.dm @@ -46,7 +46,7 @@ var/mob/living/carbon/human/H = M if(H.species.flags & IS_SYNTHETIC) - H << "\red They have a monitor for a head, where do you think you're going to put that?" + user << "\red They have a monitor for a head, where do you think you're going to put that?" return for(var/mob/O in viewers(world.view, user)) @@ -84,6 +84,13 @@ afterattack(obj/target, mob/user, proximity) if(!proximity) return + // Moved from the can code; not necessary since closed cans aren't open containers now, but, eh. + if (istype(target, /obj/item/weapon/reagent_containers/food/drinks/cans)) + var/obj/item/weapon/reagent_containers/food/drinks/cans/cantarget = target + if(cantarget.canopened == 0) + user << "You need to open the drink you want to pour into!" + return + if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us. if(!target.reagents.total_volume)