Work on flying creature inertia
This commit is contained in:
@@ -122,7 +122,6 @@ crPathing cr = case cr ^. crStance . carriage of
|
||||
performPathTo :: Creature -> World -> Point2 -> ActionUpdate
|
||||
performPathTo cr w p
|
||||
| dist cpos p <= crRad (cr ^. crType) = mempty
|
||||
-- | isWalkable cpos p w = gotowards p
|
||||
| fst (crPathing cr) cpos p w = gotowards p
|
||||
| otherwise = case uncurry pointTowardsImpulse' (crPathing cr) cpos p w of
|
||||
Just q -> gotowards q
|
||||
|
||||
@@ -36,7 +36,7 @@ hoverCrit :: Creature
|
||||
hoverCrit =
|
||||
defaultCreature
|
||||
& crName .~ "hoverCrit"
|
||||
& crHP .~ HP 100
|
||||
& crHP .~ HP 10000
|
||||
& crType .~ HoverCrit 0
|
||||
& crFaction .~ ColorFaction blue
|
||||
& crStance . carriage .~ Flying 15
|
||||
& crStance . carriage .~ Flying 15 0.91 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module Dodge.Creature.Damage (applyCreatureDamage) where
|
||||
|
||||
--import Linear
|
||||
import Dodge.Creature.Mass
|
||||
import Linear
|
||||
import Dodge.Material.Damage
|
||||
import Data.List
|
||||
--import Dodge.Creature.Mass
|
||||
@@ -15,6 +16,8 @@ applyCreatureDamage :: [Damage] -> Creature -> World -> World
|
||||
applyCreatureDamage dms cr w = foldl' (applyIndividualDamage cr) w dms
|
||||
|
||||
applyIndividualDamage :: Creature -> World -> Damage -> World
|
||||
applyIndividualDamage cr w (Inertial _ _ v) = w
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crPos . _xy +~ fmap (/ crMass (cr ^. crType)) v
|
||||
applyIndividualDamage cr w dm =
|
||||
let (i,w') = damMatSideEffect dm (crMaterial (_crType cr)) (Left cr) w
|
||||
in w' & damageHP cr i
|
||||
|
||||
@@ -2,12 +2,13 @@ module Dodge.Creature.MoveType (crMvType) where
|
||||
|
||||
import Dodge.Data.FloatFunction
|
||||
import Dodge.Data.Creature
|
||||
import Control.Lens
|
||||
|
||||
crMvType :: Creature -> CrMvType
|
||||
crMvType cr = case _crType cr of
|
||||
Avatar {_avMoveSpeed = s} -> MvWalking s
|
||||
ChaseCrit {} -> defaultChaseMvType
|
||||
HoverCrit {} -> defaultChaseMvType
|
||||
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.3
|
||||
SwarmCrit -> defaultChaseMvType
|
||||
AutoCrit -> defaultAimMvType
|
||||
BarrelCrit {} -> defaultAimMvType
|
||||
|
||||
@@ -48,6 +48,7 @@ doDamage cid w = fromMaybe w $ do
|
||||
-- TODO generalise shake to arbitrary damage amounts
|
||||
applyPastDamages :: Creature -> World -> World
|
||||
applyPastDamages cr w
|
||||
| HoverCrit {} <- cr ^. crType = w
|
||||
| _crPain cr > 200 = dojitter 3 100
|
||||
| _crPain cr > 20 = dojitter 2 10
|
||||
| _crPain cr > 0 = dojitter 1 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Creature.State.WalkCycle (updateWalkCycle) where
|
||||
module Dodge.Creature.State.WalkCycle (updateCarriage) where
|
||||
|
||||
import Dodge.Creature.HandPos
|
||||
import Linear
|
||||
@@ -9,8 +9,8 @@ import Dodge.Data.World
|
||||
import Dodge.SoundLogic
|
||||
import Sound.Data
|
||||
|
||||
updateWalkCycle :: Int -> World -> World
|
||||
updateWalkCycle cid w
|
||||
updateCarriage :: Int -> World -> World
|
||||
updateCarriage cid w
|
||||
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
, Walking x ff <- cr ^. crStance . carriage
|
||||
, x >= strideLength cr =
|
||||
@@ -21,7 +21,15 @@ updateWalkCycle cid w
|
||||
(chooseFootSound ff)
|
||||
Nothing
|
||||
& over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride
|
||||
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
, Flying _ x oop <- cr ^. crStance . carriage =
|
||||
w & cWorld . lWorld . creatures . ix cid . crPos . _xy +~ x *^ f (cr ^. crOldPos . _xy - oop)
|
||||
| otherwise = w
|
||||
where
|
||||
-- limits max speed gained through inertia
|
||||
-- f = id
|
||||
f v | norm v > 10 = 10 *^ signorm v
|
||||
| otherwise = v
|
||||
|
||||
resetStride :: Carriage -> Carriage
|
||||
resetStride = \case
|
||||
|
||||
@@ -76,7 +76,7 @@ crUpdate cid =
|
||||
checkDeath cid
|
||||
. doDamage cid
|
||||
. invItemEffs cid
|
||||
. updateWalkCycle cid -- stride appears to be updated elsewhere as well
|
||||
. updateCarriage cid -- stride appears to be updated elsewhere as well
|
||||
|
||||
checkDeath :: Int -> World -> World
|
||||
checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix cid) w
|
||||
|
||||
Reference in New Issue
Block a user