[READY] Welders consume fuel when they destroy an object during attack (#46842)

About The Pull Request

Welders didn't actually consume fuel if their attack deleted an object. This was first noticed when welding space vines, in that the welder didn't consume any fuel to do so. Further testing showed that this was the case for any object that gets destroyed on hit, including APCs, Air Alarms, Girders etc.

Problem was that the code for actually consuming fuel after an attack is in the afterattack proc which doesn't actually get called if the target is QDELETED. PR moves that code to the attack proc, along with (regrettably) implementing attack_obj too. This feels hacky and reeks of duplicate code, so if anyone has a better option for how I could implement this fix I'm all ears.
Why It's Good For The Game

Fixes unintentional behavior
Changelog

cl
fix: Welders now consume fuel when they destroy an object
/cl
This commit is contained in:
James
2019-10-13 14:41:14 +11:00
committed by oranges
parent b1a1061d84
commit fffb74bdcf
3 changed files with 35 additions and 12 deletions
+28 -12
View File
@@ -120,28 +120,38 @@
else
return ..()
/obj/item/weldingtool/afterattack(atom/O, mob/user, proximity)
. = ..()
if(!proximity)
return
if(!status && O.is_refillable())
reagents.trans_to(O, reagents.total_volume, transfered_by = user)
to_chat(user, "<span class='notice'>You empty [src]'s fuel tank into [O].</span>")
update_icon()
if(isOn())
use(1)
var/turf/location = get_turf(user)
location.hotspot_expose(700, 50, 1)
if(get_fuel() <= 0)
set_light(0)
if(isliving(O))
handle_fuel_and_temps(1, user)
if(!QDELETED(O) && isliving(O)) // can't ignite something that doesn't exist
var/mob/living/L = O
if(L.IgniteMob())
message_admins("[ADMIN_LOOKUPFLW(user)] set [key_name_admin(L)] on fire with [src] at [AREACOORD(user)]")
log_game("[key_name(user)] set [key_name(L)] on fire with [src] at [AREACOORD(user)]")
if(!status && O.is_refillable())
reagents.trans_to(O, reagents.total_volume, transfered_by = user)
to_chat(user, "<span class='notice'>You empty [src]'s fuel tank into [O].</span>")
update_icon()
/obj/item/weldingtool/attack_qdeleted(atom/O, mob/user, proximity)
. = ..()
if(!proximity)
return
if(isOn())
handle_fuel_and_temps(1, user)
if(!QDELETED(O) && isliving(O)) // can't ignite something that doesn't exist
var/mob/living/L = O
if(L.IgniteMob())
message_admins("[ADMIN_LOOKUPFLW(user)] set [key_name_admin(L)] on fire with [src] at [AREACOORD(user)]")
log_game("[key_name(user)] set [key_name(L)] on fire with [src] at [AREACOORD(user)]")
/obj/item/weldingtool/attack_self(mob/user)
if(src.reagents.has_reagent(/datum/reagent/toxin/plasma))
@@ -153,6 +163,11 @@
update_icon()
// Ah fuck, I can't believe you've done this
/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()
@@ -177,6 +192,7 @@
//Turns off the welder if there is no more fuel (does this really need to be its own proc?)
/obj/item/weldingtool/proc/check_fuel(mob/user)
if(get_fuel() <= 0 && welding)
set_light(0)
switched_on(user)
update_icon()
//mob icon update