soundloop fix. also it gets deleted (woo)

This commit is contained in:
LetterN
2021-10-30 13:16:31 +08:00
parent ec85d5575d
commit 1fc778f70a
8 changed files with 50 additions and 25 deletions
@@ -24,8 +24,8 @@
/obj/item/reverse_bear_trap/Initialize()
. = ..()
soundloop = new(list(src))
soundloop2 = new(list(src))
soundloop = new(src)
soundloop2 = new(src)
/obj/item/reverse_bear_trap/Destroy()
QDEL_NULL(soundloop)
@@ -33,16 +33,16 @@
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/reverse_bear_trap/process()
/obj/item/reverse_bear_trap/process(delta_time)
if(!ticking)
return
time_left--
time_left -= delta_time
soundloop2.mid_length = max(0.5, time_left - 5) //beepbeepbeepbeepbeep
if(!time_left || !isliving(loc))
if(time_left <= 0 || !isliving(loc))
playsound(src, 'sound/machines/microwave/microwave-end.ogg', 100, FALSE)
soundloop.stop()
soundloop2.stop()
to_chat(loc, "<span class='userdanger'>*ding*</span>")
to_chat(loc, span_userdanger("*ding*"))
addtimer(CALLBACK(src, .proc/snap), 2)
/obj/item/reverse_bear_trap/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
@@ -116,13 +116,22 @@
/obj/item/reverse_bear_trap/proc/reset()
ticking = FALSE
update_appearance(UPDATE_OVERLAYS)
REMOVE_TRAIT(src, TRAIT_NODROP, REVERSE_BEAR_TRAP_TRAIT)
soundloop.stop()
soundloop2.stop()
STOP_PROCESSING(SSprocessing, src)
/obj/item/reverse_bear_trap/update_overlays()
. = ..()
if(ticking != TRUE)
return
/// note: this timer overlay increments one frame every second (to simulate a clock ticking). If you want to instead have it do a full cycle in a minute, set the 'delay' of each frame of the icon overlay to 75 rather than 10, and the worn overlay to twice that.
// . += "rbt_ticking"
/obj/item/reverse_bear_trap/proc/arm() //hulen
ticking = TRUE
update_appearance(UPDATE_OVERLAYS)
escape_chance = initial(escape_chance) //we keep these vars until re-arm, for tracking purposes
time_left = initial(time_left)
ADD_TRAIT(src, TRAIT_NODROP, REVERSE_BEAR_TRAP_TRAIT)