Work on crab crit

This commit is contained in:
2026-04-08 23:47:22 +01:00
parent 77c0680bd5
commit 52d389f342
6 changed files with 230 additions and 186 deletions
+26 -8
View File
@@ -9,7 +9,7 @@ module Dodge.Creature.ReaderUpdate (
-- goToTarget,
flockACC,
chaseCritMv,
crabCritMv,
crabActionUpdate,
setMvPosToTargetCr,
setViewPos,
hoverCritMv,
@@ -121,12 +121,16 @@ flockACC w cr = fromMaybe cr $ do
else negate r *.* horDir
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
crabCritMv :: World -> Creature -> Creature
crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
_ | Just tid <- melee -> cr & crActionPlan . apAction
.~ DoImpulses [Melee tid] `DoActionThen`
crabActionUpdate :: World -> Creature -> Creature
crabActionUpdate w cr = case _apStrategy (_crActionPlan cr) of
_ | Just tid <- meleel -> cr & crActionPlan . apAction
.~ DoImpulses [MeleeL tid] `DoActionThen`
DoReplicate 10 NoAction
& crType . meleeCooldownL .~ 20
-- & crType . meleeCooldownL .~ 20
_ | Just tid <- meleer -> cr & crActionPlan . apAction
.~ DoImpulses [MeleeR tid] `DoActionThen`
DoReplicate 10 NoAction
-- & crType . meleeCooldownR .~ 20
WarningCry -> cr
CloseToMelee tid | aimi tid -> cr & crActionPlan . apAction .~ EvadeAim
& crType . dodgeCooldown .~ dc
@@ -143,7 +147,7 @@ crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
& crIntention . mvToPoint .~ Nothing
_ -> viewTarget w cr
where
melee = do
meleel = do
tid <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix tid
let cpos = cr ^. crPos . _xy
@@ -151,7 +155,21 @@ crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
guard $ _meleeCooldownL (_crType cr) == 0
&& Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4
&& (_crDir cr - argV (tpos -.- cpos)) > (-pi / 4)
&& (_crDir cr - argV (tpos -.- cpos)) <= 0
&& cr ^?! crType . meleeCooldownR < 15
return tid
meleer = do
tid <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix tid
let cpos = cr ^. crPos . _xy
tpos = tcr ^. crPos . _xy
guard $ _meleeCooldownR (_crType cr) == 0
&& Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
&& (_crDir cr - argV (tpos -.- cpos)) < pi / 4
&& (_crDir cr - argV (tpos -.- cpos)) >= 0
&& cr ^?! crType . meleeCooldownL < 15
return tid
--dc = fst $ randomR (15,25) (w ^. randGen)
dc = fst $ randomR (15,50) (w ^. randGen)