Add randomness to chase crit corpses
This commit is contained in:
@@ -11,11 +11,12 @@ import Dodge.Data.Creature
|
|||||||
import Geometry
|
import Geometry
|
||||||
import Shape
|
import Shape
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
import RandomHelp
|
||||||
|
|
||||||
makeCorpse :: Creature -> SPic
|
makeCorpse :: StdGen -> Creature -> SPic
|
||||||
makeCorpse cr = case cr ^. crType of
|
makeCorpse g cr = case cr ^. crType of
|
||||||
HoverCrit{} -> noPic $ drawHoverCrit cr
|
HoverCrit{} -> noPic $ drawHoverCrit cr
|
||||||
ChaseCrit{} -> noPic $ chaseCorpse cr
|
ChaseCrit{} -> noPic $ chaseCorpse g cr
|
||||||
_ ->
|
_ ->
|
||||||
noPic
|
noPic
|
||||||
. scaleSH (V3 crsize crsize crsize)
|
. scaleSH (V3 crsize crsize crsize)
|
||||||
@@ -29,8 +30,8 @@ makeCorpse cr = case cr ^. crType of
|
|||||||
crsize = 0.1 * crRad (cr ^. crType)
|
crsize = 0.1 * crRad (cr ^. crType)
|
||||||
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
||||||
|
|
||||||
chaseCorpse :: Creature -> Shape
|
chaseCorpse :: StdGen -> Creature -> Shape
|
||||||
chaseCorpse cr = mconcat
|
chaseCorpse g cr = mconcat
|
||||||
[colorSH (_skinUpper cskin) . upperPrismPolyHalfMI 0 $ polyCirc 3 12
|
[colorSH (_skinUpper cskin) . upperPrismPolyHalfMI 0 $ polyCirc 3 12
|
||||||
& each %~ vNormal
|
& each %~ vNormal
|
||||||
& each . _y *~ 0.6
|
& each . _y *~ 0.6
|
||||||
@@ -41,7 +42,9 @@ chaseCorpse cr = mconcat
|
|||||||
, rotmdir $ colorSH (_skinLower cskin) $ deadFeet cr
|
, rotmdir $ colorSH (_skinLower cskin) $ deadFeet cr
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
neckq = (V3 6 0 0, Q.qid)
|
neckq = (V3 6 0 0, Q.qz a)
|
||||||
|
a = fst $ randomR (-2,2) $ g
|
||||||
|
b = fst $ randomR (-2,2) $ g
|
||||||
cskin = crShape $ _crType cr -- this should be fixed
|
cskin = crShape $ _crType cr -- this should be fixed
|
||||||
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
||||||
headq = neckq `Q.comp` (V3 16 0 0, Q.qid )
|
headq = neckq `Q.comp` (V3 16 0 0, Q.qz b )
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ drawChaseCrit w cr = mconcat
|
|||||||
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
||||||
|
|
||||||
crabUpperBody :: World -> Creature -> Shape
|
crabUpperBody :: World -> Creature -> Shape
|
||||||
crabUpperBody w cr = colorSH (_skinUpper cskin)
|
crabUpperBody _ cr = colorSH (_skinUpper cskin)
|
||||||
$
|
$
|
||||||
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI 5 $ polyCirc 4 12
|
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI 5 $ polyCirc 4 12
|
||||||
& each . _x *~ 0.6)
|
& each . _x *~ 0.6)
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ toDeathCarriage = \case
|
|||||||
|
|
||||||
-- could look at the amount of damage here (given by maxDamage) too
|
-- could look at the amount of damage here (given by maxDamage) too
|
||||||
corpseOrGib :: Creature -> World -> World
|
corpseOrGib :: Creature -> World -> World
|
||||||
corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
|
corpseOrGib cr w = w & case cr ^? crDamage . to maxDamageType . _Just . _1 of
|
||||||
Just CookingDamage ->
|
Just CookingDamage ->
|
||||||
sethp (CrIsCorpse $ scorchSPic thecorpse)
|
sethp (CrIsCorpse $ scorchSPic thecorpse)
|
||||||
. dodeathsound CookDeath
|
. dodeathsound CookDeath
|
||||||
@@ -150,16 +150,16 @@ corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
|
|||||||
. dodeathsound PlainDeath
|
. dodeathsound PlainDeath
|
||||||
where
|
where
|
||||||
dodeathsound dt = f dt . stopSoundFrom (CrMouth cid)
|
dodeathsound dt = f dt . stopSoundFrom (CrMouth cid)
|
||||||
f dt w = fromMaybe w $ do
|
f dt w' = fromMaybe w' $ do
|
||||||
let (msid, g) = runState (maybeTakeOne (crDeathSounds cr dt)) (_randGen w)
|
let (msid, g) = runState (maybeTakeOne (crDeathSounds cr dt)) (_randGen w')
|
||||||
sid <- msid
|
sid <- msid
|
||||||
return $
|
return $
|
||||||
w
|
w'
|
||||||
& soundStart (CrMouth cid) (cr ^. crPos . _xy) sid Nothing
|
& soundStart (CrMouth cid) (cr ^. crPos . _xy) sid Nothing
|
||||||
& randGen .~ g
|
& randGen .~ g
|
||||||
cid = cr ^. crID
|
cid = cr ^. crID
|
||||||
sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x
|
sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x
|
||||||
thecorpse = makeCorpse cr
|
thecorpse = makeCorpse (w ^. randGen) cr
|
||||||
|
|
||||||
scorchSPic :: SPic -> SPic
|
scorchSPic :: SPic -> SPic
|
||||||
scorchSPic = _1 %~ overColSH (mixColors 0.9 0.1 black . normalizeColor)
|
scorchSPic = _1 %~ overColSH (mixColors 0.9 0.1 black . normalizeColor)
|
||||||
|
|||||||
Reference in New Issue
Block a user