Allow slimes to recombine
This commit is contained in:
@@ -66,7 +66,7 @@ slimeCrit :: Creature
|
||||
slimeCrit = defaultCreature
|
||||
& crName .~ "slimeCrit"
|
||||
& crHP .~ HP 1000
|
||||
& crType .~ SlimeCrit 40 (V2 30 0) False
|
||||
& crType .~ SlimeCrit 40 (V2 30 0) False True
|
||||
& crFaction .~ ColorFaction (light green)
|
||||
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Creature.Radius
|
||||
import Color
|
||||
import Control.Monad
|
||||
@@ -82,23 +82,32 @@ slimeCritUpdate cid w
|
||||
| otherwise = w
|
||||
& cWorld . lWorld . creatures . ix cid .~ mvslime
|
||||
& cWorld . lWorld . creatures . ix cid . crDamage .~ []
|
||||
& cWorld . lWorld . creatures . ix cid . crDir .~ d
|
||||
& cWorld . lWorld . creatures . ix cid . crType . slimeResetDir .~ rb'
|
||||
& randGen .~ g
|
||||
where
|
||||
txy = w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
cxy = cr ^. crPos . _xy
|
||||
mvslime
|
||||
| hasLOS cxy txy w = mvslime'
|
||||
| otherwise = cr
|
||||
mvslime' = cr & crType . slimeCompression .~ p' + x
|
||||
-- & crPos . _xy +~ g (x)
|
||||
& crPos . _xy +~ 0.1 *^ normalize (txy-cxy)
|
||||
rb = cr ^?! crType . slimeResetDir
|
||||
(d,rb',g)
|
||||
| isWalkable cxy txy w && distance cxy txy < 50 + r
|
||||
, rb == cr ^?! crType . slimeIsCompressing
|
||||
= (argV (txy-cxy), rb, w ^. randGen)
|
||||
| abs (norm p - r) < 0.1
|
||||
, rb == cr ^?! crType . slimeIsCompressing
|
||||
= let (d',g') = randomR (0, 2* pi) (w ^. randGen)
|
||||
in (d',not rb, g')
|
||||
| otherwise = (cr ^. crDir, rb, w ^. randGen)
|
||||
mvslime = cr & crType . slimeCompression .~ p' + x
|
||||
-- & crPos . _xy +~ 0.1 *^ normalize (txy-cxy)
|
||||
& crPos . _xy +~ 0.1 *^ unitVectorAtAngle d
|
||||
& crType . slimeIsCompressing %~ (f . f')
|
||||
& crDir .~ argV (txy-cxy)
|
||||
-- g | cr ^?! crType . slimeIsCompressing = negate
|
||||
-- | otherwise = id
|
||||
s | cr ^?! crType . slimeIsCompressing = 2/3
|
||||
| otherwise = 1.5
|
||||
f | abs (norm v - norm p') < 0.1 = not
|
||||
f | abs (norm v - norm p') < 0.2 = not
|
||||
| otherwise = id
|
||||
v = (s * r) *^ unitVectorAtAngle (cr ^. crDir)
|
||||
r = crRad (cr ^. crType)
|
||||
@@ -123,9 +132,13 @@ splitSlimeCrit p v cr = do
|
||||
return (cr' & crPos . _xy .~ mp + r1 *^ normalize (mp - cxy)
|
||||
& crType . slimeRad .~ r1
|
||||
& crType . slimeCompression .~ V2 r1 0
|
||||
& crDir .~ argV (mp - cxy)
|
||||
& crType . slimeResetDir .~ not (cr ^?! crType . slimeIsCompressing)
|
||||
,cr' & crPos . _xy .~ mp - r2 *^ normalize (mp - cxy)
|
||||
& crType . slimeRad .~ r2
|
||||
& crType . slimeCompression .~ V2 r2 0
|
||||
& crDir .~ argV (cxy - mp)
|
||||
& crType . slimeResetDir .~ not (cr ^?! crType . slimeIsCompressing)
|
||||
)
|
||||
where
|
||||
cxy = cr ^. crPos . _xy
|
||||
|
||||
Reference in New Issue
Block a user