diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm index 8645d633227..02feb57dd98 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm @@ -21,6 +21,10 @@ var/turf/target_turf ///The timer that tracks how long the arm should be doing arm things. var/active_arm_timer_id + ///Next time a success sound can play. + var/next_success_sound = 0 + ///Next time a fail sound can play. + var/next_fail_sound = 0 /obj/machinery/missile_builder/attackby(obj/item/I, mob/user, params) if(default_unfasten_wrench(user, I)) @@ -106,6 +110,7 @@ * * Does not return anything. SHOULD NOT RETURN ANYTHING. **/ /obj/machinery/missile_builder/proc/attempt_assembler_action(turf/source, atom/movable/entering, old_loc, old_locs) + SIGNAL_HANDLER if(QDELETED(entering)) //How would this happen? Who knows.. but this is NSV after all. return if(!isobj(entering) || iseffect(entering)) @@ -113,31 +118,41 @@ if(!(entering.type in munition_types)) visible_message("[src] shakes its arm melancholically.") arm.shake_animation() - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.2 SECONDS return switch(entering.type) //This is VERY BAD but they do not share a common type. if(/obj/item/ship_weapon/ammunition/missile/missile_casing) var/obj/item/ship_weapon/ammunition/missile/missile_casing/missile_target = entering if(!(missile_target.state in target_states)) visible_message("[src] sighs.") - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.5 SECONDS return trigger_arm_animation() missile_target.state++ //Next step! missile_target.check_completion() - do_sparks(4, TRUE, missile_target) - playsound(src, 'sound/items/welder.ogg', 100, 1) + if(world.time >= next_success_sound) + do_sparks(4, TRUE, missile_target) + playsound(src, 'sound/items/welder.ogg', 100, 1) + next_success_sound = world.time + 0.2 SECONDS if(/obj/item/ship_weapon/ammunition/torpedo/torpedo_casing) var/obj/item/ship_weapon/ammunition/torpedo/torpedo_casing/torpedo_target = entering if(!(torpedo_target.state in target_states)) visible_message("[src] sighs.") - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.5 SECONDS return trigger_arm_animation() torpedo_target.state++ //Next step! torpedo_target.check_completion() - do_sparks(4, TRUE, torpedo_target) - playsound(src, 'sound/items/welder.ogg', 100, 1) + if(world.time >= next_success_sound) + do_sparks(4, TRUE, torpedo_target) + playsound(src, 'sound/items/welder.ogg', 100, 1) + next_success_sound = world.time + 0.2 SECONDS else CRASH("Please stop handing the missile assemblers invalid types as valid ammunition. Type: [entering.type]. ALL valid casings must be missile or torpedo types.") @@ -149,32 +164,38 @@ return if(entering.loc != source) return - if(length(held_components) > 0) - var/obj/held_component = held_components[1] - if(held_component.type == entering.type) //Please do throw these hungry machines some components. - var/obj/item/entering_item = entering - visible_message("[src] happily adds [entering_item] to its component storage.") + if(tracked_component_type && tracked_component_type == entering.type) //Please do throw these hungry machines some components. + var/obj/item/entering_item = entering + visible_message("[src] happily adds [entering_item] to its component storage.") + if(world.time >= next_success_sound) playsound(src, 'sound/machines/ping.ogg', 50, 0) - entering_item.do_pickup_animation(src) - entering_item.forceMove(src) - held_components += entering_item - return + next_success_sound = world.time + 0.2 SECONDS + entering_item.do_pickup_animation(src) + entering_item.forceMove(src) + held_components += entering_item + return if(!(entering.type in munition_types)) visible_message("[src] shakes its arm melancholically.") arm.shake_animation() - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.2 SECONDS return switch(entering.type) //This is VERY BAD but they do not share a common type. if(/obj/item/ship_weapon/ammunition/missile/missile_casing) var/obj/item/ship_weapon/ammunition/missile/missile_casing/missile_target = entering if(!length(held_components)) visible_message("[src] sighs.") - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.5 SECONDS return var/obj/item/ship_weapon/parts/missile/missile_part = held_components[1] if((missile_part.fits_type && !istype(missile_target, missile_part.fits_type)) || missile_target.state != missile_part.target_state) visible_message("[src] sighs.") - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.5 SECONDS return trigger_arm_animation() do_item_attack_animation(missile_target, used_item = missile_part) @@ -183,18 +204,22 @@ missile_part.forceMove(missile_target) held_components -= missile_part missile_target.check_completion() - do_sparks(4, TRUE, missile_target) - playsound(src, 'sound/machines/ping.ogg', 50, 0) + if(world.time >= next_success_sound) + do_sparks(4, TRUE, missile_target) + playsound(src, 'sound/machines/ping.ogg', 50, 0) + next_success_sound = world.time + 0.2 SECONDS if(/obj/item/ship_weapon/ammunition/torpedo/torpedo_casing) var/obj/item/ship_weapon/ammunition/torpedo/torpedo_casing/torpedo_target = entering if(!length(held_components)) - visible_message("[src] sighs.") - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.5 SECONDS return var/obj/item/ship_weapon/parts/missile/torpedo_part = held_components[1] if((torpedo_part.fits_type && !istype(torpedo_target, torpedo_part.fits_type)) || torpedo_target.state != torpedo_part.target_state) - visible_message("[src] sighs.") - playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + if(world.time >= next_fail_sound) + playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0) + next_fail_sound = world.time + 0.5 SECONDS return trigger_arm_animation() do_item_attack_animation(torpedo_target, used_item = torpedo_part) @@ -203,8 +228,10 @@ torpedo_part.forceMove(torpedo_target) held_components -= torpedo_part torpedo_target.check_completion() - do_sparks(4, TRUE, torpedo_target) - playsound(src, 'sound/machines/ping.ogg', 50, 0) + if(world.time >= next_success_sound) + do_sparks(4, TRUE, torpedo_target) + playsound(src, 'sound/machines/ping.ogg', 50, 0) + next_success_sound = world.time + 0.2 SECONDS else CRASH("Please stop handing the missile assemblers invalid types as valid ammunition. Type: [entering.type]. ALL valid casings must be missile or torpedo types.") @@ -229,8 +256,10 @@ desc = "An assembly arm which can slot a multitude of missile components into casings for you! Swipe it with an ID to release its stored components." req_one_access = list(ACCESS_MUNITIONS) circuit = /obj/item/circuitboard/machine/missile_builder/assembler - //Currently loaded missile components. + ///Currently loaded missile components. var/list/held_components = list() + ///Currently tracked type for autopickup + var/tracked_component_type = null /obj/machinery/missile_builder/assembler/examine(mob/user) . = ..() @@ -255,11 +284,13 @@ to_chat(user, "You slot [I] into [src], ready for construction.") I.forceMove(src) held_components += I + tracked_component_type = I.type if(istype(I, /obj/item/card/id) && allowed(user)) to_chat(user, "You dump [src]'s contents out.") for(var/obj/item/X in held_components) X.forceMove(get_turf(src)) held_components -= X + tracked_component_type = null /obj/machinery/missile_builder/assembler/MouseDrop_T(obj/structure/A, mob/user) . = ..()