diff --git a/code/modules/vehicles/hardpoints/hardpoint.dm b/code/modules/vehicles/hardpoints/hardpoint.dm
index d23d43f343..2a7ca11151 100644
--- a/code/modules/vehicles/hardpoints/hardpoint.dm
+++ b/code/modules/vehicles/hardpoints/hardpoint.dm
@@ -300,14 +300,12 @@
return data
-/*
-// Traces backwards from the gun origin to the vehicle to check for obstacles between the vehicle and the muzzle
-/obj/item/hardpoint/proc/clear_los(atom/A)
-
+/// Traces backwards from the gun origin to the vehicle to check for obstacles between the vehicle and the muzzle.
+/obj/item/hardpoint/proc/clear_los()
if(origins[1] == 0 && origins[2] == 0) //skipping check for modules we don't need this
return TRUE
- var/turf/muzzle_turf = locate(owner.x + origins[1], owner.y + origins[2], owner.z)
+ var/turf/muzzle_turf = get_origin_turf()
var/turf/checking_turf = muzzle_turf
while(!(owner in checking_turf))
@@ -316,31 +314,30 @@
return FALSE
// Ensure that we can pass over all objects in the turf
- for(var/obj/O in checking_turf)
+ for(var/obj/object in checking_turf)
// Since vehicles are multitile the
- if(O == owner)
+ if(object == owner)
continue
// Non-dense objects are irrelevant
- if(!O.density)
+ if(!object.density)
continue
// Make sure we can pass object from all directions
- if(!(O.pass_flags.flags_can_pass_all & PASS_OVER_THROW_ITEM))
- if(!(O.flags_atom & ON_BORDER))
+ if(!HAS_FLAG(object.pass_flags.flags_can_pass_all, PASS_OVER_THROW_ITEM))
+ if(!HAS_FLAG(object.flags_atom, ON_BORDER))
return FALSE
//If we're behind the object, check the behind pass flags
- else if(dir == O.dir && !(O.pass_flags.flags_can_pass_behind & PASS_OVER_THROW_ITEM))
+ else if(dir == object.dir && !HAS_FLAG(object.pass_flags.flags_can_pass_behind, PASS_OVER_THROW_ITEM))
return FALSE
//If we're in front, check front pass flags
- else if(dir == turn(O.dir, 180) && !(O.pass_flags.flags_can_pass_front & PASS_OVER_THROW_ITEM))
+ else if(dir == turn(object.dir, 180) && !HAS_FLAG(object.pass_flags.flags_can_pass_front, PASS_OVER_THROW_ITEM))
return FALSE
// Trace back towards the vehicle
checking_turf = get_step(checking_turf, turn(dir,180))
return TRUE
-*/
//-----------------------------
//------INTERACTION PROCS----------
@@ -613,6 +610,10 @@
to_chat(user, SPAN_WARNING("The target is not within your firing arc!"))
return NONE
+ if(!clear_los())
+ to_chat(user, SPAN_WARNING("The muzzle is obstructed!"))
+ return NONE
+
return handle_fire(target, user, params)
/// Actually fires the gun, sets up the projectile and fires it.