From ae49ba210b087bfe8abb7ae1e96908febcea45b5 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 29 Apr 2014 20:34:01 -0400 Subject: [PATCH] Webbings now use internal storage Clothing no longer manipulates webbing members for better encapsulation. Instead attackby() and attack_hand() are forwarded to accessories if they are present. Removed "Look in Storage" verb for less verb clutter. --- .../objects/items/weapons/storage/internal.dm | 1 - .../objects/items/weapons/storage/storage.dm | 9 +-- code/modules/clothing/clothing.dm | 64 ++++++++++--------- code/modules/clothing/under/ties.dm | 62 ++++++++++++++---- 4 files changed, 87 insertions(+), 49 deletions(-) diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index 59f2e7b2aa8..11058f0dc56 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -19,7 +19,6 @@ //Helper procs to cleanly implement internal storages - storage items that provide inventory slots for other items. //These procs are completely optional, it is up to the master item to decide when it's storage get's opened by calling open() //However they are helpful for allowing the master item to pretend it is a storage item itself. -//Mostly just copypasta'd from /obj/item/weapon/storage. Not sure how else to do it, other than moving all of this into storage.dm //If you are using these you will probably want to override attackby() as well. //See /obj/item/clothing/suit/storage for an example. diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index 7da16bc368c..4e669384ec8 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -317,17 +317,17 @@ if(isrobot(user)) user << "\blue You're a robot. No." - return 1 //Robots can't interact with storage items. + return //Robots can't interact with storage items. if(!can_be_inserted(W)) - return 0 + return if(istype(W, /obj/item/weapon/tray)) var/obj/item/weapon/tray/T = W if(T.calc_carry() > 0) if(prob(85)) user << "\red The tray won't fit in [src]." - return 1 + return else W.loc = user.loc if ((user.client && user.s_active != src)) @@ -335,8 +335,9 @@ W.dropped(user) user << "\red God damnit!" + W.add_fingerprint(user) handle_item_insertion(W) - return 1 + return /obj/item/weapon/storage/dropped(mob/user as mob) return diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 4b6e1f7de6b..649ba8e54eb 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -250,18 +250,18 @@ BLIND // can't see anything /obj/item/clothing/under/attackby(obj/item/I, mob/user) + if(hastie) + hastie.attackby(I, user) + return + if(!hastie && istype(I, /obj/item/clothing/tie)) user.drop_item() hastie = I - I.loc = src - user << "You attach [I] to [src]." + hastie.attach_to(src, user) if (istype(hastie,/obj/item/clothing/tie/holster)) verbs += /obj/item/clothing/under/proc/holster - if (istype(hastie,/obj/item/clothing/tie/storage)) - verbs += /obj/item/clothing/under/proc/storage - if(istype(loc, /mob/living/carbon/human)) var/mob/living/carbon/human/H = loc H.update_inv_w_uniform() @@ -269,6 +269,33 @@ BLIND // can't see anything return ..() + +/obj/item/clothing/under/attack_hand(mob/user as mob) + //only forward to the attached accessory if the clothing is equipped (not in a storage) + if(hastie && src.loc == user) + hastie.attack_hand(user) + return + + ..() + +//This is to allow people to take off suits when there is an attached accessory +/obj/item/weapon/storage/MouseDrop(obj/over_object as obj) + if (ishuman(usr) || ismonkey(usr)) + //makes sure that the clothing is equipped so that we can't drag it into our hand from miles away. + if (!(src.loc == usr)) + return + + if (!( usr.restrained() ) && !( usr.stat )) + switch(over_object.name) + if("r_hand") + usr.u_equip(src) + usr.put_in_r_hand(src) + if("l_hand") + usr.u_equip(src) + usr.put_in_l_hand(src) + src.add_fingerprint(usr) + return + return /obj/item/clothing/under/examine() set src in view() @@ -340,13 +367,7 @@ BLIND // can't see anything if (istype(hastie,/obj/item/clothing/tie/holster)) verbs -= /obj/item/clothing/under/proc/holster - if (istype(hastie,/obj/item/clothing/tie/storage)) - verbs -= /obj/item/clothing/under/proc/storage - var/obj/item/clothing/tie/storage/W = hastie - if (W.hold) - W.hold.close(usr) - - usr.put_in_hands(hastie) + hastie.remove(usr) hastie = null if(istype(loc, /mob/living/carbon/human)) @@ -393,22 +414,3 @@ BLIND // can't see anything "\blue You draw \the [H.holstered], pointing it at the ground.") usr.put_in_hands(H.holstered) H.holstered = null - -/obj/item/clothing/under/proc/storage() - set name = "Look in storage" - set category = "Object" - set src in usr - if(!istype(usr, /mob/living)) return - if(usr.stat) return - - if (!hastie || !istype(hastie,/obj/item/clothing/tie/storage)) - usr << "\red You need something to store items in for that!" - return - var/obj/item/clothing/tie/storage/W = hastie - - if (!istype(W.hold)) - return - - W.hold.open(usr) - - diff --git a/code/modules/clothing/under/ties.dm b/code/modules/clothing/under/ties.dm index 031ef5ebb65..666c1233288 100644 --- a/code/modules/clothing/under/ties.dm +++ b/code/modules/clothing/under/ties.dm @@ -8,6 +8,23 @@ flags = FPRINT | TABLEPASS slot_flags = 0 w_class = 2.0 + var/obj/item/clothing/under/has_suit = null //the suit the tie may be attached to + +//when user attached an accessory to S +/obj/item/clothing/tie/proc/attach_to(obj/item/clothing/under/S, mob/user as mob) + if(!istype(S)) + return + has_suit = S + loc = has_suit + user << "You attach [src] to [has_suit]." + src.add_fingerprint(user) + +/obj/item/clothing/tie/proc/remove(mob/user as mob) + if(!has_suit) + return + has_suit = null + usr.put_in_hands(src) + src.add_fingerprint(user) /obj/item/clothing/tie/blue name = "blue tie" @@ -116,7 +133,7 @@ //Armbands /obj/item/clothing/tie/armband name = "red armband" - desc = "An fancy red armband!" + desc = "A fancy red armband!" icon_state = "red" item_color = "red" @@ -177,17 +194,44 @@ /obj/item/clothing/tie/storage name = "load bearing equipment" - desc = "Used to hold things when you don't have enough hands for that." + desc = "Used to hold things when you don't have enough hands." icon_state = "webbing" item_color = "webbing" var/slots = 3 - var/obj/item/weapon/storage/pockets/hold + var/obj/item/weapon/storage/internal/hold /obj/item/clothing/tie/storage/New() - hold = new /obj/item/weapon/storage/pockets(src) - hold.master_item = src + ..() + hold = new/obj/item/weapon/storage/internal(src) hold.storage_slots = slots +/obj/item/clothing/tie/storage/attack_hand(mob/user as mob) + if (has_suit) //if we are part of a suit + hold.open(user) + return + + if (hold.handle_attack_hand(user)) //otherwise interact as a regular storage item + ..(user) + +/obj/item/clothing/tie/storage/MouseDrop(obj/over_object as obj) + if (has_suit) + return + + if (hold.handle_mousedrop(usr, over_object)) + ..(over_object) + +/obj/item/clothing/tie/storage/attackby(obj/item/W as obj, mob/user as mob) + ..() + hold.attackby(W, user) + +/obj/item/clothing/tie/storage/emp_act(severity) + hold.emp_act(severity) + ..() + +/obj/item/clothing/tie/storage/hear_talk(mob/M, var/msg) + hold.hear_talk(M, msg) + ..() + /obj/item/clothing/tie/storage/attack_self(mob/user as mob) user << "You empty [src]." var/turf/T = get_turf(src) @@ -196,14 +240,6 @@ hold.remove_from_storage(I, T) src.add_fingerprint(user) -/obj/item/clothing/tie/storage/attackby(obj/item/weapon/W as obj, mob/user as mob) - hold.attackby(W,user) - src.add_fingerprint(user) - -/obj/item/weapon/storage/pockets - name = "storage" - var/master_item //item it belongs to - /obj/item/clothing/tie/storage/webbing name = "webbing" desc = "Strudy mess of synthcotton belts and buckles, ready to share your burden."