fixes a bunch of broken clickdelays (#13218)

* fixes

* fix
This commit is contained in:
silicons
2020-08-25 11:58:20 -07:00
committed by GitHub
parent d4196650fd
commit 8699ce2174
6 changed files with 32 additions and 16 deletions
@@ -19,6 +19,10 @@
var/stream_range = 1 //the range of tiles the sprayer will reach when in stream mode.
var/stream_amount = 10 //the amount of reagents transfered when in stream mode.
var/spray_delay = 3 //The amount of sleep() delay between each chempuff step.
/// Last world.time of spray
var/last_spray = 0
/// Spray cooldown
var/spray_cooldown = CLICK_CD_MELEE
var/can_fill_from_container = TRUE
amount_per_transfer_from_this = 5
volume = 250
@@ -27,8 +31,6 @@
/obj/item/reagent_containers/spray/afterattack(atom/A, mob/user)
. = ..()
if(!user.CheckActionCooldown(CLICK_CD_MELEE))
return
if(istype(A, /obj/structure/sink) || istype(A, /obj/structure/janitorialcart) || istype(A, /obj/machinery/hydroponics))
return
@@ -49,7 +51,8 @@
to_chat(user, "<span class='warning'>[src] is empty!</span>")
return
spray(A)
if(!spray(A))
return
playsound(src.loc, 'sound/effects/spray2.ogg', 50, 1, -6)
user.last_action = world.time
@@ -64,10 +67,10 @@
if(reagents.has_reagent(/datum/reagent/lube))
message_admins("[ADMIN_LOOKUPFLW(user)] fired Space lube from \a [src] at [ADMIN_VERBOSEJMP(T)].")
log_game("[key_name(user)] fired Space lube from \a [src] at [AREACOORD(T)].")
return
/obj/item/reagent_containers/spray/proc/spray(atom/A)
if((last_spray + spray_cooldown) > world.time)
return
var/range = clamp(get_dist(src, A), 1, current_range)
var/obj/effect/decal/chempuff/D = new /obj/effect/decal/chempuff(get_turf(src))
D.create_reagents(amount_per_transfer_from_this, NONE, NO_REAGENTS_VALUE)
@@ -79,10 +82,11 @@
reagents.trans_to(D, amount_per_transfer_from_this, 1/range)
D.color = mix_color_from_reagents(D.reagents.reagent_list)
var/wait_step = max(round(2+ spray_delay * INVERSE(range)), 2)
do_spray(A, wait_step, D, range, puff_reagent_left)
last_spray = world.time
INVOKE_ASYNC(src, .proc/do_spray, A, wait_step, D, range, puff_reagent_left)
return TRUE
/obj/item/reagent_containers/spray/proc/do_spray(atom/A, wait_step, obj/effect/decal/chempuff/D, range, puff_reagent_left)
set waitfor = FALSE
var/range_left = range
for(var/i=0, i<range, i++)
range_left--