Allow slime to eat creatures
This commit is contained in:
@@ -65,7 +65,7 @@ data CrHP
|
||||
| CrIsCorpse SPic
|
||||
| CrDestroyed CrDestructionType
|
||||
|
||||
data CrDestructionType = Gibbed | Pitted
|
||||
data CrDestructionType = Gibbed | Pitted | Swallowed
|
||||
|
||||
data DeathType = CookDeath | PoisonDeath | PlainDeath | GibsDeath
|
||||
|
||||
|
||||
@@ -58,8 +58,11 @@ tutAnoTree = do
|
||||
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
||||
, corDoor
|
||||
--, tToBTree "" . return . cleatOnward <$> (xChasm 200 200
|
||||
, tToBTree "" . return . cleatOnward <$> (roomRectAutoLights 300 300
|
||||
<&> rmPmnts .:~ (sps0 (PutCrit slimeCrit) & plSpot . psPos .~ V2 100 100))
|
||||
, tToBTree "" . return . cleatOnward <$> ((putSingleLight =<< roomRectAutoLights 300 300)
|
||||
<&> rmPmnts <>~ [sps0 (PutCrit slimeCrit) & plSpot . psPos .~ V2 150 100
|
||||
, sps0 (PutCrit chaseCrit) & plSpot . psPos .~ V2 250 100
|
||||
]
|
||||
)
|
||||
-- , tToBTree "" . return . cleatOnward <$> (cChasm
|
||||
-- <&> rmPmnts .:~ (sps0 (PutCrit slimeCrit) & plSpot . psPos .~ V2 100 20))
|
||||
-- , corDoor
|
||||
|
||||
+28
-3
@@ -1004,6 +1004,10 @@ crCrSpring c1 c2
|
||||
, SlimeCrit{} <- c2 ^. crType
|
||||
, id2 > id1
|
||||
, distance xy1 xy2 < abs (r1 - r2) + 1 = fuseSlimes c1 c2
|
||||
| SlimeCrit{} <- c1 ^. crType
|
||||
, slimeFood c2
|
||||
, distance xy1 xy2 < r1 - (r2 + 5)
|
||||
= feedSlime c1 c2
|
||||
| Just t <- c1 ^? crType . slimeSplitTimer
|
||||
, t <= 0 =
|
||||
cWorld . lWorld . creatures %~ (rolap . rolap')
|
||||
@@ -1037,13 +1041,32 @@ crCrSpring c1 c2
|
||||
m1 = crMass $ c1 ^. crType
|
||||
m2 = crMass $ c2 ^. crType
|
||||
|
||||
slimeFood :: Creature -> Bool
|
||||
slimeFood cr = case cr ^. crType of
|
||||
Avatar{} -> True
|
||||
ChaseCrit{} -> True
|
||||
_ -> False
|
||||
|
||||
feedSlime :: Creature -> Creature -> World -> World
|
||||
feedSlime s c w = w
|
||||
& cWorld . lWorld . creatures . ix (c ^. crID) . crHP .~ CrDestroyed Swallowed
|
||||
& cWorld . lWorld . creatures . ix (s ^. crID) %~ f
|
||||
& slimeEatSound (s ^. crID) (s ^. crPos . _xy)
|
||||
where
|
||||
f cr = cr & crType . slimeRad .~ r
|
||||
& crType . slimeRadWobble +~ r - r1
|
||||
& crType . slimeCompression %~ ((r/r1) *^)
|
||||
r1 = s ^?! crType . slimeRad
|
||||
r2 = 2 * c ^. crType . to crRad
|
||||
r = sqrt (r1*r1 + r2*r2)
|
||||
|
||||
fuseSlimes :: Creature -> Creature -> World -> World
|
||||
fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix mini .~ c)
|
||||
. (cWorld . lWorld . creatures . at maxi .~ Nothing)
|
||||
. dosound
|
||||
. slimeEatSound i1 (c ^. crPos . _xy)
|
||||
where
|
||||
c' | c1 ^?! crType . slimeRad > c2 ^?! crType . slimeRad = c1
|
||||
| otherwise = c2
|
||||
| otherwise = c2
|
||||
mini = min i1 i2
|
||||
maxi = max i1 i2
|
||||
i1 = c1 ^. crID
|
||||
@@ -1055,7 +1078,9 @@ fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix mini .~ c)
|
||||
r1 = c1 ^?! crType . slimeRad
|
||||
r2 = c2 ^?! crType . slimeRad
|
||||
r = sqrt (r1*r1 + r2*r2)
|
||||
dosound w = w & soundStart (CrSound i1) (c ^. crPos . _xy) s Nothing
|
||||
|
||||
slimeEatSound :: Int -> Point2 -> World -> World
|
||||
slimeEatSound i p w = w & soundStart (CrSound i) p s Nothing
|
||||
& randGen .~ g
|
||||
where
|
||||
(s,g) = runState (takeOne [slurp1S,slurp2S,slurp3S,slurp4S,slurp5S]) (w ^. randGen)
|
||||
|
||||
Reference in New Issue
Block a user