diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm
index 6bb59e936a1..84bb23a5746 100644
--- a/code/game/objects/structures/tables_racks.dm
+++ b/code/game/objects/structures/tables_racks.dm
@@ -289,16 +289,7 @@
/obj/structure/table/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(air_group || (height==0)) return 1
if(istype(mover,/obj/item/projectile))
- var/obj/item/projectile/P = mover
- if(flipped & prob(20))
- health -= P.damage
- if (health > 0)
- visible_message("[P] hits \the [src]!")
- return 0
- else
- visible_message("[src] breaks down!")
- destroy()
- return 1
+ return (check_cover(mover,target))
if(istype(mover) && mover.checkpass(PASSTABLE))
return 1
if (flipped)
@@ -308,6 +299,33 @@
return 1
return 0
+//checks if projectile 'P' from turf 'from' can hit whatever is behind the table. Returns 1 if it can, 0 if bullet stops.
+/obj/structure/table/proc/check_cover(obj/item/projectile/P, turf/from)
+ var/turf/cover = flipped ? get_turf(src) : get_step(loc, get_dir(from, loc))
+ if (get_dist(P.starting, loc) <= 1) //Tables won't help you if people are THIS close
+ return 1
+ if (get_turf(P.original) == cover)
+ var/chance = 20
+ if (ismob(P.original))
+ var/mob/M = P.original
+ if (M.lying)
+ chance += 20 //Lying down lets you catch less bullets
+ if(flipped)
+ if(get_dir(loc, from) == dir) //Flipped tables catch mroe bullets
+ chance += 20
+ else
+ return 1 //But only from one side
+ if(prob(chance))
+ health -= P.damage/2
+ if (health > 0)
+ visible_message("[P] hits \the [src]!")
+ return 0
+ else
+ visible_message("[src] breaks down!")
+ destroy()
+ return 1
+ return 1
+
/obj/structure/table/CheckExit(atom/movable/O as mob|obj, target as turf)
if(istype(O) && O.checkpass(PASSTABLE))
return 1