Continue weapon effect chain work
Start work on using muzzles to determine the effect of the ammo when loaded
This commit is contained in:
+39
-38
@@ -1,6 +1,6 @@
|
||||
module Dodge.Bullet (
|
||||
updateBullet,
|
||||
shootBullet,
|
||||
-- shootBullet,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
@@ -58,43 +58,44 @@ updateBulVel bt = case _buTrajectory bt of
|
||||
where
|
||||
t = _buTimer bt
|
||||
|
||||
shootBullet :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
shootBullet itm cr w = fromMaybe (error "cannot find bullet ammo when expected to") $ do
|
||||
atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
|
||||
leftitms <- itm ^? ldtLeft
|
||||
mag <- lookup (AmmoInLink 0 atype) leftitms
|
||||
thebullet <- mag ^? ldtValue . itUse . amagParams . ampBullet
|
||||
return $ w
|
||||
& randGen .~ g'
|
||||
& cWorld . lWorld . instantBullets
|
||||
.:~ ( thebullet
|
||||
& buPos .~ _crPos cr
|
||||
& buTrajectory %~ settrajectory
|
||||
& buVel %~ (rotateV dir . (muzvel *.*))
|
||||
& buDrag *~ drag
|
||||
)
|
||||
where
|
||||
it = itm ^. ldtValue
|
||||
sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
(drag,g) = case _rifling (_heldParams $ _itUse it) of
|
||||
ConstFloat x -> (x, _randGen w)
|
||||
UniRandFloat x y -> randomR (x,y) $ _randGen w
|
||||
(muzvel,g') = case _muzVel $ _heldParams $ _itUse it of
|
||||
ConstFloat x -> (x,g)
|
||||
UniRandFloat x y -> randomR (x,y) $ _randGen w
|
||||
muzlength = aimingMuzzlePos cr it
|
||||
settrajectory traj = case traj of
|
||||
BasicBulletTrajectory -> BasicBulletTrajectory
|
||||
MagnetTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||
tpos <- cr ^? crTargeting . ctPos . _Just
|
||||
return $ MagnetTrajectory tpos
|
||||
FlechetteTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||
tpos <- cr ^? crTargeting . ctPos . _Just
|
||||
return $ FlechetteTrajectory tpos
|
||||
BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||
tpos <- cr ^? crTargeting . ctPos . _Just
|
||||
return $ BezierTrajectory sp tpos (mouseWorldPos (w ^. input) (w ^. wCam))
|
||||
-- NOTE THE FOLLOWING HAS BEZIER CURE/FLECHETTE STUFF THAT MIGHT BE USEFUL
|
||||
--shootBullet :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
--shootBullet itm cr w = fromMaybe (error "cannot find bullet ammo when expected to") $ do
|
||||
-- atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
|
||||
-- leftitms <- itm ^? ldtLeft
|
||||
-- mag <- lookup (AmmoInLink 0 atype) leftitms
|
||||
-- thebullet <- mag ^? ldtValue . itUse . amagParams . ampBullet
|
||||
-- return $ w
|
||||
-- & randGen .~ g'
|
||||
-- & cWorld . lWorld . instantBullets
|
||||
-- .:~ ( thebullet
|
||||
-- & buPos .~ _crPos cr
|
||||
-- & buTrajectory %~ settrajectory
|
||||
-- & buVel %~ (rotateV dir . (muzvel *.*))
|
||||
-- & buDrag *~ drag
|
||||
-- )
|
||||
-- where
|
||||
-- it = itm ^. ldtValue
|
||||
-- sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
|
||||
-- dir = _crDir cr
|
||||
-- (drag,g) = case _rifling (_heldParams $ _itUse it) of
|
||||
-- ConstFloat x -> (x, _randGen w)
|
||||
-- UniRandFloat x y -> randomR (x,y) $ _randGen w
|
||||
-- (muzvel,g') = case _muzVel $ _heldParams $ _itUse it of
|
||||
-- ConstFloat x -> (x,g)
|
||||
-- UniRandFloat x y -> randomR (x,y) $ _randGen w
|
||||
-- muzlength = aimingMuzzlePos cr it
|
||||
-- settrajectory traj = case traj of
|
||||
-- BasicBulletTrajectory -> BasicBulletTrajectory
|
||||
-- MagnetTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||
-- tpos <- cr ^? crTargeting . ctPos . _Just
|
||||
-- return $ MagnetTrajectory tpos
|
||||
-- FlechetteTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||
-- tpos <- cr ^? crTargeting . ctPos . _Just
|
||||
-- return $ FlechetteTrajectory tpos
|
||||
-- BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||
-- tpos <- cr ^? crTargeting . ctPos . _Just
|
||||
-- return $ BezierTrajectory sp tpos (mouseWorldPos (w ^. input) (w ^. wCam))
|
||||
|
||||
bounceDir :: (Point2, Either Creature Wall) -> Maybe Point2
|
||||
bounceDir (_, Right wl) | _wlBouncy wl = Just $ uncurry (-.-) (_wlLine wl)
|
||||
|
||||
Reference in New Issue
Block a user