From 386ed871260dff6f15cac6e62ea9b4af13e1d5f9 Mon Sep 17 00:00:00 2001 From: VampyrBytes Date: Sat, 20 Feb 2016 12:01:40 +0000 Subject: [PATCH] refactors washing items fixes #3570 Could have fixed with another if statement in sink/attackby, but it was already pretty snowflakey, and had the potential to get worse Items now have a wash proc that the sink calls, that can be overridden when needed --- code/game/objects/items.dm | 11 +++++ code/game/objects/items/weapons/mop.dm | 6 +++ code/game/objects/items/weapons/stunbaton.dm | 15 ++++++ code/game/objects/structures/watercloset.dm | 46 ++----------------- code/modules/reagents/reagent_containers.dm | 9 +++- .../reagent_containers/food/snacks.dm | 7 +++ 6 files changed, 52 insertions(+), 42 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 1ccb002abb9..365e587e634 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -512,3 +512,14 @@ return 1 return 0 + +/obj/item/proc/wash(mob/user, atom/source) + if(flags & ABSTRACT) //Abstract items like grabs won't wash. No-drop items will though because it's still technically an item in your hand. + return + user << "You start washing [src]..." + if(!do_after(user, 40, target = source)) + return + clean_blood() + user.visible_message("[user] washes [src] using [source].", \ + "You wash [src] using [source].") + return 1 \ No newline at end of file diff --git a/code/game/objects/items/weapons/mop.dm b/code/game/objects/items/weapons/mop.dm index 05a367fc075..521c75f63fd 100644 --- a/code/game/objects/items/weapons/mop.dm +++ b/code/game/objects/items/weapons/mop.dm @@ -65,6 +65,12 @@ J.mymop=src J.update_icon() +/obj/item/weapon/mop/wash(mob/user, atom/source) + reagents.add_reagent("water", 5) + user << "You wet [src] in [source]." + playsound(loc, 'sound/effects/slosh.ogg', 25, 1) + return 1 + /obj/item/weapon/mop/advanced desc = "The most advanced tool in a custodian's arsenal. Just think of all the viscera you will clean up with this!" name = "advanced mop" diff --git a/code/game/objects/items/weapons/stunbaton.dm b/code/game/objects/items/weapons/stunbaton.dm index 0c5df41adb0..04c15fe1d97 100644 --- a/code/game/objects/items/weapons/stunbaton.dm +++ b/code/game/objects/items/weapons/stunbaton.dm @@ -163,6 +163,21 @@ bcell.reliability -= 10 / severity ..() +/obj/item/weapon/melee/baton/wash(mob/user, atom/source) + if(bcell) + if(bcell.charge > 0 && status == 1) + flick("baton_active", source) + user.Stun(stunforce) + user.Weaken(stunforce) + user.stuttering = stunforce + deductcharge(hitcost) + user.visible_message("[user] shocks themself while attempting to wash the active [src]!", \ + "You unwisely attempt to wash [src] while it's still on.") + playsound(src, "sparks", 50, 1) + return 1 + ..() + + //secborg stun baton module /obj/item/weapon/melee/baton/loaded/robot hitcost = 1000 diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index ef25216b560..cc73a42f0d0 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -424,51 +424,15 @@ user << "Someone's already washing here!" return - if(istype(O, /obj/item/weapon/reagent_containers)) - var/obj/item/weapon/reagent_containers/RG = O - if(RG.is_open_container()) - RG.reagents.add_reagent("water", min(RG.volume - RG.reagents.total_volume, RG.amount_per_transfer_from_this)) - user << "You fill [RG] from [src]." - return - - O.water_act(20,310.15,src) - - if(istype(O, /obj/item/weapon/melee/baton)) - var/obj/item/weapon/melee/baton/B = O - if(B.bcell) - if(B.bcell.charge > 0 && B.status == 1) - flick("baton_active", src) - var/stunforce = B.stunforce - user.Stun(stunforce) - user.Weaken(stunforce) - user.stuttering = stunforce - B.deductcharge(B.hitcost) - user.visible_message("[user] shocks themself while attempting to wash the active [B.name]!", \ - "You unwisely attempt to wash [B] while it's still on.") - playsound(src, "sparks", 50, 1) - return - - if(istype(O, /obj/item/weapon/mop)) - O.reagents.add_reagent("water", 5) - user << "You wet [O] in [src]." - playsound(loc, 'sound/effects/slosh.ogg', 25, 1) - - var/obj/item/I = O - if(!I || !istype(I)) - return - if(I.flags & ABSTRACT) //Abstract items like grabs won't wash. No-drop items will though because it's still technically an item in your hand. + if(!(istype(O))) return - user << "You start washing [I]..." busy = 1 - if(!do_after(user, 40, target = src)) - busy = 0 - return + var/wateract = 0 + wateract = (O.wash(user, src)) busy = 0 - O.clean_blood() - user.visible_message("[user] washes [I] using [src].", \ - "You wash [I] using [src].") - + if (wateract) + O.water_act(20,310.15,src) /obj/structure/sink/kitchen name = "kitchen sink" diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index e80b3574106..9aca545cf22 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -71,4 +71,11 @@ for (var/datum/reagent/R in snack.reagents.reagent_list) //no reagents will be left behind data += "[R.id]([R.volume] units); " //Using IDs because SOME chemicals(I'm looking at you, chlorhydrate-beer) have the same names as other chemicals. return data - else return "No reagents" \ No newline at end of file + else return "No reagents" + +/obj/item/weapon/reagent_containers/wash(mob/user, atom/source) + if(is_open_container()) + reagents.add_reagent("water", min(volume - reagents.total_volume, amount_per_transfer_from_this)) + user << "You fill [src] from [source]." + return + ..() \ No newline at end of file diff --git a/code/modules/reagents/reagent_containers/food/snacks.dm b/code/modules/reagents/reagent_containers/food/snacks.dm index aa5f7723316..0b47df7c1c8 100644 --- a/code/modules/reagents/reagent_containers/food/snacks.dm +++ b/code/modules/reagents/reagent_containers/food/snacks.dm @@ -1674,6 +1674,13 @@ if(volume >= 5) return Expand() +/obj/item/weapon/reagent_containers/food/snacks/monkeycube/wash(mob/user, atom/source) + if(wrapped) + ..() + return + if(do_after(user, 40, target = source)) + return 1 + /obj/item/weapon/reagent_containers/food/snacks/monkeycube/proc/Expand() if(isnull(gcDestroyed)) visible_message("[src] expands!")