Allow bullets to fire above corspes

This commit is contained in:
2025-10-08 10:00:29 +01:00
parent 1e73565900
commit 031f07f14c
3 changed files with 88 additions and 59 deletions
+24
View File
@@ -5,6 +5,7 @@ Find which objects lie upon a line.
-}
module Dodge.WorldEvent.ThingsHit (
thingsHit,
thingsHitZ,
thingHit,
thingHitFilt,
thingsHitExceptCr,
@@ -38,6 +39,14 @@ thingsHit sp ep w =
(map (second Left) (crsHit sp ep w))
(map (second Right) (wlsHit sp ep w))
{- Does not hit corpses -}
thingsHitZ :: Point2 -> Point2 -> World -> [(Point2, Either Creature Wall)]
thingsHitZ sp ep w =
List.mergeOn
(dist sp . fst)
(map (second Left) (crsHitZ sp ep w))
(map (second Right) (wlsHit sp ep w))
crWlPbHit :: Point2 -> Point2 -> World -> [(Point2, Object)]
crWlPbHit sp ep w =
List.mergeOn
@@ -59,6 +68,21 @@ crsHit sp ep w
. crixsNearSeg sp ep
$ w
crsHitZ :: Point2 -> Point2 -> World -> [(Point2, Creature)]
crsHitZ sp ep w
| sp == ep = mempty
| otherwise =
sortOn (dist sp . fst)
. overlapSegCrs sp ep
. mapMaybe (\cid -> f =<< w ^? cWorld . lWorld . creatures . ix cid)
. IS.toList
. crixsNearSeg sp ep
$ w
where
f cr
| HP{} <- cr ^. crHP = Just cr
| otherwise = Nothing
pbsHit :: Point2 -> Point2 -> World -> [(Point2, PulseBall)]
pbsHit sp ep w
| sp == ep = mempty