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
This commit is contained in:
Krausus
2015-05-04 04:59:04 -04:00
parent 7b34faae40
commit 2dde7e42d6
2 changed files with 22 additions and 108 deletions
@@ -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 << "<span class='notice'>You open the drink with an audible pop!</span>"
canopened = 1
flags |= OPENCONTAINER
else
return
@@ -13,117 +18,19 @@
if (canopened == 0)
user << "<span class='notice'>You need to open the drink!</span>"
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 << "<span class='notice'>You need to open the drink!</span>"
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()]\] <font color='orange'>Has been fed [src.name] by [user.name] ([user.ckey]) Reagents: [reagentlist(src)]</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Fed [M.name] by [M.name] ([M.ckey]) Reagents: [reagentlist(src)]</font>")
msg_admin_attack("[key_name(user)][isAntag(user) ? "(ANTAG)" : ""] fed [key_name(M)] with [src.name] Reagents: [reagentlist(src)] (INTENT: [uppertext(user.a_intent)]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
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 << "<span class='notice'>You need to open the drink!</span>"
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 << "<span class='notice'>You need to open the drink!</span>"
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 << "<span class='notice'>You need to open the drink you want to pour into!</span>"
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 << "<span class='notice'>You need to open the drink!</span>"
return
else if(target.is_open_container() && (canopened == 0))
user << "<span class='notice'>You need to open the drink!</span>"
return
else
return ..(target, user, proximity)
/* examine()
set src in view()
@@ -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 << "<span class='notice'>You need to open the drink you want to pour into!</span>"
return
if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us.
if(!target.reagents.total_volume)