Improve awareness
This commit is contained in:
@@ -82,6 +82,7 @@ miniGunCrit = defaultCreature
|
|||||||
, _crRad = 10
|
, _crRad = 10
|
||||||
, _crState = defaultState
|
, _crState = defaultState
|
||||||
, _crHP = 500
|
, _crHP = 500
|
||||||
|
, _crMvType = defaultAimMvType
|
||||||
}
|
}
|
||||||
longCrit :: Creature
|
longCrit :: Creature
|
||||||
longCrit = defaultCreature
|
longCrit = defaultCreature
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
{- | Actions performed by creatures within the world
|
{- | Actions performed by creatures within the world
|
||||||
-}
|
-}
|
||||||
module Dodge.Creature.Action
|
module Dodge.Creature.Action
|
||||||
-- ( module Dodge.Creature.Action
|
( performActionsR
|
||||||
-- , module Dodge.Creature.Action.UseItem
|
, startReloadingWeapon
|
||||||
-- , module Dodge.Creature.Action.Movement
|
, blinkAction
|
||||||
-- )
|
, crAutoReload
|
||||||
|
, copyItemToFloor
|
||||||
|
, youDropItem
|
||||||
|
, pickUpItem
|
||||||
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Creature.Stance.Data
|
import Dodge.Creature.Stance.Data
|
||||||
import Dodge.WorldEvent.Shockwave
|
import Dodge.WorldEvent.Shockwave
|
||||||
@@ -39,6 +43,28 @@ performActions w cr = cr
|
|||||||
performActionsR :: Creature -> Reader World Creature
|
performActionsR :: Creature -> Reader World Creature
|
||||||
performActionsR cr = reader $ \w -> performActions w cr
|
performActionsR cr = reader $ \w -> performActions w cr
|
||||||
|
|
||||||
|
type OutAction = ( [Impulse] , Maybe Action )
|
||||||
|
|
||||||
|
performAimAt :: Creature -> World -> Int -> Point2 -> OutAction
|
||||||
|
performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
|
||||||
|
where
|
||||||
|
cdir = _crDir cr
|
||||||
|
cpos = _crPos cr
|
||||||
|
canSee' = canSee (_crID cr) tcid w
|
||||||
|
aimSp = case cr ^? crMvType . mvAimSpeed of
|
||||||
|
Just f -> f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
|
||||||
|
Nothing -> error "creature without aiming type"
|
||||||
|
tpos | canSee' = _crPos (_creatures w IM.! tcid)
|
||||||
|
| otherwise = p
|
||||||
|
|
||||||
|
performPathTo :: Creature -> World -> Point2 -> OutAction
|
||||||
|
performPathTo cr w p
|
||||||
|
| dist cpos p < 5 = ([], Nothing)
|
||||||
|
| hasLOS cpos p w = ([MvTurnToward p,MvForward] , Just (PathTo p))
|
||||||
|
| otherwise = ([], Nothing)
|
||||||
|
where
|
||||||
|
cpos = _crPos cr
|
||||||
|
|
||||||
{- | Performing an action means that a creature has some impulses for a frame, and
|
{- | Performing an action means that a creature has some impulses for a frame, and
|
||||||
updates or deletes the action itself.
|
updates or deletes the action itself.
|
||||||
-- doAction -}
|
-- doAction -}
|
||||||
@@ -46,17 +72,9 @@ performAction
|
|||||||
:: Creature
|
:: Creature
|
||||||
-> World
|
-> World
|
||||||
-> Action
|
-> Action
|
||||||
-> ( [Impulse] , Maybe Action )
|
-> OutAction
|
||||||
performAction cr w ac = case ac of
|
performAction cr w ac = case ac of
|
||||||
AimAt tcid p
|
AimAt tcid p -> performAimAt cr w tcid p
|
||||||
-> ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
|
|
||||||
where
|
|
||||||
canSee' = canSee (_crID cr) tcid w
|
|
||||||
aimSp = case cr ^? crMvType . mvAimSpeed of
|
|
||||||
Just f -> f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
|
|
||||||
Nothing -> error "creature without aiming type"
|
|
||||||
tpos | canSee' = _crPos (_creatures w IM.! tcid)
|
|
||||||
| otherwise = p
|
|
||||||
WaitThen 0 newAc -> ([] , Just newAc)
|
WaitThen 0 newAc -> ([] , Just newAc)
|
||||||
WaitThen t newAc -> ([] , Just (WaitThen (t-1) newAc))
|
WaitThen t newAc -> ([] , Just (WaitThen (t-1) newAc))
|
||||||
ImpulsesList (xs:xss) -> (xs, Just $ ImpulsesList xss)
|
ImpulsesList (xs:xss) -> (xs, Just $ ImpulsesList xss)
|
||||||
@@ -85,10 +103,7 @@ performAction cr w ac = case ac of
|
|||||||
let (imps, newAcs) = unzip $ map (performAction cr w) acs
|
let (imps, newAcs) = unzip $ map (performAction cr w) acs
|
||||||
in (concat imps, Just . DoActions $ catMaybes newAcs)
|
in (concat imps, Just . DoActions $ catMaybes newAcs)
|
||||||
StartSentinelPost -> ([AddGoal $ SentinelAt (_crPos cr) (_crDir cr)], Nothing)
|
StartSentinelPost -> ([AddGoal $ SentinelAt (_crPos cr) (_crDir cr)], Nothing)
|
||||||
PathTo p
|
PathTo p -> performPathTo cr w p
|
||||||
| dist cpos p < 5 -> ([], Nothing)
|
|
||||||
| hasLOS cpos p w -> ([MvTurnToward p,MvForward] , Just (PathTo p))
|
|
||||||
| otherwise -> ([], Nothing)
|
|
||||||
LeadTarget p -> case cr ^? crTarget . _Just of
|
LeadTarget p -> case cr ^? crTarget . _Just of
|
||||||
Just tcr -> ([TurnTo (_crPos tcr +.+ rotateV (_crDir tcr) p)], Nothing)
|
Just tcr -> ([TurnTo (_crPos tcr +.+ rotateV (_crDir tcr) p)], Nothing)
|
||||||
_ -> ([], Nothing)
|
_ -> ([], Nothing)
|
||||||
@@ -106,10 +121,6 @@ performAction cr w ac = case ac of
|
|||||||
(imps , Just nac) -> (imps, Just $ DoReplicatePartial sac t nac)
|
(imps , Just nac) -> (imps, Just $ DoReplicatePartial sac t nac)
|
||||||
(imps , _) -> (imps, Just $ DoReplicatePartial sac (t-1) sac)
|
(imps , _) -> (imps, Just $ DoReplicatePartial sac (t-1) sac)
|
||||||
NoAction -> ([],Nothing)
|
NoAction -> ([],Nothing)
|
||||||
-- _ -> ([], Nothing)
|
|
||||||
where
|
|
||||||
cpos = _crPos cr
|
|
||||||
cdir = _crDir cr
|
|
||||||
|
|
||||||
startReloadingWeapon
|
startReloadingWeapon
|
||||||
:: Creature
|
:: Creature
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
module Dodge.Creature.Action.Flee
|
|
||||||
where
|
|
||||||
import Dodge.Data
|
|
||||||
import Geometry
|
|
||||||
import FoldableHelp
|
|
||||||
|
|
||||||
retreatPointForFrom
|
|
||||||
:: Float -> World -> Creature -> Point2 -> Maybe Point2
|
|
||||||
retreatPointForFrom d _ cr p
|
|
||||||
= safeMinimumOn (dist cpos)
|
|
||||||
$ divideCircle 10 p d
|
|
||||||
where
|
|
||||||
cpos = _crPos cr
|
|
||||||
-- = head $ sortBy (compare `on` (\p -> dist p ypos < 300)) $ retreatP'' : retreatPs
|
|
||||||
-- where
|
|
||||||
-- retreatPs = sortBy (compare `on` dist cpos) $ map f $ nRaysRad 8 400
|
|
||||||
-- where f p = fromMaybe (ypos +.+ p) $ fmap fst
|
|
||||||
-- $ reflectPointWalls ypos (ypos +.+ p) (wallsAlongLine ypos (ypos +.+ p) w)
|
|
||||||
-- retreatP' = cpos +.+ 300 *.* (cpos -.- ypos)
|
|
||||||
-- retreatP'' = fromMaybe retreatP' $ fmap fst
|
|
||||||
-- $ reflectPointWalls ypos retreatP'
|
|
||||||
-- $ wallsAlongLine ypos retreatP' w
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
module Dodge.Creature.Action.Movement
|
|
||||||
where
|
|
||||||
import Dodge.Data
|
|
||||||
import Dodge.Creature.Stance.Data
|
|
||||||
import Dodge.Item.Data
|
|
||||||
import Geometry
|
|
||||||
|
|
||||||
import Data.Maybe
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
|
||||||
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 ^? itAimingSpeed
|
|
||||||
| otherwise = 1
|
|
||||||
it = _crInv cr IM.! _crInvSel cr
|
|
||||||
|
|
||||||
crMvAbsolute
|
|
||||||
:: Point2 -- ^ Movement translation vector
|
|
||||||
-> Creature
|
|
||||||
-> Creature
|
|
||||||
crMvAbsolute p' cr = advanceStepCounter (magV p) cr
|
|
||||||
& crPos %~ (+.+ p)
|
|
||||||
& crMvDir .~ argV p
|
|
||||||
where
|
|
||||||
p = (*.*) (equipFactor * aimingFactor) 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 ^? itAimingSpeed
|
|
||||||
| otherwise = 1
|
|
||||||
it = _crInv cr IM.! _crInvSel cr
|
|
||||||
|
|
||||||
crMvForward
|
|
||||||
:: Float -- ^ Speed
|
|
||||||
-> Creature
|
|
||||||
-> Creature
|
|
||||||
crMvForward speed = crMvBy (V2 speed 0)
|
|
||||||
|
|
||||||
advanceStepCounter
|
|
||||||
:: Float -- ^ Speed
|
|
||||||
-> Creature
|
|
||||||
-> Creature
|
|
||||||
advanceStepCounter speed cr = cr & 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
|
|
||||||
_ -> car
|
|
||||||
|
|
||||||
creatureTurn :: Float -> Creature -> Creature
|
|
||||||
creatureTurn a = crDir +~ a
|
|
||||||
|
|
||||||
creatureTurnTo :: Point2 -> Creature -> Creature
|
|
||||||
creatureTurnTo p cr
|
|
||||||
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
|
||||||
| otherwise = cr & crDir .~ dirToTarget
|
|
||||||
where
|
|
||||||
vToTarg = p -.- _crPos cr
|
|
||||||
dirToTarget = argV vToTarg
|
|
||||||
|
|
||||||
creatureTurnTowardDir
|
|
||||||
:: Float -- ^ Angle
|
|
||||||
-> Float -- ^ Turn speed
|
|
||||||
-> Creature
|
|
||||||
-> Creature
|
|
||||||
creatureTurnTowardDir a turnSpeed cr
|
|
||||||
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
|
||||||
| errorAngleVV 3 vToTarg (unitVectorAtAngle (_crDir cr)) <= turnSpeed
|
|
||||||
= cr & crDir .~ dirToTarget
|
|
||||||
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
|
|
||||||
| otherwise = cr & crDir -~ turnSpeed
|
|
||||||
where
|
|
||||||
vToTarg = rotateV a (V2 1 0)
|
|
||||||
dirToTarget = argV vToTarg
|
|
||||||
|
|
||||||
creatureTurnToward :: Point2 -> Float -> Creature -> Creature
|
|
||||||
creatureTurnToward p turnSpeed cr
|
|
||||||
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
|
||||||
| errorAngleVV 3 vToTarg (unitVectorAtAngle (_crDir cr)) <= turnSpeed
|
|
||||||
= cr & crDir .~ dirToTarget
|
|
||||||
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
|
|
||||||
| otherwise = cr & crDir -~ turnSpeed
|
|
||||||
where
|
|
||||||
vToTarg = p -.- _crPos cr
|
|
||||||
dirToTarget = argV vToTarg
|
|
||||||
|
|
||||||
{- | Speed modifier of an item when not aiming. -}
|
|
||||||
equipSpeed :: Item -> Float
|
|
||||||
equipSpeed _ = 1
|
|
||||||
{- | Speed modifier of an item when aiming. -}
|
|
||||||
equipAimSpeed :: Item -> Float
|
|
||||||
equipAimSpeed NoItem = 1
|
|
||||||
equipAimSpeed it
|
|
||||||
| _itIdentity it == FrontArmour = 0.5
|
|
||||||
| _itIdentity it == FlameShield = 0.5
|
|
||||||
| otherwise = 1
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
module Dodge.Creature.Action.UseItem
|
|
||||||
( useItem
|
|
||||||
, tryUseItem
|
|
||||||
, useLeftItem
|
|
||||||
)
|
|
||||||
where
|
|
||||||
import Dodge.Data
|
|
||||||
import Dodge.Inventory
|
|
||||||
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
|
||||||
import Control.Lens
|
|
||||||
import Data.Maybe
|
|
||||||
|
|
||||||
useItem :: Int -> World -> World
|
|
||||||
useItem n w = itemEffect c it w
|
|
||||||
where
|
|
||||||
c = _creatures w IM.! n
|
|
||||||
it = _crInv c IM.! _crInvSel c
|
|
||||||
|
|
||||||
tryUseItem
|
|
||||||
:: Creature
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
tryUseItem cr' w = case w ^? creatures . ix (_crID cr') of
|
|
||||||
Just cr -> itemEffect cr (_crInv cr IM.! _crInvSel cr) w
|
|
||||||
Nothing -> w
|
|
||||||
|
|
||||||
itemEffect
|
|
||||||
:: Creature
|
|
||||||
-> Item
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w)
|
|
||||||
itemEffect cr it@Weapon{_itUse=eff} w = foldr ($) eff (_itUseModifiers it) it cr w
|
|
||||||
itemEffect cr it@Throwable{_itUse = eff} w = foldr ($) eff (_itUseModifiers it) it cr w
|
|
||||||
itemEffect _ _ w = w
|
|
||||||
|
|
||||||
useLeftItem
|
|
||||||
:: Int
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
useLeftItem cid w = case luse of
|
|
||||||
Nothing -> w
|
|
||||||
Just (invid, f) -> f cr invid w
|
|
||||||
where
|
|
||||||
cr = _creatures w IM.! cid
|
|
||||||
luses = IM.mapMaybe (^? itLeftClickUse . _Just) (_crInv cr)
|
|
||||||
luse = listToMaybe $ IM.toList luses
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
module Dodge.Creature.ActionRat
|
|
||||||
( goToPostStrat
|
|
||||||
)
|
|
||||||
where
|
|
||||||
import Dodge.Data
|
|
||||||
--import Dodge.Base
|
|
||||||
--import Dodge.Base.Collide
|
|
||||||
--import Dodge.Creature.ChooseTarget
|
|
||||||
--import Dodge.Creature.Stance.Data
|
|
||||||
import Dodge.Creature.Test
|
|
||||||
import Dodge.Creature.Volition
|
|
||||||
--import Geometry
|
|
||||||
|
|
||||||
import Data.List
|
|
||||||
--import qualified Data.IntMap.Strict as IM
|
|
||||||
--import Control.Lens
|
|
||||||
|
|
||||||
goToPostStrat :: World -> Creature -> Strategy
|
|
||||||
goToPostStrat w cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
|
||||||
Just (SentinelAt p _) -> StrategyActions (GetTo p)
|
|
||||||
[DoActionThen (WaitThen 150 holsterIfAiming)
|
|
||||||
$ DoActionThen (PathTo p)
|
|
||||||
NoAction
|
|
||||||
-- $ DoImpulses [ChangeStrategy WatchAndWait]
|
|
||||||
]
|
|
||||||
_ -> WatchAndWait
|
|
||||||
where
|
|
||||||
sentinelGoal (SentinelAt _ _) = True
|
|
||||||
sentinelGoal _ = False
|
|
||||||
holsterIfAiming
|
|
||||||
| crIsAiming (w,cr) = holsterWeapon
|
|
||||||
| otherwise = NoAction
|
|
||||||
|
|
||||||
@@ -1,52 +1,43 @@
|
|||||||
|
{-# LANGUAGE TupleSections #-}
|
||||||
{- | Deals with changes in a creature's awareness of other creatures. -}
|
{- | Deals with changes in a creature's awareness of other creatures. -}
|
||||||
module Dodge.Creature.AlertLevel
|
module Dodge.Creature.AlertLevel
|
||||||
|
( basicPerceptionUpdateR
|
||||||
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Creature.AlertLevel.Data
|
import Dodge.Creature.AlertLevel.Data
|
||||||
import Dodge.Base.Collide
|
import Dodge.Base.Collide
|
||||||
import StrictHelp
|
--import StrictHelp
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
{- | Ties together (currently) an awareness and attention update -}
|
|
||||||
basicPerceptionUpdate
|
|
||||||
:: [Int] -- ^ List of creature ids that may direct attention and awareness
|
|
||||||
-> World
|
|
||||||
-> Creature
|
|
||||||
-> Creature
|
|
||||||
basicPerceptionUpdate is w cr
|
|
||||||
= basicAwarenessUpdate w $ basicAttentionUpdate is w cr
|
|
||||||
|
|
||||||
|
{- | Ties together (currently) an awareness and attention update -}
|
||||||
basicPerceptionUpdateR
|
basicPerceptionUpdateR
|
||||||
:: [Int] -- ^ List of creature ids that may direct attention and awareness
|
:: [Int] -- ^ List of creature ids that may direct attention and awareness
|
||||||
-> Creature
|
-> Creature
|
||||||
-> Reader World Creature
|
-> Reader World Creature
|
||||||
basicPerceptionUpdateR is cr = reader $ \w ->
|
basicPerceptionUpdateR is cr = basicAttentionUpdate is cr >>= basicAwarenessUpdate
|
||||||
basicAwarenessUpdate w $ basicAttentionUpdate is w cr
|
|
||||||
|
|
||||||
{- | Update a creatures awareness based upon the creatures current direction
|
{- | Update a creatures awareness based upon the creatures' current direction
|
||||||
of attention -}
|
of attention -}
|
||||||
basicAwarenessUpdate
|
basicAwarenessUpdate
|
||||||
:: World -> Creature -> Creature
|
:: Creature -> Reader World Creature
|
||||||
basicAwarenessUpdate _ cr = case _crAttentionDir cr of
|
basicAwarenessUpdate cr = case _crAttentionDir cr of
|
||||||
AttentiveTo is -> cr & crAwarenessLevel %~ updateAwareness is
|
AttentiveTo is -> pure $ cr & crAwarenessLevel
|
||||||
Fixated i -> cr & crAwarenessLevel
|
%~ (IM.unionWith combineAwareness is . IM.mapMaybe decreaseAwareness)
|
||||||
|
Fixated i -> pure $ cr & crAwarenessLevel
|
||||||
%~ ( IM.insert i (Cognizant 100) . IM.mapMaybe decreaseAwareness)
|
%~ ( IM.insert i (Cognizant 100) . IM.mapMaybe decreaseAwareness)
|
||||||
{- | Increase awareness of a given list of ids -}
|
|
||||||
updateAwareness :: [Int] -> IM.IntMap AwarenessLevel -> IM.IntMap AwarenessLevel
|
combineAwareness :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel
|
||||||
updateAwareness is imawareness
|
combineAwareness (AwarenessInt x) (AwarenessInt y)
|
||||||
= foldr (\k -> IM.insertWith (\_ x -> increaseAwareness x) k (AwarenessInt 1))
|
| x + y < 100 = AwarenessInt $ x + y
|
||||||
(IM.mapMaybe decreaseAwareness imawareness) is
|
| otherwise = Cognizant 50
|
||||||
-- (IM.mapMaybe decreaseAwareness imawareness) is
|
combineAwareness (AwarenessInt x) (Cognizant y) = Cognizant $ min 100 $ x + y
|
||||||
{- | Increase awareness level -}
|
combineAwareness (Cognizant x) (AwarenessInt y) = Cognizant $ min 100 $ x + y
|
||||||
increaseAwareness :: AwarenessLevel -> AwarenessLevel
|
combineAwareness (Cognizant x) (Cognizant y) = Cognizant $ min 100 $ x + y
|
||||||
increaseAwareness (AwarenessInt x)
|
|
||||||
| x < 100 = AwarenessInt $ x + 2
|
|
||||||
| otherwise = Cognizant 1
|
|
||||||
increaseAwareness (Cognizant x)
|
|
||||||
| x < 100 = Cognizant (x + 2)
|
|
||||||
| otherwise = Cognizant 100
|
|
||||||
{- | Decrease awareness level. Returns 'Maybe' value for use with 'IM.mapMaybe'
|
{- | Decrease awareness level. Returns 'Maybe' value for use with 'IM.mapMaybe'
|
||||||
-}
|
-}
|
||||||
decreaseAwareness :: AwarenessLevel -> Maybe AwarenessLevel
|
decreaseAwareness :: AwarenessLevel -> Maybe AwarenessLevel
|
||||||
@@ -58,8 +49,9 @@ decreaseAwareness (Cognizant x) = Just $ Cognizant $ x - 1
|
|||||||
- are in view. -}
|
- are in view. -}
|
||||||
basicAttentionUpdate
|
basicAttentionUpdate
|
||||||
:: [Int] -- ^ Creatures that may attract this creature's attention
|
:: [Int] -- ^ Creatures that may attract this creature's attention
|
||||||
-> World
|
|
||||||
-> Creature
|
-> Creature
|
||||||
-> Creature
|
-> Reader World Creature
|
||||||
basicAttentionUpdate cids w cr = cr & crAttentionDir .~
|
basicAttentionUpdate cids cr = do
|
||||||
AttentiveTo (forceFoldable $ filter (\cid -> canSee (_crID cr) cid w) cids)
|
w <- ask
|
||||||
|
pure $ cr & crAttentionDir .~
|
||||||
|
AttentiveTo (IM.fromList $ map (, AwarenessInt 2) $ filter (\cid -> canSeeIndirect (_crID cr) cid w) cids)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module Dodge.Creature.AlertLevel.Data
|
|||||||
, getFixated
|
, getFixated
|
||||||
) where
|
) where
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
import qualified Data.IntMap as IM
|
||||||
|
|
||||||
data AwakeLevel
|
data AwakeLevel
|
||||||
= Comatose
|
= Comatose
|
||||||
@@ -18,7 +19,7 @@ data AwakeLevel
|
|||||||
| Overstrung
|
| Overstrung
|
||||||
|
|
||||||
data AttentionDir
|
data AttentionDir
|
||||||
= AttentiveTo {_getAttentiveTo :: [Int]}
|
= AttentiveTo {_getAttentiveTo :: IM.IntMap AwarenessLevel }
|
||||||
| Fixated {_getFixated :: Int }
|
| Fixated {_getFixated :: Int }
|
||||||
|
|
||||||
data AwarenessLevel
|
data AwarenessLevel
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ armourChaseCrit = defaultCreature
|
|||||||
doStrategyActionsR >=>
|
doStrategyActionsR >=>
|
||||||
performActionsR >=>
|
performActionsR >=>
|
||||||
targetYouWhenCognizantR >=>
|
targetYouWhenCognizantR >=>
|
||||||
setTargetMv (pure . _crTarget) >=>
|
setTargetMv (pure . _crTarget) >=> -- should be able to remove this?
|
||||||
flockACCR >=>
|
flockACCR >=>
|
||||||
basicPerceptionUpdateR [0] >=>
|
basicPerceptionUpdateR [0] >=>
|
||||||
goToTarget >=>
|
goToTarget >=>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ module Dodge.Creature.Boid
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Creature.State.Data
|
import Dodge.Creature.State.Data
|
||||||
import Dodge.Creature.ImpulseRat
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import Geometry.ConvexPoly
|
import Geometry.ConvexPoly
|
||||||
|
|
||||||
@@ -254,3 +253,46 @@ flockPointTargetR f targFunc cr = reader $ \w -> case targFunc cr w of
|
|||||||
is = _swarm $ _crGroup cr
|
is = _swarm $ _crGroup cr
|
||||||
crs = IM.restrictKeys (_creatures w) is
|
crs = IM.restrictKeys (_creatures w) is
|
||||||
p = f crTarg crs cr
|
p = f crTarg crs cr
|
||||||
|
|
||||||
|
meleeHeadingMove
|
||||||
|
:: Float -- ^ max turn speed
|
||||||
|
-> Float -- ^ min turn speed
|
||||||
|
-> Float -- ^ turn speed cutoff angle
|
||||||
|
-> Float -- ^ move speed
|
||||||
|
-> Point2 -- ^ target point
|
||||||
|
-> Creature -- ^ start creature
|
||||||
|
-> Creature -- ^ target creature
|
||||||
|
-> [Impulse]
|
||||||
|
meleeHeadingMove maxta minta tacutoff speed tp cr tcr
|
||||||
|
| dist tpos cpos < combinedRad + 5
|
||||||
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
|
||||||
|
&& _crMeleeCooldown cr == 0
|
||||||
|
= [Melee (_crID tcr), Turn pi]
|
||||||
|
| dist tpos cpos < combinedRad + 5
|
||||||
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
|
||||||
|
= [ TurnToward tpos minta ]
|
||||||
|
| abs (_crDir cr - argV (tp -.- cpos)) < tacutoff
|
||||||
|
= [MoveForward speed , TurnToward tp maxta , RandomTurn maxta ]
|
||||||
|
| otherwise = [MoveForward speed , TurnToward tp minta, RandomTurn maxta ]
|
||||||
|
where
|
||||||
|
cpos = _crPos cr
|
||||||
|
tpos = _crPos tcr
|
||||||
|
combinedRad = _crRad cr + _crRad tcr
|
||||||
|
|
||||||
|
|
||||||
|
mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse]
|
||||||
|
mvPointMeleeTarg p cr crT
|
||||||
|
| dist tpos cpos < combinedRad + 5
|
||||||
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
||||||
|
&& _crMeleeCooldown cr == 0
|
||||||
|
= [Melee (_crID crT)]
|
||||||
|
| dist tpos cpos < combinedRad + 5
|
||||||
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
||||||
|
= [ TurnToward tpos 0.05 ]
|
||||||
|
| abs (_crDir cr - argV (p -.- cpos)) < pi/4
|
||||||
|
= [MoveForward 3 , TurnToward p 0.2 , RandomTurn 0.2 ]
|
||||||
|
| otherwise = [MoveForward 3 , TurnToward p 0.05, RandomTurn 0.2 ]
|
||||||
|
where
|
||||||
|
cpos = _crPos cr
|
||||||
|
tpos = _crPos crT
|
||||||
|
combinedRad = _crRad cr + _crRad crT
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ module Dodge.Creature.ChaseCrit
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Creature.Picture
|
import Dodge.Creature.Picture
|
||||||
--import Dodge.Creature.Test
|
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.ChooseTarget
|
|
||||||
import Dodge.Creature.Impulse
|
import Dodge.Creature.Impulse
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
@@ -40,7 +38,8 @@ chaseCrit = defaultCreature
|
|||||||
doStrategyActionsR >=>
|
doStrategyActionsR >=>
|
||||||
performActionsR >=>
|
performActionsR >=>
|
||||||
overrideMeleeCloseTargetR >=>
|
overrideMeleeCloseTargetR >=>
|
||||||
chaseTargetR targetYouLOS >=>
|
setTargetMv (pure . _crTarget) >=>
|
||||||
|
goToTarget >=>
|
||||||
basicPerceptionUpdateR [0] >=>
|
basicPerceptionUpdateR [0] >=>
|
||||||
targetYouWhenCognizantR >=>
|
targetYouWhenCognizantR >=>
|
||||||
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
module Dodge.Creature.ImpulseRat
|
|
||||||
( mvPointMeleeTarg
|
|
||||||
, meleeHeadingMove
|
|
||||||
)
|
|
||||||
where
|
|
||||||
import Dodge.Data
|
|
||||||
|
|
||||||
import Geometry
|
|
||||||
|
|
||||||
meleeHeadingMove
|
|
||||||
:: Float -- ^ max turn speed
|
|
||||||
-> Float -- ^ min turn speed
|
|
||||||
-> Float -- ^ turn speed cutoff angle
|
|
||||||
-> Float -- ^ move speed
|
|
||||||
-> Point2 -- ^ target point
|
|
||||||
-> Creature -- ^ start creature
|
|
||||||
-> Creature -- ^ target creature
|
|
||||||
-> [Impulse]
|
|
||||||
meleeHeadingMove maxta minta tacutoff speed tp cr tcr
|
|
||||||
| dist tpos cpos < combinedRad + 5
|
|
||||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
|
|
||||||
&& _crMeleeCooldown cr == 0
|
|
||||||
= [Melee (_crID tcr), Turn pi]
|
|
||||||
| dist tpos cpos < combinedRad + 5
|
|
||||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
|
|
||||||
= [ TurnToward tpos minta ]
|
|
||||||
| abs (_crDir cr - argV (tp -.- cpos)) < tacutoff
|
|
||||||
= [MoveForward speed , TurnToward tp maxta , RandomTurn maxta ]
|
|
||||||
| otherwise = [MoveForward speed , TurnToward tp minta, RandomTurn maxta ]
|
|
||||||
where
|
|
||||||
cpos = _crPos cr
|
|
||||||
tpos = _crPos tcr
|
|
||||||
combinedRad = _crRad cr + _crRad tcr
|
|
||||||
|
|
||||||
|
|
||||||
mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse]
|
|
||||||
mvPointMeleeTarg p cr crT
|
|
||||||
| dist tpos cpos < combinedRad + 5
|
|
||||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
|
||||||
&& _crMeleeCooldown cr == 0
|
|
||||||
= [Melee (_crID crT)]
|
|
||||||
| dist tpos cpos < combinedRad + 5
|
|
||||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
|
||||||
= [ TurnToward tpos 0.05 ]
|
|
||||||
| abs (_crDir cr - argV (p -.- cpos)) < pi/4
|
|
||||||
= [MoveForward 3 , TurnToward p 0.2 , RandomTurn 0.2 ]
|
|
||||||
| otherwise = [MoveForward 3 , TurnToward p 0.05, RandomTurn 0.2 ]
|
|
||||||
where
|
|
||||||
cpos = _crPos cr
|
|
||||||
tpos = _crPos crT
|
|
||||||
combinedRad = _crRad cr + _crRad crT
|
|
||||||
@@ -7,14 +7,11 @@ import Dodge.Default
|
|||||||
import Dodge.Creature.Picture
|
import Dodge.Creature.Picture
|
||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Creature.Volition
|
import Dodge.Creature.Volition
|
||||||
import Dodge.Creature.ActionRat
|
import Dodge.Creature.Strategy
|
||||||
--import Dodge.Creature.ChooseTarget
|
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
import Dodge.Creature.State
|
import Dodge.Creature.State
|
||||||
--import Dodge.Creature.State.Data
|
|
||||||
import Dodge.Item.Weapon.Launcher
|
import Dodge.Item.Weapon.Launcher
|
||||||
--import Dodge.Item.Consumable
|
|
||||||
import Dodge.Creature.Impulse
|
import Dodge.Creature.Impulse
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Dodge.Creature.Impulse
|
|||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Creature.Volition
|
import Dodge.Creature.Volition
|
||||||
import Dodge.Creature.ActionRat
|
import Dodge.Creature.Strategy
|
||||||
--import Dodge.Creature.ChooseTarget
|
--import Dodge.Creature.ChooseTarget
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Dodge.Creature.Test
|
|||||||
import Dodge.Creature.Impulse
|
import Dodge.Creature.Impulse
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
import Dodge.Creature.Volition
|
import Dodge.Creature.Volition
|
||||||
import Dodge.Creature.ActionRat
|
import Dodge.Creature.Strategy
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
--import Dodge.Creature.ChooseTarget
|
--import Dodge.Creature.ChooseTarget
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
{- | Functions updating a creature in a Reader World environment -}
|
{- | Functions updating a creature in a Reader World environment -}
|
||||||
module Dodge.Creature.ReaderUpdate
|
module Dodge.Creature.ReaderUpdate
|
||||||
( doStrategyActionsR
|
( doStrategyActionsR
|
||||||
, chaseTargetR
|
|
||||||
, chaseTargetRR
|
|
||||||
, setTargetMv
|
, setTargetMv
|
||||||
, targetYouWhenCognizantR
|
, targetYouWhenCognizantR
|
||||||
, overrideMeleeCloseTargetR
|
, overrideMeleeCloseTargetR
|
||||||
@@ -43,15 +41,6 @@ tryMeleeAttack cr tcr
|
|||||||
where
|
where
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
|
|
||||||
chaseTargetRR
|
|
||||||
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
|
|
||||||
-> Creature
|
|
||||||
-> Reader World Creature
|
|
||||||
chaseTargetRR targFunc cr = do
|
|
||||||
targ <- targFunc cr
|
|
||||||
case targ of
|
|
||||||
Nothing -> pure cr
|
|
||||||
Just crTarg -> pure $ cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg
|
|
||||||
setTargetMv
|
setTargetMv
|
||||||
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
|
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
|
||||||
-> Creature
|
-> Creature
|
||||||
@@ -107,26 +96,6 @@ goToTarget cr = do
|
|||||||
trad = _mvTurnRad mvType
|
trad = _mvTurnRad mvType
|
||||||
jit = _mvTurnJit mvType
|
jit = _mvTurnJit mvType
|
||||||
|
|
||||||
|
|
||||||
chaseTargetR
|
|
||||||
:: (Creature -> World -> Maybe Creature) -- ^ Function for determining target
|
|
||||||
-> Creature
|
|
||||||
-> Reader World Creature
|
|
||||||
chaseTargetR targFunc cr = reader $ \w -> case targFunc cr w of
|
|
||||||
Nothing -> cr
|
|
||||||
Just crTarg -> cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg
|
|
||||||
|
|
||||||
chaseTarg :: Creature -> Creature -> [Impulse]
|
|
||||||
chaseTarg cr crT = [MoveForward speed, TurnToward tpos (trad dirOffset), RandomTurn jit]
|
|
||||||
where
|
|
||||||
cpos = _crPos cr
|
|
||||||
tpos = _crPos crT
|
|
||||||
mvType = _crMvType cr
|
|
||||||
speed = _mvSpeed mvType
|
|
||||||
trad = _mvTurnRad mvType
|
|
||||||
jit = _mvTurnJit mvType
|
|
||||||
dirOffset = abs (_crDir cr - argV (tpos -.- cpos))
|
|
||||||
|
|
||||||
doStrategyActionsR
|
doStrategyActionsR
|
||||||
:: Creature
|
:: Creature
|
||||||
-> Reader World Creature
|
-> Reader World Creature
|
||||||
@@ -178,13 +147,3 @@ targetYouWhenCognizantR :: Creature -> Reader World Creature
|
|||||||
targetYouWhenCognizantR cr = reader $ \w -> case cr ^? crAwarenessLevel . ix 0 of
|
targetYouWhenCognizantR cr = reader $ \w -> case cr ^? crAwarenessLevel . ix 0 of
|
||||||
Just (Cognizant _) -> cr {_crTarget = Just $! _creatures w IM.! 0}
|
Just (Cognizant _) -> cr {_crTarget = Just $! _creatures w IM.! 0}
|
||||||
_ -> cr & crTarget .~ Nothing
|
_ -> cr & crTarget .~ Nothing
|
||||||
|
|
||||||
--shootTargetWithStratR
|
|
||||||
-- :: (Creature -> World -> Maybe Creature) -- ^ Function for determining target
|
|
||||||
-- -> (World -> Creature -> Creature -> [Action] -> [Action])
|
|
||||||
-- -- ^ Function for determining shooting strategy given target
|
|
||||||
-- -> Creature
|
|
||||||
-- -> Reader World Creature
|
|
||||||
--shootTargetWithStratR targFunc strat cr = reader $ \w -> case targFunc cr w of
|
|
||||||
-- Nothing -> cr
|
|
||||||
-- Just crTarg -> cr & crActionPlan . crAction %~ strat w cr crTarg
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Dodge.Base.Collide
|
|||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Creature.Volition
|
import Dodge.Creature.Volition
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.ActionRat
|
import Dodge.Creature.Strategy
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
--import Dodge.Creature.ChooseTarget
|
--import Dodge.Creature.ChooseTarget
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Dodge.Creature.Test
|
|||||||
import Dodge.Creature.Impulse
|
import Dodge.Creature.Impulse
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
import Dodge.Creature.Volition
|
import Dodge.Creature.Volition
|
||||||
import Dodge.Creature.ActionRat
|
import Dodge.Creature.Strategy
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
--import Dodge.Creature.ChooseTarget
|
--import Dodge.Creature.ChooseTarget
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
|
|||||||
@@ -6,27 +6,16 @@ import Dodge.Data
|
|||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Creature.Picture
|
import Dodge.Creature.Picture
|
||||||
import Dodge.Creature.Boid
|
import Dodge.Creature.Boid
|
||||||
--import Dodge.Creature.Test
|
|
||||||
--import Dodge.Creature.ActionRat
|
|
||||||
import Dodge.Creature.ImpulseRat
|
|
||||||
--import Dodge.Creature.ChooseTarget
|
|
||||||
--import Dodge.Creature.SetTarget
|
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
import Dodge.Creature.Impulse
|
import Dodge.Creature.Impulse
|
||||||
import Dodge.Creature.State
|
import Dodge.Creature.State
|
||||||
import Dodge.Creature.State.Data
|
import Dodge.Creature.State.Data
|
||||||
import Dodge.Picture.Layer
|
import Dodge.Picture.Layer
|
||||||
--import Geometry
|
|
||||||
import Picture
|
import Picture
|
||||||
--import Dodge.RandomHelp
|
|
||||||
|
|
||||||
--import Data.Maybe
|
|
||||||
--import qualified Data.IntMap.Strict as IM
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
--import Control.Monad.State
|
|
||||||
--import System.Random
|
|
||||||
|
|
||||||
swarmCrit :: Creature
|
swarmCrit :: Creature
|
||||||
swarmCrit = defaultCreature
|
swarmCrit = defaultCreature
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Dodge.Creature.YourControl
|
|||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
--import Dodge.Base
|
--import Dodge.Base
|
||||||
import Dodge.Creature.Action.Movement
|
import Dodge.Creature.Impulse.Movement
|
||||||
--import Dodge.Creature.State
|
--import Dodge.Creature.State
|
||||||
--import Dodge.Creature.State.Data
|
--import Dodge.Creature.State.Data
|
||||||
import Dodge.Creature.Stance.Data
|
import Dodge.Creature.Stance.Data
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ defaultCreature = Creature
|
|||||||
, _crActionPlan = ActionPlan [] [] WatchAndWait [LiveLongAndProsper]
|
, _crActionPlan = ActionPlan [] [] WatchAndWait [LiveLongAndProsper]
|
||||||
, _crMeleeCooldown = 0
|
, _crMeleeCooldown = 0
|
||||||
, _crAwakeLevel = Vigilant
|
, _crAwakeLevel = Vigilant
|
||||||
, _crAttentionDir = AttentiveTo []
|
, _crAttentionDir = AttentiveTo IM.empty
|
||||||
, _crAwarenessLevel = IM.empty
|
, _crAwarenessLevel = IM.empty
|
||||||
, _crFaction = NoFaction
|
, _crFaction = NoFaction
|
||||||
, _crTarget = Nothing
|
, _crTarget = Nothing
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Dodge.Creature.State.Data
|
|||||||
import Dodge.Room.Procedural
|
import Dodge.Room.Procedural
|
||||||
import Dodge.Room.RoadBlock
|
import Dodge.Room.RoadBlock
|
||||||
import Dodge.Room.Data
|
import Dodge.Room.Data
|
||||||
|
import Dodge.Room
|
||||||
--import Dodge.Room.Link
|
--import Dodge.Room.Link
|
||||||
--import Dodge.Room.Door
|
--import Dodge.Room.Door
|
||||||
import Dodge.Room.Branch
|
import Dodge.Room.Branch
|
||||||
@@ -50,6 +51,9 @@ roomTreex = do
|
|||||||
[[StartRoom]
|
[[StartRoom]
|
||||||
,[Corridor]
|
,[Corridor]
|
||||||
,[Corridor]
|
,[Corridor]
|
||||||
|
,[SpecificRoom roomCCrits]
|
||||||
|
,[Corridor]
|
||||||
|
,[Corridor]
|
||||||
,[SpecificRoom . pure . pure . Right $ roomGlassOctogon 400
|
,[SpecificRoom . pure . pure . Right $ roomGlassOctogon 400
|
||||||
& rmPS %~ ([sPS (V2 0 50) 0 $ PutCrit armourChaseCrit
|
& rmPS %~ ([sPS (V2 0 50) 0 $ PutCrit armourChaseCrit
|
||||||
,sPS (V2 50 25) 0 $ PutCrit armourChaseCrit
|
,sPS (V2 50 25) 0 $ PutCrit armourChaseCrit
|
||||||
|
|||||||
@@ -80,15 +80,12 @@ withThickSmokeI eff item cr w = eff item cr $ foldl' (flip $ makeThickSmokeAt .
|
|||||||
ps = replicateM 20 randOnUnitSphere & evalState $ _randGen w
|
ps = replicateM 20 randOnUnitSphere & evalState $ _randGen w
|
||||||
-- TODO create a trigger that does different things on first and continued
|
-- TODO create a trigger that does different things on first and continued
|
||||||
-- fire.
|
-- fire.
|
||||||
|
|
||||||
|
|
||||||
ammoCheckI :: ChainEffect
|
ammoCheckI :: ChainEffect
|
||||||
ammoCheckI eff item cr w
|
ammoCheckI eff item cr w
|
||||||
| _wpLoadedAmmo item <= 0
|
| _wpLoadedAmmo item <= 0
|
||||||
= fromMaybe w (startReloadingWeapon cr w)
|
= fromMaybe w (startReloadingWeapon cr w)
|
||||||
| _wpReloadState item > 0 = w
|
| _wpReloadState item > 0 = w
|
||||||
| otherwise = eff item cr w
|
| otherwise = eff item cr w
|
||||||
|
|
||||||
{- |
|
{- |
|
||||||
Fires at an increasing rate.
|
Fires at an increasing rate.
|
||||||
Has different effect after first fire.
|
Has different effect after first fire.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module Dodge.Update.UsingInput
|
|||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Item.Data
|
import Dodge.Item.Data
|
||||||
import Dodge.Creature.Action.UseItem
|
import Dodge.Creature.Impulse.UseItem
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
import SDL
|
import SDL
|
||||||
|
|||||||
Reference in New Issue
Block a user