mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 16:10:02 +01:00
Refactors Glass Jars (#10703)
This commit is contained in:
@@ -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("<b>\The [user]</b> 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("<b>\The [user]</b> 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("<b>[user]</b> 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("<b>[user]</b> takes \the [A] out from \the [src]."), SPAN_NOTICE("You take \the [A] out from \the [src]."))
|
||||
else
|
||||
user.visible_message(SPAN_NOTICE("<b>[user]</b> 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("<b>[user]</b> 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("<b>[user]</b> 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("<b>[user]</b> 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("<b>[user]</b> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user