From 5e74a9803c4e4242f4a796eaae8aea1328c3dc5d Mon Sep 17 00:00:00 2001 From: GauHelldragon Date: Tue, 27 Nov 2012 15:16:59 -0800 Subject: [PATCH] Modified Service Bot's Tray to actually be useful Service Borg's tray now can load and unload items. --- .../mob/living/silicon/robot/robot_items.dm | 79 +++++++++++++++++++ .../mob/living/silicon/robot/robot_modules.dm | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 code/modules/mob/living/silicon/robot/robot_items.dm diff --git a/code/modules/mob/living/silicon/robot/robot_items.dm b/code/modules/mob/living/silicon/robot/robot_items.dm new file mode 100644 index 00000000000..5d121d909e4 --- /dev/null +++ b/code/modules/mob/living/silicon/robot/robot_items.dm @@ -0,0 +1,79 @@ +// A special tray for the service droid. Allow droid to pick up and drop items as if they were using the tray normally +// Click on table to unload, click on item to load. Otherwise works identically to a tray. + +/obj/item/weapon/tray/robotray + name = "RoboTray" + desc = "An autoloading tray specilized made for carrying refreshments." + +/obj/item/weapon/tray/robotray/afterattack(atom/target, mob/user as mob) + if ( !target ) + return + if ( istype(target,/obj/item)) //pick up items, mostly copied from base tray pickup + if ( !isturf(target.loc) ) // Don't load up stuff if it's inside a container or mob! + return + var turf/pickup = target.loc + + var addedSomething = 0 + + for(var/obj/item/I in pickup) + if( I != src && !I.anchored && !istype(I, /obj/item/clothing/under) && !istype(I, /obj/item/clothing/suit) && !istype(I, /obj/item/projectile) ) + var/add = 0 + if(I.w_class == 1.0) + add = 1 + else if(I.w_class == 2.0) + add = 3 + else + add = 5 + if(calc_carry() + add >= max_carry) + break + + I.loc = src + carrying.Add(I) + overlays += image("icon" = I.icon, "icon_state" = I.icon_state, "layer" = 30 + I.layer) + addedSomething = 1 + if ( addedSomething ) + user.visible_message("\blue [user] load some items onto their service tray.") + + return + + + if ( isturf(target) || istype(target,/obj/structure/table) ) // Unload the tray! + var foundtable = istype(target,/obj/structure/table/) + if ( !foundtable ) //it must be a turf! + for(var/obj/structure/table/T in target) + foundtable = 1 + break + + var turf/dropspot + if ( !foundtable ) // don't unload things onto walls or other silly places. + dropspot = user.loc + else if ( isturf(target) ) // they clicked on a turf with a table in it + dropspot = target + else // they clicked on a table + dropspot = target.loc + + + overlays = null + + var droppedSomething = 0 + + for(var/obj/item/I in carrying) + I.loc = dropspot + carrying.Remove(I) + droppedSomething = 1 + if(!foundtable && isturf(dropspot)) + // if no table, presume that the person just shittily dropped the tray on the ground and made a mess everywhere! + spawn() + for(var/i = 1, i <= rand(1,2), i++) + if(I) + step(I, pick(NORTH,SOUTH,EAST,WEST)) + sleep(rand(2,4)) + if ( droppedSomething ) + if ( foundtable ) + user.visible_message("\blue [user] unloads their service tray.") + else + user.visible_message("\blue [user] drops all the items on their tray.") + + return ..() + + diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index 2817ab49579..40ccc5a96dd 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -182,7 +182,7 @@ L.lit = 1 src.modules += L - src.modules += new /obj/item/weapon/tray(src) + src.modules += new /obj/item/weapon/tray/robotray(src) src.modules += new /obj/item/weapon/reagent_containers/food/drinks/shaker(src) src.emag = new /obj/item/weapon/reagent_containers/food/drinks/beer(src)