mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 13:05:36 +01:00
[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:
@@ -186,6 +186,7 @@
|
||||
#define COMPONENT_ITEM_NO_ATTACK 1
|
||||
#define COMSIG_MOB_APPLY_DAMGE "mob_apply_damage" //from base of /mob/living/proc/apply_damage(): (damage, damagetype, def_zone)
|
||||
#define COMSIG_MOB_ITEM_AFTERATTACK "mob_item_afterattack" //from base of obj/item/afterattack(): (atom/target, mob/user, proximity_flag, click_parameters)
|
||||
#define COMSIG_MOB_ITEM_ATTACK_QDELETED "mob_item_attack_qdeleted" //from base of obj/item/attack_qdeleted(): (atom/target, mob/user, proxiumity_flag, click_parameters)
|
||||
#define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged" //from base of mob/RangedAttack(): (atom/A, params)
|
||||
#define COMSIG_MOB_THROW "mob_throw" //from base of /mob/throw_item(): (atom/target)
|
||||
#define COMSIG_MOB_EXAMINATE "mob_examinate" //from base of /mob/verb/examinate(): (atom/target)
|
||||
@@ -250,6 +251,7 @@
|
||||
#define COMSIG_ITEM_PRE_ATTACK "item_pre_attack" //from base of obj/item/pre_attack(): (atom/target, mob/user, params)
|
||||
#define COMPONENT_NO_ATTACK 1
|
||||
#define COMSIG_ITEM_AFTERATTACK "item_afterattack" //from base of obj/item/afterattack(): (atom/target, mob/user, params)
|
||||
#define COMSIG_ITEM_ATTACK_QDELETED "item_attack_qdeleted" //from base of obj/item/attack_qdeleted(): (atom/target, mob/user, params)
|
||||
#define COMSIG_ITEM_EQUIPPED "item_equip" //from base of obj/item/equipped(): (/mob/equipper, slot)
|
||||
#define COMSIG_ITEM_DROPPED "item_drop" //from base of obj/item/dropped(): (mob/user)
|
||||
#define COMSIG_ITEM_PICKUP "item_pickup" //from base of obj/item/pickup(): (/mob/taker)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
if(target.attackby(src,user, params))
|
||||
return
|
||||
if(QDELETED(src) || QDELETED(target))
|
||||
attack_qdeleted(target, user, TRUE, params)
|
||||
return
|
||||
afterattack(target, user, TRUE, params)
|
||||
|
||||
@@ -117,6 +118,10 @@
|
||||
SEND_SIGNAL(src, COMSIG_ITEM_AFTERATTACK, target, user, proximity_flag, click_parameters)
|
||||
SEND_SIGNAL(user, COMSIG_MOB_ITEM_AFTERATTACK, target, user, proximity_flag, click_parameters)
|
||||
|
||||
// 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user