mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 18:11:47 +00:00
Fixes plasma cutters not using charge when used as welder, and adds flashing (#40423)
* Plasma cutters now require charge (100, 10%) to be used as a welder. * Plasma cutters now flash you, same as experimental welders. Plasma cutters now use charge proportional to time spent welding (25 to start and 25 every 10th welding tick - 50 per scrubber/vent/girder, 175 per regular wall, etc). * Cell use sanity. If you somehow popped the cell out of plasma cutter you have bigger problems. * Annnd PCs are back to not using charge for most tasks (exceptions: plasma tiles, airlock wire shielding...) because everything calls amount=0 and zero amount means use() isn't called. They still flash you, though. * Comments + a bit more sanity. * Actual sanity. Also did a rebase, let's see how much stuff that wrecked. * Oops apparently you indeed cannot stack inline conditionals or it requires some special syntax. * Plasma cutters now use a minimum of charge_weld charge again. Also known as "who says I can't override your stupid zero-amount calls?". * And here's the rebase problems. Reverted accidental sanity revert.
This commit is contained in:
@@ -113,6 +113,7 @@
|
||||
ammo_type = list(/obj/item/ammo_casing/energy/bolt/large)
|
||||
pin = null
|
||||
|
||||
|
||||
/obj/item/gun/energy/plasmacutter
|
||||
name = "plasma cutter"
|
||||
desc = "A mining tool capable of expelling concentrated plasma bursts. You could use it to cut limbs off xenos! Or, you know, mine stuff."
|
||||
@@ -129,6 +130,9 @@
|
||||
usesound = list('sound/items/welder.ogg', 'sound/items/welder2.ogg')
|
||||
tool_behaviour = TOOL_WELDER
|
||||
toolspeed = 0.7 //plasmacutters can be used as welders, and are faster than standard welders
|
||||
var/progress_flash_divisor = 10 //copypasta is best pasta
|
||||
var/light_intensity = 1
|
||||
var/charge_weld = 25 //amount of charge used up to start action (multiplied by amount) and per progress_flash_divisor ticks of welding
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/Initialize()
|
||||
. = ..()
|
||||
@@ -152,15 +156,47 @@
|
||||
..()
|
||||
|
||||
// Tool procs, in case plasma cutter is used as welder
|
||||
/obj/item/gun/energy/plasmacutter/tool_use_check(mob/living/user, amount)
|
||||
if(!QDELETED(cell) && (cell.charge >= amount * 100))
|
||||
return TRUE
|
||||
// Can we start welding?
|
||||
/obj/item/gun/energy/plasmacutter/tool_start_check(mob/living/user, amount)
|
||||
. = tool_use_check(user, amount)
|
||||
if(. && user)
|
||||
user.flash_act(light_intensity)
|
||||
|
||||
to_chat(user, "<span class='warning'>You need more charge to complete this task!</span>")
|
||||
return FALSE
|
||||
// Can we weld? Plasma cutter does not use charge continuously.
|
||||
// Amount cannot be defaulted to 1: most of the code specifies 0 in the call.
|
||||
/obj/item/gun/energy/plasmacutter/tool_use_check(mob/living/user, amount)
|
||||
if(QDELETED(cell))
|
||||
to_chat(user, "<span class='warning'>[src] does not have a cell, and cannot be used!</span>")
|
||||
return FALSE
|
||||
// Amount cannot be used if drain is made continuous, e.g. amount = 5, charge_weld = 25
|
||||
// Then it'll drain 125 at first and 25 periodically, but fail if charge dips below 125 even though it still can finish action
|
||||
// Alternately it'll need to drain amount*charge_weld every period, which is either obscene or makes it free for other uses
|
||||
if(amount ? cell.charge < charge_weld * amount : cell.charge < charge_weld)
|
||||
to_chat(user, "<span class='warning'>You need more charge to complete this task!</span>")
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/use(amount)
|
||||
return cell.use(amount * 100)
|
||||
return (!QDELETED(cell) && cell.use(amount ? amount * charge_weld : charge_weld))
|
||||
|
||||
// This only gets called by use_tool(delay > 0)
|
||||
// It's also supposed to not get overridden in the first place.
|
||||
/obj/item/gun/energy/plasmacutter/tool_check_callback(mob/living/user, amount, datum/callback/extra_checks)
|
||||
. = ..() //return tool_use_check(user, amount) && (!extra_checks || extra_checks.Invoke())
|
||||
if(. && user)
|
||||
if (progress_flash_divisor == 0)
|
||||
user.flash_act(min(light_intensity,1))
|
||||
progress_flash_divisor = initial(progress_flash_divisor)
|
||||
else
|
||||
progress_flash_divisor--
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/use_tool(atom/target, mob/living/user, delay, amount=1, volume=0, datum/callback/extra_checks)
|
||||
if(amount)
|
||||
. = ..()
|
||||
else
|
||||
. = ..(amount=1)
|
||||
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/update_icon()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user