Googly Eyes (#11951)

This commit is contained in:
Geeves
2021-05-28 21:59:30 +02:00
committed by GitHub
parent b4262ab848
commit e0170928f1
13 changed files with 130 additions and 5 deletions
+88
View File
@@ -0,0 +1,88 @@
/obj/item/sticker
name = "sticker"
desc = "It's a sticker."
icon = 'icons/obj/sticker.dmi'
icon_state = "sticker"
flags = NOBLUDGEON
w_class = ITEMSIZE_TINY
vis_flags = VIS_INHERIT_LAYER | VIS_INHERIT_DIR
var/datum/weakref/attached
var/list/rand_icons
/obj/item/sticker/Initialize()
. = ..()
if(LAZYLEN(rand_icons))
icon_state = pick(rand_icons)
/obj/item/sticker/attack_hand(mob/user)
if(!attached)
return ..()
if(user.a_intent == I_HELP)
remove_sticker(user)
return
var/atom/movable/attached_atom = attached.resolve()
if(attached_atom)
attached_atom.attack_hand(user) // don't allow people to make sticker armor
/obj/item/sticker/attack_ranged(mob/user)
if(!attached)
return
var/atom/movable/attached_atom = attached.resolve()
if(attached_atom && user.Adjacent(attached_atom))
attack_hand(user)
/obj/item/sticker/attackby(obj/item/I, mob/user)
if(!attached)
return ..()
var/atom/movable/attached_atom = attached.resolve()
if(attached_atom)
attached_atom.attackby(I, user) // don't allow people to make sticker armor
/obj/item/sticker/afterattack(atom/movable/target, mob/user, proximity_flag, click_parameters)
if(!proximity_flag)
return
if(!istype(target) || (ismob(target) && !isbot(target)))
return
if(!target.can_attach_sticker(user, src))
return
var/list/mouse_control = mouse_safe_xy(click_parameters)
pixel_x = mouse_control["icon-x"] - 16
pixel_y = mouse_control["icon-y"] - 16
attach_to(user, target)
/obj/item/sticker/proc/attach_to(var/mob/user, var/atom/movable/A)
to_chat(user, SPAN_NOTICE("You attach \the [src] to \the [A]."))
user.drop_from_inventory(src, A)
attached = WEAKREF(A)
A.vis_contents += src
A.verbs += /atom/movable/proc/take_off_sticker
/obj/item/sticker/proc/remove_sticker(var/mob/user)
user.put_in_hands(src)
var/atom/movable/attached_atom = attached.resolve()
if(attached_atom)
to_chat(user, SPAN_NOTICE("You remove \the [src] from \the [attached_atom]."))
attached_atom.vis_contents -= src
attached_atom.verbs -= /atom/movable/proc/take_off_sticker
attached = null
/obj/item/sticker/googly_eye
name = "googly eye"
desc = "A large googly eye sticker."
rand_icons = list("googly", "googly1", "googly2")
/atom/movable/proc/take_off_sticker()
set name = "Remove Sticker"
set src in view(1)
var/obj/item/sticker/S = locate() in src
if(S)
S.remove_sticker(usr)
@@ -902,3 +902,8 @@
var/obj/item/closet_teleporter/CT_2 = new /obj/item/closet_teleporter(src)
CT_1.linked_teleporter = CT_2
CT_2.linked_teleporter = CT_1
/obj/item/storage/box/googly
name = "googly eye box"
desc = "A box containing googly eyes."
starts_with = list(/obj/item/sticker/googly_eye = 8)
@@ -704,6 +704,9 @@
remove_from_storage(O, T)
O.tumble(2)
// putting a sticker on something puts it in its contents, storage items use their contents to store their items
/obj/item/storage/can_attach_sticker(var/mob/user, var/obj/item/sticker/S)
return FALSE
//Returns the storage depth of an atom. This is the number of storage items the atom is contained in before reaching toplevel (the area).
//Returns -1 if the atom was not found on container.
@@ -770,4 +773,4 @@
//return 2**(w_class-1) //1,2,4,8,16,...
#undef STORAGE_SPACE_CAP
#undef STORAGE_SPACE_CAP