Refactor bullet particles
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
module Dodge.Creature.SentinelAI
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Creature.Volition
|
||||
import Dodge.Creature.ReaderUpdate
|
||||
import Dodge.Creature.ActionRat
|
||||
--import Dodge.Creature.ChooseTarget
|
||||
import Dodge.Creature.Rationality
|
||||
import Dodge.Creature.AlertLevel
|
||||
--import Dodge.Creature.State
|
||||
--import Dodge.Creature.State.Data
|
||||
--import Geometry
|
||||
--import Picture
|
||||
--import Dodge.RandomHelp
|
||||
|
||||
import Data.Maybe
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Control.Monad.Reader
|
||||
--import System.Random
|
||||
|
||||
sentinelAI :: Creature -> Reader World Creature
|
||||
sentinelAI = sentinelExtraWatchUpdate
|
||||
[ (crHasTargetLOS
|
||||
, \ _ cr ->
|
||||
let lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
tcid = _crID $ fromJust $ _crTarget cr
|
||||
in StrategyActions (ShootAt tcid)
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen drawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
lostest `DoActionWhile`
|
||||
advanceShoot `DoActionThen`
|
||||
75 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
, _aimSpeed = 0.2
|
||||
, _slowAimSpeed = 0.01
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
]
|
||||
)
|
||||
]
|
||||
>=> reloadOverrideR
|
||||
where
|
||||
|
||||
sentinelFireType
|
||||
:: (Int -> Action)
|
||||
-> Creature
|
||||
-> Reader World Creature
|
||||
sentinelFireType f = performActionsR
|
||||
>=> watchUpdateStratR
|
||||
[ (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
|
||||
[ drawwp `DoActionThen` f 0 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, aiming]
|
||||
)
|
||||
, (crAwayFromPost, goToPostStrat)
|
||||
]
|
||||
>=> basicPerceptionUpdateR [0]
|
||||
>=> doStrategyActionsR
|
||||
>=> reloadOverrideR
|
||||
>=> targetYouWhenCognizantR
|
||||
>=> (overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
|
||||
$ \ _ -> crActionPlan . crStrategy .~ WatchAndWait)
|
||||
where
|
||||
drawwp = DoActionIfElse NoAction crIsAiming (DoActionThen drawWeapon (WaitThen 50 NoAction))
|
||||
aiming = AimAtCloseSlow
|
||||
{ _targetID = 0
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
, _aimSpeed = 0.2
|
||||
, _slowAimSpeed = 0.01
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
|
||||
sentinelExtraWatchUpdate
|
||||
:: [((World, Creature) -> Bool , World -> Creature -> Strategy)]
|
||||
-> Creature
|
||||
-> Reader World Creature
|
||||
sentinelExtraWatchUpdate xs = performActionsR
|
||||
>=> watchUpdateStratR
|
||||
( xs ++ [(crAwayFromPost, goToPostStrat)] )
|
||||
>=> basicPerceptionUpdateR [0]
|
||||
>=> doStrategyActionsR
|
||||
-- >=> reloadOverrideR
|
||||
>=> targetYouWhenCognizantR
|
||||
>=> (overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
|
||||
$ \ _ -> crActionPlan . crStrategy .~ WatchAndWait)
|
||||
|
||||
|
||||
shootAtAdvance :: Int -> [Action]
|
||||
shootAtAdvance tcid =
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen drawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
lostest `DoActionWhile`
|
||||
advanceShoot `DoActionThen`
|
||||
75 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
, _aimSpeed = 0.2
|
||||
, _slowAimSpeed = 0.01
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
]
|
||||
where
|
||||
lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
shootAtWhileContinueTime :: Int -> World -> Creature -> Strategy
|
||||
shootAtWhileContinueTime tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen drawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
lostest `DoActionWhile`
|
||||
advanceShoot `DoActionThen`
|
||||
75 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
, _aimSpeed = 0.2
|
||||
, _slowAimSpeed = 0.01
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
]
|
||||
where
|
||||
lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
Reference in New Issue
Block a user