Remove creature move type record
This commit is contained in:
@@ -100,8 +100,8 @@ startCr =
|
||||
& crHP .~ 10000
|
||||
& crInv .~ startInventory
|
||||
& crFaction .~ PlayerFaction
|
||||
& crMvType .~ MvWalking yourDefaultSpeed
|
||||
& crType .~ Avatar (PulseStatus 55 0) Flesh
|
||||
-- & crMvType .~ MvWalking yourDefaultSpeed
|
||||
& crType .~ Avatar (PulseStatus 55 0) Flesh 50 50 50 3
|
||||
|
||||
-- | Items you start with.
|
||||
startInvList :: [Item]
|
||||
|
||||
@@ -13,6 +13,7 @@ module Dodge.Creature.Action (
|
||||
youDropItem,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.MoveType
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Item.BackgroundEffect
|
||||
import Control.Applicative
|
||||
@@ -49,7 +50,7 @@ performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
|
||||
cdir = _crDir cr
|
||||
cpos = _crPos cr
|
||||
canSee' = canSee (_crID cr) tcid w
|
||||
aimSp = case cr ^? crMvType . mvAimSpeed of
|
||||
aimSp = case crMvType cr ^? mvAimSpeed of
|
||||
Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
|
||||
Nothing -> error "creature without aiming type"
|
||||
tpos
|
||||
@@ -72,7 +73,7 @@ performPathTo cr w p
|
||||
_ -> ([], Nothing)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
jit = _mvTurnJit $ _crMvType cr
|
||||
jit = _mvTurnJit $ crMvType cr
|
||||
|
||||
performTurnToA :: Creature -> Point2 -> OutAction
|
||||
performTurnToA cr p
|
||||
@@ -82,7 +83,7 @@ performTurnToA cr p
|
||||
cpos = _crPos cr
|
||||
cdirv = unitVectorAtAngle (_crDir cr)
|
||||
dirv = p -.- cpos
|
||||
jit = _mvTurnJit $ _crMvType cr
|
||||
jit = _mvTurnJit $ crMvType cr
|
||||
|
||||
{- | Performing an action on a frame creates an OutAction:
|
||||
adds impulses and updates or deletes the action itself.
|
||||
|
||||
@@ -7,7 +7,6 @@ import Dodge.Data.Equipment.Misc
|
||||
import Control.Lens
|
||||
import Dodge.Creature.ChaseCrit
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Data.FloatFunction
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Equipment
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -29,7 +28,7 @@ flockArmourChaseCrit =
|
||||
, _apGoal = [Kill 0]
|
||||
}
|
||||
, _crGroup = ShieldGroup
|
||||
, _crMvType = defaultChaseMvType
|
||||
-- , _crMvType = defaultChaseMvType
|
||||
}
|
||||
-- & crType . humanoidAI .~ FlockArmourChaseAI
|
||||
|
||||
@@ -42,6 +41,6 @@ armourChaseCrit =
|
||||
IM.fromList
|
||||
[ (0, frontArmour)
|
||||
]
|
||||
, _crMvType = defaultChaseMvType{_mvTurnRad = FloatConst 0.05}
|
||||
-- , _crMvType = defaultChaseMvType{_mvTurnRad = FloatConst 0.05}
|
||||
}
|
||||
& crEquipment . at OnChest ?~ 0
|
||||
|
||||
@@ -14,7 +14,7 @@ autoCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, autoRifle)]
|
||||
, _crHP = 300
|
||||
, _crMvType = defaultAimMvType
|
||||
-- , _crMvType = defaultAimMvType
|
||||
}
|
||||
-- & crType . skinUpper .~ lightx4 red
|
||||
-- & crType . humanoidAI .~ AutoAI
|
||||
|
||||
@@ -16,13 +16,11 @@ smallChaseCrit =
|
||||
chaseCrit
|
||||
{ _crHP = 1
|
||||
, _crInv = mempty
|
||||
-- , _crCorpse = MakeDefaultCorpse
|
||||
}
|
||||
|
||||
invisibleChaseCrit :: Creature
|
||||
invisibleChaseCrit =
|
||||
chaseCrit
|
||||
-- & crCamouflage .~ Invisible
|
||||
& crInv . at 0 ?~ wristInvisibility
|
||||
& crEquipment . at OnLeftWrist ?~ 0
|
||||
|
||||
@@ -34,12 +32,7 @@ chaseCrit =
|
||||
, _crInv = mempty
|
||||
, _crFaction = ColorFaction green
|
||||
, _crVocalization = chaseCritVocalization
|
||||
, _crMvType = defaultChaseMvType
|
||||
}
|
||||
-- & crType . humanoidAI .~ ChaseAI
|
||||
|
||||
chaseCritVocalization :: Vocalization
|
||||
chaseCritVocalization =
|
||||
Vocalization
|
||||
(50, 200)
|
||||
0
|
||||
chaseCritVocalization = Vocalization (50, 200) 0
|
||||
|
||||
@@ -4,6 +4,7 @@ module Dodge.Creature.Impulse (
|
||||
impulsiveAIBefore,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.MoveType
|
||||
import Data.Foldable
|
||||
import Control.Monad.State
|
||||
import Data.Bifunctor
|
||||
@@ -76,7 +77,7 @@ followImpulse cr w imp = case imp of
|
||||
creatureTurnToward p (turnRad $ safeAngleVV (p -.- cpos) (unitVectorAtAngle cdir)) cr
|
||||
where
|
||||
crup = (id,)
|
||||
mvType = _crMvType cr
|
||||
mvType = crMvType cr
|
||||
speed = _mvSpeed mvType
|
||||
turnRad = doFloatFloat $ _mvTurnRad mvType
|
||||
cpos = _crPos cr
|
||||
|
||||
@@ -2,6 +2,7 @@ module Dodge.Creature.Info (
|
||||
yourInfo,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.Statistics
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Data.Creature
|
||||
import LensHelp
|
||||
@@ -28,8 +29,8 @@ yourStatsInfo cr =
|
||||
"You are " ++ statsModifier str "weak" "strength" "strong" ++ conj
|
||||
++ statsModifier dex "clumsy." "dexterity." "dexterous."
|
||||
where
|
||||
str = cr ^. crStatistics . strength
|
||||
dex = cr ^. crStatistics . dexterity
|
||||
str = cr & crStrength
|
||||
dex = cr & crDexterity
|
||||
conj
|
||||
| (str < 45 && dex < 45) || (str > 55 && dex > 55) || (mid str && mid dex) =
|
||||
" and "
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Creature.Statistics (
|
||||
getCrMoveSpeed,
|
||||
getCrDexterity,
|
||||
crStrength,
|
||||
crDexterity,
|
||||
crIntelligence,
|
||||
) where
|
||||
|
||||
import Data.Maybe
|
||||
@@ -9,11 +11,39 @@ import Dodge.Data.Creature
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
|
||||
getCrDexterity :: Creature -> Int
|
||||
getCrDexterity = _dexterity . _crStatistics
|
||||
crDexterity :: Creature -> Int
|
||||
crDexterity cr = case cr ^. crType of
|
||||
Avatar { _avDexterity = x } -> x
|
||||
AvatarDead -> 0
|
||||
ChaseCrit {} -> 46
|
||||
SwarmCrit -> 46
|
||||
AutoCrit -> 46
|
||||
BarrelCrit {} -> 0
|
||||
LampCrit {} -> 0
|
||||
|
||||
crStrength :: Creature -> Int
|
||||
crStrength cr = case cr ^. crType of
|
||||
Avatar { _avStrength = x } -> x
|
||||
AvatarDead -> 0
|
||||
ChaseCrit {} -> 46
|
||||
SwarmCrit -> 40
|
||||
AutoCrit -> 46
|
||||
BarrelCrit {} -> 0
|
||||
LampCrit {} -> 0
|
||||
|
||||
crIntelligence :: Creature -> Int
|
||||
crIntelligence cr = case cr ^. crType of
|
||||
Avatar { _avIntelligence = x } -> x
|
||||
AvatarDead -> 0
|
||||
ChaseCrit {} -> 20
|
||||
SwarmCrit -> 20
|
||||
AutoCrit -> 20
|
||||
BarrelCrit {} -> 0
|
||||
LampCrit {} -> 0
|
||||
|
||||
|
||||
getCrMoveSpeed :: Creature -> Int
|
||||
getCrMoveSpeed cr = strFromHeldItem cr + strFromEquipment cr + _strength (_crStatistics cr)
|
||||
getCrMoveSpeed cr = strFromHeldItem cr + strFromEquipment cr + crStrength cr
|
||||
|
||||
strFromEquipment :: Creature -> Int
|
||||
strFromEquipment = sum . fmap equipmentStrValue . crCurrentEquipment
|
||||
|
||||
@@ -4,6 +4,7 @@ module Dodge.Creature.YourControl (
|
||||
yourControl,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.MoveType
|
||||
import Dodge.Data.Equipment.Misc
|
||||
import Control.Monad
|
||||
import qualified Data.Map.Strict as M
|
||||
@@ -118,7 +119,7 @@ scancodeToHotkey x = case x of
|
||||
wasdWithAiming :: World -> Creature -> Creature
|
||||
wasdWithAiming w cr = wasdAim inp w $ wasdMovement inp cam speed cr
|
||||
where
|
||||
speed = _mvSpeed $ _crMvType cr
|
||||
speed = _mvSpeed $ crMvType cr
|
||||
inp = w ^. input
|
||||
cam = w ^. wCam
|
||||
|
||||
|
||||
@@ -54,9 +54,8 @@ data Creature = Creature
|
||||
, _crFaction :: Faction
|
||||
, _crGroup :: CrGroup
|
||||
, _crIntention :: Intention
|
||||
, _crMvType :: CrMvType
|
||||
-- , _crMvType :: CrMvType
|
||||
, _crName :: String
|
||||
, _crStatistics :: CreatureStatistics
|
||||
, _crDeathTimer :: Int
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
@@ -8,27 +8,25 @@ module Dodge.Data.Creature.Misc (
|
||||
module Dodge.Data.CamouflageStatus,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Material
|
||||
import Color
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import Dodge.Data.CamouflageStatus
|
||||
import Dodge.Data.FloatFunction
|
||||
import Dodge.Data.Material
|
||||
import Geometry.Data
|
||||
|
||||
data CreatureStatistics = CreatureStatistics
|
||||
{ _strength :: Int
|
||||
, _dexterity :: Int
|
||||
, _intelligence :: Int
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
--data CreatureStatistics = CreatureStatistics
|
||||
-- { _strength :: Int
|
||||
-- , _dexterity :: Int
|
||||
-- , _intelligence :: Int
|
||||
-- }
|
||||
-- deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data Vocalization
|
||||
= Mute
|
||||
| Vocalization
|
||||
-- { _vcSound :: SoundID
|
||||
-- , _vcWarnings :: [SoundID]
|
||||
{ _vcMaxCoolDown :: (Int, Int)
|
||||
, _vcCoolDown :: Int
|
||||
}
|
||||
@@ -67,12 +65,19 @@ data Pulse = PulseStatus
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data CreatureType
|
||||
= Avatar { _avatarPulse :: Pulse , _avatarMaterial :: Material}
|
||||
= Avatar
|
||||
{ _avatarPulse :: Pulse
|
||||
, _avatarMaterial :: Material
|
||||
, _avStrength :: Int
|
||||
, _avDexterity :: Int
|
||||
, _avIntelligence :: Int
|
||||
, _avMoveSpeed :: Float
|
||||
}
|
||||
| AvatarDead
|
||||
| ChaseCrit {_meleeCooldown :: Int}
|
||||
| SwarmCrit
|
||||
| AutoCrit
|
||||
| BarrelCrit{_barrelType :: BarrelType}
|
||||
| BarrelCrit {_barrelType :: BarrelType}
|
||||
| LampCrit {_lampHeight :: Float, _lampColor :: Point3, _lampLSID :: Maybe Int}
|
||||
|
||||
data CreatureShape
|
||||
@@ -90,14 +95,14 @@ data BarrelType = PlainBarrel | ExplosiveBarrel
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
makeLenses ''Pulse
|
||||
makeLenses ''CreatureStatistics
|
||||
--makeLenses ''CreatureStatistics
|
||||
makeLenses ''Vocalization
|
||||
makeLenses ''CrMvType
|
||||
makeLenses ''CreatureType
|
||||
deriveJSON defaultOptions ''Pulse
|
||||
deriveJSON defaultOptions ''CreatureStatistics
|
||||
--deriveJSON defaultOptions ''CreatureStatistics
|
||||
deriveJSON defaultOptions ''Vocalization
|
||||
deriveJSON defaultOptions ''CrMvType
|
||||
--deriveJSON defaultOptions ''CrMvType
|
||||
deriveJSON defaultOptions ''HumanoidAI
|
||||
deriveJSON defaultOptions ''BarrelType
|
||||
deriveJSON defaultOptions ''CreatureType
|
||||
|
||||
@@ -46,13 +46,13 @@ applyTerminalCommandArguments command args u = case command of
|
||||
return $ u & uvWorld %~ flip (foldl' (&)) (replicate n (snd . createItemYou (itemFromBase ibt)))
|
||||
"DEX" -> fromMaybe u $ do
|
||||
x <- readMaybe =<< args ^? _head
|
||||
return $ u & ypoint . crStatistics . dexterity .~ x
|
||||
return $ u & ypoint . crType . avDexterity .~ x
|
||||
"STR" -> fromMaybe u $ do
|
||||
x <- readMaybe =<< args ^? _head
|
||||
return $ u & ypoint . crStatistics . strength .~ x
|
||||
return $ u & ypoint . crType . avStrength .~ x
|
||||
"INT" -> fromMaybe u $ do
|
||||
x <- readMaybe =<< args ^? _head
|
||||
return $ u & ypoint . crStatistics . intelligence .~ x
|
||||
return $ u & ypoint . crType . avIntelligence .~ x
|
||||
_ -> u
|
||||
where
|
||||
ypoint = uvWorld . cWorld . lWorld . creatures . ix 0
|
||||
@@ -85,7 +85,8 @@ applySetTerminalString var = case key' of
|
||||
"hp" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crHP .~ round (fromJust val')
|
||||
-- "invcap" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ round (fromJust val')
|
||||
-- "mass" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMass .~ fromJust val'
|
||||
"mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMvType . mvSpeed .~ fromJust val'
|
||||
-- "mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMvType . mvSpeed .~ fromJust val'
|
||||
"mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avMoveSpeed .~ fromJust val'
|
||||
_ -> showTerminalError ("set " ++ var) ("Invalid set command: " ++ key) -- never reached?
|
||||
where
|
||||
(key, val) = getSplitString var
|
||||
|
||||
@@ -47,10 +47,10 @@ defaultCreature =
|
||||
, _crFaction = NoFaction
|
||||
, _crIntention = defaultIntention
|
||||
, _crGroup = LoneWolf
|
||||
, _crMvType = defaultAimMvType
|
||||
-- , _crMvType = defaultAimMvType
|
||||
-- , _crHammerPosition = HammerUp
|
||||
, _crName = "DEFAULTCRNAME"
|
||||
, _crStatistics = CreatureStatistics 50 50 50
|
||||
-- , _crStatistics = CreatureStatistics 50 50 50
|
||||
, _crDeathTimer = 0
|
||||
}
|
||||
|
||||
@@ -101,29 +101,9 @@ defaultIntention =
|
||||
, _viewPoint = Nothing
|
||||
}
|
||||
|
||||
defaultChaseMvType :: CrMvType
|
||||
defaultChaseMvType =
|
||||
CrMvType
|
||||
{ _mvSpeed = 2
|
||||
, _mvTurnRad = FloatAbsCheckGreaterLess (pi / 4) 0.2 0.05
|
||||
, _mvTurnJit = 0.2
|
||||
, _mvAimSpeed = FloatAbsCheckGreaterLess (pi / 8) 0.2 0.01
|
||||
}
|
||||
|
||||
defaultAimMvType :: CrMvType
|
||||
defaultAimMvType =
|
||||
CrMvType
|
||||
{ _mvSpeed = 3
|
||||
, _mvTurnRad = FloatConst 0.2
|
||||
, _mvTurnJit = 0.05
|
||||
, _mvAimSpeed = FloatAbsCheckGreaterLess (pi / 8) 0.2 0.01
|
||||
}
|
||||
|
||||
defaultAimingCrit :: Creature
|
||||
defaultAimingCrit = defaultCreature{_crMvType = defaultAimMvType}
|
||||
|
||||
yourDefaultSpeed :: Float
|
||||
yourDefaultSpeed = 3
|
||||
defaultAimingCrit = defaultCreature
|
||||
|
||||
yourDefaultStrideLength :: Int
|
||||
yourDefaultStrideLength = 40
|
||||
|
||||
@@ -7,9 +7,7 @@ import Control.Lens
|
||||
import Dodge.Data.World
|
||||
|
||||
lockInv :: World -> World
|
||||
--lockInv cid = cWorld . lWorld . creatures . ix cid . crInvLock ||~ True
|
||||
lockInv = cWorld . lWorld . lInvLock .~ True
|
||||
|
||||
--unlockInv :: Int -> World -> World
|
||||
unlockInv :: World -> World
|
||||
unlockInv = cWorld . lWorld . lInvLock .~ False
|
||||
|
||||
Reference in New Issue
Block a user