Work on bee aggression
This commit is contained in:
@@ -91,7 +91,7 @@ beeCrit =
|
||||
defaultCreature
|
||||
& crName .~ "beeCrit"
|
||||
& crHP .~ HP 100
|
||||
& crType .~ BeeCrit 0 Nothing 0
|
||||
& crType .~ BeeCrit 0 Nothing 0 0
|
||||
& crFaction .~ ColorFaction yellow
|
||||
& crStance . carriage .~ Flying 15
|
||||
|
||||
|
||||
@@ -120,13 +120,15 @@ drawHive :: SPic
|
||||
drawHive = noPic $ upperPrismPolyHalfMI 25 $ polyCirc 6 20
|
||||
|
||||
drawBeeCrit :: Creature -> Shape
|
||||
drawBeeCrit cr = colorSH yellow
|
||||
drawBeeCrit cr = colorSH col
|
||||
(upperPrismPolyHalfMI 3 $ polyCirc 6 r)
|
||||
<>
|
||||
colorSH (dark yellow) (overPosSH (Q.apply (beakpos)) $ upperPrismPolyHalfST 1 $ [V2 0 (-2), V2 4 0,V2 0 2])
|
||||
colorSH (dark col) (overPosSH (Q.apply (beakpos)) $ upperPrismPolyHalfST 1 $ [V2 0 (-2), V2 4 0,V2 0 2])
|
||||
where
|
||||
r = cr ^. crType . to crRad
|
||||
beakpos = (V3 (r-1) 0 0, Q.qid)
|
||||
col | cr ^?! crType . beeAggro > 0 = red
|
||||
| otherwise = yellow
|
||||
|
||||
drawCrabCrit :: World -> Creature -> Shape
|
||||
drawCrabCrit w cr = mconcat
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user