Implement pulse rifle with explodable pulse balls

This commit is contained in:
2025-07-27 11:10:30 +01:00
parent 68a4bc7aab
commit f1fb0ee768
19 changed files with 190 additions and 108 deletions
+1
View File
@@ -48,6 +48,7 @@ itemAboveAttachables (itm,sf) = case (itm ^. itType, sf) of
itemBelowAttachables :: CItem -> [ItemSF]
itemBelowAttachables (itm,sf) = case (itm ^. itType, sf) of
(HELD LASER, _) -> getAmmoLinks itm <> [PulseBallSF]
--(HELD LASER, _) -> [PulseBallSF]
(HELD TORCH, _) -> getAmmoLinks itm
(ATTACH CAPACITOR, _) -> [AmmoMagSF 0 ElectricalAmmo]
(ATTACH UNDERBARRELSLOT, _) -> [UnderBarrelPlatformSF]
+29
View File
@@ -1,7 +1,10 @@
module Dodge.Item.Weapon.LaserPath (
reflectLaserAlong,
reflectPulseLaserAlong,
) where
import Dodge.Data.Object
import Data.Maybe
import Data.Bifunctor
import Data.Tuple
import Dodge.Base.Wall
@@ -61,3 +64,29 @@ refract phasev x y wl p
| otherwise = asin $ phasev * sin angleInc'
reflectInternal = 1 < abs (phasev * sin angleInc')
reflectExternal = 1 < abs (sin angleInc / phasev)
reflectPulseLaserAlong :: Float -> Point2 -> Point2 -> World ->
(Maybe (Point2, Object), [Point2])
{-# INLINE reflectPulseLaserAlong #-}
reflectPulseLaserAlong phasev sp ep w = case listToMaybe . filter (isunshad . snd) $ crWlPbHit sp ep w of
Just (p, OWall wl)
| _wlReflect wl ->
second (p :) $
reflectPulseLaserAlong
phasev
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
(p +.+ dist p ep *.* unitVectorAtAngle (reflDirWall sp p wl))
w
| wlIsSeeThrough wl ->
second (p :) $
reflectPulseLaserAlong
phasev
(p +.+ normalizeV (refract phasev sp ep wl p))
(refract phasev sp ep wl p)
w
| otherwise -> (Just (p, OWall wl), [p])
Just (p, obj) -> (Just (p, obj), [p])
Nothing -> (Nothing, [ep])
where
isunshad (OWall wl) = _wlUnshadowed wl
isunshad _ = True