From 516321794bd6239fe5d88185e8bd477b012cbecd Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:22:28 -0400 Subject: [PATCH] [MIRROR] Yeets `ATTACK_QDELETED`, fixes welding torches not using fuel on attacking non-mobs (2 year old bug) (#2030) * Yeets `ATTACK_QDELETED`, fixes welding torches not using fuel on attacking non-mobs (2 year old bug) (#82694) ## About The Pull Request - Deletes `ATTACK_QDELETED` - May have been necessary in the past but it's pointless now. All it does is clutter the attack chain. Perish. - Fixes welders not using fuel on attacking non-mobs - #65762 "fixed" welders consuming fuel on clicking turfs by adding an `isliving` check and not an `ismovable` check? ## Changelog :cl: Melbert fix: Blobs may rejoice, welding torches now consume fuel when attacking objects again after two years. /:cl: * Yeets `ATTACK_QDELETED`, fixes welding torches not using fuel on attacking non-mobs (2 year old bug) * Electric welders are hot too now. Starting fires is definitely in their wheelhouse --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com> --- .../signals/signals_mob/signals_mob_main.dm | 2 -- code/__DEFINES/dcs/signals/signals_object.dm | 2 -- code/_onclick/item_attack.dm | 9 ------- code/game/objects/items/tools/weldingtool.dm | 26 +++---------------- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/combat_welder.dm | 26 +++++++++++++++++++ .../electric_welder/code/electric_welder.dm | 4 --- 7 files changed, 31 insertions(+), 39 deletions(-) create mode 100644 code/modules/unit_tests/combat_welder.dm diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm index 068aadf6a5e..f33d2f1f40d 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm @@ -182,8 +182,6 @@ #define COMSIG_MOB_ITEM_AFTERATTACK "mob_item_afterattack" ///from base of obj/item/afterattack_secondary(): (atom/target, obj/item/weapon, proximity_flag, click_parameters) #define COMSIG_MOB_ITEM_AFTERATTACK_SECONDARY "mob_item_afterattack_secondary" -///from base of obj/item/attack_qdeleted(): (atom/target, mob/user, proximity_flag, click_parameters) -#define COMSIG_MOB_ITEM_ATTACK_QDELETED "mob_item_attack_qdeleted" ///from base of mob/RangedAttack(): (atom/A, modifiers) #define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged" ///from base of mob/ranged_secondary_attack(): (atom/target, modifiers) diff --git a/code/__DEFINES/dcs/signals/signals_object.dm b/code/__DEFINES/dcs/signals/signals_object.dm index d926cc6d5df..43e3a09a028 100644 --- a/code/__DEFINES/dcs/signals/signals_object.dm +++ b/code/__DEFINES/dcs/signals/signals_object.dm @@ -472,8 +472,6 @@ #define COMPONENT_AFTERATTACK_PROCESSED_ITEM (1<<0) ///from base of obj/item/afterattack_secondary(): (atom/target, mob/user, proximity_flag, click_parameters) #define COMSIG_ITEM_AFTERATTACK_SECONDARY "item_afterattack_secondary" -///from base of obj/item/attack_qdeleted(): (atom/target, mob/user, params) -#define COMSIG_ITEM_ATTACK_QDELETED "item_attack_qdeleted" ///from base of obj/item/embedded(): (atom/target, obj/item/bodypart/part) #define COMSIG_ITEM_EMBEDDED "item_embedded" ///from base of datum/component/embedded/safeRemove(): (mob/living/carbon/victim) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index eb5de5971d8..09187b5019d 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -52,10 +52,6 @@ if (attackby_result) return TRUE - if(QDELETED(src) || QDELETED(target)) - attack_qdeleted(target, user, TRUE, params) - return TRUE - if (is_right_clicking) var/after_attack_secondary_result = afterattack_secondary(target, user, TRUE, params) @@ -472,11 +468,6 @@ return SECONDARY_ATTACK_CALL_NORMAL -/// Called if the target gets deleted by our attack -/obj/item/proc/attack_qdeleted(atom/target, mob/user, proximity_flag, click_parameters) - SEND_SIGNAL(src, COMSIG_ITEM_ATTACK_QDELETED, target, user, proximity_flag, click_parameters) - SEND_SIGNAL(user, COMSIG_MOB_ITEM_ATTACK_QDELETED, target, user, proximity_flag, click_parameters) - /obj/item/proc/get_clamped_volume() if(w_class) if(force) diff --git a/code/game/objects/items/tools/weldingtool.dm b/code/game/objects/items/tools/weldingtool.dm index 1cbaee96cdb..7c770cfab48 100644 --- a/code/game/objects/items/tools/weldingtool.dm +++ b/code/game/objects/items/tools/weldingtool.dm @@ -167,10 +167,12 @@ if(!proximity) return - if(isOn()) + if(isOn() && ismovable(attacked_atom)) + use(1) + var/turf/location = get_turf(user) + location.hotspot_expose(700, 50, 1) . |= AFTERATTACK_PROCESSED_ITEM if (!QDELETED(attacked_atom) && isliving(attacked_atom)) // can't ignite something that doesn't exist - handle_fuel_and_temps(1, user) var/mob/living/attacked_mob = attacked_atom if(attacked_mob.ignite_mob()) message_admins("[ADMIN_LOOKUPFLW(user)] set [key_name_admin(attacked_mob)] on fire with [src] at [AREACOORD(user)]") @@ -184,21 +186,6 @@ return . -/obj/item/weldingtool/attack_qdeleted(atom/attacked_atom, mob/user, proximity) - . = ..() - if(!proximity) - return - - if(isOn()) - handle_fuel_and_temps(1, user) - - if(!QDELETED(attacked_atom) && isliving(attacked_atom)) // can't ignite something that doesn't exist - var/mob/living/attacked_mob = attacked_atom - if(attacked_mob.ignite_mob()) - message_admins("[ADMIN_LOOKUPFLW(user)] set [key_name_admin(attacked_mob)] on fire with [src] at [AREACOORD(user)].") - user.log_message("set [key_name(attacked_mob)] on fire with [src]", LOG_ATTACK) - - /obj/item/weldingtool/attack_self(mob/user) if(src.reagents.has_reagent(/datum/reagent/toxin/plasma)) message_admins("[ADMIN_LOOKUPFLW(user)] activated a rigged welder at [AREACOORD(user)].") @@ -208,11 +195,6 @@ update_appearance() -/obj/item/weldingtool/proc/handle_fuel_and_temps(used = 0, mob/living/user) - use(used) - var/turf/location = get_turf(user) - location.hotspot_expose(700, 50, 1) - /// Returns the amount of fuel in the welder /obj/item/weldingtool/proc/get_fuel() return reagents.get_reagent_amount(/datum/reagent/fuel) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index a82e51bc737..98a234cbf0e 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -117,6 +117,7 @@ #include "closets.dm" #include "clothing_under_armor_subtype_check.dm" #include "combat.dm" +#include "combat_welder.dm" #include "component_tests.dm" #include "confusion.dm" #include "connect_loc.dm" diff --git a/code/modules/unit_tests/combat_welder.dm b/code/modules/unit_tests/combat_welder.dm new file mode 100644 index 00000000000..2fa9052d6fb --- /dev/null +++ b/code/modules/unit_tests/combat_welder.dm @@ -0,0 +1,26 @@ +/datum/unit_test/welder_combat + +/datum/unit_test/welder_combat/Run() + var/mob/living/carbon/human/tider = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + var/mob/living/carbon/human/victim = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + var/obj/item/weldingtool/weapon = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + tider.put_in_active_hand(weapon, forced = TRUE) + tider.set_combat_mode(TRUE) + weapon.attack_self(tider) + weapon.melee_attack_chain(tider, victim) + + TEST_ASSERT_NOTEQUAL(victim.getFireLoss(), 0, "Victim did not get burned by welder.") + TEST_ASSERT_EQUAL(weapon.get_fuel(), weapon.max_fuel - 1, "Welder did not consume fuel on attacking a mob") + + var/obj/structure/blob/blobby = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + weapon.melee_attack_chain(tider, blobby) + + TEST_ASSERT_NOTEQUAL(blobby.get_integrity(), blobby.max_integrity, "Blob did not get burned by welder.") + TEST_ASSERT_EQUAL(weapon.get_fuel(), weapon.max_fuel - 2, "Welder did not consume fuel on attacking a blob") + + weapon.force = 999 + weapon.melee_attack_chain(tider, blobby) + + TEST_ASSERT(QDELETED(blobby), "Blob was not destroyed by welder.") + TEST_ASSERT_EQUAL(weapon.get_fuel(), weapon.max_fuel - 3, "Welder did not consume fuel on deleting a blob") diff --git a/modular_nova/modules/electric_welder/code/electric_welder.dm b/modular_nova/modules/electric_welder/code/electric_welder.dm index 4765c9ad449..3374d695d12 100644 --- a/modular_nova/modules/electric_welder/code/electric_welder.dm +++ b/modular_nova/modules/electric_welder/code/electric_welder.dm @@ -71,10 +71,6 @@ /obj/item/weldingtool/electric/use(used = 0) return isOn() -// This is what starts fires. Overriding it stops it starting fires -/obj/item/weldingtool/electric/handle_fuel_and_temps(used = 0, mob/living/user) - return - /obj/item/weldingtool/electric/examine() . = ..() . += "[src] is currently [powered ? "powered" : "unpowered"]."