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
+23
View File
@@ -45,6 +45,19 @@ followImpulse cid w = \case
crup
( crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) . (crType . meleeCooldown .~ 20)
)
MeleeL cid' ->
hitCrl cid' $
crup
-- ( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ 10 *.* normalizeV (posFromID cid' -.- cpos))
-- .
(crType . meleeCooldownL .~ 20)
-- )
MeleeR cid' ->
hitCrr cid' $
crup
--( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ (-10) *.* normalizeV (posFromID cid' -.- cpos)) .
(crType . meleeCooldownR .~ 20)
--)
RandomTurn a ->
let (aa, g) = rr a
in (randGen .~ g) (crup (crDir +~ aa))
@@ -74,3 +87,13 @@ followImpulse cid w = \case
hitCr i =
cWorld . lWorld . creatures . ix i . crDamage
.:~ Blunt 100 (posFromID i) (posFromID i - cpos)
hitCrl i =
cWorld . lWorld . creatures . ix i . crDamage
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir - pi/2))
]
hitCrr i =
cWorld . lWorld . creatures . ix i . crDamage
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + pi/2))
]
+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)
+1
View File
@@ -68,6 +68,7 @@ walkCliffPush cr xs = pushAgainst (cr ^. crOldPos . _xy - cr ^. crOldOldPos . _x
groundCliffPush :: Creature -> [(Point2,Point2)] -> Point2
groundCliffPush cr xs = x *^ circSegsInside cxy r xs
where
-- at least 0.01 so that corpses don't hang on the edge of a cliff too long
x = max 0.01 $ 0.25 * (1 - dist cxy p / (2*r)) ** 2
cxy = cr ^. crPos . _xy
r = cr ^. crType . to crRad
+2
View File
@@ -39,6 +39,8 @@ data Impulse
| DropItem
| Bark SoundID -- placeholder for various communication types
| Melee Int
| MeleeL Int
| MeleeR Int
| ChangePosture Posture
| MakeSound SoundID
| ChangeStrategy Strategy
+1 -1
View File
@@ -35,7 +35,7 @@ crabCritInternal w =
. searchIfDamaged
. targetYouWhenCognizant w
. perceptionUpdate [0] w
. crabCritMv w
. crabActionUpdate w
. setMvPosToTargetCr w
. setViewPos w
-- . overrideMeleeCloseTarget w