Tweak chaseCrit melee striking

This commit is contained in:
2023-05-01 10:21:03 +01:00
parent ba12a73842
commit 06608c60bf
3 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ followImpulse cr w imp = case imp of
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ InInventory (SelItem i NoInvSelAction)
Melee cid' ->
( hitCr cid'
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20
, crMvAbsolute (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20
)
RandomTurn a -> (randGen .~ snd (rr a), creatureTurn (fst $ rr a) cr)
MakeSound sid -> (soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing, cr)
@@ -83,6 +83,6 @@ followImpulse cr w imp = case imp of
rr a = randomR (- a, a) $ _randGen w
hitCr i =
( cWorld . lWorld . creatures . ix i . crState . csDamage
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) NoDamageEffect
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) (PushBackDamage 3)
)
. soundStart (CrSound cid) cpos hitS Nothing
+7
View File
@@ -36,9 +36,13 @@ overrideMeleeCloseTarget cr = maybe cr (tryMeleeAttack cr) (_targetCr $ _crInten
tryMeleeAttack :: Creature -> Creature -> Creature
tryMeleeAttack cr tcr
| _crMeleeCooldown cr == 0
&& Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget
&& dist tpos cpos < _crRad cr + _crRad tcr + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
cr & crActionPlan . apImpulse .~ [Melee $ _crID tcr]
& crActionPlan . apAction .~ [DoReplicate 10 NoAction `DoActionThen` DoImpulses
[ChangeStrategy (CloseToMelee $ _crID tcr)] ]
& crActionPlan . apStrategy .~ MeleeStrike
| otherwise = cr
where
cpos = _crPos cr
@@ -109,6 +113,7 @@ chaseCritMv :: World -> Creature -> Creature
chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
StrategyActions _ _ -> cr
WarningCry -> cr
MeleeStrike -> cr
_ -> case cr ^? crIntention . mvToPoint . _Just of
Just p
| dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p]
@@ -136,7 +141,9 @@ viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
-- ( TurnToPoint p
-- )
& crIntention . viewPoint .~ Nothing
& crActionPlan . apStrategy .~ Investigate
| otherwise -> cr & crActionPlan . apAction %~ replaceNullWith (PathTo p)
& crActionPlan . apStrategy .~ Investigate
Nothing -> cr
replaceNullWith :: a -> [a] -> [a]
+2
View File
@@ -181,6 +181,7 @@ data Strategy
| ShootAt Int
| FollowImpulses
| WatchAndWait
| Investigate
| WarningCry
| LookAround
| CloseToMelee {_meleeTarget :: Int}
@@ -218,3 +219,4 @@ concat <$> mapM (deriveJSON defaultOptions)
makeLenses ''ActionPlan
makeLenses ''Impulse
makeLenses ''Action
makeLenses ''Strategy