Add creature statistics, speed depends on strength and equip weight
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Impulse.Movement where
|
||||
import Dodge.Data
|
||||
import Dodge.Creature.Statistics
|
||||
import Geometry
|
||||
|
||||
import Data.Maybe
|
||||
@@ -8,31 +9,11 @@ import Control.Lens
|
||||
{- | Creature attempts to moves under its own steam.
|
||||
The idea is that this may or may not work, depending on the status of the creature.
|
||||
For now, though, this cannot fail. -}
|
||||
--crMvBy
|
||||
-- :: Point2 -- ^ Movement translation vector, will be made relative to creature direction
|
||||
-- -> Creature
|
||||
-- -> Creature
|
||||
--crMvBy p' cr = advanceStepCounter (magV p) cr
|
||||
-- & crPos %~ (+.+ p)
|
||||
-- & crMvDir .~ argV p
|
||||
-- where
|
||||
-- p = (*.*) (equipFactor * aimingFactor) $ rotateV (_crDir cr) p'
|
||||
-- equipFactor
|
||||
-- | _posture (_crStance cr) == Aiming
|
||||
-- = product $ map equipAimSpeed $ IM.elems $ _crInv cr
|
||||
-- | otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr
|
||||
-- aimingFactor
|
||||
-- | _posture (_crStance cr) == Aiming = fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
|
||||
-- | otherwise = 1
|
||||
-- it = _crInv cr IM.! _crInvSel cr
|
||||
|
||||
crMvBy
|
||||
:: Point2 -- ^ Movement translation vector, will be made relative to creature direction
|
||||
-> Creature
|
||||
-> Creature
|
||||
crMvBy p' cr = crMvAbsolute p cr
|
||||
where
|
||||
p = rotateV (_crDir cr) p'
|
||||
crMvBy p cr = crMvAbsolute (rotateV (_crDir cr) p) cr
|
||||
|
||||
crMvAbsolute
|
||||
:: Point2 -- ^ Movement translation vector
|
||||
@@ -42,7 +23,8 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
|
||||
& crPos %~ (+.+ p)
|
||||
& crMvDir .~ argV p
|
||||
where
|
||||
p = (equipFactor * aimingFactor) *.* p'
|
||||
--p = (equipFactor * aimingFactor) *.* p'
|
||||
p = (strengthFactor (getCrStrength cr) * aimingFactor) *.* p'
|
||||
isAiming = _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
|
||||
invItSpeed
|
||||
| isAiming = equipAimSpeed
|
||||
@@ -52,6 +34,12 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
|
||||
| isAiming = fromMaybe 1 $ cr ^? crInv . ix (_crInvSel cr) . itUse . useAim . aimSpeed
|
||||
| otherwise = 1
|
||||
|
||||
strengthFactor :: Int -> Float
|
||||
strengthFactor i
|
||||
| i > 9 = 1
|
||||
| i < 1 = 0.1
|
||||
| otherwise = 0.1 * fromIntegral i
|
||||
|
||||
crMvForward
|
||||
:: Float -- ^ Speed
|
||||
-> Creature
|
||||
@@ -62,9 +50,8 @@ advanceStepCounter
|
||||
:: Float -- ^ Speed
|
||||
-> Creature
|
||||
-> Creature
|
||||
advanceStepCounter speed cr = cr & crStance . carriage %~ f
|
||||
advanceStepCounter speed = crStance . carriage %~ f
|
||||
where
|
||||
--stnce = _crStance cr
|
||||
f car = case car of
|
||||
Standing -> f (Walking 0 RightForward)
|
||||
Walking i ff -> Walking (i + ceiling speed) ff
|
||||
|
||||
Reference in New Issue
Block a user