Improve sticky grenades
This commit is contained in:
@@ -19,7 +19,7 @@ data ProjectileUpdate
|
||||
= ThrustPU {_pjuStart :: Int, _pjuEnd :: Int}
|
||||
| StartSpinPU {_pjuTime :: Int, _pjuCID :: Int, _pjuSpinAmound :: Int}
|
||||
| RemoteDirectionPU {_pjuStart :: Int, _pjuEnd :: Int}
|
||||
| ApplyGravityPU
|
||||
-- | ApplyGravityPU
|
||||
deriving (Show, Eq, Ord, Read) --Generic, Flat)
|
||||
|
||||
data AmmoType
|
||||
|
||||
@@ -60,7 +60,7 @@ createShell mdetonator mscreen stab pjtype payload muz cr w = w
|
||||
RetiredProjectile -> 0
|
||||
lifespan = 350
|
||||
thrustorgrav = case pjtype of
|
||||
Grenade {}-> [ApplyGravityPU]
|
||||
Grenade {}-> []
|
||||
Rocket{} -> [ThrustPU (lifespan - thrustdelay) 0]
|
||||
RetiredProjectile -> []
|
||||
thrustdelay = 20
|
||||
|
||||
@@ -28,6 +28,7 @@ updateProjectile pj w =
|
||||
. pjMovement pj
|
||||
. shellCollisionCheck
|
||||
pj
|
||||
. doGravityPU pj
|
||||
$ foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
|
||||
|
||||
upProjectile :: Projectile -> ProjectileUpdate -> World -> World
|
||||
@@ -41,12 +42,17 @@ upProjectile pj pu = case pu of
|
||||
RemoteDirectionPU st et
|
||||
| act st et -> pjRemoteSetDirection (pj ^? pjType . rkHoming) pj
|
||||
| otherwise -> id
|
||||
-- ReduceSpinPU x -> reduceSpinBy x (_pjID pj)
|
||||
ApplyGravityPU -> applyGravityPU pj
|
||||
-- ApplyGravityPU -> applyGravityPU pj
|
||||
where
|
||||
time = _pjTimer pj
|
||||
act st et = time <= st && time >= et
|
||||
|
||||
doGravityPU :: Projectile -> World -> World
|
||||
doGravityPU pj
|
||||
| Grenade GBounce {} <- pj ^. pjType = applyGravityPU pj
|
||||
| Grenade GStick <- pj ^. pjType = applyGravityPU pj
|
||||
| otherwise = id
|
||||
|
||||
applyGravityPU :: Projectile -> World -> World
|
||||
applyGravityPU pj w
|
||||
| newz <= 0 && abs (pj ^. pjZVel) < 1 =
|
||||
@@ -103,7 +109,7 @@ tryShellBounce (p, Right wl) pj w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect = w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
.~ Grenade (GStuckWall (wl ^. wlStructure))
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
|
||||
| Just x <- pj ^? pjType . gnHitEffect . bounceTolerance =
|
||||
if abs (dotV (pj ^. pjVel) (vNormal hitline)) < x
|
||||
@@ -126,7 +132,7 @@ tryShellBounce (p, Left cr) pj w
|
||||
(rotateV (- cr ^. crDir) (p - cr ^. crPos))
|
||||
(pj ^. pjDir - cr ^. crDir)
|
||||
)
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
|
||||
tryShellBounce _ pj w = explodeShell pj w
|
||||
|
||||
@@ -203,14 +209,16 @@ pjRemoteSetDirection ph pj w = case ph of
|
||||
pjMovement :: Projectile -> World -> World
|
||||
pjMovement pj w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just (GStuckCreature crid p d) <- pj ^? pjType . gnHitEffect = fromMaybe w $ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix crid . crPos
|
||||
cdir <- w ^? cWorld . lWorld . creatures . ix crid . crDir
|
||||
return $
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos
|
||||
.~ cpos + rotateV cdir p
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
|
||||
.~ d + cdir
|
||||
| Just (GStuckCreature crid p d) <- pj ^? pjType . gnHitEffect = fromMaybe
|
||||
(w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick)
|
||||
$ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix crid . crPos
|
||||
cdir <- w ^? cWorld . lWorld . creatures . ix crid . crDir
|
||||
return $
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos
|
||||
.~ cpos + rotateV cdir p
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
|
||||
.~ d + cdir
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjSpin *~ 0.99
|
||||
|
||||
Reference in New Issue
Block a user