From ff3c5238aaa6c4139037cfdd9f62b1f366f3238a Mon Sep 17 00:00:00 2001 From: Leshana Date: Thu, 13 Apr 2017 22:09:46 -0400 Subject: [PATCH] De-snowflake thrown objects hitting turfs. * Port of https://github.com/Baystation12/Baystation12/pull/16942 * Actually tell turfs when a thrown object hits them, and let them decide what to do about it! * We do this by calling hitby(), which is how it already works for obj and mob, so this makes behavior consistent. * This allows us to cleanly solve the problem of a thrown object landing on open space without falling. --- code/game/atoms_movable.dm | 7 +------ code/game/turfs/turf.dm | 8 ++++++++ code/modules/multiz/turf.dm | 5 +++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index b511c9befd..fe9f99b032 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -115,12 +115,7 @@ else if(isturf(hit_atom)) src.throwing = 0 var/turf/T = hit_atom - if(T.density) - spawn(2) - step(src, turn(src.last_move, 180)) - if(istype(src,/mob/living)) - var/mob/living/M = src - M.turf_collision(T, speed) + T.hitby(src,speed) //decided whether a movable atom being thrown can pass through the turf it is in. /atom/movable/proc/hit_check(var/speed) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index c13b4606d3..028223ef26 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -243,3 +243,11 @@ var/const/enterloopsanity = 100 /turf/proc/update_blood_overlays() return +// Called when turf is hit by a thrown object +/turf/hitby(atom/movable/AM as mob|obj, var/speed) + if(src.density) + spawn(2) + step(AM, turn(AM.last_move, 180)) + if(isliving(AM)) + var/mob/living/M = AM + M.turf_collision(src, speed) diff --git a/code/modules/multiz/turf.dm b/code/modules/multiz/turf.dm index caa859f369..b6845d076f 100644 --- a/code/modules/multiz/turf.dm +++ b/code/modules/multiz/turf.dm @@ -36,6 +36,11 @@ ..() mover.fall() +// Called when thrown object lands on this turf. +/turf/simulated/open/hitby(var/atom/movable/AM, var/speed) + . = ..() + AM.fall() + /turf/simulated/open/proc/update() below = GetBelow(src) turf_changed_event.register(below, src, /turf/simulated/open/update_icon)