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