From a18fbaac1d22ba31c3a72d840de6c90c29ee2248 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Fri, 11 Oct 2013 22:17:45 +0400 Subject: [PATCH] Cover system. Tables now give some cover from bullets and beams. Standing behind the table gives you 20% chance of table taking the hit instead. Flipped table gives +20%, but only if bullet comes from the side it faces. Otherwise no cover is provided at all. Lying on the floor gives +20%. Table takes half of damage human would, and breaks down after its health goes to zero. Reinforced talbes have double the health, wooden ones - half. --- code/game/objects/structures/tables_racks.dm | 38 ++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) 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