Work on flying creature inertia
This commit is contained in:
+2
-1
@@ -172,7 +172,8 @@ hitEffFromBul w bu = case _buEffect bu of
|
||||
|
||||
getBulHitDams :: Bullet -> Point2 -> [Damage]
|
||||
getBulHitDams bu p = case _buPayload bu of
|
||||
BulPlain x -> [Piercing x p v]
|
||||
BulPlain x -> [Piercing x p v
|
||||
,Inertial 0 p v]
|
||||
_ -> []
|
||||
where
|
||||
v = _buVel bu
|
||||
|
||||
@@ -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
|
||||
|
||||
+25
-25
@@ -55,30 +55,30 @@ doCrWdAc cw = case cw of
|
||||
-- $
|
||||
-- DoReplicate t $
|
||||
-- foldr DoActionThen NoAction as
|
||||
ChooseMovementSpreadGun -> chooseMovementSpreadGun
|
||||
-- ChooseMovementSpreadGun -> chooseMovementSpreadGun
|
||||
ChooseMovementLtAuto -> chooseMovementLtAuto
|
||||
|
||||
chooseMovementSpreadGun :: Creature -> World -> Action
|
||||
chooseMovementSpreadGun cr w
|
||||
| dist cpos p < 30 && safeAngleVV (p -.- cpos) (unitVectorAtAngle (_crDir cr)) > pi =
|
||||
DoImpulses [UseItem, MoveForward (-3)]
|
||||
| d < 30 = DoImpulses [UseItem, TurnToward p 0.06]
|
||||
| d < 60 = DoImpulses [UseItem, TurnToward p 0.06, MoveForward 3]
|
||||
| d < 100 = DoImpulses [TurnToward p 0.06, MoveForward 3]
|
||||
| d < 200 = DoImpulses [TurnToward p (0.06 + 0.002 * (d -100)), MoveForward 3]
|
||||
| otherwise =
|
||||
DoImpulses [TurnToward p 0.26, MoveForward 3]
|
||||
where
|
||||
d = dist cpos p
|
||||
cpos = cr ^. crPos . _xy
|
||||
--tcr = _creatures (_cWorld w) IM.! 0
|
||||
tcr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
p = tcr ^. crPos . _xy
|
||||
--chooseMovementSpreadGun :: Creature -> World -> Action
|
||||
--chooseMovementSpreadGun cr w
|
||||
-- | dist cpos p < 30 && safeAngleVV (p -.- cpos) (unitVectorAtAngle (_crDir cr)) > pi =
|
||||
-- DoImpulses [UseItem, MoveForward (-3)]
|
||||
-- | d < 30 = DoImpulses [UseItem, TurnToward p 0.06]
|
||||
-- | d < 60 = DoImpulses [UseItem, TurnToward p 0.06, MoveForward 3]
|
||||
-- | d < 100 = DoImpulses [TurnToward p 0.06, MoveForward 3]
|
||||
-- | d < 200 = DoImpulses [TurnToward p (0.06 + 0.002 * (d -100)), MoveForward 3]
|
||||
-- | otherwise =
|
||||
-- DoImpulses [TurnToward p 0.26, MoveForward 3]
|
||||
-- where
|
||||
-- d = dist cpos p
|
||||
-- cpos = cr ^. crPos . _xy
|
||||
-- --tcr = _creatures (_cWorld w) IM.! 0
|
||||
-- tcr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
-- p = tcr ^. crPos . _xy
|
||||
|
||||
chooseMovementLtAuto :: Creature -> World -> Action
|
||||
chooseMovementLtAuto cr w
|
||||
| dist cpos p > 200 = DoImpulses [UseItem, TurnToward p 0.05, MoveForward 3]
|
||||
| dist cpos p < 80 = DoImpulses [UseItem, TurnToward p 0.05, MoveForward (-3)]
|
||||
-- | dist cpos p > 200 = DoImpulses [UseItem, TurnToward p 0.05, MoveForward 3]
|
||||
-- | dist cpos p < 80 = DoImpulses [UseItem, TurnToward p 0.05, MoveForward (-3)]
|
||||
| errorAngleVV 22 (p' -.- cpos) (unitVectorAtAngle (_crDir cr)) < 0.4 =
|
||||
DoImpulses [UseItem, TurnToward p' 0.01, Move (V2 0 3)]
|
||||
| otherwise =
|
||||
@@ -90,9 +90,9 @@ chooseMovementLtAuto cr w
|
||||
v = vNormal $ p -.- cpos
|
||||
p' = p +.+ 0.5 *.* (v -.- 20 *.* normalizeV v)
|
||||
|
||||
fleeFrom :: Creature -> Maybe Creature -> Action
|
||||
fleeFrom cr mtcr = case mtcr of
|
||||
Just tcr -> DoImpulses
|
||||
[MoveForward 3
|
||||
, TurnToward ((2 *.* (cr ^. crPos ._xy)) -.- (tcr ^. crPos . _xy)) (pi / 4)]
|
||||
Nothing -> NoAction
|
||||
--fleeFrom :: Creature -> Maybe Creature -> Action
|
||||
--fleeFrom cr mtcr = case mtcr of
|
||||
-- Just tcr -> DoImpulses
|
||||
-- [MoveForward 3
|
||||
-- , TurnToward ((2 *.* (cr ^. crPos ._xy)) -.- (tcr ^. crPos . _xy)) (pi / 4)]
|
||||
-- Nothing -> NoAction
|
||||
|
||||
@@ -49,6 +49,7 @@ dmType = \case
|
||||
Explosive{} -> PhysicalDamage
|
||||
Poison{} -> PoisonDamage
|
||||
Enterrement{} -> PhysicalDamage
|
||||
Inertial {} -> PhysicalDamage
|
||||
|
||||
collectDamageTypes :: [Damage] -> M.Map DamageType Int
|
||||
collectDamageTypes = foldl' (flip f) M.empty
|
||||
|
||||
@@ -29,6 +29,10 @@ data CrMvType
|
||||
, _mvTurnJit :: Float
|
||||
, _mvAimSpeed :: FloatFloat
|
||||
}
|
||||
-- | CrAccMv
|
||||
-- { _mvAcc :: Float
|
||||
-- , _mvTopSpeed :: Float
|
||||
-- }
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data Pulse = PulseStatus
|
||||
|
||||
@@ -21,7 +21,7 @@ data Stance = Stance
|
||||
data Carriage
|
||||
= Walking {_strideAmount :: Float, _footForward :: FootForward}
|
||||
| Floating
|
||||
| Flying {_flyHeight :: Float}
|
||||
| Flying {_flyHeight :: Float, _flyInertia :: Float, _oldOldPos :: Point2}
|
||||
| Boosting Point2
|
||||
| Falling {_fallFlail :: Float, _fallFoot :: FootForward}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
@@ -26,7 +26,7 @@ data CrAc = CrTurnAround
|
||||
|
||||
data CrWdAc
|
||||
= CrWdBFSThenReturn Int
|
||||
| ChooseMovementSpreadGun
|
||||
-- | ChooseMovementSpreadGun
|
||||
| ChooseMovementLtAuto
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ data Damage
|
||||
| Explosive {_dmAmount :: Int, _dmCenter :: Point2}
|
||||
| Poison {_dmAmount :: Int}
|
||||
| Enterrement {_dmAmount :: Int}
|
||||
| Inertial {_dmAmount :: Int, _dmPos :: Point2, _dmVector :: Point2}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
makeLenses ''Damage
|
||||
|
||||
@@ -12,7 +12,6 @@ module Dodge.Data.Machine (
|
||||
module Dodge.Data.GenParams,
|
||||
) where
|
||||
|
||||
import Color.Data
|
||||
import ShortShow
|
||||
import Dodge.Data.AmmoType
|
||||
import Control.Lens
|
||||
|
||||
@@ -56,6 +56,7 @@ damageStone dm ecw w = case dm of
|
||||
Poison{} -> f 0 id
|
||||
Enterrement{} -> f 0 id
|
||||
Flashing{} -> f 0 id
|
||||
Inertial{} -> f 0 id
|
||||
where
|
||||
f x g = (x, g w)
|
||||
dmam = dm ^. dmAmount
|
||||
@@ -105,7 +106,8 @@ damagePhotovoltaic dm ecw w = case dm of
|
||||
Electrical{} -> f 0 id
|
||||
Poison{} -> f 0 id
|
||||
Enterrement{} -> f 0 id
|
||||
Flashing{} -> f 0 id
|
||||
Flashing{} -> f (10*dmam) id
|
||||
Inertial{} -> f 0 id
|
||||
where
|
||||
f x g = (x, g w)
|
||||
dmam = dm ^. dmAmount
|
||||
@@ -138,6 +140,7 @@ damageMetal dm ecw w = case dm of
|
||||
Poison{} -> f 0 id
|
||||
Enterrement{} -> f 0 id
|
||||
Flashing{} -> f 0 id
|
||||
Inertial{} -> f 0 id
|
||||
where
|
||||
f x g = (x, g w)
|
||||
dmam = dm ^. dmAmount
|
||||
@@ -178,6 +181,7 @@ damageFlesh dm _ w = (dm ^. dmAmount,) $ w & case dm of
|
||||
Poison{} -> id
|
||||
Enterrement{} -> id
|
||||
Flashing{} -> id
|
||||
Inertial{} -> id
|
||||
where
|
||||
randsound p xs =
|
||||
let (x, g) = runState (takeOne xs) $ _randGen w
|
||||
@@ -204,6 +208,7 @@ damageDirt dm _ w =
|
||||
Poison{} -> id
|
||||
Enterrement{} -> id
|
||||
Flashing{} -> id
|
||||
Inertial{} -> id
|
||||
where
|
||||
randsound p xs =
|
||||
let (x, g) = runState (takeOne xs) $ _randGen w
|
||||
@@ -231,6 +236,7 @@ damageGlass dm ecw w = case dm of
|
||||
Poison{} -> f 0 id
|
||||
Enterrement{} -> f 0 id
|
||||
Flashing{} -> f 0 id
|
||||
Inertial{} -> f 0 id
|
||||
where
|
||||
f x g = (x, g w)
|
||||
dmam = dm ^. dmAmount
|
||||
@@ -295,6 +301,7 @@ damageCrystal dm ecw w = case dm of
|
||||
Poison{} -> f id
|
||||
Enterrement{} -> f id
|
||||
Flashing{} -> f id
|
||||
Inertial{} -> f id
|
||||
where
|
||||
f g = (0, g w)
|
||||
rdir p t = argV $ reflectIn v t
|
||||
|
||||
@@ -35,7 +35,12 @@ import Data.Monoid
|
||||
import RandomHelp
|
||||
|
||||
testStringInit :: Universe -> [String]
|
||||
testStringInit u = u ^.. uvWorld . cWorld . lWorld . creatures . each . crActionPlan . apAction . to show
|
||||
testStringInit u = [show p, show op, show oop, show (op - oop), show . norm $ op - oop]
|
||||
where
|
||||
f = fromMaybe 0
|
||||
p = f $ u ^? uvWorld . cWorld . lWorld . creatures . ix 2 . crPos . _xy
|
||||
op = f $ u ^? uvWorld . cWorld . lWorld . creatures . ix 2 . crOldPos . _xy
|
||||
oop = fromMaybe 0 $ u ^? uvWorld . cWorld . lWorld . creatures . ix 2 . crStance . carriage . oldOldPos
|
||||
-- fmap show (u ^.. uvWorld . cWorld . lWorld . creatures . ix 0 . crWallTouch . each)
|
||||
-- (fmap show $ u ^.. uvWorld . cWorld . lWorld . creatures . each . crStance . carriage)
|
||||
-- (fmap show $ u ^.. uvWorld . cWorld . lWorld . creatures . each . crStance . carriage . strideAmount)
|
||||
|
||||
@@ -579,6 +579,7 @@ updateTerminal tm w = fromMaybe w $ do
|
||||
|
||||
setOldPos :: Creature -> Creature
|
||||
setOldPos cr = cr & crOldPos .~ _crPos cr
|
||||
& crStance . carriage . oldOldPos .~ cr ^. crOldPos . _xy
|
||||
|
||||
--doRewind :: World -> World
|
||||
--doRewind w = case w ^. cwTime . maybeWorld of
|
||||
|
||||
Reference in New Issue
Block a user