From 0c9eb8a112ef003378c2d71abf712f2f34470207 Mon Sep 17 00:00:00 2001 From: Kelenius Date: Thu, 16 Apr 2015 17:30:01 +0300 Subject: [PATCH] Minor jar fixes --- code/game/objects/items/glassjar.dm | 111 +++++++++++++++------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/code/game/objects/items/glassjar.dm b/code/game/objects/items/glassjar.dm index de183dc345d..54062ff8530 100644 --- a/code/game/objects/items/glassjar.dm +++ b/code/game/objects/items/glassjar.dm @@ -5,6 +5,8 @@ icon_state = "jar" w_class = 2 matter = list("glass" = 200) + flags = NOBLUDGEON + var/list/accept_mobs = list(/mob/living/simple_animal/lizard, /mob/living/simple_animal/mouse) var/contains = 0 // 0 = nothing, 1 = money, 2 = animal, 3 = spiderling /obj/item/glass_jar/New() @@ -14,14 +16,21 @@ /obj/item/glass_jar/afterattack(var/atom/A, var/mob/user, var/proximity) if(!proximity || contains) return - if(istype(A, /mob/living/simple_animal/lizard) || istype(A, /mob/living/simple_animal/mouse)) - var/mob/living/simple_animal/L = A + if(istype(A, /mob)) + var/accept = 0 + for(var/D in accept_mobs) + if(istype(A, D)) + accept = 1 + if(!accept) + user << "[A] doesn't fit into \the [src]." + return + var/mob/L = A user.visible_message("[user] scoops [L] into \the [src].", "You scoop [L] into \the [src].") L.loc = src contains = 2 update_icon() return - if(istype(A, /obj/effect/spider/spiderling)) + else if(istype(A, /obj/effect/spider/spiderling)) var/obj/effect/spider/spiderling/S = A user.visible_message("[user] scoops [S] into \the [src].", "You scoop [S] into \the [src].") S.loc = src @@ -31,28 +40,29 @@ return /obj/item/glass_jar/attack_self(var/mob/user) - if(contains == 1) - for(var/obj/O in src) - O.loc = user.loc - user << "You take money out of \the [src]." - contains = 0 - update_icon() - return - if(contains == 2) - for(var/mob/M in src) - M.loc = user.loc - user.visible_message("[user] releases [M] from \the [src].", "You release [M] from \the [src].") - contains = 0 - update_icon() - return - if(contains == 3) - for(var/obj/effect/spider/spiderling/S in src) - S.loc = user.loc - user.visible_message("[user] releases [S] from \the [src].", "You release [S] from \the [src].") - processing_objects.Add(S) // They can grow after being let out though - contains = 0 - update_icon() - return + switch(contains) + if(1) + for(var/obj/O in src) + O.loc = user.loc + user << "You take money out of \the [src]." + contains = 0 + update_icon() + return + if(2) + for(var/mob/M in src) + M.loc = user.loc + user.visible_message("[user] releases [M] from \the [src].", "You release [M] from \the [src].") + contains = 0 + update_icon() + return + if(3) + for(var/obj/effect/spider/spiderling/S in src) + S.loc = user.loc + user.visible_message("[user] releases [S] from \the [src].", "You release [S] from \the [src].") + processing_objects.Add(S) // They can grow after being let out though + contains = 0 + update_icon() + return /obj/item/glass_jar/attackby(var/obj/item/W, var/mob/user) if(istype(W, /obj/item/weapon/spacecash)) @@ -69,29 +79,30 @@ /obj/item/glass_jar/update_icon() // Also updates name and desc underlays.Cut() overlays.Cut() - if(contains == 0) - name = initial(name) - desc = initial(desc) - else if(contains == 1) - name = "tip jar" - desc = "A small jar with money inside." - for(var/obj/item/weapon/spacecash/S in src) - var/image/money = image(S.icon, S.icon_state) - money.pixel_x = rand(-2, 3) - money.pixel_y = rand(-6, 6) - money.transform *= 0.6 - underlays += money - else if(contains == 2) - for(var/mob/M in src) - var/image/victim = image(M.icon, M.icon_state) - victim.pixel_y = 6 - underlays += victim - name = "glass jar with [M]" - desc = "A small jar with [M] inside." - else if(contains == 3) - for(var/obj/effect/spider/spiderling/S in src) - var/image/victim = image(S.icon, S.icon_state) - underlays += victim - name = "glass jar with [S]" - desc = "A small jar with [S] inside." + switch(contains) + if(0) + name = initial(name) + desc = initial(desc) + if(1) + name = "tip jar" + desc = "A small jar with money inside." + for(var/obj/item/weapon/spacecash/S in src) + var/image/money = image(S.icon, S.icon_state) + money.pixel_x = rand(-2, 3) + money.pixel_y = rand(-6, 6) + money.transform *= 0.6 + underlays += money + if(2) + for(var/mob/M in src) + var/image/victim = image(M.icon, M.icon_state) + victim.pixel_y = 6 + underlays += victim + name = "glass jar with [M]" + desc = "A small jar with [M] inside." + if(3) + for(var/obj/effect/spider/spiderling/S in src) + var/image/victim = image(S.icon, S.icon_state) + underlays += victim + name = "glass jar with [S]" + desc = "A small jar with [S] inside." return \ No newline at end of file