Work on bee movement
This commit is contained in:
@@ -116,7 +116,7 @@ updateBeeCrit cr
|
||||
updateAggroBee :: Creature -> Int -> World -> World
|
||||
updateAggroBee cr cid w
|
||||
| Mounted{} <- cr ^. crStance . carriage = w & tocr . crStance . carriage .~ Flying 0
|
||||
| Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w
|
||||
| Just tcr <- atarget
|
||||
, distance (tcr ^. crPos . _xy) (cr ^. crPos . _xy) < crRad (cr ^. crType) + crRad (tcr ^. crType) + 1
|
||||
, nearZeroAngle (argV (tcr ^. crPos . _xy - cr ^. crPos . _xy) - cr ^. crDir) < pi / 2
|
||||
, 0 <- cr ^?! crType . meleeCooldown
|
||||
@@ -125,16 +125,18 @@ updateAggroBee cr cid w
|
||||
& cWorld . lWorld . creatures . ix (tcr ^. crID) . crDamage
|
||||
.:~ Blunt 50 (cxy + crRad (cr ^. crType) *^ vdir) vdir (CrMeleeO (cr ^. crID))
|
||||
& tocr . crType . meleeCooldown .~ 20
|
||||
| Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w = w & tocr . crActionPlan . apStrategy .~ CloseToMelee (tcr ^. crID)
|
||||
| Just tcr <- atarget = w & tocr . crActionPlan . apStrategy .~ CloseToMelee (tcr ^. crID)
|
||||
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
|
||||
& tocr . crType . meleeCooldown %~ (max 0 . subtract 1)
|
||||
| Just PathTo{} <- cr ^? crActionPlan . apAction = w & tocr . crType . beeAggro -~ 1
|
||||
& tocr . crType . meleeCooldown %~ (max 0 . subtract 1)
|
||||
| otherwise = w & tocr . crType . beeAggro -~ 1
|
||||
& tocr . crActionPlan . apStrategy .~ Search
|
||||
& tocr . crActionPlan . apAction .~ PathTo (cxy + p) NoAction
|
||||
& tocr . crType . meleeCooldown %~ (max 0 . subtract 1)
|
||||
& randGen .~ g
|
||||
where
|
||||
|
||||
(p,g) = runState (randOnCirc 150) (w ^. randGen)
|
||||
atarget = listToMaybe . sortOn (distance cxy . (^.crPos._xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w
|
||||
vdir = unitVectorAtAngle (cr ^. crDir)
|
||||
cxy = cr ^. crPos . _xy
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
@@ -154,21 +156,27 @@ 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 >= 0.5 = w & tocr . crType . beeSlime -~ 0.5
|
||||
| Just x <- cr ^? crType . beeSlime
|
||||
, x < 0.5
|
||||
, Just ReturnToHive <- cr ^? crActionPlan . apStrategy
|
||||
= w & tocr . crActionPlan . apAction .~ NoAction
|
||||
| Just hcr <- gethive
|
||||
, Just _ <- cr ^? crStance . carriage . mountID
|
||||
, Just x <- cr ^? crType . beeSlime
|
||||
, x >= 15
|
||||
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
|
||||
& tocr . crStance . carriage .~ Flying 0
|
||||
& tocr . crActionPlan . apStrategy .~ ReturnToHive
|
||||
| Just mid <- cr ^? crStance . carriage . mountID
|
||||
, mountshakeoff mid = w & tocr . crActionPlan . apStrategy .~ Search
|
||||
, mountshakeoff mid = w -- & tocr . crActionPlan . apStrategy .~ Search
|
||||
& tocr . crStance . carriage .~ Flying 0
|
||||
& tocr . crActionPlan . apStrategy .~ Search
|
||||
| Just hcr <- gethive
|
||||
, Just x <- cr ^? crType . beeSlime
|
||||
, x >= 15
|
||||
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
|
||||
& tocr . crActionPlan . apStrategy .~ ReturnToHive
|
||||
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
|
||||
, Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w =
|
||||
w & tocr . crActionPlan . apStrategy .~ HarvestFrom (tcr ^. crID)
|
||||
@@ -177,7 +185,7 @@ updateCalmBee cr cid w
|
||||
& tocr . crType . beeSlime +~ sspeed
|
||||
& cWorld . lWorld . creatures . ix tid . crType . slimeRad %~ (sqrt . subtract sspeed . (^(2::Int)))
|
||||
| Just (tcr,ti) <- gettarg
|
||||
, distance (cr ^. crPos . _xy) (tcr ^. crPos . _xy) < 0.9*crRad (tcr ^. crType)
|
||||
, distance (cr ^. crPos . _xy) (tcr ^. crPos . _xy) < 0.8*crRad (tcr ^. crType)
|
||||
, Just r <- tcr ^? crType . slimeRad
|
||||
, Just d <- tcr ^? crType . slimeCompression
|
||||
= w
|
||||
@@ -185,8 +193,13 @@ updateCalmBee cr cid w
|
||||
& tocr . crActionPlan . apAction .~ NoAction
|
||||
| Just (tcr,_) <- gettarg = w
|
||||
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
|
||||
| otherwise = w & tocr . crActionPlan . apStrategy .~ Search
|
||||
| Just PathTo{} <- cr ^? crActionPlan . apAction = w
|
||||
| otherwise = w
|
||||
& tocr . crActionPlan . apAction .~ PathTo (cxy + p) NoAction
|
||||
& randGen .~ g
|
||||
& tocr . crActionPlan . apStrategy .~ Search
|
||||
where
|
||||
(p,g) = runState (randOnCirc 150) (w ^. randGen)
|
||||
cxy = cr ^. crPos . _xy
|
||||
mountshakeoff mid = fromMaybe True $ do
|
||||
mcr <- w ^? cWorld . lWorld . creatures . ix mid
|
||||
|
||||
Reference in New Issue
Block a user