Track slime amount using ints
This commit is contained in:
@@ -84,16 +84,20 @@ updateHiveCrit cr cid w
|
||||
| Just x <- cr ^? crType . hiveChildren . to IS.size
|
||||
, x < nbees
|
||||
, Just y <- cr ^? crType . hiveGestation
|
||||
, y == 0 = w
|
||||
, y == 0
|
||||
, Just z <- cr ^? crType . hiveSlime
|
||||
, z >= 400
|
||||
= w
|
||||
& tocr . crType . hiveChildren %~ IS.insert nid
|
||||
& tocr . crType . hiveGestation .~ 50
|
||||
& cWorld . lWorld . creatures . at nid ?~ ncr
|
||||
& tocr . crType . hiveSlime -~ 400
|
||||
| Just x <- cr ^? crType . hiveChildren . to IS.size
|
||||
, x < nbees = w
|
||||
& tocr . crType . hiveGestation %~ (max 0 . subtract 1)
|
||||
| otherwise = w
|
||||
where
|
||||
nbees = 25
|
||||
nbees = 15
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
nid = IM.newKey $ w ^. cWorld . lWorld . creatures
|
||||
ncr = beeCrit & crPos .~ (cr ^. crPos + (0 & _xy +~ 25))
|
||||
@@ -108,9 +112,18 @@ updateBeeFromPheremones cr cid w
|
||||
f bp = distance (cr ^. crPos . _xy) (bp ^. bpPos . _xy) < 20
|
||||
|
||||
updateBeeCrit :: Creature -> Int -> World -> World
|
||||
updateBeeCrit cr
|
||||
| cr ^?! crType . beeAggro > 0 = updateAggroBee cr
|
||||
| otherwise = updateCalmBee cr
|
||||
updateBeeCrit cr cid
|
||||
| cr ^?! crType . beeAggro > 0 = updateAggroBee cr cid
|
||||
| otherwise = beeLifespanCheck cr cid . updateCalmBee cr cid
|
||||
|
||||
beeLifespanCheck :: Creature -> Int -> World -> World
|
||||
beeLifespanCheck cr cid
|
||||
| Just ls <- cr ^? crType . beeLifespan
|
||||
, Just x <- cr ^? crType . beeSlime
|
||||
, ls < 1
|
||||
, x < 5
|
||||
= cWorld . lWorld . creatures . ix cid . crHP . _HP -~ 1
|
||||
| otherwise = id
|
||||
|
||||
updateAggroBee :: Creature -> Int -> World -> World
|
||||
updateAggroBee cr cid w
|
||||
@@ -158,15 +171,19 @@ updateCalmBee cr cid w
|
||||
| Just hcr <- gethive
|
||||
, distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30
|
||||
, Just x <- cr ^? crType . beeSlime
|
||||
, x >= 0.5 = w & tocr . crType . beeSlime -~ 0.5
|
||||
, x >= 50 = w
|
||||
& tocr . crType . beeSlime -~ 50
|
||||
& cWorld . lWorld . creatures . ix (hcr ^. crID) . crType . hiveSlime +~ 50
|
||||
| Just x <- cr ^? crType . beeSlime
|
||||
, x < 0.5
|
||||
, x < 50
|
||||
, Just hcr <- gethive
|
||||
, distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30
|
||||
, Just ReturnToHive <- cr ^? crActionPlan . apStrategy = startsearch
|
||||
| Just ReturnToHive <- cr ^? crActionPlan . apStrategy = w
|
||||
| Just x <- cr ^? crType . beeSlime
|
||||
, x >= 15 = starthivereturn
|
||||
, x >= 1500 = starthivereturn
|
||||
& randGen .~ gsa
|
||||
& tocr . crType . beeLifespan %~ max 0 . subtract sa
|
||||
| Just mid <- cr ^? crStance . carriage . mountID
|
||||
, mountshakeoff mid = startsearch
|
||||
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
|
||||
@@ -177,10 +194,11 @@ updateCalmBee cr cid w
|
||||
| Just tid <- cr ^? crStance . carriage . mountID
|
||||
, Just SlimeCrit{} <- w ^? cWorld . lWorld . creatures . ix tid . crType = w
|
||||
& tocr . crType . beeSlime +~ sspeed
|
||||
& cWorld . lWorld . creatures . ix tid . crType . slimeRad %~ (sqrt . subtract sspeed . (^(2::Int)))
|
||||
-- & cWorld . lWorld . creatures . ix tid . crType . slimeRad %~ (sqrt . subtract sspeed . (^(2::Int)))
|
||||
& cWorld . lWorld . creatures . ix tid . crType . slimeSlime -~ sspeed
|
||||
| Just (tcr,ti) <- gettarg
|
||||
, distance (cr ^. crPos . _xy) (tcr ^. crPos . _xy) < 0.8*crRad (tcr ^. crType)
|
||||
, Just r <- tcr ^? crType . slimeRad
|
||||
, Just r <- tcr ^? crType . slimeSlime . to slimeToRad
|
||||
, Just d <- tcr ^? crType . slimeCompression
|
||||
= w
|
||||
& tocr . crStance . carriage .~ Mounted ti (cr ^. crPos - tcr ^. crPos & _xy %~ compressionScale (vNormal ((1/r) *^d)))
|
||||
@@ -193,6 +211,7 @@ updateCalmBee cr cid w
|
||||
& tocr . crActionPlan . apStrategy . searchTimer %~ (max 0 . subtract 1)
|
||||
| otherwise = startsearch
|
||||
where
|
||||
(sa,gsa) = runState (takeOne [0,1]) (w ^. randGen)
|
||||
starthivereturn = fromMaybe w $ do
|
||||
hcr <- gethive
|
||||
return $ w
|
||||
@@ -213,11 +232,12 @@ updateCalmBee cr cid w
|
||||
mcr <- w ^? cWorld . lWorld . creatures . ix mid
|
||||
SlimeCrit {_slimeSplitTimer = x} <- mcr ^? crType
|
||||
return $ x > 0
|
||||
sspeed = 0.05
|
||||
--sspeed = 0.05
|
||||
sspeed = 5
|
||||
gettarg = do
|
||||
i <- cr ^? crActionPlan . apStrategy . harvestTarget
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||
x <- tcr ^? crType . slimeRad
|
||||
x <- tcr ^? crType . slimeSlime . to slimeToRad
|
||||
guard $ x > 12
|
||||
return (tcr,i)
|
||||
gethive = do
|
||||
@@ -225,7 +245,7 @@ updateCalmBee cr cid w
|
||||
w ^? cWorld . lWorld . creatures . ix i
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
istarget tcr = fromMaybe False $ do
|
||||
r <- tcr ^? crType . slimeRad
|
||||
r <- tcr ^? crType . slimeSlime . to slimeToRad
|
||||
return $ r > 12
|
||||
|
||||
slimeCritUpdate :: Int -> World -> World
|
||||
@@ -260,7 +280,7 @@ slimeCritUpdate cid w
|
||||
f' | norm p > 3*r/2 = const True
|
||||
| otherwise = id
|
||||
t = cr ^?! crType . slimeIsCompressing
|
||||
r = cr ^?! crType . slimeRad
|
||||
r = cr ^?! crType . slimeSlime . to slimeToRad
|
||||
p = cr ^?! crType . slimeCompression
|
||||
|
||||
setSlimeDir :: Int -> Creature -> World -> State StdGen World
|
||||
@@ -281,7 +301,7 @@ setSlimeDir cid cr w = do
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
-- tocr' i = cWorld . lWorld . creatures . at i
|
||||
cxy = cr ^. crPos . _xy
|
||||
r = cr ^?! crType . slimeRad
|
||||
r = cr ^?! crType . slimeSlime . to slimeToRad
|
||||
|
||||
|
||||
doSlimeRadChange :: Creature -> Creature
|
||||
@@ -314,18 +334,20 @@ splitSlimeCrit p v cr = do
|
||||
| isLHS p (p+v) cxy = normalize (vNormal v)
|
||||
| otherwise = - normalize (vNormal v)
|
||||
return (cr' & crPos . _xy .~ mp + (r1 + 0.51) *^ mvdir
|
||||
& crType . slimeRad .~ r1
|
||||
-- & crType . slimeRad .~ r1
|
||||
& crType . slimeSlime .~ round (r1 ^ (2 :: Int) * 100)
|
||||
& crType . slimeCompression .~ rotateV (argV mvdir) (V2 r1 0)
|
||||
& crDir .~ argV mvdir
|
||||
,cr' & crPos . _xy .~ mp - (r2 + 0.51) *^ mvdir
|
||||
& crType . slimeRad .~ r2
|
||||
-- & crType . slimeRad .~ r2
|
||||
& crType . slimeSlime .~ round (r2^(2::Int) * 100)
|
||||
& crType . slimeCompression .~ rotateV (argV (-mvdir)) (V2 r2 0)
|
||||
& crDir .~ argV (-mvdir)
|
||||
& crType . slimeEngulfProgress .~ 0
|
||||
)
|
||||
where
|
||||
cxy = cr ^. crPos . _xy
|
||||
r = cr ^?! crType . slimeRad
|
||||
r = cr ^?! crType . slimeSlime . to slimeToRad
|
||||
cr' = cr & crDamage .~ []
|
||||
& crType . slimeRadWobble .~ 0
|
||||
& crType . slimeSplitTimer .~ 10
|
||||
@@ -412,7 +434,10 @@ crDeathEffects cr w = case cr ^. crType of
|
||||
return $ w & cWorld . lWorld . creatures . ix hid . crType . hiveChildren %~ IS.delete (cr ^. crID)
|
||||
_ -> w
|
||||
where
|
||||
beepheremone = cWorld . lWorld . beePheremones .:~ BPheremone (cr ^. crPos) (cr ^. crPos - cr ^. crOldPos) 200
|
||||
beepheremone
|
||||
| Just x <- cr ^? crType . beeLifespan
|
||||
, x < 1 = id
|
||||
| otherwise = cWorld . lWorld . beePheremones .:~ BPheremone (cr ^. crPos) (cr ^. crPos - cr ^. crOldPos) 200
|
||||
|
||||
startDeathTimer :: Creature -> Creature
|
||||
startDeathTimer cr = cr & crDeathTimer ?~ case cr ^. crType of
|
||||
|
||||
Reference in New Issue
Block a user