Add creature statistics, speed depends on strength and equip weight

This commit is contained in:
2022-05-22 12:25:15 +01:00
parent ee31fcbdd9
commit 6891bd7541
5 changed files with 46 additions and 24 deletions
+2
View File
@@ -76,6 +76,8 @@ itemCombinations =
, po [MAGNET,TIN] magShield
, p [p 2 PIPE,o PLATE,o MOTOR] powerLegs
, p [p 4 CAN] plateCraft
, p [p 3 TIN] plateCraft
, p [p 2 DRUM] plateCraft
+11 -24
View File
@@ -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
+25
View File
@@ -0,0 +1,25 @@
module Dodge.Creature.Statistics
( getCrStrength
) where
import Dodge.Data
import qualified IntMapHelp as IM
import Data.IntMap.Merge.Strict
getCrStrength :: Creature -> Int
getCrStrength cr = strFromEquipment cr + _crStrength (_crStatistics cr)
strFromEquipment :: Creature -> Int
strFromEquipment = sum . fmap equipmentStrValue . crCurrentEquipment
equipmentStrValue :: Item -> Int
equipmentStrValue itm = case _itType itm of
FRONTARMOUR -> negate 2
POWERLEGS -> 3
_ -> 0
crCurrentEquipment :: Creature -> IM.IntMap Item
crCurrentEquipment cr = merge dropMissing dropMissing (zipWithMatched (\_ _ itm -> itm))
(_crInvEquipped cr)
(_crInv cr)
+7
View File
@@ -296,6 +296,12 @@ data Creature = Creature
, _crMvType :: CrMvType
, _crHammerPosition :: HammerPosition
, _crName :: String
, _crStatistics :: CreatureStatistics
}
data CreatureStatistics = CreatureStatistics
{ _crStrength :: Int
, _crDexterity :: Int
, _crIntelligence :: Int
}
data Vocalization
= Mute
@@ -1307,3 +1313,4 @@ makeLenses ''Beam
makeLenses ''BeamType
makeLenses ''WorldBeams
makeLenses ''ArcStep
makeLenses ''CreatureStatistics
+1
View File
@@ -63,6 +63,7 @@ defaultCreature = Creature
, _crMvType = defaultAimMvType
, _crHammerPosition = HammerUp
, _crName = "DEFAULTCRNAME"
, _crStatistics = CreatureStatistics 10 10 10
}
defaultInanimate :: Creature
defaultInanimate = defaultCreature & crActionPlan .~ Inanimate