From f3ea0ab2236fcd4e93ed56e10636f54ecf785516 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 10 May 2014 20:37:15 -0400 Subject: [PATCH 1/2] Fixed accessories becoming improperly detached... when the host suit was clicked on. It is also now clearer who has the responsibility for attaching and removing accessories. --- code/modules/clothing/clothing.dm | 24 ++++++++++++++---------- code/modules/clothing/under/ties.dm | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 3b1108b55b..ae3dc94e8d 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -248,7 +248,6 @@ BLIND // can't see anything var/rolled_down = 0 var/basecolor - /obj/item/clothing/under/attackby(obj/item/I, mob/user) if(hastie) hastie.attackby(I, user) @@ -257,7 +256,7 @@ BLIND // can't see anything if(!hastie && istype(I, /obj/item/clothing/tie)) user.drop_item() hastie = I - hastie.attach_to(src, user) + hastie.on_attached(src, user) if(istype(loc, /mob/living/carbon/human)) var/mob/living/carbon/human/H = loc @@ -274,7 +273,7 @@ BLIND // can't see anything return ..() -//This is to allow people to take off suits when there is an attached accessory +//This is to ensure people can take off suits when there is an attached accessory /obj/item/clothing/under/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. @@ -352,6 +351,17 @@ BLIND // can't see anything else usr << "You cannot roll down the uniform!" +/obj/item/clothing/under/proc/remove_accessory(mob/user as mob) + if(!hastie) + return + + hastie.on_removed(user) + hastie = null + + if(istype(loc, /mob/living/carbon/human)) + var/mob/living/carbon/human/H = loc + H.update_inv_w_uniform() + /obj/item/clothing/under/verb/removetie() set name = "Remove Accessory" set category = "Object" @@ -359,13 +369,7 @@ BLIND // can't see anything if(!istype(usr, /mob/living)) return if(usr.stat) return - if(hastie) - hastie.remove(usr) - hastie = null - - if(istype(loc, /mob/living/carbon/human)) - var/mob/living/carbon/human/H = loc - H.update_inv_w_uniform() + src.remove_accessory(usr) /obj/item/clothing/under/rank/New() sensor_mode = pick(0,1,2,3) diff --git a/code/modules/clothing/under/ties.dm b/code/modules/clothing/under/ties.dm index 9f45d7a53d..aedd7839ce 100644 --- a/code/modules/clothing/under/ties.dm +++ b/code/modules/clothing/under/ties.dm @@ -11,7 +11,7 @@ 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) +/obj/item/clothing/tie/proc/on_attached(obj/item/clothing/under/S, mob/user as mob) if(!istype(S)) return has_suit = S @@ -19,13 +19,24 @@ user << "You attach [src] to [has_suit]." src.add_fingerprint(user) -/obj/item/clothing/tie/proc/remove(mob/user as mob) +/obj/item/clothing/tie/proc/on_removed(mob/user as mob) if(!has_suit) return has_suit = null usr.put_in_hands(src) src.add_fingerprint(user) +//default attackby behaviour +/obj/item/clothing/tie/attackby(obj/item/I, mob/user) + ..() + +//default attack_hand behaviour +/obj/item/clothing/tie/attack_hand(mob/user as mob) + if(has_suit) + has_suit.remove_accessory(user) + return //we aren't an object on the ground so don't call parent + ..() + /obj/item/clothing/tie/blue name = "blue tie" icon_state = "bluetie" @@ -244,11 +255,11 @@ else usr << "It is empty." -/obj/item/clothing/tie/holster/attach_to(obj/item/clothing/under/S, mob/user as mob) +/obj/item/clothing/tie/holster/on_attached(obj/item/clothing/under/S, mob/user as mob) ..() has_suit.verbs += /obj/item/clothing/tie/holster/verb/holster_verb -/obj/item/clothing/tie/holster/remove(mob/user as mob) +/obj/item/clothing/tie/holster/on_removed(mob/user as mob) has_suit.verbs -= /obj/item/clothing/tie/holster/verb/holster_verb ..() From 6e391c01c979814241a5031629ed548d7071d336 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 10 May 2014 22:30:09 -0400 Subject: [PATCH 2/2] Accessories are now visible when attached Uses overlays. I was originally planning to use the SOUTH direction of the icons/mob/ties.dmi image as the overlay, however this had problems with the fact that those images are directional. Rather than override Move() in clothing/under to reset dir to SOUTH whenever clothing with an attached accessory was thrown or dragged, I thought it would be less hacky to read the overlays from a separate .dmi. --- code/modules/clothing/under/ties.dm | 8 ++++++++ .../mob/living/carbon/human/update_icons.dm | 1 + icons/obj/clothing/ties_overlay.dmi | Bin 0 -> 3091 bytes 3 files changed, 9 insertions(+) create mode 100644 icons/obj/clothing/ties_overlay.dmi diff --git a/code/modules/clothing/under/ties.dm b/code/modules/clothing/under/ties.dm index aedd7839ce..a88cd5033c 100644 --- a/code/modules/clothing/under/ties.dm +++ b/code/modules/clothing/under/ties.dm @@ -9,6 +9,11 @@ slot_flags = 0 w_class = 2.0 var/obj/item/clothing/under/has_suit = null //the suit the tie may be attached to + var/image/inv_overlay = null //overlay used when attached to clothing. + +/obj/item/clothing/tie/New() + ..() + inv_overlay = image("icon" = 'icons/obj/clothing/ties_overlay.dmi', "icon_state" = "[item_color? "[item_color]" : "[icon_state]"]") //when user attached an accessory to S /obj/item/clothing/tie/proc/on_attached(obj/item/clothing/under/S, mob/user as mob) @@ -16,12 +21,15 @@ return has_suit = S loc = has_suit + has_suit.overlays += inv_overlay + user << "You attach [src] to [has_suit]." src.add_fingerprint(user) /obj/item/clothing/tie/proc/on_removed(mob/user as mob) if(!has_suit) return + has_suit.overlays -= inv_overlay has_suit = null usr.put_in_hands(src) src.add_fingerprint(user) diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index 2c4a381d6e..72232764d1 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -501,6 +501,7 @@ proc/get_damage_icon_part(damage_state, body_part) overlays_standing[UNIFORM_LAYER] = standing else overlays_standing[UNIFORM_LAYER] = null + // This really, really seems like it should not be mixed in the middle of display code... // Automatically drop anything in store / id / belt if you're not wearing a uniform. //CHECK IF NECESARRY for( var/obj/item/thing in list(r_store, l_store, wear_id, belt) ) // if(thing) // diff --git a/icons/obj/clothing/ties_overlay.dmi b/icons/obj/clothing/ties_overlay.dmi new file mode 100644 index 0000000000000000000000000000000000000000..6c6a65afc12f6c01d739ab7a62190c4fb19ad272 GIT binary patch literal 3091 zcmb_ec{J2*8~$07A`yAXQrb*}Y(useg%MdNg(w-uHny>pY$+{-qR76FZH8h78T(e2 ziNP4tP_OL9KDIG@(|P~;&i8(QeCK?B+|Tu#`?=0_?(^Kwxt{xlg}D(QuNW@?0DLCK zhE^o+NFi4Fv`Gta{~&8|L8hT5 zW5cE?sI|m~Xs&7A3qokk%h<8v<-}5Z?UnP$6;|*E0wGEj4*{ln#r7l z9)075aN;jAja2&b*t+BJ=(tZ6)mc5HEL5h~c-k+S%e6!Ht|tDx9jR8^U%NkR_U3 z3wFo8V%|X{Rtxq4CSZ&Cq5Te3&s7?i1(%Ok`3(1|6AC?fzeiy=<)%>8-Gdt)buo)C zbzAogq0%1`*1rd2Z!Ki6 zhe{F&TeZuKo$w|?4IzIgOh>?Es56yhqLoGArJI;>QZ&nb(L03k)@g=tdQRL6N+8}N|` zrt=p4_{E2txci{MJvuj%6+K1HQF?k@>`?^^%7BUHP<~lme|K3LlBCo0=fY?(ke~(a zn=|JHSNH(&6Js;#1!gk}4X#Kt_*T?Kq$nU5Z!Ikt&n7+ad;9+c?^d>p^24_9k~$pE&Gr_WEu3^-S;8?p zJo`mj_@|Y=nDK~CswDn%TN%)7pO$b0s@{2qsW4lbcN`2y8psXi1()p9xgKUV2}!c? zOKrkqj};U6?jHmw#l(u-XsPPY>9)){;BrhU=P=KDy@wm7DN)epE(}q(|5&QCiV?wI zT4E5o(#sI^wNFDJmF4pBB6af*NCJw0tZ%vUb5v1facY!@)EBn9JWnO7cdBU^@4D^r^^KMCyc?jc0Gd@YV6WZV+wE=pX9Z62$IhvHe!wrwc#~>+R-Q)N?fS*e(VbR;+>f}O z{HyC&{pwz8ko|c1JPghKL|uD?y!&z2ex~Ugd3UW=Kie4bGOv2xi`bv#L0hC{Ct93b!S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