From 59cb87efd4e49dbdadad0567395e5529743a862c Mon Sep 17 00:00:00 2001 From: Geeves Date: Wed, 21 Jul 2021 14:08:01 +0200 Subject: [PATCH] Buddy Tag Options (#12143) --- code/__defines/_macros.dm | 1 + .../preference_setup/loadout/gear_tweaks.dm | 31 ++++++++++++++++++- .../loadout/loadout_utility.dm | 6 +++- .../clothing/under/accessories/buddy_tag.dm | 27 ++++++++++++---- html/changelogs/geeves-buddytag_options.yml | 6 ++++ 5 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 html/changelogs/geeves-buddytag_options.yml diff --git a/code/__defines/_macros.dm b/code/__defines/_macros.dm index de8863444b0..d0da4aef0f8 100644 --- a/code/__defines/_macros.dm +++ b/code/__defines/_macros.dm @@ -1,5 +1,6 @@ #define Clamp(x, low, high) max(low, min(high, x)) #define CLAMP01(x) (Clamp(x, 0, 1)) +#define JOINTEXT(X) jointext(X, null) #define span(class, text) "[text]" #define SPAN_NOTICE(X) "[X]" diff --git a/code/modules/client/preference_setup/loadout/gear_tweaks.dm b/code/modules/client/preference_setup/loadout/gear_tweaks.dm index dc554967b83..a37fc24954c 100644 --- a/code/modules/client/preference_setup/loadout/gear_tweaks.dm +++ b/code/modules/client/preference_setup/loadout/gear_tweaks.dm @@ -262,4 +262,33 @@ Paper Data /datum/gear_tweak/paper_data/tweak_item(var/obj/item/paper/P, var/metadata, var/mob/living/carbon/human/H) if(!metadata || !istype(P)) return - P.info = P.parsepencode(metadata) \ No newline at end of file + P.info = P.parsepencode(metadata) + + + +// Buddy Tag Settings +/datum/gear_tweak/buddy_tag_config/get_contents(var/metadata) + return "ID: [metadata[1]] | Distance: [metadata[2]] | Interval: [metadata[3]]s" + +/datum/gear_tweak/buddy_tag_config/get_default() + return list(1, 10, 30) + +/datum/gear_tweak/buddy_tag_config/get_metadata(var/user, var/metadata) + var/newcode = input("Set new buddy ID number.", "Buddy Tag ID", metadata[1]) as num|null + if(isnull(newcode)) + newcode = metadata[1] + var/newdist = input("Set new maximum range.", "Buddy Tag Range", metadata[2]) as num|null + if(isnull(newdist)) + newdist = metadata[2] + var/newtime = input("Set new search interval in seconds (minimum 30s).", "Buddy Tag Time Interval", metadata[3]) as num|null + if(isnull(newtime)) + newtime = metadata[3] + newtime = max(30, newtime) + return list(newcode, newdist, newtime) + +/datum/gear_tweak/buddy_tag_config/tweak_item(var/obj/item/clothing/accessory/buddytag/BT, var/list/metadata, var/mob/living/carbon/human/H) + if(!length(metadata) || !istype(BT)) + return + BT.id = metadata[1] + BT.distance = metadata[2] + BT.search_interval = metadata[3] SECONDS \ No newline at end of file diff --git a/code/modules/client/preference_setup/loadout/loadout_utility.dm b/code/modules/client/preference_setup/loadout/loadout_utility.dm index 74d760d4ee1..f51b3121f7f 100644 --- a/code/modules/client/preference_setup/loadout/loadout_utility.dm +++ b/code/modules/client/preference_setup/loadout/loadout_utility.dm @@ -138,4 +138,8 @@ /datum/gear/utility/buddy_tag display_name = "buddy tag" path = /obj/item/clothing/accessory/buddytag - cost = 2 \ No newline at end of file + cost = 2 + +/datum/gear/utility/buddy_tag/New() + ..() + gear_tweaks += new /datum/gear_tweak/buddy_tag_config() \ No newline at end of file diff --git a/code/modules/clothing/under/accessories/buddy_tag.dm b/code/modules/clothing/under/accessories/buddy_tag.dm index d9aff1ec34c..3c0d41512ad 100644 --- a/code/modules/clothing/under/accessories/buddy_tag.dm +++ b/code/modules/clothing/under/accessories/buddy_tag.dm @@ -11,6 +11,8 @@ var/list/active_buddy_tags = list() var/next_search = 0 var/on = FALSE var/id = 1 + var/distance = 10 + var/search_interval = 30 SECONDS /obj/item/clothing/accessory/buddytag/Initialize() . = ..() @@ -23,11 +25,13 @@ var/list/active_buddy_tags = list() if(use_check_and_message(user)) return - var/dat = "[on ? "Disable" : "Enable"]
" - dat += "ID: [id]" + var/list/dat = "[on ? "Disable" : "Enable"]" + dat += "
ID: [id]" + dat += "
Search Interval: [search_interval/10] seconds" + dat += "
Search Distance: [distance]" var/datum/browser/popup = new(user, "buddytag", "Buddy Tag", 290, 200) - popup.set_content(dat) + popup.set_content(JOINTEXT(dat)) popup.open() /obj/item/clothing/accessory/buddytag/Topic(href, href_list, state) @@ -44,10 +48,21 @@ var/list/active_buddy_tags = list() active_buddy_tags -= src update_icon() if(href_list["setcode"]) - var/newcode = input("Set new buddy ID number." , "Buddy Tag ID" , "") as num|null + var/newcode = input("Set new buddy ID number.", "Buddy Tag ID", id) as num|null if(isnull(newcode) || !CanInteract(usr, state)) return id = newcode + if(href_list["set_distance"]) + var/newdist = input("Set new maximum range.", "Buddy Tag Range", distance) as num|null + if(isnull(newdist) || !CanInteract(usr, state)) + return + distance = newdist + if(href_list["set_interval"]) + var/newtime = input("Set new search interval in seconds (minimum 30s).", "Buddy Tag Time Interval", search_interval / 10) as num|null + if(isnull(newtime) || !CanInteract(usr, state)) + return + newtime = max(30, newtime) + search_interval = newtime SECONDS attack_self(usr) /obj/item/clothing/accessory/buddytag/process() @@ -55,14 +70,14 @@ var/list/active_buddy_tags = list() return PROCESS_KILL if(world.time < next_search) return - next_search = world.time + 30 SECONDS + next_search = world.time + search_interval 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) + if(get_dist(get_turf(src), get_turf(buddy)) <= distance) has_friend = TRUE break if(!has_friend) diff --git a/html/changelogs/geeves-buddytag_options.yml b/html/changelogs/geeves-buddytag_options.yml new file mode 100644 index 00000000000..35217f5cfcb --- /dev/null +++ b/html/changelogs/geeves-buddytag_options.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "Added additional configuration options to buddy tags. You can also set their configs in the loadout menu now, where it will persist." \ No newline at end of file