Add file, fix lamp doDamage space leak
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
module Dodge.Creature.ActionRat
|
||||
( shootTargetWithStrat
|
||||
, aimThenShootStrat
|
||||
, suppressShootTarget
|
||||
, suppress
|
||||
, shootAdvance
|
||||
, shootFirstMiss
|
||||
, doStrategyActions
|
||||
, reloadOverride
|
||||
, reloadOverrideNoHolster
|
||||
, shootAdvanceStrat
|
||||
, watchUpdateStrat
|
||||
, goToPostStrat
|
||||
, overrideInternal
|
||||
, fleeTime
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
@@ -63,16 +66,16 @@ suppress w cr tcr as
|
||||
| otherwise = as
|
||||
|
||||
shootFirstMiss :: Int -> World -> Creature -> Strategy
|
||||
shootFirstMiss tcid w cr = StrategyActions acs (ShootAt tcid)
|
||||
shootFirstMiss tcid w cr = StrategyActions (ShootAt tcid) acs
|
||||
where
|
||||
acs =
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
LeadTarget (10,50)
|
||||
LeadTarget (30,50)
|
||||
`DoActionThen`
|
||||
advanceShoot
|
||||
`DoActionThen`
|
||||
LeadTarget (50,0)
|
||||
LeadTarget (0,0)
|
||||
`DoActionThen`
|
||||
(advanceShoot `DoActionWhileThen` lostest
|
||||
$ DoReplicateThen advanceShoot 75
|
||||
@@ -82,36 +85,59 @@ shootFirstMiss tcid w cr = StrategyActions acs (ShootAt tcid)
|
||||
lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
fleeTime :: Int -> World -> Creature -> Strategy
|
||||
fleeTime t w cr = StrategyActions Flee
|
||||
[ UseTargetCID FleeFrom `DoReplicateThen` t
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
]
|
||||
|
||||
aimThenShootStrat :: Int -> World -> Creature -> Strategy
|
||||
aimThenShootStrat tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
50
|
||||
`WaitThen`
|
||||
DoImpulses [UseItem, 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]]
|
||||
|
||||
shootAdvanceStrat :: Int -> World -> Creature -> Strategy
|
||||
shootAdvanceStrat tcid _ _ = StrategyActions acs (ShootAt tcid)
|
||||
shootAdvanceStrat tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
(DoActionWhileThen advanceShoot lostest
|
||||
. DoReplicateThen advanceShoot 75
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
)
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
, _aimSpeed = 0.2
|
||||
, _slowAimSpeed = 0.01
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
]
|
||||
where
|
||||
acs =
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
(DoActionWhileThen advanceShoot lostest
|
||||
. DoReplicateThen advanceShoot 75
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
)
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
, _aimSpeed = 0.2
|
||||
, _slowAimSpeed = 0.01
|
||||
, _slowAimAngle = pi/8
|
||||
}
|
||||
]
|
||||
lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
goToPostStrat :: World -> Creature -> Strategy
|
||||
goToPostStrat w cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
||||
Just (SentinelAt p _) -> StrategyActions
|
||||
Just (SentinelAt p _) -> StrategyActions (GetTo p)
|
||||
[DoActionThen (WaitThen 150 holsterIfAiming)
|
||||
$ DoActionThen (PathTo p)
|
||||
NoAction
|
||||
-- $ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
] $ GetTo p
|
||||
]
|
||||
_ -> WatchAndWait
|
||||
where
|
||||
sentinelGoal (SentinelAt p dir) = True
|
||||
@@ -160,7 +186,7 @@ applyNewStrategies
|
||||
-> Creature
|
||||
-> Creature
|
||||
applyNewStrategies w cr = case cr ^? crActionPlan . crStrategy of
|
||||
Just (StrategyActions acs strat) -> cr & crActionPlan . crAction .~ acs
|
||||
Just (StrategyActions strat acs) -> cr & crActionPlan . crAction .~ acs
|
||||
& crActionPlan . crStrategy .~ strat
|
||||
otherwise -> cr
|
||||
|
||||
@@ -169,7 +195,7 @@ doStrategyActions
|
||||
-> Creature
|
||||
-> Creature
|
||||
doStrategyActions w cr = case cr ^? crActionPlan . crStrategy of
|
||||
Just (StrategyActions acs strat) -> cr & crActionPlan . crAction .~ acs
|
||||
Just (StrategyActions strat acs) -> cr & crActionPlan . crAction .~ acs
|
||||
& crActionPlan . crStrategy .~ strat
|
||||
otherwise -> cr
|
||||
|
||||
@@ -187,7 +213,7 @@ reloadOverride
|
||||
reloadOverride _ cr
|
||||
| cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo == Just 0
|
||||
&& cr ^. crStance . posture == Aiming
|
||||
= cr & crActionPlan . crStrategy .~ StrategyActions reloadActions Reload
|
||||
= cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
|
||||
| otherwise = cr
|
||||
where
|
||||
reloadActions =
|
||||
@@ -195,6 +221,20 @@ reloadOverride _ cr
|
||||
, WaitThen 1 $ DoActionWhileThen NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
|
||||
reloadOverrideNoHolster
|
||||
:: World
|
||||
-> Creature
|
||||
-> Creature
|
||||
reloadOverrideNoHolster _ cr
|
||||
| cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo == Just 0
|
||||
&& cr ^. crStance . posture == Aiming
|
||||
= cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
|
||||
| otherwise = cr
|
||||
where
|
||||
reloadActions =
|
||||
[ DoActionWhileThen NoAction crIsReloading (DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
|
||||
watchUpdateStrat
|
||||
:: [ ((World, Creature) -> Bool, World -> Creature -> Strategy) ]
|
||||
-> World
|
||||
|
||||
Reference in New Issue
Block a user