diff --git a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm
index 4791b1f5dba..23c296da7f6 100644
--- a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm
+++ b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm
@@ -25,38 +25,47 @@
AddComponent(/datum/component/butchering, 50, 100, null, null, TRUE)
/obj/item/mecha_parts/mecha_equipment/drill/action(mob/source, atom/target, params)
+ // Check if we can even use the equipment to begin with.
if(!action_checks(target))
return
- if(isspaceturf(target))
+
+ // We can only drill non-space turfs, living mobs and objects.
+ if(isspaceturf(target) || !isliving(target) || !isobj(target) || !isturf(target))
return
+
+ // For whatever reason we can't drill things that acid won't even stick too, and probably
+ // shouldn't waste our time drilling indestructible things.
if(isobj(target))
var/obj/target_obj = target
- if(target_obj.resistance_flags & UNACIDABLE)
+ if(target_obj.resistance_flags & (UNACIDABLE | INDESTRUCTIBLE))
return
+
target.visible_message("[chassis] starts to drill [target].", \
"[chassis] starts to drill [target]...", \
"You hear drilling.")
if(do_after_cooldown(target, source))
log_message("Started drilling [target]", LOG_MECHA)
+ // Drilling a turf is a one-and-done procedure.
if(isturf(target))
var/turf/T = target
T.drill_act(src, source)
- return
+ return ..()
+ // Drilling objects and mobs is a repeating procedure.
while(do_after_mecha(target, source, drill_delay))
if(isliving(target))
drill_mob(target, source)
playsound(src,'sound/weapons/drill.ogg',40,TRUE)
- // If we gibbed the target by drilling them, we can stop drilling them.
- // Prevents starting a do_after on a qdeleted target.
- if(QDELETED(target))
- break
else if(isobj(target))
var/obj/O = target
O.take_damage(15, BRUTE, 0, FALSE, get_dir(chassis, target))
playsound(src,'sound/weapons/drill.ogg',40,TRUE)
- else
- return
+
+ // If we caused a qdel drilling the target, we can stop drilling them.
+ // Prevents starting a do_after on a qdeleted target.
+ if(QDELETED(target))
+ break
+
return ..()
/turf/proc/drill_act(obj/item/mecha_parts/mecha_equipment/drill/drill, mob/user)