From 2c0053906dac5e98323ccb1b03435b18173646f2 Mon Sep 17 00:00:00 2001 From: Erika Fox <94164348+Bjarl@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:15:01 -0400 Subject: [PATCH] Cabinet Refactor (#3378) Mildly refactors fireaxe cabinets to allow them to be subtyped with different items. Also adds an is_wielded proc to most weapons that can be wielded to prevent potential weirdness with this down the line. Cabinets are soulful :cl: Erika Fox code: Fireaxe cabinets have been repathed, and now function as a more general cabinet object. please report any inconsistencies with behavior /:cl: --------- Signed-off-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: FalloutFalcon Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> --- code/game/machinery/doors/airlock.dm | 2 +- code/game/objects/items/melee/fireaxe.dm | 4 - code/game/objects/items/melee/spear.dm | 5 +- code/game/objects/items/melee/sword.dm | 10 +- code/game/objects/structures/fireaxe.dm | 179 ----------------------- 5 files changed, 4 insertions(+), 196 deletions(-) delete mode 100644 code/game/objects/structures/fireaxe.dm diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index b30c42c97863..3412321b380b 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -1238,7 +1238,7 @@ if(!operating) if(istype(I, /obj/item/melee/axe/fire)) //being fireaxe'd var/obj/item/melee/axe/fire/axe = I - if(axe && !axe.wielded) + if(axe && !HAS_TRAIT(axe, TRAIT_WIELDED)) to_chat(user, "You need to be wielding \the [axe] to do that!") return INVOKE_ASYNC(src, (density ? PROC_REF(open) : PROC_REF(close)), 2) diff --git a/code/game/objects/items/melee/fireaxe.dm b/code/game/objects/items/melee/fireaxe.dm index 443836a9ccc1..73c3a19f13b9 100644 --- a/code/game/objects/items/melee/fireaxe.dm +++ b/code/game/objects/items/melee/fireaxe.dm @@ -26,7 +26,6 @@ wielded = TRUE - /// triggered on unwield of two handed item /obj/item/melee/axe/proc/on_unwield(obj/item/source, mob/user) SIGNAL_HANDLER @@ -34,9 +33,6 @@ wielded = FALSE /obj/item/melee/axe/update_icon_state() - icon_state = "[base_icon_state]0" - return ..() -/obj/item/melee/axe/afterattack(atom/A, mob/user, proximity) . = ..() if(!proximity) return diff --git a/code/game/objects/items/melee/spear.dm b/code/game/objects/items/melee/spear.dm index 4eb7aeb3fa98..cbee81798249 100644 --- a/code/game/objects/items/melee/spear.dm +++ b/code/game/objects/items/melee/spear.dm @@ -66,12 +66,9 @@ icon_prefix = "spearbomb" var/obj/item/grenade/explosive = null var/war_cry = "AAAAARGH!!!" - var/wielded = FALSE // track wielded status on item /obj/item/melee/spear/explosive/Initialize(mapload) . = ..() - RegisterSignal(src, COMSIG_TWOHANDED_WIELD, PROC_REF(on_wield)) - RegisterSignal(src, COMSIG_TWOHANDED_UNWIELD, PROC_REF(on_unwield)) set_explosive(new /obj/item/grenade/iedcasing/spawned()) //For admin-spawned explosive lances /obj/item/melee/spear/explosive/ComponentInitialize() @@ -127,7 +124,7 @@ . = ..() if(!proximity) return - if(wielded) + if(HAS_TRAIT(src, TRAIT_WIELDED)) user.say("[war_cry]", forced="spear warcry") explosive.forceMove(AM) explosive.prime() diff --git a/code/game/objects/items/melee/sword.dm b/code/game/objects/items/melee/sword.dm index 8edf932f500e..2624a0a4f6b5 100644 --- a/code/game/objects/items/melee/sword.dm +++ b/code/game/objects/items/melee/sword.dm @@ -332,12 +332,6 @@ attack_verb = list("cut", "sliced", "diced") slot_flags = ITEM_SLOT_BACK hitsound = 'sound/weapons/bladeslice.ogg' - var/wielded = FALSE // track wielded status on item - -/obj/item/melee/sword/vibro/Initialize() - . = ..() - RegisterSignal(src, COMSIG_TWOHANDED_WIELD, PROC_REF(on_wield)) - RegisterSignal(src, COMSIG_TWOHANDED_UNWIELD, PROC_REF(on_unwield)) /obj/item/melee/sword/vibro/ComponentInitialize() . = ..() @@ -358,9 +352,9 @@ icon_state = "[base_icon_state]0" /obj/item/melee/sword/vibro/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) - if(wielded) + if(HAS_TRAIT(src, TRAIT_WIELDED)) final_block_chance *= 2 - if(wielded || attack_type != PROJECTILE_ATTACK) + if(HAS_TRAIT(src, TRAIT_WIELDED) || attack_type != PROJECTILE_ATTACK) if(prob(final_block_chance)) if(attack_type == PROJECTILE_ATTACK) owner.visible_message("[owner] deflects [attack_text] with [src]!") diff --git a/code/game/objects/structures/fireaxe.dm b/code/game/objects/structures/fireaxe.dm deleted file mode 100644 index a164248a2bdd..000000000000 --- a/code/game/objects/structures/fireaxe.dm +++ /dev/null @@ -1,179 +0,0 @@ -/obj/structure/fireaxecabinet - name = "fire axe cabinet" - desc = "There is a small label that reads \"For Emergency use only\" along with details for safe use of the axe. As if." - icon = 'icons/obj/wallmounts.dmi' - icon_state = "fireaxe" - anchored = TRUE - density = FALSE - armor = list("melee" = 50, "bullet" = 20, "laser" = 0, "energy" = 100, "bomb" = 10, "bio" = 100, "rad" = 100, "fire" = 90, "acid" = 50) - max_integrity = 150 - integrity_failure = 0.33 - var/locked = TRUE - var/open = FALSE - var/obj/item/melee/axe/fire/fireaxe - -/obj/structure/fireaxecabinet/Initialize() - . = ..() - fireaxe = new - update_appearance() - -/obj/structure/fireaxecabinet/Destroy() - if(fireaxe) - QDEL_NULL(fireaxe) - return ..() - -/obj/structure/fireaxecabinet/attackby(obj/item/I, mob/user, params) - if(iscyborg(user) || I.tool_behaviour == TOOL_MULTITOOL) - toggle_lock(user) - else if(I.tool_behaviour == TOOL_WELDER && user.a_intent == INTENT_HELP && !broken) - if(obj_integrity < max_integrity) - if(!I.tool_start_check(user, amount=2)) - return - - to_chat(user, "You begin repairing [src].") - if(I.use_tool(src, user, 40, volume=50, amount=2)) - obj_integrity = max_integrity - update_appearance() - to_chat(user, "You repair [src].") - else - to_chat(user, "[src] is already in good condition!") - return - else if(istype(I, /obj/item/stack/sheet/glass) && broken) - var/obj/item/stack/sheet/glass/G = I - if(G.get_amount() < 2) - to_chat(user, "You need two glass sheets to fix [src]!") - return - to_chat(user, "You start fixing [src]...") - if(do_after(user, 20, target = src) && G.use(2)) - broken = 0 - obj_integrity = max_integrity - update_appearance() - else if(open || broken) - if(istype(I, /obj/item/melee/axe/fire) && !fireaxe) - var/obj/item/melee/axe/fire/F = I - if(F && F.wielded) - to_chat(user, "Unwield the [F.name] first.") - return - if(!user.transferItemToLoc(F, src)) - return - fireaxe = F - to_chat(user, "You place the [F.name] back in the [name].") - update_appearance() - return - else if(!broken) - toggle_open() - else - return ..() - -/obj/structure/fireaxecabinet/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0) - switch(damage_type) - if(BRUTE) - if(broken) - playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 90, TRUE) - else - playsound(loc, 'sound/effects/glasshit.ogg', 90, TRUE) - if(BURN) - playsound(src.loc, 'sound/items/welder.ogg', 100, TRUE) - -/obj/structure/fireaxecabinet/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, attack_dir) - if(open) - return - . = ..() - if(.) - update_appearance() - -/obj/structure/fireaxecabinet/obj_break(damage_flag) - if(!broken && !(flags_1 & NODECONSTRUCT_1)) - update_appearance() - broken = TRUE - playsound(src, 'sound/effects/glassbr3.ogg', 100, TRUE) - new /obj/item/shard(loc) - new /obj/item/shard(loc) - -/obj/structure/fireaxecabinet/deconstruct(disassembled = TRUE) - if(!(flags_1 & NODECONSTRUCT_1)) - if(fireaxe && loc) - fireaxe.forceMove(loc) - fireaxe = null - new /obj/item/stack/sheet/metal(loc, 2) - qdel(src) - -/obj/structure/fireaxecabinet/attack_hand(mob/user) - . = ..() - if(.) - return - if(open || broken) - if(fireaxe) - user.put_in_hands(fireaxe) - fireaxe = null - to_chat(user, "You take the fire axe from the [name].") - src.add_fingerprint(user) - update_appearance() - return - if(locked) - to_chat(user, "The [name] won't budge!") - return - else - open = !open - update_appearance() - return - -/obj/structure/fireaxecabinet/attack_paw(mob/living/user) - return attack_hand(user) - -/obj/structure/fireaxecabinet/attack_ai(mob/user) - toggle_lock(user) - return - -/obj/structure/fireaxecabinet/attack_tk(mob/user) - if(locked) - to_chat(user, "The [name] won't budge!") - return - else - open = !open - update_appearance() - return - -/obj/structure/fireaxecabinet/update_overlays() - . = ..() - if(fireaxe) - . += "axe" - if(open) - . += "glass_raised" - return - var/hp_percent = obj_integrity/max_integrity * 100 - if(broken) - . += "glass4" - else - switch(hp_percent) - if(-INFINITY to 40) - . += "glass3" - if(40 to 60) - . += "glass2" - if(60 to 80) - . += "glass1" - if(80 to INFINITY) - . += "glass" - - . += locked ? "locked" : "unlocked" - -/obj/structure/fireaxecabinet/proc/toggle_lock(mob/user) - to_chat(user, "Resetting circuitry...") - playsound(src, 'sound/machines/locktoggle.ogg', 50, TRUE) - if(do_after(user, 20, target = src)) - to_chat(user, "You [locked ? "disable" : "re-enable"] the locking modules.") - locked = !locked - update_appearance() - -/obj/structure/fireaxecabinet/verb/toggle_open() - set name = "Open/Close" - set category = "Object" - set src in oview(1) - - if(locked) - to_chat(usr, "The [name] won't budge!") - return - else - open = !open - update_appearance() - return