Skip to content

Commit

Permalink
re-introduces muzzle los check
Browse files Browse the repository at this point in the history
  • Loading branch information
Doubleumc committed Nov 8, 2023
1 parent df3df8e commit afbb80b
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions code/modules/vehicles/hardpoints/hardpoint.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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----------
Expand Down Expand Up @@ -613,6 +610,10 @@
to_chat(user, SPAN_WARNING("<b>The target is not within your firing arc!</b>"))
return NONE

if(!clear_los())
to_chat(user, SPAN_WARNING("<b>The muzzle is obstructed!</b>"))
return NONE

return handle_fire(target, user, params)

/// Actually fires the gun, sets up the projectile and fires it.
Expand Down

0 comments on commit afbb80b

Please sign in to comment.