Improve bee pheremones
This commit is contained in:
@@ -4,6 +4,7 @@ module Dodge.Creature.State (
|
||||
invItemEffs,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.Radius
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Linear
|
||||
import NewInt
|
||||
@@ -43,16 +44,38 @@ import qualified SDL
|
||||
doDamage :: Int -> World -> World
|
||||
doDamage cid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
return $ applyPastDamages cr $ applyCreatureDamage (cr ^. crDamage) cr w
|
||||
return $ crPainEffect cr $ applyCreatureDamage (cr ^. crDamage) cr w
|
||||
|
||||
-- TODO generalise shake to arbitrary damage amounts
|
||||
applyPastDamages :: Creature -> World -> World
|
||||
applyPastDamages cr w
|
||||
| HoverCrit {} <- cr ^. crType
|
||||
, _crPain cr > 50 = w
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crPain -~ 50
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crPos . _z %~ max 12 . subtract 1
|
||||
| HoverCrit {} <- cr ^. crType = w
|
||||
crPainEffect :: Creature -> World -> World
|
||||
crPainEffect cr = case cr ^. crType of
|
||||
HoverCrit {} -> hoverPainEffect cr
|
||||
HiveCrit{} -> hivePainEffect cr
|
||||
_ -> jitterPain cr
|
||||
|
||||
|
||||
hoverPainEffect :: Creature -> World -> World
|
||||
hoverPainEffect cr
|
||||
| _crPain cr > 50 =
|
||||
(cWorld . lWorld . creatures . ix (_crID cr) . crPain -~ 50)
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crPos . _z %~ max 12 . subtract 1)
|
||||
| otherwise = id
|
||||
|
||||
|
||||
hivePainEffect :: Creature -> World -> World
|
||||
hivePainEffect cr w
|
||||
| _crPain cr > 0 = w & cWorld . lWorld . creatures . ix (cr ^. crID) . crPain %~ (max 0 . subtract 5)
|
||||
& cWorld . lWorld . beePheremones .:~ BPheremone (cr ^. crPos & _xy +~ p & _z .~ 20) v 200
|
||||
& randGen .~ g
|
||||
| otherwise = w
|
||||
where
|
||||
(a,g') = randomR (0,2*pi) $ w ^. randGen
|
||||
(b,g) = runState randOnUnitSphere $ g'
|
||||
p = (crRad (cr ^. crType) + 5) *^ unitVectorAtAngle a
|
||||
v = 3 *^ b
|
||||
|
||||
jitterPain :: Creature -> World -> World
|
||||
jitterPain cr w
|
||||
| _crPain cr > 200 = dojitter 3 100
|
||||
| _crPain cr > 20 = dojitter 2 10
|
||||
| _crPain cr > 0 = dojitter 1 1
|
||||
|
||||
@@ -108,7 +108,7 @@ 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
|
||||
f bp = distance (cr ^. crPos . _xy) (bp ^. bpPos . _xy) < 20
|
||||
|
||||
updateBeeCrit :: Creature -> Int -> World -> World
|
||||
updateBeeCrit cr
|
||||
@@ -371,11 +371,12 @@ 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 . _xy) 200
|
||||
beepheremone = cWorld . lWorld . beePheremones .:~ BPheremone (cr ^. crPos) (cr ^. crPos - cr ^. crOldPos) 200
|
||||
|
||||
startDeathTimer :: Creature -> Creature
|
||||
startDeathTimer cr = cr & crDeathTimer ?~ case cr ^. crType of
|
||||
HoverCrit{} -> 0
|
||||
BeeCrit{} -> 0
|
||||
_ -> 5
|
||||
|
||||
toDeathCarriage :: Carriage -> Carriage
|
||||
|
||||
Reference in New Issue
Block a user