Add creature statistics, speed depends on strength and equip weight
This commit is contained in:
@@ -76,6 +76,8 @@ itemCombinations =
|
|||||||
|
|
||||||
, po [MAGNET,TIN] magShield
|
, po [MAGNET,TIN] magShield
|
||||||
|
|
||||||
|
, p [p 2 PIPE,o PLATE,o MOTOR] powerLegs
|
||||||
|
|
||||||
, p [p 4 CAN] plateCraft
|
, p [p 4 CAN] plateCraft
|
||||||
, p [p 3 TIN] plateCraft
|
, p [p 3 TIN] plateCraft
|
||||||
, p [p 2 DRUM] plateCraft
|
, p [p 2 DRUM] plateCraft
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Creature.Impulse.Movement where
|
module Dodge.Creature.Impulse.Movement where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Creature.Statistics
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
@@ -8,31 +9,11 @@ import Control.Lens
|
|||||||
{- | Creature attempts to moves under its own steam.
|
{- | 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.
|
The idea is that this may or may not work, depending on the status of the creature.
|
||||||
For now, though, this cannot fail. -}
|
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
|
crMvBy
|
||||||
:: Point2 -- ^ Movement translation vector, will be made relative to creature direction
|
:: Point2 -- ^ Movement translation vector, will be made relative to creature direction
|
||||||
-> Creature
|
-> Creature
|
||||||
-> Creature
|
-> Creature
|
||||||
crMvBy p' cr = crMvAbsolute p cr
|
crMvBy p cr = crMvAbsolute (rotateV (_crDir cr) p) cr
|
||||||
where
|
|
||||||
p = rotateV (_crDir cr) p'
|
|
||||||
|
|
||||||
crMvAbsolute
|
crMvAbsolute
|
||||||
:: Point2 -- ^ Movement translation vector
|
:: Point2 -- ^ Movement translation vector
|
||||||
@@ -42,7 +23,8 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
|
|||||||
& crPos %~ (+.+ p)
|
& crPos %~ (+.+ p)
|
||||||
& crMvDir .~ argV p
|
& crMvDir .~ argV p
|
||||||
where
|
where
|
||||||
p = (equipFactor * aimingFactor) *.* p'
|
--p = (equipFactor * aimingFactor) *.* p'
|
||||||
|
p = (strengthFactor (getCrStrength cr) * aimingFactor) *.* p'
|
||||||
isAiming = _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
|
isAiming = _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
|
||||||
invItSpeed
|
invItSpeed
|
||||||
| isAiming = equipAimSpeed
|
| isAiming = equipAimSpeed
|
||||||
@@ -52,6 +34,12 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
|
|||||||
| isAiming = fromMaybe 1 $ cr ^? crInv . ix (_crInvSel cr) . itUse . useAim . aimSpeed
|
| isAiming = fromMaybe 1 $ cr ^? crInv . ix (_crInvSel cr) . itUse . useAim . aimSpeed
|
||||||
| otherwise = 1
|
| otherwise = 1
|
||||||
|
|
||||||
|
strengthFactor :: Int -> Float
|
||||||
|
strengthFactor i
|
||||||
|
| i > 9 = 1
|
||||||
|
| i < 1 = 0.1
|
||||||
|
| otherwise = 0.1 * fromIntegral i
|
||||||
|
|
||||||
crMvForward
|
crMvForward
|
||||||
:: Float -- ^ Speed
|
:: Float -- ^ Speed
|
||||||
-> Creature
|
-> Creature
|
||||||
@@ -62,9 +50,8 @@ advanceStepCounter
|
|||||||
:: Float -- ^ Speed
|
:: Float -- ^ Speed
|
||||||
-> Creature
|
-> Creature
|
||||||
-> Creature
|
-> Creature
|
||||||
advanceStepCounter speed cr = cr & crStance . carriage %~ f
|
advanceStepCounter speed = crStance . carriage %~ f
|
||||||
where
|
where
|
||||||
--stnce = _crStance cr
|
|
||||||
f car = case car of
|
f car = case car of
|
||||||
Standing -> f (Walking 0 RightForward)
|
Standing -> f (Walking 0 RightForward)
|
||||||
Walking i ff -> Walking (i + ceiling speed) ff
|
Walking i ff -> Walking (i + ceiling speed) ff
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
@@ -296,6 +296,12 @@ data Creature = Creature
|
|||||||
, _crMvType :: CrMvType
|
, _crMvType :: CrMvType
|
||||||
, _crHammerPosition :: HammerPosition
|
, _crHammerPosition :: HammerPosition
|
||||||
, _crName :: String
|
, _crName :: String
|
||||||
|
, _crStatistics :: CreatureStatistics
|
||||||
|
}
|
||||||
|
data CreatureStatistics = CreatureStatistics
|
||||||
|
{ _crStrength :: Int
|
||||||
|
, _crDexterity :: Int
|
||||||
|
, _crIntelligence :: Int
|
||||||
}
|
}
|
||||||
data Vocalization
|
data Vocalization
|
||||||
= Mute
|
= Mute
|
||||||
@@ -1307,3 +1313,4 @@ makeLenses ''Beam
|
|||||||
makeLenses ''BeamType
|
makeLenses ''BeamType
|
||||||
makeLenses ''WorldBeams
|
makeLenses ''WorldBeams
|
||||||
makeLenses ''ArcStep
|
makeLenses ''ArcStep
|
||||||
|
makeLenses ''CreatureStatistics
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ defaultCreature = Creature
|
|||||||
, _crMvType = defaultAimMvType
|
, _crMvType = defaultAimMvType
|
||||||
, _crHammerPosition = HammerUp
|
, _crHammerPosition = HammerUp
|
||||||
, _crName = "DEFAULTCRNAME"
|
, _crName = "DEFAULTCRNAME"
|
||||||
|
, _crStatistics = CreatureStatistics 10 10 10
|
||||||
}
|
}
|
||||||
defaultInanimate :: Creature
|
defaultInanimate :: Creature
|
||||||
defaultInanimate = defaultCreature & crActionPlan .~ Inanimate
|
defaultInanimate = defaultCreature & crActionPlan .~ Inanimate
|
||||||
|
|||||||
Reference in New Issue
Block a user