Add slime sounds
This commit is contained in:
@@ -73,11 +73,12 @@ slimeCritUpdate cid w
|
||||
| r < 5 = w & cWorld . lWorld . creatures . ix cid . crHP .~ CrDestroyed Gibbed
|
||||
| Just hitp <- w ^? cWorld . lWorld . creatures . ix cid . crDamage . ix 0 . dmPos
|
||||
, Just hitv <- w ^? cWorld . lWorld . creatures . ix cid . crDamage . ix 0 . dmVector
|
||||
, Just (cr1,cr2) <- splitSlimeCrit hitp hitv cr
|
||||
=
|
||||
let cid' = IM.newKey $ w ^. cWorld . lWorld . creatures
|
||||
in w & cWorld . lWorld . creatures . ix cid .~ cr1
|
||||
& cWorld . lWorld . creatures . at cid' ?~ (cr2 & crID .~ cid')
|
||||
-- , Just (cr1,cr2) <- splitSlimeCrit hitp hitv cr
|
||||
-- =
|
||||
-- let cid' = IM.newKey $ w ^. cWorld . lWorld . creatures
|
||||
-- in w & cWorld . lWorld . creatures . ix cid .~ cr1
|
||||
-- & cWorld . lWorld . creatures . at cid' ?~ (cr2 & crID .~ cid')
|
||||
, Just w' <- splitSlimeCrit' hitp hitv cid cr w = w'
|
||||
| (cr ^?! crType . slimeIsCompressing) && r > norm p
|
||||
= let (w',g) = runState (setSlimeDir cid (cr & crDamage .~ []) w) (w ^. randGen)
|
||||
in w' & randGen .~ g
|
||||
@@ -108,15 +109,16 @@ setSlimeDir cid cr w = do
|
||||
if i < (r - 11) / 50
|
||||
then do
|
||||
x <- randInCirc 1
|
||||
let (cr1,cr2) = splitSlimeCrit (x + cxy) (unitVectorAtAngle d) cr ^?! _Just
|
||||
cid' = IM.newKey $ w ^. cWorld . lWorld . creatures
|
||||
return $ w & tocr .~ cr1
|
||||
& tocr' cid' ?~ (cr2 & crID .~ cid')
|
||||
return $ fromMaybe w $ splitSlimeCrit' (x + cxy) (unitVectorAtAngle d) cid cr w
|
||||
-- let (cr1,cr2) = splitSlimeCrit (x + cxy) (unitVectorAtAngle d) cr ^?! _Just
|
||||
-- cid' = IM.newKey $ w ^. cWorld . lWorld . creatures
|
||||
-- return $ w & tocr .~ cr1
|
||||
-- & tocr' cid' ?~ (cr2 & crID .~ cid')
|
||||
else return $ w & tocr . crType . slimeCompression .~ r *^ unitVectorAtAngle d
|
||||
& tocr . crType . slimeIsCompressing .~ False
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
tocr' i = cWorld . lWorld . creatures . at i
|
||||
-- tocr' i = cWorld . lWorld . creatures . at i
|
||||
cxy = cr ^. crPos . _xy
|
||||
r = cr ^?! crType . slimeRad
|
||||
|
||||
@@ -128,6 +130,16 @@ doSlimeRadChange = crType . slimeRadWobble %~ f
|
||||
| x < -1 = x + 1
|
||||
| otherwise = 0
|
||||
|
||||
splitSlimeCrit' :: Point2 -> Point2 -> Int -> Creature -> World -> Maybe World
|
||||
splitSlimeCrit' p v cid cr w = do
|
||||
(cr1,cr2) <- splitSlimeCrit p v cr
|
||||
let cid' = IM.newKey $ w ^. cWorld . lWorld . creatures
|
||||
(s,g) = runState (takeOne [popS,pop1S,pop2S]) (w ^. randGen)
|
||||
return $ w & cWorld . lWorld . creatures . ix cid .~ cr1
|
||||
& cWorld . lWorld . creatures . at cid' ?~ (cr2 & crID .~ cid')
|
||||
& soundStart (CrSound cid) (cr ^. crPos . _xy) s Nothing
|
||||
& randGen .~ g
|
||||
|
||||
splitSlimeCrit :: Point2 -> Point2 -> Creature -> Maybe (Creature, Creature)
|
||||
splitSlimeCrit p v cr = do
|
||||
let mp = closestPointOnLine p (p+v) cxy
|
||||
|
||||
Reference in New Issue
Block a user