Work on Falling carriage type
This commit is contained in:
@@ -36,7 +36,7 @@ hoverCrit :: Creature
|
||||
hoverCrit =
|
||||
defaultCreature
|
||||
& crName .~ "hoverCrit"
|
||||
& crHP .~ HP 1000
|
||||
& crHP .~ HP 500
|
||||
& crType .~ HoverCrit 0
|
||||
& crFaction .~ ColorFaction blue
|
||||
& crStance . carriage .~ Flying 15 0.975
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Creature.State.WalkCycle (updateCarriage) where
|
||||
|
||||
import Geometry.Polygon
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.HandPos
|
||||
import Linear
|
||||
@@ -32,8 +33,13 @@ updateCarriage' cid cr w = \case
|
||||
& cWorld . lWorld . creatures . ix cid . crStance . carriage . zSpeed
|
||||
%~ if cr ^. crPos . _z < 17 then min 0.05 . (+0.001) else max (-0.05) . subtract 0.001
|
||||
Boosting {} -> w
|
||||
Falling _ _ -> w & cWorld . lWorld . creatures . ix cid . crPos +~
|
||||
0.99 *^ (cr ^. crOldPos - oop & _z -~ 0.5)
|
||||
Falling _ _ ->
|
||||
let v = 0.9 *^ (cr ^. crOldPos - oop & _z -~ 0.5)
|
||||
ep = cr ^. crPos + v
|
||||
in if ep ^. _z < 0 && not (any (pointInPoly (ep ^. _xy)) (w ^. cWorld . chasms))
|
||||
then w & cWorld . lWorld . creatures . ix cid . crPos .~ (ep & _z .~ 0)
|
||||
& cWorld . lWorld . creatures . ix cid . crStance . carriage .~ OnGround
|
||||
else w & cWorld . lWorld . creatures . ix cid . crPos .~ ep
|
||||
OnGround {} -> w
|
||||
where
|
||||
oop = cr ^. crOldOldPos
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
import Color
|
||||
@@ -93,10 +94,16 @@ checkDeath' cr w = case cr ^. crHP of
|
||||
& dropAll cr -- the order of these is possibly important
|
||||
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||
& corpseOrGib cr
|
||||
& tocr . crStance . carriage %~ toDeathCarriage
|
||||
_ -> w
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
|
||||
toDeathCarriage :: Carriage -> Carriage
|
||||
toDeathCarriage = \case
|
||||
Flying {} -> Falling 0 RightForward
|
||||
x -> x
|
||||
|
||||
-- could look at the amount of damage here (given by maxDamage) too
|
||||
corpseOrGib :: Creature -> World -> World
|
||||
corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
|
||||
|
||||
Reference in New Issue
Block a user