From fa5049ca856e94788c185a3f1f6d5386fde1dad3 Mon Sep 17 00:00:00 2001 From: Aranclanos Date: Thu, 4 Jul 2013 10:33:52 -0300 Subject: [PATCH] Windows have a new proc, can_be_reached(), it will check if there's an object blocking the way on the turf if a mob clicks on the window. It will make some pretty dir checks and then use CanPass(). And before it starts, it checks if it's a full tile window too. --- code/game/objects/structures/window.dm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 5fa32b1e03a..61e863bd604 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -98,6 +98,8 @@ /obj/structure/window/attack_hand(mob/user as mob) + if(!can_be_reached(user)) + return if(HULK in user.mutations) user.say(pick(";RAAAAAAAARGH!", ";HNNNNNNNNNGGGGGGH!", ";GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", ";AAAAAAARRRGH!")) user.visible_message("[user] smashes through [src]!") @@ -114,6 +116,8 @@ /obj/structure/window/proc/attack_generic(mob/user as mob, damage = 0) //used by attack_alien, attack_animal, and attack_slime + if(!can_be_reached(user)) + return health -= damage if(health <= 0) user.visible_message("[user] smashes through [src]!") @@ -142,6 +146,8 @@ /obj/structure/window/attackby(obj/item/I, mob/user) + if(!can_be_reached(user)) + return 1 //returning 1 will skip the afterattack() if(istype(I, /obj/item/weapon/screwdriver)) if(reinf && state >= 1) state = 3 - state @@ -173,6 +179,14 @@ ..() return +/obj/structure/window/proc/can_be_reached(mob/user) + if(!is_fulltile()) + if(get_dir(user,src) & dir) + for(var/obj/O in loc) + if(!O.CanPass(user, user.loc, 1, 0)) + return 0 + return 1 + /obj/structure/window/proc/hit(var/damage, var/sound_effect = 1) if(reinf) damage *= 0.5 health = max(0, health - damage)