Work on rocket/grenade launcher

This commit is contained in:
2024-12-27 21:46:46 +00:00
parent 0ef28c132e
commit 5c749bff63
19 changed files with 400 additions and 324 deletions
+11 -8
View File
@@ -3,6 +3,7 @@ module Dodge.Projectile.Update (
updateProjectile,
) where
import Data.List (delete)
import LensHelp
import Control.Monad
import Data.Foldable
@@ -28,8 +29,8 @@ upProjectile pu pj = case pu of
CollisionEffectPU mcontrolid mdetonatorid mscreenid -> shellCollisionCheck
mcontrolid mdetonatorid mscreenid pj
TimePU -> decTimMvVel pj
ThrustPU st et
| act st et -> doThrust pj
ThrustPU st et smoke
| act st et -> doThrust pj smoke
| otherwise -> id
StartSpinPU t cid spinamount
| time == t -> trySpinByCID cid spinamount pj
@@ -100,20 +101,22 @@ destroyProjectile mitid pjid w =
guard $ itm == pjid
return $ pointerToItemLocation loc . itUse . uaParams . apLinkedProjectile .~ Nothing
doThrust :: Projectile -> World -> World
doThrust pj w =
doThrust :: Projectile -> Bool -> World -> World
doThrust pj smoke w =
w
& randGen .~ g
& cWorld . lWorld . projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v)
& soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
& makeFlamelet (oldPos -.- vel) (vel +.+ rotateV (pi + sparkD) accel) 3 10
& shellTrailCloud
trailage
lifetime
trailfadetime
(addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)))
where
trailage = fst . randomR (300, 500) $ _randGen w
trailfadetime = fst . randomR (100, 300) $ _randGen w
lifetime = fst . randomR lt $ _randGen w
lt | smoke = (50, 200)
| otherwise = (300,500)
trailfadetime = fst . randomR (100,300) $ _randGen w
accel = _prjAcc pj
i = _prjID pj
oldPos = _prjPos pj
@@ -198,7 +201,7 @@ explodeShell controlid mdetid screenid pj w =
where
updatedetonator = fromMaybe id $ do
detid <- mdetid
return $ pointerToItemID detid . itUse . uaParams . apLinkedProjectile %~ deleteif
return $ pointerToItemID detid . itUse . uaParams . apProjectiles %~ delete pjid
deleteif (Just x) | x == pjid = Nothing
deleteif x = x
updatecontroller = fromMaybe id $ do