Cleanup, move towards explosions at different z positions
This commit is contained in:
@@ -64,7 +64,7 @@ shellExplosionCheck pj w
|
||||
time = _pjTimer pj
|
||||
|
||||
shellHitWall :: Point3 -> Point3 -> Wall -> Projectile -> World -> World
|
||||
shellHitWall p' n wl pj w
|
||||
shellHitWall p' _ wl pj w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
@@ -84,28 +84,27 @@ shellHitWall p' n wl pj w
|
||||
p = xyV3 p'
|
||||
hitline = normalizeV $ uncurry (-) $ _wlLine wl
|
||||
|
||||
shellHitCreature :: Point3 -> Point3 -> Creature -> Projectile -> World -> World
|
||||
shellHitCreature p' n cr pj w
|
||||
shellHitCreature :: Point3 -> Creature -> Projectile -> World -> World
|
||||
shellHitCreature p cr pj w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
.~ Grenade
|
||||
( GStuckCreature
|
||||
(cr ^. crID)
|
||||
(rotate3z (- cr ^. crDir) (p' - ((cr ^. crPos)`v2z`0)))
|
||||
(rotate3z (- cr ^. crDir) (p - ((cr ^. crPos)`v2z`0)))
|
||||
(pj ^. pjDir - cr ^. crDir)
|
||||
)
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos . _xy)
|
||||
| otherwise = w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjPos .~ p'
|
||||
| otherwise = w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjTimer .~ 0
|
||||
where
|
||||
p = xyV3 p'
|
||||
|
||||
shellHitFloor :: Point3 -> Point3 -> Projectile -> World -> World
|
||||
shellHitFloor p' n pj w
|
||||
shellHitFloor :: Point3 -> Projectile -> World -> World
|
||||
shellHitFloor p' pj w
|
||||
| z < 1 && norm (_pjVel pj) < 1 = w
|
||||
| otherwise =
|
||||
w & topj . pjPos . _z .~ 0.1
|
||||
w
|
||||
& topj . pjPos .~ (p' & _z .~ 0.1)
|
||||
& topj . pjVel . _z %~ bouncez
|
||||
& topj . pjVel . _xy %~ decvel
|
||||
& topj . pjSpin %~ decspin
|
||||
@@ -244,14 +243,9 @@ pjRemoteSetDirection ph pj w = case ph of
|
||||
where
|
||||
lw = w ^. cWorld . lWorld
|
||||
|
||||
moveStuckGrenade :: Creature -> Point3 -> Float -> Projectile -> World -> World
|
||||
moveStuckGrenade cr p d pj w = w
|
||||
|
||||
moveProjectile :: Projectile -> World -> World
|
||||
moveProjectile pj w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just (GStuckCreature crid poff d) <- pj ^? pjType . gnHitEffect
|
||||
, Just cr <- w ^? cWorld . lWorld . creatures . ix crid =
|
||||
moveStuckGrenade :: Int -> Point3 -> Float -> Projectile -> World -> World
|
||||
moveStuckGrenade cid poff d pj w
|
||||
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid =
|
||||
let cpos = cr ^. crPos
|
||||
cdir = cr ^. crDir
|
||||
vel = cpos - cr ^. crOldPos
|
||||
@@ -260,21 +254,30 @@ moveProjectile pj w
|
||||
.~ xyV3 ((cpos `v2z` 0) + rotate3z cdir poff)
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir .~ d + cdir
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjVel . _xy .~ vel
|
||||
| Just GStuckCreature{} <- pj ^? pjType . gnHitEffect =
|
||||
| otherwise =
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick
|
||||
| (p,Just (n,OWall wl)) <- collide3 p (p + _pjVel pj) w
|
||||
|
||||
moveProjectile :: Projectile -> World -> World
|
||||
moveProjectile pj w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just (GStuckCreature crid poff d) <- pj ^? pjType . gnHitEffect
|
||||
= moveStuckGrenade crid poff d pj w
|
||||
| (p,Just (n,OWall wl)) <- collide3 sp (sp + _pjVel pj) w
|
||||
= shellHitWall p n wl pj w
|
||||
| (p,Just (n,OFloor)) <- collide3 p (p + _pjVel pj) w
|
||||
= shellHitFloor p n pj w
|
||||
| (p,Just (n,OCreature cr)) <- collide3 p (p + _pjVel pj) w
|
||||
= shellHitCreature p n cr pj w
|
||||
| (p,Just (_,OFloor)) <- collide3 sp (sp + _pjVel pj) w
|
||||
= shellHitFloor p pj w
|
||||
| (p,Just (_,OCreature cr)) <- collide3 sp (sp + _pjVel pj) w
|
||||
= shellHitCreature p cr pj w
|
||||
| (_,Just (_,OChasmWall)) <- collide3 sp (sp + _pjVel pj) w
|
||||
-- no stick or bounce for now
|
||||
= w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjTimer .~ 0
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjSpin *~ 0.99
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos +~ _pjVel pj
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir +~ _pjSpin pj
|
||||
where
|
||||
p = _pjPos pj
|
||||
sp = _pjPos pj
|
||||
|
||||
explodeShell :: Projectile -> World -> World
|
||||
explodeShell pj w =
|
||||
|
||||
Reference in New Issue
Block a user