Start implementing sticky grenades
This commit is contained in:
@@ -14,6 +14,7 @@ import Dodge.Movement.Turn
|
||||
import Dodge.Payload
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.WorldEvent.Cloud
|
||||
import Dodge.WorldEvent.Sound
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -23,8 +24,9 @@ import RandomHelp
|
||||
|
||||
updateProjectile :: Projectile -> World -> World
|
||||
updateProjectile pj w =
|
||||
(cWorld . lWorld . projectiles . ix (pj ^. pjID) %~
|
||||
decTimMvVel)
|
||||
( cWorld . lWorld . projectiles . ix (pj ^. pjID)
|
||||
%~ decTimMvVel
|
||||
)
|
||||
. shellCollisionCheck
|
||||
pj
|
||||
$ foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
|
||||
@@ -83,10 +85,10 @@ shellCollisionCheck pj w
|
||||
| RetiredProjectile <- pj ^. pjType
|
||||
, time <= 0 =
|
||||
destroyProjectile (pj ^. pjScreenID) (_pjID pj) w
|
||||
| time <= 0 = g
|
||||
| RetiredProjectile <- pj ^. pjType = w
|
||||
| Just thit <- thingHit oldPos (oldPos + _pjVel pj) w = tryShellBounce thit pj w
|
||||
-- | anythingHitCirc 2 oldPos (oldPos + _pjVel pj) w = g
|
||||
| time <= 0 = g
|
||||
| otherwise = w
|
||||
where
|
||||
g = explodeShell pj w
|
||||
@@ -97,12 +99,20 @@ shellCollisionCheck pj w
|
||||
-- bouncing in some way
|
||||
tryShellBounce :: (Point2, Either Creature Wall) -> Projectile -> World -> World
|
||||
tryShellBounce (p, Right wl) pj w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect = w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect =
|
||||
w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjType .~ Grenade
|
||||
(GStuckWall (wl ^. wlID))
|
||||
& 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
|
||||
then w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjVel %~ reflectIn
|
||||
hitline
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjPos .~ p
|
||||
then
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjVel
|
||||
%~ reflectIn
|
||||
hitline
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjPos .~ p
|
||||
& soundStart (ShellSound (pj ^. pjID)) (pj ^. pjPos) click1S Nothing
|
||||
else explodeShell pj w
|
||||
where
|
||||
@@ -180,12 +190,14 @@ pjRemoteSetDirection ph pj w = case ph of
|
||||
lw = w ^. cWorld . lWorld
|
||||
|
||||
decTimMvVel :: Projectile -> Projectile
|
||||
decTimMvVel pj = pj
|
||||
& pjSpin *~ 0.99
|
||||
& pjTimer -~ 1
|
||||
& pjPos +~ _pjVel pj
|
||||
& pjDir +~ _pjSpin pj
|
||||
|
||||
decTimMvVel pj
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = pj & pjTimer -~ 1
|
||||
| otherwise =
|
||||
pj
|
||||
& pjSpin *~ 0.99
|
||||
& pjTimer -~ 1
|
||||
& pjPos +~ _pjVel pj
|
||||
& pjDir +~ _pjSpin pj
|
||||
|
||||
explodeShell ::
|
||||
Projectile ->
|
||||
|
||||
Reference in New Issue
Block a user