Fix bee slime mounting

This commit is contained in:
2026-05-09 17:46:27 +01:00
parent 437ca007ef
commit 72056e5e3e
7 changed files with 173 additions and 187 deletions
+13 -16
View File
@@ -69,7 +69,7 @@ updateLivingCreature cr = case cr ^. crType of
HoverCrit{} -> crUpdate cid . performActions cid . hoverCritHoverSound cr .
updateHoverCrit cid
SlinkCrit{} -> slinkCritUpdate cid
SlimeCrit{} -> slimeCritUpdate cid
SlimeCrit{} -> updateSlimeCrit cid
BeeCrit{} -> crUpdate cid . performActions cid . updateBeeFromPheremones cr cid . updateBeeCrit cr cid
HiveCrit{} -> crUpdate cid . performActions cid . updateHiveCrit cr cid
where
@@ -196,7 +196,9 @@ updateCalmBee cr cid w
, distance (cr ^. crPos . _xy) (tcr ^. crPos . _xy) < 0.8*crRad (tcr ^. crType)
, Just d <- tcr ^? crType . slimeCompression
= w
& tocr . crStance . carriage .~ Mounted ti (cr ^. crPos - tcr ^. crPos & _x %~ (/d) & _y *~ d)
& tocr . crStance . carriage .~ Mounted ti
(oxyrot (tcr^.crDir)
(oxyrot (-tcr^.crDir) (cr ^. crPos - tcr ^. crPos) & _x %~ (/d) & _y *~ d))
& tocr . crActionPlan . apAction .~ NoAction
| Just (tcr,_) <- gettarg = w
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
@@ -206,6 +208,7 @@ updateCalmBee cr cid w
& tocr . crActionPlan . apStrategy . searchTimer %~ (max 0 . subtract 1)
| otherwise = startsearch
where
oxyrot a = over _xy (rotateV a)
(sa,gsa) = runState (takeOne [0,1]) (w ^. randGen)
starthivereturn = fromMaybe w $ do
hcr <- gethive
@@ -242,8 +245,8 @@ updateCalmBee cr cid w
r <- tcr ^? crType . slimeSlime . to slimeToRad
return $ r > 12
slimeCritUpdate :: Int -> World -> World
slimeCritUpdate cid w
updateSlimeCrit :: Int -> World -> World
updateSlimeCrit cid w
| r < 5 = w & cWorld . lWorld . creatures . at cid .~ Nothing
| Just hitp <- w ^? cWorld . lWorld . creatures . ix cid . crDamage . ix 0 . dmPos
, Just hitv <- w ^? cWorld . lWorld . creatures . ix cid . crDamage . ix 0 . dmVector
@@ -341,9 +344,9 @@ splitSlimeCrit p v cr = do
r = cr ^?! crType . slimeSlime . to slimeToRad
cr' = cr & crDamage .~ []
& crType . slimeSlimeChange .~ 0
& crType . slimeSplitTimer .~ Just (10, mempty)
& crType . slimeSplitTimer ?~ (10, mempty)
& crType . slimeIsCompressing .~ False
& crType . slimeCompression .~ 1 -- rotateV (argV mvdir) (V2 r1 0)
& crType . slimeCompression .~ 1
(ps,qs) = cutPoly (p-cxy) (p+v-cxy) $ slimeOutline cr & each %~ rotateV (cr ^. crDir)
-- h is the height of the segment, ie r - distance to center
@@ -364,16 +367,10 @@ slinkCritUpdate cid w =
*~ Q.axisAngle (V3 0 1 0) (pi / 1000)
hoverCritHoverSound :: Creature -> World -> World
hoverCritHoverSound cr w = fromMaybe w $ do
guard $ d < 100
return $
soundContinueVol
(0.5 * (1 - 0.01 * d))
(CrSound cid)
cxy
buzz1S
(Just 2)
w
hoverCritHoverSound cr w
| d < 100
= soundContinueVol (0.5 * (1 - 0.01 * d)) (CrSound cid) cxy buzz1S (Just 2) w
| otherwise = w
where
cxy = cr ^. crPos . _xy
d = max 0 (dist (you w ^. crPos . _xy) cxy - 100)