|
|
|
@@ -3,6 +3,7 @@
|
|
|
|
|
module Dodge.Creature.Update (updateCreature) where
|
|
|
|
|
|
|
|
|
|
--import Dodge.WorldEvent.ThingsHit
|
|
|
|
|
import Dodge.Base.Collide
|
|
|
|
|
import Data.List (sortOn)
|
|
|
|
|
import Dodge.Creature.Radius
|
|
|
|
|
import Dodge.Zoning.Creature
|
|
|
|
@@ -76,7 +77,7 @@ updateLivingCreature cr = case cr ^. crType of
|
|
|
|
|
over (cWorld . lWorld . creatures . ix cid) (hoverCritInternal w) w
|
|
|
|
|
SlinkCrit{} -> slinkCritUpdate cid
|
|
|
|
|
SlimeCrit{} -> slimeCritUpdate cid
|
|
|
|
|
BeeCrit{} -> crUpdate cid . performActions cid . updateBeeCrit cr cid
|
|
|
|
|
BeeCrit{} -> crUpdate cid . performActions cid . updateBeeFromPheremones cr cid . updateBeeCrit cr cid
|
|
|
|
|
HiveCrit{} -> crUpdate cid . performActions cid . updateHiveCrit cr cid
|
|
|
|
|
where
|
|
|
|
|
cid = cr ^. crID
|
|
|
|
@@ -102,8 +103,34 @@ updateHiveCrit cr cid w
|
|
|
|
|
& crID .~ nid
|
|
|
|
|
& crType . beeHive ?~ cid
|
|
|
|
|
|
|
|
|
|
updateBeeFromPheremones :: Creature -> Int -> World -> World
|
|
|
|
|
updateBeeFromPheremones cr cid w
|
|
|
|
|
| any f (w ^. cWorld . lWorld . beePheremones) = w & cWorld . lWorld . creatures . ix cid . crType . beeAggro .~ 300
|
|
|
|
|
| otherwise = w
|
|
|
|
|
where
|
|
|
|
|
f bp = distance (cr ^. crPos . _xy) (bp ^. bpPos) < 20
|
|
|
|
|
|
|
|
|
|
updateBeeCrit :: Creature -> Int -> World -> World
|
|
|
|
|
updateBeeCrit cr cid w
|
|
|
|
|
updateBeeCrit cr
|
|
|
|
|
| cr ^?! crType . beeAggro > 0 = updateAggroBee cr
|
|
|
|
|
| otherwise = updateCalmBee cr
|
|
|
|
|
|
|
|
|
|
updateAggroBee :: Creature -> Int -> World -> World
|
|
|
|
|
updateAggroBee cr cid w
|
|
|
|
|
| Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w = w & tocr . crActionPlan . apStrategy .~ CloseToMelee (tcr ^. crID)
|
|
|
|
|
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
|
|
|
|
|
| otherwise = w & tocr . crType . beeAggro -~ 1
|
|
|
|
|
& tocr . crActionPlan . apStrategy .~ Search
|
|
|
|
|
where
|
|
|
|
|
cxy = cr ^. crPos . _xy
|
|
|
|
|
tocr = cWorld . lWorld . creatures . ix cid
|
|
|
|
|
istarget tcr = tcr ^. crID == 0
|
|
|
|
|
&& hasLOS cxy (tcr ^. crPos . _xy) w
|
|
|
|
|
|
|
|
|
|
-- do bees need to be able to see slime targets?
|
|
|
|
|
-- if no path can be made, reset harvest action
|
|
|
|
|
updateCalmBee :: Creature -> Int -> World -> World
|
|
|
|
|
updateCalmBee cr cid w
|
|
|
|
|
| Just hcr <- gethive
|
|
|
|
|
, distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30
|
|
|
|
|
, Just x <- cr ^? crType . beeSlime
|
|
|
|
@@ -123,7 +150,7 @@ updateBeeCrit cr cid w
|
|
|
|
|
, x >= 15
|
|
|
|
|
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
|
|
|
|
|
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
|
|
|
|
|
, Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc (cr ^. crPos . _xy) 100 w =
|
|
|
|
|
, Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w =
|
|
|
|
|
w & tocr . crActionPlan . apStrategy .~ HarvestFrom (tcr ^. crID)
|
|
|
|
|
| Just tid <- cr ^? crStance . carriage . mountID
|
|
|
|
|
, Just SlimeCrit{} <- w ^? cWorld . lWorld . creatures . ix tid . crType = w
|
|
|
|
|