From fda350cd1e8e6ee1e0451c70c5b0abca6f90a7a0 Mon Sep 17 00:00:00 2001 From: Toastical Date: Tue, 21 Jan 2025 19:18:43 +0200 Subject: [PATCH] Migrates door remotes to the new attack chain + fixes janikeyring (#27925) * migrates door remotes + removes unused airlock var * remove janikey do_after bar * me stoopid * initializes + remove extra line --------- Co-authored-by: Toastical --- code/game/machinery/doors/airlock.dm | 1 - code/game/objects/items/control_wand.dm | 94 ++++++++++++++++--------- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 5fdc17752760..e21895e48194 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -103,7 +103,6 @@ GLOBAL_LIST_EMPTY(airlock_emissive_underlays) var/doorDeni = 'sound/machines/deniedbeep.ogg' // i'm thinkin' Deni's var/boltUp = 'sound/machines/boltsup.ogg' var/boltDown = 'sound/machines/boltsdown.ogg' - var/is_special = FALSE /// Our ID tag for map-based linking shenanigans var/id_tag /// List of people who have shocked this door for logging purposes diff --git a/code/game/objects/items/control_wand.dm b/code/game/objects/items/control_wand.dm index d3905586c9ab..195c4a6ed18e 100644 --- a/code/game/objects/items/control_wand.dm +++ b/code/game/objects/items/control_wand.dm @@ -16,8 +16,10 @@ var/additional_access = list() var/obj/item/card/id/ID -/obj/item/door_remote/New() - ..() + new_attack_chain = TRUE + +/obj/item/door_remote/Initialize(mapload) + . = ..() ID = new /obj/item/card/id for(var/region in region_access) ID.access += get_region_accesses(region) @@ -28,7 +30,10 @@ QDEL_NULL(ID) return ..() -/obj/item/door_remote/attack_self__legacy__attackchain(mob/user) +/obj/item/door_remote/activate_self(mob/user) + if(..()) + return + var/list/options = list(WAND_OPEN = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_open"), WAND_BOLT = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_bolt"), WAND_EMERGENCY = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_ea"), @@ -49,21 +54,25 @@ . = ..() . += "It's current mode is: [mode]" -/obj/item/door_remote/afterattack__legacy__attackchain(obj/target, mob/user) +/obj/item/door_remote/interact_with_atom(atom/target, mob/living/user, list/modifiers) if(istype(target, /obj/machinery/door/airlock)) access_airlock(target, user) if(istype(target, /obj/machinery/door/window)) access_windoor(target, user) + return ITEM_INTERACT_COMPLETE + +/obj/item/door_remote/ranged_interact_with_atom(atom/target, mob/living/user, list/modifiers) + if(istype(target, /obj/machinery/door/airlock)) + access_airlock(target, user) + if(istype(target, /obj/machinery/door/window)) + access_windoor(target, user) + return ITEM_INTERACT_COMPLETE /obj/item/door_remote/proc/access_airlock(obj/machinery/door/airlock/D, mob/user) if(HAS_TRAIT(D, TRAIT_CMAGGED)) to_chat(user, "The door doesn't respond to [src]!") return - if(D.is_special) - to_chat(user, "[src] cannot access this kind of door!") - return - if(!(D.arePowerSystemsOn())) to_chat(user, "[D] has no power!") return @@ -184,10 +193,20 @@ /// How far can we use this. Leave `null` for infinite range var/range -/obj/item/door_remote/omni/access_tuner/afterattack__legacy__attackchain(obj/machinery/door/D, mob/user) - if(!istype(D, /obj/machinery/door/airlock) && !istype(D, /obj/machinery/door/window)) +/obj/item/door_remote/omni/access_tuner/interact_with_atom(atom/target, mob/living/user, list/modifiers) + if(!hack(target, user)) // if the hack is successful, calls the parent proc and does the door stuff + return ITEM_INTERACT_COMPLETE + return ..() + +/obj/item/door_remote/omni/access_tuner/ranged_interact_with_atom(atom/target, mob/living/user, list/modifiers) + if(!hack(target, user)) + return ITEM_INTERACT_COMPLETE + return ..() + +/obj/item/door_remote/omni/access_tuner/proc/hack(atom/target, mob/user) + if(!istype(target, /obj/machinery/door/airlock) && !istype(target, /obj/machinery/door/window)) return - if(!isnull(range) && get_dist(src, D) > range) + if(!isnull(range) && get_dist(src, target) > range) return if(busy) @@ -195,9 +214,11 @@ return icon_state = "hacktool-g" busy = TRUE - to_chat(user, "[src] is attempting to interface with [D]...") - if(do_after(user, hack_speed, target = D)) - . = ..() + to_chat(user, "[src] is attempting to interface with [target]...") + if(do_after(user, hack_speed, target = target)) + busy = FALSE + icon_state = "hacktool" + return TRUE busy = FALSE icon_state = "hacktool" @@ -224,41 +245,54 @@ var/last_airlock_uid additional_access = list(ACCESS_MEDICAL, ACCESS_RESEARCH, ACCESS_CONSTRUCTION, ACCESS_MAILSORTING, ACCESS_CARGO, ACCESS_MINING, ACCESS_KITCHEN, ACCESS_BAR, ACCESS_JANITOR, ACCESS_CHAPEL_OFFICE) +/obj/item/door_remote/janikeyring/Initialize(mapload) + . = ..() + RegisterSignal(src, COMSIG_ACTIVATE_SELF, TYPE_PROC_REF(/datum, signal_cancel_activate_self)) + /obj/item/door_remote/janikeyring/examine(mob/user) . = ..() . += "This keyring has access to Medbay, Science, Engineering, Cargo, the Bar and the Kitchen!" -/obj/item/door_remote/janikeyring/attack_self__legacy__attackchain(mob/user) - if(cooldown > world.time) +/obj/item/door_remote/janikeyring/activate_self(mob/user) + if(..() || cooldown > world.time) return + to_chat(user, "You shake [src]!") playsound(src, 'sound/items/keyring_shake.ogg', 50) cooldown = world.time + JANGLE_COOLDOWN -/obj/item/door_remote/janikeyring/afterattack__legacy__attackchain(obj/machinery/door/D, mob/user, proximity) - if(!proximity) - return - if(!istype(D, /obj/machinery/door/airlock) && !istype(D, /obj/machinery/door/window)) +/obj/item/door_remote/janikeyring/interact_with_atom(obj/machinery/door/target, mob/living/user, list/modifiers) + if(!unlock(target, user)) + return ITEM_INTERACT_COMPLETE + return ..() + +/obj/item/door_remote/janikeyring/ranged_interact_with_atom(atom/target, mob/living/user, list/modifiers) // THOSE AINT MAGICAL REMOTE KEYS + return ITEM_INTERACT_COMPLETE + + +/obj/item/door_remote/janikeyring/proc/unlock(obj/machinery/door/target, mob/living/user) + if(!istype(target, /obj/machinery/door/airlock) && !istype(target, /obj/machinery/door/window)) return if(busy) - to_chat(user, "You are already using [src] on the [D]'s access panel!") + to_chat(user, "You are already using [src] on the [target]'s access panel!") return busy = TRUE var/mob/living/carbon/human/H = user - if(H.mind.assigned_role == "Janitor" && last_airlock_uid == D.UID()) - to_chat(user, "You recognize [D] and look for the key you used...") + if(H.mind.assigned_role == "Janitor" && last_airlock_uid == target.UID()) + to_chat(user, "You recognize [target] and look for the key you used...") hack_speed = 5 SECONDS else - to_chat(user, "You fiddle with [src], trying different keys to open [D]...") + to_chat(user, "You fiddle with [src], trying different keys to open [target]...") if(H.mind.assigned_role != "Janitor") hack_speed = rand(30, 60) SECONDS else hack_speed = rand(5, 20) SECONDS playsound(src, 'sound/items/keyring_unlock.ogg', 50) - if(do_after(user, hack_speed, target = D, progress = 0)) - if(D.check_access(ID)) - last_airlock_uid = D.UID() - . = ..() + if(do_after(user, hack_speed, target = target, progress = 0)) + if(target.check_access(ID)) + last_airlock_uid = target.UID() + busy = FALSE + return TRUE busy = FALSE /obj/item/door_remote/janikeyring/access_airlock(obj/machinery/door/airlock/D, mob/user) @@ -266,10 +300,6 @@ to_chat(user, "[src] won't fit in the [D] airlock's access panel, there's slime everywhere!") return - if(D.is_special) - to_chat(user, "[src] cannot fit in the [D] airlock's access panel!") - return - if(!D.arePowerSystemsOn()) to_chat(user, "The [D] airlock has no power!") return