Separate out creature data
This commit is contained in:
+2
-355
@@ -10,6 +10,7 @@ circular imports are probably not a good idea.
|
|||||||
{-# LANGUAGE DerivingStrategies #-}
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
module Dodge.Data
|
module Dodge.Data
|
||||||
( module Dodge.Data
|
( module Dodge.Data
|
||||||
|
, module Dodge.Data.ActionPlan
|
||||||
, module Dodge.Data.CreatureEffect
|
, module Dodge.Data.CreatureEffect
|
||||||
, module Dodge.Data.WorldEffect
|
, module Dodge.Data.WorldEffect
|
||||||
, module Dodge.Data.Button
|
, module Dodge.Data.Button
|
||||||
@@ -71,6 +72,7 @@ module Dodge.Data
|
|||||||
, module Dodge.Data.RadarBlip
|
, module Dodge.Data.RadarBlip
|
||||||
, module Dodge.Data.PathGraph
|
, module Dodge.Data.PathGraph
|
||||||
) where
|
) where
|
||||||
|
import Dodge.Data.ActionPlan
|
||||||
import Dodge.Data.CreatureEffect
|
import Dodge.Data.CreatureEffect
|
||||||
import Dodge.Data.WorldEffect
|
import Dodge.Data.WorldEffect
|
||||||
import Dodge.Data.Button
|
import Dodge.Data.Button
|
||||||
@@ -118,7 +120,6 @@ import Dodge.Data.Wall
|
|||||||
import Dodge.Data.Bounds
|
import Dodge.Data.Bounds
|
||||||
import Dodge.RoomCluster.Data
|
import Dodge.RoomCluster.Data
|
||||||
import Dodge.Data.ItemAmount
|
import Dodge.Data.ItemAmount
|
||||||
import Dodge.ShortShow
|
|
||||||
import Dodge.Creature.State.Data
|
import Dodge.Creature.State.Data
|
||||||
import Dodge.Creature.Stance.Data
|
import Dodge.Creature.Stance.Data
|
||||||
import Dodge.Creature.Perception.Data
|
import Dodge.Creature.Perception.Data
|
||||||
@@ -146,7 +147,6 @@ import MaybeHelp
|
|||||||
|
|
||||||
--import qualified Data.Vector as V
|
--import qualified Data.Vector as V
|
||||||
import qualified Linear.Quaternion as Q
|
import qualified Linear.Quaternion as Q
|
||||||
import GHC.Generics
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
import System.Random
|
import System.Random
|
||||||
@@ -330,64 +330,12 @@ data CrGroupParams = CrGroupParams
|
|||||||
, _crGroupCenter :: Point2
|
, _crGroupCenter :: Point2
|
||||||
, _crGroupUpdate :: World -> CrGroupParams -> Maybe CrGroupParams
|
, _crGroupUpdate :: World -> CrGroupParams -> Maybe CrGroupParams
|
||||||
}
|
}
|
||||||
data Corpse = Corpse
|
|
||||||
{ _cpID :: Int
|
|
||||||
, _cpPos :: Point2
|
|
||||||
, _cpDir :: Float
|
|
||||||
, _cpPict :: Corpse -> SPic
|
|
||||||
, _cpRes :: Maybe Creature
|
|
||||||
}
|
|
||||||
data Gust = Gust
|
data Gust = Gust
|
||||||
{ _guID :: Int
|
{ _guID :: Int
|
||||||
, _guPos :: Point2
|
, _guPos :: Point2
|
||||||
, _guVel :: Point2
|
, _guVel :: Point2
|
||||||
, _guTime :: Int
|
, _guTime :: Int
|
||||||
}
|
}
|
||||||
data Creature = Creature
|
|
||||||
{ _crPos :: Point2
|
|
||||||
, _crOldPos :: Point2
|
|
||||||
, _crVel :: Point2
|
|
||||||
, _crDir :: Float
|
|
||||||
, _crOldDir :: Float
|
|
||||||
, _crMvDir :: Float
|
|
||||||
, _crTwist :: Float
|
|
||||||
, _crType :: CreatureType
|
|
||||||
, _crID :: Int
|
|
||||||
, _crRad :: Float
|
|
||||||
, _crMass :: Float
|
|
||||||
, _crHP :: Int
|
|
||||||
, _crMaxHP :: Int
|
|
||||||
, _crInv :: IM.IntMap Item
|
|
||||||
, _crInvSel :: InvSel
|
|
||||||
, _crInvCapacity :: Int
|
|
||||||
, _crInvLock :: Bool
|
|
||||||
, _crInvEquipped :: IM.IntMap EquipPosition
|
|
||||||
, _crEquipment :: M.Map EquipPosition Int
|
|
||||||
, _crLeftInvSel :: Maybe Int
|
|
||||||
, _crState :: CreatureState
|
|
||||||
, _crCorpse :: Creature -> Corpse -> SPic
|
|
||||||
, _crMaterial :: Material
|
|
||||||
, _crPastDamage :: Int
|
|
||||||
, _crStance :: Stance
|
|
||||||
, _crActionPlan :: ActionPlan
|
|
||||||
, _crMeleeCooldown :: Int
|
|
||||||
, _crPerception :: Perception
|
|
||||||
, _crMemory :: Memory
|
|
||||||
, _crVocalization :: Vocalization
|
|
||||||
, _crFaction :: Faction
|
|
||||||
, _crGroup :: CrGroup
|
|
||||||
, _crIntention :: Intention
|
|
||||||
, _crMvType :: CrMvType
|
|
||||||
, _crHammerPosition :: HammerPosition
|
|
||||||
, _crName :: String
|
|
||||||
, _crStatistics :: CreatureStatistics
|
|
||||||
, _crCamouflage :: CamouflageStatus
|
|
||||||
}
|
|
||||||
data Intention = Intention
|
|
||||||
{ _targetCr :: Maybe Creature
|
|
||||||
, _mvToPoint :: Maybe Point2
|
|
||||||
, _viewPoint :: Maybe Point2
|
|
||||||
}
|
|
||||||
data TerminalLine
|
data TerminalLine
|
||||||
= TerminalLineDisplay
|
= TerminalLineDisplay
|
||||||
{_tlPause :: Int
|
{_tlPause :: Int
|
||||||
@@ -662,302 +610,6 @@ data MountedObject
|
|||||||
| MountedProp Int
|
| MountedProp Int
|
||||||
deriving (Eq,Ord,Show)
|
deriving (Eq,Ord,Show)
|
||||||
|
|
||||||
data ActionPlan
|
|
||||||
= Inanimate
|
|
||||||
| ActionPlan
|
|
||||||
{_apImpulse :: [Impulse]
|
|
||||||
,_apAction :: [Action]
|
|
||||||
,_apStrategy :: Strategy
|
|
||||||
,_apGoal :: [Goal]
|
|
||||||
}
|
|
||||||
data RandImpulse = RandImpulseList [Impulse]
|
|
||||||
data Impulse
|
|
||||||
= Move Point2
|
|
||||||
| MoveForward Float
|
|
||||||
| Turn Float
|
|
||||||
| RandomTurn Float
|
|
||||||
| RandomImpulse (State StdGen Impulse)
|
|
||||||
| TurnToward Point2 Float
|
|
||||||
| MvTurnToward Point2
|
|
||||||
| MvForward
|
|
||||||
| TurnTo Point2
|
|
||||||
| UseItem
|
|
||||||
| SwitchToItem Int
|
|
||||||
| DropItem
|
|
||||||
| Bark SoundID -- placeholder for various communication types
|
|
||||||
| Melee Int
|
|
||||||
| ChangePosture Posture
|
|
||||||
| MakeSound SoundID
|
|
||||||
| ChangeStrategy Strategy
|
|
||||||
| AddGoal Goal
|
|
||||||
| ArbitraryImpulseFunction WdCrCr
|
|
||||||
| ArbitraryImpulse CrWdImp
|
|
||||||
| ArbitraryImpulseEffect CrWdWd
|
|
||||||
| ImpulseUseTargetCID
|
|
||||||
{_impulseUseTargetCID :: IntImp
|
|
||||||
}
|
|
||||||
| ImpulseUseTarget
|
|
||||||
{_impulseUseTarget :: CrImp
|
|
||||||
}
|
|
||||||
| ImpulseUseAheadPos
|
|
||||||
{_impulseUseAheadPos :: P2Imp
|
|
||||||
}
|
|
||||||
| ImpulseNothing
|
|
||||||
instance Show Impulse where
|
|
||||||
show imp = case imp of
|
|
||||||
Move p -> "Move "++shortPoint2 p
|
|
||||||
MoveForward f -> "MoveForward "++ show f
|
|
||||||
Turn f -> "Turn "++show f
|
|
||||||
RandomTurn f -> "RandomTurn "++show f
|
|
||||||
TurnToward p f -> "TurnToward "++shortPoint2 p++show f
|
|
||||||
MvTurnToward p -> "MvTurnToward "++shortPoint2 p
|
|
||||||
MvForward -> "MvForward"
|
|
||||||
TurnTo p -> "TurnTo "++shortPoint2 p
|
|
||||||
UseItem -> "UseItem"
|
|
||||||
SwitchToItem i -> "SwitchToItem "++show i
|
|
||||||
DropItem -> "DropItem"
|
|
||||||
Bark sid -> "Bark "++show sid
|
|
||||||
Melee i -> "Melee "++show i
|
|
||||||
ChangePosture post -> "ChangePosture " ++ show post
|
|
||||||
MakeSound sid -> "MakeSound " ++ show sid
|
|
||||||
ChangeStrategy s -> "ChangeStrategy " ++ show s
|
|
||||||
AddGoal g -> "AddGoal " ++ show g
|
|
||||||
ArbitraryImpulseFunction {} -> "ArbitraryImpulseFunction"
|
|
||||||
ArbitraryImpulse {} -> "ArbitraryImpulse"
|
|
||||||
ArbitraryImpulseEffect {} -> "ArbitraryImpulseEffect"
|
|
||||||
ImpulseUseTargetCID {} -> "ImpulseUseTargetCID"
|
|
||||||
ImpulseUseTarget {} -> "ImpulseUseTarget"
|
|
||||||
ImpulseUseAheadPos {} -> "ImpulseUseAheadPos"
|
|
||||||
RandomImpulse {} -> "RandomImpulse"
|
|
||||||
ImpulseNothing -> "ImpulseNothing"
|
|
||||||
-- deriving (Eq,Ord,Show)
|
|
||||||
infixr 9 `WaitThen`
|
|
||||||
infixr 9 `DoActionThen`
|
|
||||||
infixr 9 `DoActionWhile`
|
|
||||||
infixr 9 `DoReplicate`
|
|
||||||
infixr 9 `DoImpulsesAlongside`
|
|
||||||
data Action
|
|
||||||
= LabelAction
|
|
||||||
{_actLabel :: String
|
|
||||||
,_actAction :: Action
|
|
||||||
}
|
|
||||||
| ActionNothing
|
|
||||||
| AimAt
|
|
||||||
{_targetID :: Int
|
|
||||||
,_targetSeenAt :: Point2
|
|
||||||
}
|
|
||||||
| PathTo
|
|
||||||
{_pathToPoint :: Point2
|
|
||||||
}
|
|
||||||
| TurnToPoint
|
|
||||||
{_turnToPoint :: Point2
|
|
||||||
}
|
|
||||||
-- | PickupItem
|
|
||||||
-- {_pickupItemID :: Int
|
|
||||||
-- }
|
|
||||||
| ImpulsesList
|
|
||||||
{_impulsesListList :: [[Impulse]]
|
|
||||||
}
|
|
||||||
| DoImpulses
|
|
||||||
{_doImpulsesList :: [Impulse]
|
|
||||||
}
|
|
||||||
| WaitThen
|
|
||||||
{_waitThenTimer :: Int
|
|
||||||
,_waitThenAction :: Action
|
|
||||||
}
|
|
||||||
| DoActionWhile
|
|
||||||
{_doActionWhileCondition :: WdCrBl
|
|
||||||
,_doActionWhileAction :: Action
|
|
||||||
}
|
|
||||||
| DoActionWhilePartial
|
|
||||||
{_doActionWhilePartial :: Action
|
|
||||||
,_doActionWhileCondition :: WdCrBl
|
|
||||||
,_doActionWhileAction :: Action
|
|
||||||
}
|
|
||||||
| DoActionIf
|
|
||||||
{_doActionIfCondition :: WdCrBl
|
|
||||||
,_doActionIfAction :: Action
|
|
||||||
}
|
|
||||||
| DoActionIfElse
|
|
||||||
{_doActionIfElseIfAction :: Action
|
|
||||||
,_doActionIfElseCondition :: WdCrBl
|
|
||||||
,_doActionIfElseElseAction :: Action
|
|
||||||
}
|
|
||||||
| DoActionWhileInterrupt
|
|
||||||
{_doActionWhileThenDo :: Action
|
|
||||||
,_doActionWhileThenCondition :: WdCrBl
|
|
||||||
,_doActionWhileThenThen :: Action
|
|
||||||
}
|
|
||||||
| DoActions
|
|
||||||
{_doActionsList :: [Action]
|
|
||||||
}
|
|
||||||
| DoActionThen
|
|
||||||
{_doActionThenFirst :: Action
|
|
||||||
,_doActionThenSecond :: Action
|
|
||||||
}
|
|
||||||
-- | DoGuardActions
|
|
||||||
-- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
|
||||||
-- }
|
|
||||||
| DoReplicate
|
|
||||||
{_doReplicateTimes :: Int
|
|
||||||
,_doReplicateAction :: Action
|
|
||||||
}
|
|
||||||
| DoReplicatePartial
|
|
||||||
{_partialAction :: Action
|
|
||||||
,_doReplicateTimes :: Int
|
|
||||||
,_doReplicateAction :: Action
|
|
||||||
}
|
|
||||||
| LeadTarget
|
|
||||||
{_leadTargetBy :: Point2
|
|
||||||
}
|
|
||||||
| NoAction
|
|
||||||
| StartSentinelPost
|
|
||||||
| UseTarget
|
|
||||||
{_useTarget :: MCrAc
|
|
||||||
}
|
|
||||||
| UseSelf
|
|
||||||
{_useSelf :: CrAc
|
|
||||||
}
|
|
||||||
| UseAheadPos
|
|
||||||
{_useAheadPos :: P2Ac
|
|
||||||
}
|
|
||||||
| UseMvTargetPos
|
|
||||||
{_useMvTargetPos :: MP2Ac
|
|
||||||
}
|
|
||||||
| ArbitraryAction
|
|
||||||
{ _arbitraryAction :: CrWdAc }
|
|
||||||
| DoImpulsesAlongside
|
|
||||||
-- ^ Repeatedly perform impulses alongside a main action until the main action terminates
|
|
||||||
{_sideImpulses :: [Impulse]
|
|
||||||
,_mainAction :: Action
|
|
||||||
}
|
|
||||||
deriving (Generic)
|
|
||||||
instance Show Action where
|
|
||||||
show act = case act of
|
|
||||||
ActionNothing -> "ActionNothing"
|
|
||||||
LabelAction
|
|
||||||
{_actLabel = str
|
|
||||||
,_actAction = subAct
|
|
||||||
} -> str++":"++show subAct
|
|
||||||
AimAt
|
|
||||||
{_targetID = tid
|
|
||||||
,_targetSeenAt = p
|
|
||||||
} -> "AimAt tid:"++show tid++" seenAt:"++shortPoint2 p
|
|
||||||
PathTo
|
|
||||||
{_pathToPoint = p
|
|
||||||
} -> "PathTo:"++shortPoint2 p
|
|
||||||
TurnToPoint
|
|
||||||
{_turnToPoint = p
|
|
||||||
} -> "TurnToPoint:"++shortPoint2 p
|
|
||||||
---- | PickupItem
|
|
||||||
---- {_pickupItemID :: Int
|
|
||||||
---- }
|
|
||||||
ImpulsesList
|
|
||||||
{_impulsesListList = iss
|
|
||||||
} -> "ImpulsesList:"++show iss
|
|
||||||
DoImpulses
|
|
||||||
{_doImpulsesList = is
|
|
||||||
} -> "DoImpulses:"++show is
|
|
||||||
WaitThen
|
|
||||||
{_waitThenTimer = i
|
|
||||||
,_waitThenAction = a
|
|
||||||
} -> "WaitThen timer:"++show i++" act:"++show a
|
|
||||||
DoActionWhile
|
|
||||||
{_doActionWhileCondition = _
|
|
||||||
,_doActionWhileAction = a
|
|
||||||
} -> "DoActionWhile (function) act:"++show a
|
|
||||||
DoActionWhilePartial
|
|
||||||
{_doActionWhilePartial = partact
|
|
||||||
,_doActionWhileCondition = _
|
|
||||||
,_doActionWhileAction = a
|
|
||||||
} -> "DoActionWhilePartial partAct:"++show partact++" resetAct:"++show a
|
|
||||||
DoActionIf
|
|
||||||
{_doActionIfCondition = _
|
|
||||||
,_doActionIfAction = a
|
|
||||||
} -> "DoActionIf act:"++show a
|
|
||||||
DoActionIfElse
|
|
||||||
{_doActionIfElseIfAction = ifa
|
|
||||||
,_doActionIfElseCondition = _
|
|
||||||
,_doActionIfElseElseAction = elsea
|
|
||||||
} -> "DoActionIfElse ifa:"++show ifa++" elsea:"++show elsea
|
|
||||||
DoActionWhileInterrupt
|
|
||||||
{_doActionWhileThenDo = whilea
|
|
||||||
,_doActionWhileThenCondition = _
|
|
||||||
,_doActionWhileThenThen = thena
|
|
||||||
} -> "DoActionWhileInterrupt whilea:" ++show whilea++" interrupta:"++show thena
|
|
||||||
DoActions
|
|
||||||
{_doActionsList = as
|
|
||||||
} -> "DoActions " ++ foldMap show as
|
|
||||||
DoActionThen
|
|
||||||
{_doActionThenFirst = a1
|
|
||||||
,_doActionThenSecond = a2
|
|
||||||
} -> "DoActionThen " ++ show a1 ++ " then:" ++ show a2
|
|
||||||
---- | DoGuardActions
|
|
||||||
---- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
|
||||||
---- }
|
|
||||||
DoReplicate
|
|
||||||
{_doReplicateTimes = i
|
|
||||||
,_doReplicateAction = a
|
|
||||||
} -> "DoReplicate times:" ++ show i ++ " act:"++ show a
|
|
||||||
DoReplicatePartial
|
|
||||||
{_partialAction = pa
|
|
||||||
,_doReplicateTimes = i
|
|
||||||
,_doReplicateAction = ra
|
|
||||||
} -> "DoReplicatePartial pa:" ++ show pa ++ " times:" ++ show i ++ " reset:"++ show ra
|
|
||||||
LeadTarget
|
|
||||||
{_leadTargetBy = p
|
|
||||||
} -> "LeadTarget by:"++ show p
|
|
||||||
NoAction -> "NoAction"
|
|
||||||
StartSentinelPost -> "StartSentinelPost"
|
|
||||||
UseTarget
|
|
||||||
{_useTarget = _
|
|
||||||
} -> "UseTarget func"
|
|
||||||
UseSelf
|
|
||||||
{_useSelf = _
|
|
||||||
} -> "UseSelf func"
|
|
||||||
UseAheadPos
|
|
||||||
{_useAheadPos = _
|
|
||||||
} -> "UseAheadPos func"
|
|
||||||
UseMvTargetPos
|
|
||||||
{_useMvTargetPos = _
|
|
||||||
} -> "UseMvTargetPos func"
|
|
||||||
ArbitraryAction {} -> "ArbitraryAction func"
|
|
||||||
DoImpulsesAlongside
|
|
||||||
{_sideImpulses = is
|
|
||||||
,_mainAction = a
|
|
||||||
} -> "DoImpulsesAlongside sideImpulses:"++show is ++ " mainA:"++show a
|
|
||||||
|
|
||||||
-- deriving (Eq,Ord,Show)
|
|
||||||
data Strategy
|
|
||||||
= Flank Int
|
|
||||||
| Ambush Int
|
|
||||||
| Lure Int Point2
|
|
||||||
| Patrol [Point2]
|
|
||||||
| ShootAt Int
|
|
||||||
| FollowImpulses
|
|
||||||
| WatchAndWait
|
|
||||||
| WarningCry
|
|
||||||
| LookAround
|
|
||||||
| CloseToMelee Int
|
|
||||||
| StrategyActions Strategy [Action]
|
|
||||||
| GetTo Point2
|
|
||||||
| Reload
|
|
||||||
| Flee
|
|
||||||
| MeleeStrike
|
|
||||||
deriving (Generic,Show)
|
|
||||||
-- deriving (Eq,Ord,Show)
|
|
||||||
data Goal
|
|
||||||
= LiveLongAndProsper
|
|
||||||
| Kill Int
|
|
||||||
| SentinelAt Point2 Float
|
|
||||||
deriving (Show)
|
|
||||||
|
|
||||||
data CreatureState = CrSt
|
|
||||||
{ _csDamage :: [Damage]
|
|
||||||
, _csSpState :: CrSpState
|
|
||||||
, _csDropsOnDeath :: CreatureDropType
|
|
||||||
}
|
|
||||||
|
|
||||||
data EffectArguments
|
data EffectArguments
|
||||||
= NoArguments {_cmdEffect :: [TerminalLine]}
|
= NoArguments {_cmdEffect :: [TerminalLine]}
|
||||||
| OneArgument
|
| OneArgument
|
||||||
@@ -1070,8 +722,6 @@ data InPlacement = InPlacement
|
|||||||
{ _ipPlacement :: [Placement] -> Placement
|
{ _ipPlacement :: [Placement] -> Placement
|
||||||
, _ipPlacementID :: Int
|
, _ipPlacementID :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''CreatureState
|
|
||||||
makeLenses ''World
|
makeLenses ''World
|
||||||
makeLenses ''Creature
|
makeLenses ''Creature
|
||||||
makeLenses ''FloorItem
|
makeLenses ''FloorItem
|
||||||
@@ -1080,9 +730,6 @@ makeLenses ''Proj
|
|||||||
makeLenses ''Modification
|
makeLenses ''Modification
|
||||||
makeLenses ''Particle
|
makeLenses ''Particle
|
||||||
makeLenses ''PressPlate
|
makeLenses ''PressPlate
|
||||||
makeLenses ''ActionPlan
|
|
||||||
makeLenses ''Impulse
|
|
||||||
makeLenses ''Action
|
|
||||||
makeLenses ''CrGroupParams
|
makeLenses ''CrGroupParams
|
||||||
makeLenses ''Intention
|
makeLenses ''Intention
|
||||||
makeLenses ''Door
|
makeLenses ''Door
|
||||||
|
|||||||
@@ -1 +1,305 @@
|
|||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
module Dodge.Data.ActionPlan where
|
module Dodge.Data.ActionPlan where
|
||||||
|
import Dodge.Creature.Stance.Data
|
||||||
|
import Dodge.Data.CreatureEffect
|
||||||
|
import Dodge.ShortShow
|
||||||
|
import Control.Lens
|
||||||
|
import Geometry.Data
|
||||||
|
import Control.Monad.State
|
||||||
|
import System.Random
|
||||||
|
import Sound.Data
|
||||||
|
import GHC.Generics
|
||||||
|
data ActionPlan
|
||||||
|
= Inanimate
|
||||||
|
| ActionPlan
|
||||||
|
{_apImpulse :: [Impulse]
|
||||||
|
,_apAction :: [Action]
|
||||||
|
,_apStrategy :: Strategy
|
||||||
|
,_apGoal :: [Goal]
|
||||||
|
}
|
||||||
|
data RandImpulse = RandImpulseList [Impulse]
|
||||||
|
data Impulse
|
||||||
|
= Move Point2
|
||||||
|
| MoveForward Float
|
||||||
|
| Turn Float
|
||||||
|
| RandomTurn Float
|
||||||
|
| RandomImpulse (State StdGen Impulse)
|
||||||
|
| TurnToward Point2 Float
|
||||||
|
| MvTurnToward Point2
|
||||||
|
| MvForward
|
||||||
|
| TurnTo Point2
|
||||||
|
| UseItem
|
||||||
|
| SwitchToItem Int
|
||||||
|
| DropItem
|
||||||
|
| Bark SoundID -- placeholder for various communication types
|
||||||
|
| Melee Int
|
||||||
|
| ChangePosture Posture
|
||||||
|
| MakeSound SoundID
|
||||||
|
| ChangeStrategy Strategy
|
||||||
|
| AddGoal Goal
|
||||||
|
| ArbitraryImpulseFunction WdCrCr
|
||||||
|
| ArbitraryImpulse CrWdImp
|
||||||
|
| ArbitraryImpulseEffect CrWdWd
|
||||||
|
| ImpulseUseTargetCID
|
||||||
|
{_impulseUseTargetCID :: IntImp
|
||||||
|
}
|
||||||
|
| ImpulseUseTarget
|
||||||
|
{_impulseUseTarget :: CrImp
|
||||||
|
}
|
||||||
|
| ImpulseUseAheadPos
|
||||||
|
{_impulseUseAheadPos :: P2Imp
|
||||||
|
}
|
||||||
|
| ImpulseNothing
|
||||||
|
instance Show Impulse where
|
||||||
|
show imp = case imp of
|
||||||
|
Move p -> "Move "++shortPoint2 p
|
||||||
|
MoveForward f -> "MoveForward "++ show f
|
||||||
|
Turn f -> "Turn "++show f
|
||||||
|
RandomTurn f -> "RandomTurn "++show f
|
||||||
|
TurnToward p f -> "TurnToward "++shortPoint2 p++show f
|
||||||
|
MvTurnToward p -> "MvTurnToward "++shortPoint2 p
|
||||||
|
MvForward -> "MvForward"
|
||||||
|
TurnTo p -> "TurnTo "++shortPoint2 p
|
||||||
|
UseItem -> "UseItem"
|
||||||
|
SwitchToItem i -> "SwitchToItem "++show i
|
||||||
|
DropItem -> "DropItem"
|
||||||
|
Bark sid -> "Bark "++show sid
|
||||||
|
Melee i -> "Melee "++show i
|
||||||
|
ChangePosture post -> "ChangePosture " ++ show post
|
||||||
|
MakeSound sid -> "MakeSound " ++ show sid
|
||||||
|
ChangeStrategy s -> "ChangeStrategy " ++ show s
|
||||||
|
AddGoal g -> "AddGoal " ++ show g
|
||||||
|
ArbitraryImpulseFunction {} -> "ArbitraryImpulseFunction"
|
||||||
|
ArbitraryImpulse {} -> "ArbitraryImpulse"
|
||||||
|
ArbitraryImpulseEffect {} -> "ArbitraryImpulseEffect"
|
||||||
|
ImpulseUseTargetCID {} -> "ImpulseUseTargetCID"
|
||||||
|
ImpulseUseTarget {} -> "ImpulseUseTarget"
|
||||||
|
ImpulseUseAheadPos {} -> "ImpulseUseAheadPos"
|
||||||
|
RandomImpulse {} -> "RandomImpulse"
|
||||||
|
ImpulseNothing -> "ImpulseNothing"
|
||||||
|
-- deriving (Eq,Ord,Show)
|
||||||
|
infixr 9 `WaitThen`
|
||||||
|
infixr 9 `DoActionThen`
|
||||||
|
infixr 9 `DoActionWhile`
|
||||||
|
infixr 9 `DoReplicate`
|
||||||
|
infixr 9 `DoImpulsesAlongside`
|
||||||
|
data Action
|
||||||
|
= LabelAction
|
||||||
|
{_actLabel :: String
|
||||||
|
,_actAction :: Action
|
||||||
|
}
|
||||||
|
| ActionNothing
|
||||||
|
| AimAt
|
||||||
|
{_targetID :: Int
|
||||||
|
,_targetSeenAt :: Point2
|
||||||
|
}
|
||||||
|
| PathTo
|
||||||
|
{_pathToPoint :: Point2
|
||||||
|
}
|
||||||
|
| TurnToPoint
|
||||||
|
{_turnToPoint :: Point2
|
||||||
|
}
|
||||||
|
-- | PickupItem
|
||||||
|
-- {_pickupItemID :: Int
|
||||||
|
-- }
|
||||||
|
| ImpulsesList
|
||||||
|
{_impulsesListList :: [[Impulse]]
|
||||||
|
}
|
||||||
|
| DoImpulses
|
||||||
|
{_doImpulsesList :: [Impulse]
|
||||||
|
}
|
||||||
|
| WaitThen
|
||||||
|
{_waitThenTimer :: Int
|
||||||
|
,_waitThenAction :: Action
|
||||||
|
}
|
||||||
|
| DoActionWhile
|
||||||
|
{_doActionWhileCondition :: WdCrBl
|
||||||
|
,_doActionWhileAction :: Action
|
||||||
|
}
|
||||||
|
| DoActionWhilePartial
|
||||||
|
{_doActionWhilePartial :: Action
|
||||||
|
,_doActionWhileCondition :: WdCrBl
|
||||||
|
,_doActionWhileAction :: Action
|
||||||
|
}
|
||||||
|
| DoActionIf
|
||||||
|
{_doActionIfCondition :: WdCrBl
|
||||||
|
,_doActionIfAction :: Action
|
||||||
|
}
|
||||||
|
| DoActionIfElse
|
||||||
|
{_doActionIfElseIfAction :: Action
|
||||||
|
,_doActionIfElseCondition :: WdCrBl
|
||||||
|
,_doActionIfElseElseAction :: Action
|
||||||
|
}
|
||||||
|
| DoActionWhileInterrupt
|
||||||
|
{_doActionWhileThenDo :: Action
|
||||||
|
,_doActionWhileThenCondition :: WdCrBl
|
||||||
|
,_doActionWhileThenThen :: Action
|
||||||
|
}
|
||||||
|
| DoActions
|
||||||
|
{_doActionsList :: [Action]
|
||||||
|
}
|
||||||
|
| DoActionThen
|
||||||
|
{_doActionThenFirst :: Action
|
||||||
|
,_doActionThenSecond :: Action
|
||||||
|
}
|
||||||
|
-- | DoGuardActions
|
||||||
|
-- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
||||||
|
-- }
|
||||||
|
| DoReplicate
|
||||||
|
{_doReplicateTimes :: Int
|
||||||
|
,_doReplicateAction :: Action
|
||||||
|
}
|
||||||
|
| DoReplicatePartial
|
||||||
|
{_partialAction :: Action
|
||||||
|
,_doReplicateTimes :: Int
|
||||||
|
,_doReplicateAction :: Action
|
||||||
|
}
|
||||||
|
| LeadTarget
|
||||||
|
{_leadTargetBy :: Point2
|
||||||
|
}
|
||||||
|
| NoAction
|
||||||
|
| StartSentinelPost
|
||||||
|
| UseTarget
|
||||||
|
{_useTarget :: MCrAc
|
||||||
|
}
|
||||||
|
| UseSelf
|
||||||
|
{_useSelf :: CrAc
|
||||||
|
}
|
||||||
|
| UseAheadPos
|
||||||
|
{_useAheadPos :: P2Ac
|
||||||
|
}
|
||||||
|
| UseMvTargetPos
|
||||||
|
{_useMvTargetPos :: MP2Ac
|
||||||
|
}
|
||||||
|
| ArbitraryAction
|
||||||
|
{ _arbitraryAction :: CrWdAc }
|
||||||
|
| DoImpulsesAlongside
|
||||||
|
-- ^ Repeatedly perform impulses alongside a main action until the main action terminates
|
||||||
|
{_sideImpulses :: [Impulse]
|
||||||
|
,_mainAction :: Action
|
||||||
|
}
|
||||||
|
deriving (Generic)
|
||||||
|
instance Show Action where
|
||||||
|
show act = case act of
|
||||||
|
ActionNothing -> "ActionNothing"
|
||||||
|
LabelAction
|
||||||
|
{_actLabel = str
|
||||||
|
,_actAction = subAct
|
||||||
|
} -> str++":"++show subAct
|
||||||
|
AimAt
|
||||||
|
{_targetID = tid
|
||||||
|
,_targetSeenAt = p
|
||||||
|
} -> "AimAt tid:"++show tid++" seenAt:"++shortPoint2 p
|
||||||
|
PathTo
|
||||||
|
{_pathToPoint = p
|
||||||
|
} -> "PathTo:"++shortPoint2 p
|
||||||
|
TurnToPoint
|
||||||
|
{_turnToPoint = p
|
||||||
|
} -> "TurnToPoint:"++shortPoint2 p
|
||||||
|
---- | PickupItem
|
||||||
|
---- {_pickupItemID :: Int
|
||||||
|
---- }
|
||||||
|
ImpulsesList
|
||||||
|
{_impulsesListList = iss
|
||||||
|
} -> "ImpulsesList:"++show iss
|
||||||
|
DoImpulses
|
||||||
|
{_doImpulsesList = is
|
||||||
|
} -> "DoImpulses:"++show is
|
||||||
|
WaitThen
|
||||||
|
{_waitThenTimer = i
|
||||||
|
,_waitThenAction = a
|
||||||
|
} -> "WaitThen timer:"++show i++" act:"++show a
|
||||||
|
DoActionWhile
|
||||||
|
{_doActionWhileCondition = _
|
||||||
|
,_doActionWhileAction = a
|
||||||
|
} -> "DoActionWhile (function) act:"++show a
|
||||||
|
DoActionWhilePartial
|
||||||
|
{_doActionWhilePartial = partact
|
||||||
|
,_doActionWhileCondition = _
|
||||||
|
,_doActionWhileAction = a
|
||||||
|
} -> "DoActionWhilePartial partAct:"++show partact++" resetAct:"++show a
|
||||||
|
DoActionIf
|
||||||
|
{_doActionIfCondition = _
|
||||||
|
,_doActionIfAction = a
|
||||||
|
} -> "DoActionIf act:"++show a
|
||||||
|
DoActionIfElse
|
||||||
|
{_doActionIfElseIfAction = ifa
|
||||||
|
,_doActionIfElseCondition = _
|
||||||
|
,_doActionIfElseElseAction = elsea
|
||||||
|
} -> "DoActionIfElse ifa:"++show ifa++" elsea:"++show elsea
|
||||||
|
DoActionWhileInterrupt
|
||||||
|
{_doActionWhileThenDo = whilea
|
||||||
|
,_doActionWhileThenCondition = _
|
||||||
|
,_doActionWhileThenThen = thena
|
||||||
|
} -> "DoActionWhileInterrupt whilea:" ++show whilea++" interrupta:"++show thena
|
||||||
|
DoActions
|
||||||
|
{_doActionsList = as
|
||||||
|
} -> "DoActions " ++ foldMap show as
|
||||||
|
DoActionThen
|
||||||
|
{_doActionThenFirst = a1
|
||||||
|
,_doActionThenSecond = a2
|
||||||
|
} -> "DoActionThen " ++ show a1 ++ " then:" ++ show a2
|
||||||
|
---- | DoGuardActions
|
||||||
|
---- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
||||||
|
---- }
|
||||||
|
DoReplicate
|
||||||
|
{_doReplicateTimes = i
|
||||||
|
,_doReplicateAction = a
|
||||||
|
} -> "DoReplicate times:" ++ show i ++ " act:"++ show a
|
||||||
|
DoReplicatePartial
|
||||||
|
{_partialAction = pa
|
||||||
|
,_doReplicateTimes = i
|
||||||
|
,_doReplicateAction = ra
|
||||||
|
} -> "DoReplicatePartial pa:" ++ show pa ++ " times:" ++ show i ++ " reset:"++ show ra
|
||||||
|
LeadTarget
|
||||||
|
{_leadTargetBy = p
|
||||||
|
} -> "LeadTarget by:"++ show p
|
||||||
|
NoAction -> "NoAction"
|
||||||
|
StartSentinelPost -> "StartSentinelPost"
|
||||||
|
UseTarget
|
||||||
|
{_useTarget = _
|
||||||
|
} -> "UseTarget func"
|
||||||
|
UseSelf
|
||||||
|
{_useSelf = _
|
||||||
|
} -> "UseSelf func"
|
||||||
|
UseAheadPos
|
||||||
|
{_useAheadPos = _
|
||||||
|
} -> "UseAheadPos func"
|
||||||
|
UseMvTargetPos
|
||||||
|
{_useMvTargetPos = _
|
||||||
|
} -> "UseMvTargetPos func"
|
||||||
|
ArbitraryAction {} -> "ArbitraryAction func"
|
||||||
|
DoImpulsesAlongside
|
||||||
|
{_sideImpulses = is
|
||||||
|
,_mainAction = a
|
||||||
|
} -> "DoImpulsesAlongside sideImpulses:"++show is ++ " mainA:"++show a
|
||||||
|
|
||||||
|
-- deriving (Eq,Ord,Show)
|
||||||
|
data Strategy
|
||||||
|
= Flank Int
|
||||||
|
| Ambush Int
|
||||||
|
| Lure Int Point2
|
||||||
|
| Patrol [Point2]
|
||||||
|
| ShootAt Int
|
||||||
|
| FollowImpulses
|
||||||
|
| WatchAndWait
|
||||||
|
| WarningCry
|
||||||
|
| LookAround
|
||||||
|
| CloseToMelee Int
|
||||||
|
| StrategyActions Strategy [Action]
|
||||||
|
| GetTo Point2
|
||||||
|
| Reload
|
||||||
|
| Flee
|
||||||
|
| MeleeStrike
|
||||||
|
deriving (Generic,Show)
|
||||||
|
-- deriving (Eq,Ord,Show)
|
||||||
|
data Goal
|
||||||
|
= LiveLongAndProsper
|
||||||
|
| Kill Int
|
||||||
|
| SentinelAt Point2 Float
|
||||||
|
deriving (Show)
|
||||||
|
makeLenses ''ActionPlan
|
||||||
|
makeLenses ''Impulse
|
||||||
|
makeLenses ''Action
|
||||||
|
|||||||
+66
-45
@@ -2,53 +2,74 @@
|
|||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.Data.Creature
|
module Dodge.Data.Creature
|
||||||
( module Dodge.Data.Creature
|
( module Dodge.Data.Creature
|
||||||
, module Dodge.Data.CamouflageStatus
|
, module Dodge.Data.Creature.Misc
|
||||||
|
, module Dodge.Data.Creature.State
|
||||||
) where
|
) where
|
||||||
import Dodge.Data.CamouflageStatus
|
import Dodge.Data.Creature.Misc
|
||||||
import Sound.Data
|
import Dodge.Data.Creature.State
|
||||||
|
import Dodge.Data.Item
|
||||||
|
import Dodge.Data.LoadAction
|
||||||
|
import Dodge.Data.Material
|
||||||
|
import Dodge.Data.ActionPlan
|
||||||
|
import Dodge.Data.Hammer
|
||||||
|
import Dodge.Creature.Perception.Data
|
||||||
|
import Dodge.Creature.Memory.Data
|
||||||
|
import Dodge.Creature.Stance.Data
|
||||||
|
import Dodge.Creature.State.Data
|
||||||
|
import Dodge.Equipment.Data
|
||||||
|
import ShapePicture
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Color
|
import qualified IntMapHelp as IM
|
||||||
import Control.Lens
|
import qualified Data.Map.Strict as M
|
||||||
data CreatureStatistics = CreatureStatistics
|
data Creature = Creature
|
||||||
{ _strength :: Int
|
{ _crPos :: Point2
|
||||||
, _dexterity :: Int
|
, _crOldPos :: Point2
|
||||||
, _intelligence :: Int
|
, _crVel :: Point2
|
||||||
|
, _crDir :: Float
|
||||||
|
, _crOldDir :: Float
|
||||||
|
, _crMvDir :: Float
|
||||||
|
, _crTwist :: Float
|
||||||
|
, _crType :: CreatureType
|
||||||
|
, _crID :: Int
|
||||||
|
, _crRad :: Float
|
||||||
|
, _crMass :: Float
|
||||||
|
, _crHP :: Int
|
||||||
|
, _crMaxHP :: Int
|
||||||
|
, _crInv :: IM.IntMap Item
|
||||||
|
, _crInvSel :: InvSel
|
||||||
|
, _crInvCapacity :: Int
|
||||||
|
, _crInvLock :: Bool
|
||||||
|
, _crInvEquipped :: IM.IntMap EquipPosition
|
||||||
|
, _crEquipment :: M.Map EquipPosition Int
|
||||||
|
, _crLeftInvSel :: Maybe Int
|
||||||
|
, _crState :: CreatureState
|
||||||
|
, _crCorpse :: Creature -> Corpse -> SPic
|
||||||
|
, _crMaterial :: Material
|
||||||
|
, _crPastDamage :: Int
|
||||||
|
, _crStance :: Stance
|
||||||
|
, _crActionPlan :: ActionPlan
|
||||||
|
, _crMeleeCooldown :: Int
|
||||||
|
, _crPerception :: Perception
|
||||||
|
, _crMemory :: Memory
|
||||||
|
, _crVocalization :: Vocalization
|
||||||
|
, _crFaction :: Faction
|
||||||
|
, _crGroup :: CrGroup
|
||||||
|
, _crIntention :: Intention
|
||||||
|
, _crMvType :: CrMvType
|
||||||
|
, _crHammerPosition :: HammerPosition
|
||||||
|
, _crName :: String
|
||||||
|
, _crStatistics :: CreatureStatistics
|
||||||
|
, _crCamouflage :: CamouflageStatus
|
||||||
}
|
}
|
||||||
deriving (Eq,Ord,Show)
|
data Corpse = Corpse
|
||||||
data Vocalization
|
{ _cpID :: Int
|
||||||
= Mute
|
, _cpPos :: Point2
|
||||||
| Vocalization
|
, _cpDir :: Float
|
||||||
{_vcSound :: SoundID
|
, _cpPict :: Corpse -> SPic
|
||||||
,_vcWarnings :: [SoundID]
|
, _cpRes :: Maybe Creature
|
||||||
,_vcMaxCoolDown :: Int
|
|
||||||
,_vcCoolDown :: Int
|
|
||||||
}
|
}
|
||||||
deriving (Eq,Ord,Show)
|
data Intention = Intention
|
||||||
data CrMvType
|
{ _targetCr :: Maybe Creature
|
||||||
= NoMvType
|
, _mvToPoint :: Maybe Point2
|
||||||
| MvWalking { _mvSpeed :: Float }
|
, _viewPoint :: Maybe Point2
|
||||||
| CrMvType
|
|
||||||
{ _mvSpeed :: Float
|
|
||||||
, _mvTurnRad :: Float -> Float
|
|
||||||
, _mvTurnJit :: Float
|
|
||||||
, _mvAimSpeed :: Float -> Float
|
|
||||||
}
|
}
|
||||||
data HumanoidAI = YourAI | ChaseAI | InanimateAI | SpreadGunAI | PistolAI
|
|
||||||
| LtAutoAI | LauncherAI | SwarmAI | AutoAI | FlockArmourChaseAI | MiniGunAI
|
|
||||||
| LongAI | MultGunAI
|
|
||||||
data CreatureType
|
|
||||||
= Humanoid
|
|
||||||
{ _skinHead :: Color
|
|
||||||
, _skinUpper :: Color
|
|
||||||
, _skinLower :: Color
|
|
||||||
, _humanoidAI :: HumanoidAI
|
|
||||||
}
|
|
||||||
| Barreloid {_barrelType :: BarrelType}
|
|
||||||
| Lampoid {_lampHeight :: Float, _lampColor :: Point3, _lampLSID :: Maybe Int}
|
|
||||||
| Turretoid
|
|
||||||
| NonDrawnCreature
|
|
||||||
data BarrelType = PlainBarrel | ExplosiveBarrel
|
|
||||||
makeLenses ''CreatureStatistics
|
|
||||||
makeLenses ''Vocalization
|
|
||||||
makeLenses ''CrMvType
|
|
||||||
makeLenses ''CreatureType
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
module Dodge.Data.Creature.Misc
|
||||||
|
( module Dodge.Data.Creature.Misc
|
||||||
|
, module Dodge.Data.CamouflageStatus
|
||||||
|
) where
|
||||||
|
import Dodge.Data.CamouflageStatus
|
||||||
|
import Sound.Data
|
||||||
|
import Geometry.Data
|
||||||
|
import Color
|
||||||
|
import Control.Lens
|
||||||
|
data CreatureStatistics = CreatureStatistics
|
||||||
|
{ _strength :: Int
|
||||||
|
, _dexterity :: Int
|
||||||
|
, _intelligence :: Int
|
||||||
|
}
|
||||||
|
deriving (Eq,Ord,Show)
|
||||||
|
data Vocalization
|
||||||
|
= Mute
|
||||||
|
| Vocalization
|
||||||
|
{_vcSound :: SoundID
|
||||||
|
,_vcWarnings :: [SoundID]
|
||||||
|
,_vcMaxCoolDown :: Int
|
||||||
|
,_vcCoolDown :: Int
|
||||||
|
}
|
||||||
|
deriving (Eq,Ord,Show)
|
||||||
|
data CrMvType
|
||||||
|
= NoMvType
|
||||||
|
| MvWalking { _mvSpeed :: Float }
|
||||||
|
| CrMvType
|
||||||
|
{ _mvSpeed :: Float
|
||||||
|
, _mvTurnRad :: Float -> Float
|
||||||
|
, _mvTurnJit :: Float
|
||||||
|
, _mvAimSpeed :: Float -> Float
|
||||||
|
}
|
||||||
|
data HumanoidAI = YourAI | ChaseAI | InanimateAI | SpreadGunAI | PistolAI
|
||||||
|
| LtAutoAI | LauncherAI | SwarmAI | AutoAI | FlockArmourChaseAI | MiniGunAI
|
||||||
|
| LongAI | MultGunAI
|
||||||
|
data CreatureType
|
||||||
|
= Humanoid
|
||||||
|
{ _skinHead :: Color
|
||||||
|
, _skinUpper :: Color
|
||||||
|
, _skinLower :: Color
|
||||||
|
, _humanoidAI :: HumanoidAI
|
||||||
|
}
|
||||||
|
| Barreloid {_barrelType :: BarrelType}
|
||||||
|
| Lampoid {_lampHeight :: Float, _lampColor :: Point3, _lampLSID :: Maybe Int}
|
||||||
|
| Turretoid
|
||||||
|
| NonDrawnCreature
|
||||||
|
data BarrelType = PlainBarrel | ExplosiveBarrel
|
||||||
|
makeLenses ''CreatureStatistics
|
||||||
|
makeLenses ''Vocalization
|
||||||
|
makeLenses ''CrMvType
|
||||||
|
makeLenses ''CreatureType
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
module Dodge.Data.Creature.State where
|
||||||
|
import Dodge.Data.Damage
|
||||||
|
import Dodge.Creature.State.Data
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
data CreatureState = CrSt
|
||||||
|
{ _csDamage :: [Damage]
|
||||||
|
, _csSpState :: CrSpState
|
||||||
|
, _csDropsOnDeath :: CreatureDropType
|
||||||
|
}
|
||||||
|
makeLenses ''CreatureState
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
module MapHelp
|
||||||
|
( module Data.Strict.Map
|
||||||
|
) where
|
||||||
|
import Data.Strict.Map
|
||||||
Reference in New Issue
Block a user