Cleanup warnings
This commit is contained in:
@@ -6,27 +6,32 @@ module Dodge.Creature.ActionRat
|
||||
, shootAdvance
|
||||
, shootFirstMiss
|
||||
, doStrategyActions
|
||||
, doStrategyActionsR
|
||||
, reloadOverride
|
||||
, reloadOverrideR
|
||||
, reloadOverrideNoHolster
|
||||
, shootAdvanceStrat
|
||||
, shootMoveStrat
|
||||
, watchUpdateStrat
|
||||
, watchUpdateStratR
|
||||
, goToPostStrat
|
||||
, overrideInternal
|
||||
, overrideInternalR
|
||||
, fleeTime
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Creature.ChooseTarget
|
||||
--import Dodge.Base.Collide
|
||||
--import Dodge.Creature.ChooseTarget
|
||||
import Dodge.Creature.Stance.Data
|
||||
import Dodge.Creature.Test
|
||||
import Geometry
|
||||
--import Geometry
|
||||
|
||||
import Data.List
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
|
||||
shootTargetWithStrat
|
||||
:: (Creature -> World -> Maybe Creature) -- ^ Function for determining target
|
||||
@@ -65,8 +70,9 @@ suppress w cr tcr as
|
||||
]
|
||||
| otherwise = as
|
||||
|
||||
-- This should be decomposed properly
|
||||
shootFirstMiss :: Int -> World -> Creature -> Strategy
|
||||
shootFirstMiss tcid w cr = StrategyActions (ShootAt tcid) acs
|
||||
shootFirstMiss tcid _ _ = StrategyActions (ShootAt tcid) acs
|
||||
where
|
||||
acs =
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
@@ -88,7 +94,7 @@ shootFirstMiss tcid w cr = StrategyActions (ShootAt tcid) acs
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
fleeTime :: Int -> World -> Creature -> Strategy
|
||||
fleeTime t w cr = StrategyActions Flee
|
||||
fleeTime t _ _ = StrategyActions Flee
|
||||
[ t `DoReplicate`
|
||||
UseTargetCID FleeFrom
|
||||
`DoActionThen`
|
||||
@@ -110,9 +116,6 @@ aimThenShootStrat tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
]
|
||||
where
|
||||
lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
shootMoveStrat :: Point2 -> Int -> World -> Creature -> Strategy
|
||||
shootMoveStrat moveV tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
@@ -165,7 +168,7 @@ goToPostStrat w cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
||||
]
|
||||
_ -> WatchAndWait
|
||||
where
|
||||
sentinelGoal (SentinelAt p dir) = True
|
||||
sentinelGoal (SentinelAt _ _) = True
|
||||
sentinelGoal _ = False
|
||||
holsterIfAiming
|
||||
| crIsAiming (w,cr) = HolsterWeapon
|
||||
@@ -181,6 +184,16 @@ overrideInternal test update w cr
|
||||
| test (w,cr) = update w cr
|
||||
| otherwise = cr
|
||||
|
||||
overrideInternalR
|
||||
:: ((World , Creature) -> Bool)
|
||||
-> (World -> Creature -> Creature)
|
||||
-> Creature
|
||||
-> Reader World Creature
|
||||
overrideInternalR test update cr = reader $ \w ->
|
||||
if test (w,cr)
|
||||
then update w cr
|
||||
else cr
|
||||
|
||||
shootAdvance :: World -> Creature -> Creature -> [Action] -> [Action]
|
||||
shootAdvance w cr tcr as
|
||||
| lostest (w,cr) && cr ^. crStance . posture /= Aiming
|
||||
@@ -205,33 +218,25 @@ shootAdvance w cr tcr as
|
||||
= [ HolsterWeapon ]
|
||||
| otherwise = as
|
||||
where
|
||||
lostest (w,cr') = canSee (_crID cr) (_crID tcr) w
|
||||
lostest (w',cr') = canSee (_crID cr') (_crID tcr) w'
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
applyNewStrategies
|
||||
:: World
|
||||
-> Creature
|
||||
-> Creature
|
||||
applyNewStrategies w cr = case cr ^? crActionPlan . crStrategy of
|
||||
Just (StrategyActions strat acs) -> cr & crActionPlan . crAction .~ acs
|
||||
& crActionPlan . crStrategy .~ strat
|
||||
_ -> cr
|
||||
|
||||
doStrategyActions
|
||||
:: World
|
||||
-> Creature
|
||||
-> Creature
|
||||
doStrategyActions w cr = case cr ^? crActionPlan . crStrategy of
|
||||
doStrategyActions _ cr = case cr ^? crActionPlan . crStrategy of
|
||||
Just (StrategyActions strat acs) -> cr & crActionPlan . crAction .~ acs
|
||||
& crActionPlan . crStrategy .~ strat
|
||||
_ -> cr
|
||||
|
||||
updateShoot
|
||||
:: World
|
||||
-> Creature
|
||||
-> Creature
|
||||
updateShoot w cr = case _crStrategy $ _crActionPlan cr of
|
||||
WatchAndWait -> undefined
|
||||
doStrategyActionsR
|
||||
:: Creature
|
||||
-> Reader World Creature
|
||||
doStrategyActionsR cr = return $ case cr ^? crActionPlan . crStrategy of
|
||||
Just (StrategyActions strat acs) -> cr & crActionPlan . crAction .~ acs
|
||||
& crActionPlan . crStrategy .~ strat
|
||||
_ -> cr
|
||||
|
||||
reloadOverride
|
||||
:: World
|
||||
@@ -245,7 +250,21 @@ reloadOverride _ cr
|
||||
where
|
||||
reloadActions =
|
||||
[ HolsterWeapon
|
||||
, WaitThen 1 $ DoActionWhileThen NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
, WaitThen 1 $ DoActionWhileInterrupt NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
|
||||
reloadOverrideR
|
||||
:: Creature
|
||||
-> Reader World Creature
|
||||
reloadOverrideR cr
|
||||
| cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo == Just 0
|
||||
&& cr ^. crStance . posture == Aiming
|
||||
= return $ cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
|
||||
| otherwise = return $ cr
|
||||
where
|
||||
reloadActions =
|
||||
[ HolsterWeapon
|
||||
, WaitThen 1 $ DoActionWhileInterrupt NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
|
||||
reloadOverrideNoHolster
|
||||
@@ -259,7 +278,7 @@ reloadOverrideNoHolster _ cr
|
||||
| otherwise = cr
|
||||
where
|
||||
reloadActions =
|
||||
[ DoActionWhileThen NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
[ DoActionWhileInterrupt NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
|
||||
watchUpdateStrat
|
||||
@@ -272,6 +291,15 @@ watchUpdateStrat fs w cr = case cr ^? crActionPlan . crStrategy of
|
||||
& crActionPlan . crStrategy .~ listGuard (fs, \_ _ -> WatchAndWait) (w, cr) w cr
|
||||
_ -> cr
|
||||
|
||||
watchUpdateStratR
|
||||
:: [ ((World, Creature) -> Bool, World -> Creature -> Strategy) ]
|
||||
-> Creature
|
||||
-> Reader World Creature
|
||||
watchUpdateStratR fs cr = reader $ \w -> case cr ^? crActionPlan . crStrategy of
|
||||
Just WatchAndWait -> cr
|
||||
& crActionPlan . crStrategy .~ listGuard (fs, \_ _ -> WatchAndWait) (w, cr) w cr
|
||||
_ -> cr
|
||||
|
||||
listGuard :: ([(a -> Bool, b)] , b) -> a -> b
|
||||
listGuard ( (test,y):ps, z ) x
|
||||
| test x = y
|
||||
|
||||
Reference in New Issue
Block a user