Buddy Tags (#11752)

* Buddy Tag

* random ID
This commit is contained in:
Geeves
2021-04-30 02:08:37 +02:00
committed by GitHub
parent 068595e690
commit cb22e1855e
8 changed files with 90 additions and 3 deletions
+1
View File
@@ -1488,6 +1488,7 @@
#include "code\modules\clothing\under\accessories\armband.dm"
#include "code\modules\clothing\under\accessories\armor.dm"
#include "code\modules\clothing\under\accessories\badges.dm"
#include "code\modules\clothing\under\accessories\buddy_tag.dm"
#include "code\modules\clothing\under\accessories\holster.dm"
#include "code\modules\clothing\under\accessories\lockets.dm"
#include "code\modules\clothing\under\accessories\medal.dm"
+1
View File
@@ -1,5 +1,6 @@
#define ACCESSORY_SLOT_GENERIC "decor"
#define ACCESSORY_SLOT_UTILITY "utility"
#define ACCESSORY_SLOT_UTILITY_MINOR "minor utility"
#define ACCESSORY_SLOT_CAPE "cape"
#define ACCESSORY_SLOT_ARMBAND "armband"
#define ACCESSORY_SLOT_ARMOR_PLATE "armor plate"
+2
View File
@@ -441,6 +441,8 @@ Define for getting a bitfield of adjacent turfs that meet a condition.
#define GET_ABOVE(A) (HAS_ABOVE(A:z) ? get_step(A, UP) : null)
#define GET_BELOW(A) (HAS_BELOW(A:z) ? get_step(A, DOWN) : null)
#define GET_Z(A) (get_step(A, 0)?.z || 0)
#define NULL_OR_EQUAL(self,other) (!(self) || (self) == (other))
//Lying animation
@@ -127,4 +127,9 @@
pills["Neurostabin "] = /obj/item/storage/pill_bottle/neurostabin
pills["Orastabin"] = /obj/item/storage/pill_bottle/orastabin
pills["Parvosil"] = /obj/item/storage/pill_bottle/parvosil
gear_tweaks += new /datum/gear_tweak/path(pills)
gear_tweaks += new /datum/gear_tweak/path(pills)
/datum/gear/utility/buddy_tag
display_name = "buddy tag"
path = /obj/item/clothing/accessory/buddytag
cost = 2
+2 -2
View File
@@ -852,8 +852,8 @@
//convenience var for defining the icon state for the overlay used when the clothing is worn.
//Also used by rolling/unrolling.
var/worn_state = null
valid_accessory_slots = list(ACCESSORY_SLOT_UTILITY, ACCESSORY_SLOT_ARMBAND, ACCESSORY_SLOT_GENERIC, ACCESSORY_SLOT_CAPE)
restricted_accessory_slots = list(ACCESSORY_SLOT_UTILITY)
valid_accessory_slots = list(ACCESSORY_SLOT_UTILITY, ACCESSORY_SLOT_UTILITY_MINOR, ACCESSORY_SLOT_ARMBAND, ACCESSORY_SLOT_GENERIC, ACCESSORY_SLOT_CAPE)
restricted_accessory_slots = list(ACCESSORY_SLOT_UTILITY, ACCESSORY_SLOT_UTILITY_MINOR)
/obj/item/clothing/under/attack_hand(var/mob/user)
@@ -0,0 +1,72 @@
var/list/active_buddy_tags = list()
/obj/item/clothing/accessory/buddytag
name = "buddy tag"
desc = "A tiny device, paired up with a counterpart set to same code. When the paired devices are too far apart, they start beeping."
icon = 'icons/clothing/accessories/buddy_tag.dmi'
icon_state = "buddytag0"
item_state = "buddytag"
contained_sprite = TRUE
slot = ACCESSORY_SLOT_UTILITY_MINOR
var/next_search = 0
var/on = FALSE
var/id = 1
/obj/item/clothing/accessory/buddytag/Initialize()
. = ..()
id = round(rand(1, 1000))
/obj/item/clothing/accessory/buddytag/update_icon()
icon_state = "buddytag[on]"
/obj/item/clothing/accessory/buddytag/attack_self(mob/user)
if(use_check_and_message(user))
return
var/dat = "<A href='?src=\ref[src];toggle=1;'>[on ? "Disable" : "Enable"]</a><br>"
dat += "ID: <A href='?src=\ref[src];setcode=1;'>[id]</a>"
var/datum/browser/popup = new(user, "buddytag", "Buddy Tag", 290, 200)
popup.set_content(dat)
popup.open()
/obj/item/clothing/accessory/buddytag/Topic(href, href_list, state)
if(..())
return
if(href_list["toggle"])
on = !on
if(on)
next_search = world.time
active_buddy_tags += src
START_PROCESSING(SSprocessing, src)
else
active_buddy_tags -= src
update_icon()
if(href_list["setcode"])
var/newcode = input("Set new buddy ID number." , "Buddy Tag ID" , "") as num|null
if(isnull(newcode) || !CanInteract(usr, state))
return
id = newcode
attack_self(usr)
/obj/item/clothing/accessory/buddytag/process()
if(!on)
return PROCESS_KILL
if(world.time < next_search)
return
next_search = world.time + 30 SECONDS
var/has_friend
for(var/obj/item/clothing/accessory/buddytag/buddy as anything in active_buddy_tags - src)
if(buddy.id != id)
continue
if(GET_Z(buddy) != GET_Z(src))
continue
if(get_dist(get_turf(src), get_turf(buddy)) <= 10)
has_friend = TRUE
break
if(!has_friend)
playsound(src, 'sound/machines/twobeep.ogg', 10)
var/turf/T = get_turf(src)
if(T)
T.visible_message(SPAN_WARNING("[src] beeps anxiously."), range = 3)
+6
View File
@@ -0,0 +1,6 @@
author: Geeves
delete-after: True
changes:
- rscadd: "Added buddy tags to the utility loadout. They're small devices that can be attached to uniforms that will beep if they don't have a paired buddy in range."
Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B