diff --git a/code/game/objects/items/glassjar.dm b/code/game/objects/items/glassjar.dm index 40edff07361..8db7ad4c609 100644 --- a/code/game/objects/items/glassjar.dm +++ b/code/game/objects/items/glassjar.dm @@ -3,6 +3,7 @@ #define JAR_ANIMAL 2 #define JAR_SPIDERLING 3 #define JAR_GUMBALL 4 +#define JAR_HOLDER 5 // All of these defines below are to assist with gumball-related mechanics except for the contain define @@ -12,15 +13,16 @@ /obj/item/glass_jar name = "glass jar" - desc = "A glass jar. You can remove the lid and use it as a reagent container." + desc = "A glass jar. Does not contain brain submerged in formaldehyde." + desc_info = "Can be used to hold money, small animals, and gumballs. You can remove the lid and use it as a reagent container." icon = 'icons/obj/drinks.dmi' icon_state = "jar_lid" w_class = ITEMSIZE_SMALL matter = list(MATERIAL_GLASS = 200) recyclable = TRUE flags = NOBLUDGEON - var/contains = JAR_NOTHING // 0 = nothing, 1 = money, 2 = animal, 3 = spiderling, 4 = gumballs - var/list/gumballs_contained = list() + var/contains = JAR_NOTHING // 0 = nothing, 1 = money, 2 = animal, 3 = spiderling, 4 = gumballs, 5 = holder + var/list/contained = list() drop_sound = 'sound/items/drop/glass.ogg' pickup_sound = 'sound/items/pickup/glass.ogg' @@ -28,78 +30,106 @@ ..() update_icon() -/obj/item/glass_jar/MouseDrop(atom/target) - if(ishuman(target) || issmall(target) && target == usr && use_check_and_message(usr) && Adjacent(usr)) - if(contains == JAR_GUMBALL) - handle_gumball_removal(usr) - /obj/item/glass_jar/afterattack(var/atom/A, var/mob/user, var/proximity) if(!proximity || contains) return if(istype(A, /obj/effect/spider/spiderling)) var/obj/effect/spider/spiderling/S = A - user.visible_message(SPAN_NOTICE("\The [user] scoops \the [S] into \the [src]."), SPAN_NOTICE("You scoop \the [S] into \the [src].")) - S.forceMove(src) STOP_PROCESSING(SSprocessing, S) // No growing inside jars contains = JAR_SPIDERLING - update_icon() - return + scoop(S, user) if(ismob(A)) var/mob/L = A if(L.mob_size <= MOB_TINY) - user.visible_message(SPAN_NOTICE("\The [user] scoops \the [L] into \the [src]."), SPAN_NOTICE("You scoop \the [L] into \the [src].")) - L.forceMove(src) contains = JAR_ANIMAL - update_icon() - return + scoop(L, user) else - to_chat(user, SPAN_WARNING("\The [L] doesn't fit into \the [src]!")) - return + scoop_fail(L, user) + +/obj/item/glass_jar/proc/scoop(var/atom/movable/A, var/mob/user) + user.visible_message(SPAN_NOTICE("[user] scoops \the [A] into \the [src]."), SPAN_NOTICE("You scoop \the [A] into \the [src].")) + playsound(src, pickup_sound, PICKUP_SOUND_VOLUME) + A.forceMove(src) + update_icon() + return + +/obj/item/glass_jar/proc/scoop_fail(var/atom/A, var/mob/user) + to_chat(user, SPAN_WARNING("\The [A] doesn't fit into \the [initial(name)]!")) + playsound(src, drop_sound, DROP_SOUND_VOLUME) + return /obj/item/glass_jar/attack_self(var/mob/user) switch(contains) - if(JAR_MONEY) - for(var/obj/O in src) - O.forceMove(user.loc) - to_chat(user, SPAN_NOTICE("You take money out of \the [src].")) - contains = JAR_NOTHING - update_icon() - return - if(JAR_ANIMAL) - for(var/mob/M in src) - M.forceMove(user.loc) - user.visible_message(SPAN_NOTICE("\The [user] releases \the [M] from \the [src]."), SPAN_NOTICE("You release \the [M] from \the [src].")) - contains = JAR_NOTHING - update_icon() - return - if(JAR_SPIDERLING) - for(var/obj/effect/spider/spiderling/S in src) - S.forceMove(user.loc) - user.visible_message(SPAN_NOTICE("\The [user] releases \the [S] from \the [src]."), SPAN_NOTICE("You release \the [S] from \the [src].")) - START_PROCESSING(SSprocessing, S) // They can grow after being let out though - contains = JAR_NOTHING - update_icon() - return if(JAR_NOTHING) to_chat(user, SPAN_NOTICE("You remove the lid from \the [src].")) user.drop_from_inventory(src) user.put_in_hands(new /obj/item/reagent_containers/glass/beaker/jar) //found in jar.dm qdel(src) return + if(JAR_MONEY) + for(var/obj/O in src) + user.put_in_hands(O) + release(O, user) + if(JAR_ANIMAL) + for(var/mob/M in src) + M.forceMove(user.loc) + release(M, user) + if(JAR_SPIDERLING) + for(var/obj/effect/spider/spiderling/S in src) + S.forceMove(user.loc) + START_PROCESSING(SSprocessing, S) // They can grow after being let out though + release(S, user) + if(JAR_GUMBALL) + if(length(contained)) + user.put_in_hands(contained[1]) + contained -= contained[1] + release(contained[1], user) + if(JAR_HOLDER) + for(var/obj/item/holder/H in src) + H.release_to_floor() // Snowflake code because holders are ass. Q.E.D. + release(H, user) + +/obj/item/glass_jar/proc/release(var/atom/movable/A, var/mob/user) + if(istype(A, /obj/item/spacecash) || istype(A, /obj/item/clothing/mask/chewable/candy/gum/gumball)) + user.visible_message(SPAN_NOTICE("[user] takes \the [A] out from \the [src]."), SPAN_NOTICE("You take \the [A] out from \the [src].")) + else + user.visible_message(SPAN_NOTICE("[user] releases \the [A] from \the [src]."), SPAN_NOTICE("You release \the [A] from \the [src].")) + if(length(contained) == 0) + contains = JAR_NOTHING + playsound(src, drop_sound, DROP_SOUND_VOLUME) + update_icon() + return /obj/item/glass_jar/attackby(var/atom/A, var/mob/user, var/proximity) if(istype(A, /obj/item/spacecash)) + var/obj/item/spacecash/S = A if(contains == JAR_NOTHING) contains = JAR_MONEY if(contains != JAR_MONEY) return - var/obj/item/spacecash/S = A - user.visible_message(SPAN_NOTICE("\The [user] puts [S.worth] [S.worth > 1 ? "credits" : "credit"] into \the [src].")) + user.visible_message(SPAN_NOTICE("[user] puts [S.worth] [S.worth > 1 ? "credits" : "credit"] into \the [src].")) user.drop_from_inventory(S,src) update_icon() - if(istype(A, /obj/item/clothing/mask/chewable/candy/gum/gumball)) - handle_gumball_addition(user, A) + var/obj/item/clothing/mask/chewable/candy/gum/gumball/G = A + if(length(contained) < GUMBALL_MAX) + contained += G + user.drop_from_inventory(G) + G.forceMove(src) + if(!contains) + contains = JAR_GUMBALL + user.visible_message("[user] puts a gumball in \the [src].", SPAN_NOTICE("You put a gumball in \the [src].")) + update_icon() + else + to_chat(user, SPAN_WARNING("\The [name] is full!")) + return + if(istype(A, /obj/item/holder)) + var/obj/item/holder/H = A + if(H.w_class <= ITEMSIZE_SMALL) + contains = JAR_HOLDER + scoop(H, user) + else + scoop_fail(H, user) /obj/item/glass_jar/update_icon() // Also updates name and desc underlays.Cut() @@ -128,7 +158,7 @@ victim.pixel_x = 0 victim.pixel_y = 6 underlays += victim - name = "glass jar with [M]" + name = "specimen jar" desc = "A small jar with [M] inside." if(JAR_SPIDERLING) for(var/obj/effect/spider/spiderling/S in src) @@ -140,52 +170,24 @@ name = "gumball jar" desc = "A jar containing gumballs with varying colours." var/image/gumballs_overlay = image(icon) - switch(length(gumballs_contained)) + switch(length(contained)) if(1 to GUMBALL_MIN) gumballs_overlay.icon_state = "gumball_min" if(6 to GUMBALL_MEDIUM) - gumballs_overlay.icon_state = "gumball_min" + gumballs_overlay.icon_state = "gumball_med" if(11 to GUMBALL_MAX) gumballs_overlay.icon_state = "gumball_max" underlays += gumballs_overlay - + if(JAR_HOLDER) + for(var/obj/item/holder/H in src) + var/image/holder = image(H.icon, H.icon_state) + holder.pixel_x = 0 + holder.pixel_y = 6 + underlays += holder + name = "specimen jar" + desc = "A small jar with [H] inside." return -/obj/item/glass_jar/proc/handle_gumball_addition(mob/user, var/obj/item/clothing/mask/chewable/candy/gum/gumball/G) // handles the entire gumbball addition process - if(length(gumballs_contained) < GUMBALL_MAX) - gumballs_contained += G - user.drop_from_inventory(G) - G.forceMove(src) - if(!contains) - contains = JAR_GUMBALL - user.visible_message("[user] puts a gumball in \the [src].", SPAN_NOTICE("You put a gumball in \the [src].")) - handle_gumball_underlays() - else - to_chat(user, SPAN_WARNING("\The [name] is full!")) - -/obj/item/glass_jar/proc/handle_gumball_removal(mob/user) // same as the addition proc but we're removing gum instead - if(length(gumballs_contained)) - user.put_in_hands(gumballs_contained[1]) - gumballs_contained -= gumballs_contained[1] - user.visible_message("[user] takes a gumball from \the [src].", SPAN_NOTICE("You take a gumball from \the [src].")) - if(length(gumballs_contained) == 0) - contains = JAR_NOTHING - handle_gumball_underlays() - -/obj/item/glass_jar/proc/handle_gumball_underlays() // gumball overlays - underlays.Cut() - if(length(gumballs_contained)) - var/image/gumballs_overlay = image(icon) - switch(length(gumballs_contained)) - if(1 to GUMBALL_MIN) - gumballs_overlay.icon_state = "gumball_min" - if(6 to GUMBALL_MEDIUM) - gumballs_overlay.icon_state = "gumball_medium" - if(11 to GUMBALL_MAX) - gumballs_overlay.icon_state = "gumball_max" - underlays += gumballs_overlay - - /obj/item/glass_jar/peter/ name = "Peter's Jar" @@ -206,7 +208,7 @@ ..() for(var/i = 1 to GUMBALL_MAX) var/obj/item/clothing/mask/chewable/candy/gum/gumball/G = new(src) - gumballs_contained += G + contained += G return INITIALIZE_HINT_LATELOAD @@ -216,13 +218,14 @@ /obj/item/glass_jar/gumball/medical/Initialize() for(var/i = 1 to GUMBALL_MAX) var/obj/item/clothing/mask/chewable/candy/gum/gumball/medical/G = new(src) - gumballs_contained += G + contained += G #undef JAR_NOTHING #undef JAR_MONEY #undef JAR_ANIMAL #undef JAR_SPIDERLING #undef JAR_GUMBALL +#undef JAR_HOLDER #undef GUMBALL_MAX #undef GUMBALL_MEDIUM diff --git a/code/game/objects/items/weapons/chewables.dm b/code/game/objects/items/weapons/chewables.dm index fa35b05607c..9f80c20aef4 100644 --- a/code/game/objects/items/weapons/chewables.dm +++ b/code/game/objects/items/weapons/chewables.dm @@ -78,7 +78,7 @@ obj/item/clothing/mask/chewable/Destroy() chew() if(chewtime < 1) spitout() - + /obj/item/clothing/mask/chewable/tobacco name = "wad" @@ -181,7 +181,7 @@ obj/item/clothing/mask/chewable/Destroy() update_icon() /obj/item/clothing/mask/chewable/candy/gum/gumball - name = "gumball" + name = "\improper gumball" desc = "A gumball, created and patented by Chip Getmore. Known to contain a hard shell and a reagent interior!" icon_state = "gumball" item_state = null diff --git a/code/modules/mob/holder.dm b/code/modules/mob/holder.dm index a41394f69b5..73edda9a5a7 100644 --- a/code/modules/mob/holder.dm +++ b/code/modules/mob/holder.dm @@ -401,8 +401,6 @@ var/list/holder_mob_icon_cache = list() name = "kitten" icon_state = "kitten" icon_state_dead = "cat_kitten_dead" - slot_flags = SLOT_HEAD - w_class = ITEMSIZE_TINY item_state = "kitten" /obj/item/holder/cat/penny @@ -410,8 +408,6 @@ var/list/holder_mob_icon_cache = list() desc = "An important cat, straight from Central Command." icon_state = "penny" icon_state_dead = "penny_dead" - slot_flags = SLOT_HEAD - w_class = ITEMSIZE_TINY item_state = "penny" /obj/item/holder/carp/baby diff --git a/code/modules/reagents/reagent_containers/food/drinks/jar.dm b/code/modules/reagents/reagent_containers/food/drinks/jar.dm index b7a6c186e92..fc305d68d94 100644 --- a/code/modules/reagents/reagent_containers/food/drinks/jar.dm +++ b/code/modules/reagents/reagent_containers/food/drinks/jar.dm @@ -19,6 +19,7 @@ return else to_chat(user, "You put the lid on \the [src].") + user.drop_from_inventory(src) user.put_in_hands(new /obj/item/glass_jar) //found in glassjar.dm qdel(src) return diff --git a/html/changelogs/wezzy-glassjar_refactor.yml b/html/changelogs/wezzy-glassjar_refactor.yml new file mode 100644 index 00000000000..f37bb99cf4a --- /dev/null +++ b/html/changelogs/wezzy-glassjar_refactor.yml @@ -0,0 +1,42 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: Wowzewow (Wezzy) + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - refactor: "Glass jars have been refactored." + - rscadd: "Glass jars can now pick up animals held in hand." diff --git a/icons/obj/drinks.dmi b/icons/obj/drinks.dmi index c20e31ffb98..c167f1b2bae 100644 Binary files a/icons/obj/drinks.dmi and b/icons/obj/drinks.dmi differ