Refactor damages to materials

This commit is contained in:
2025-06-22 08:31:18 +01:00
parent df3fde5d3e
commit 9fa3e060d7
17 changed files with 576 additions and 609 deletions
+5 -5
View File
@@ -106,7 +106,7 @@ corpseOrGib :: Creature -> World -> World
corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
Just CookingDamage -> addcorpse (thecorpse & cpSPic %~ scorchSPic)
Just PoisonDamage -> addcorpse (thecorpse & cpSPic %~ poisonSPic)
Just PhysicalDamage | _crPastDamage cr > 200 -> addCrGibs cr
Just PhysicalDamage | _crPain cr > 200 -> addCrGibs cr
_ -> addcorpse thecorpse
where
addcorpse ctype = plNew (cWorld . lWorld . corpses) cpID ctype
@@ -130,15 +130,15 @@ doDamage cr = applyPastDamages cr . applyCreatureDamage (cr ^. crDamage) cr
-- TODO generalise shake to arbitrary damage amounts
applyPastDamages :: Creature -> World -> World
applyPastDamages cr w
| _crPastDamage cr > 200 = dojitter 3 100
| _crPastDamage cr > 20 = dojitter 2 10
| _crPastDamage cr > 0 = dojitter 1 1
| _crPain cr > 200 = dojitter 3 100
| _crPain cr > 20 = dojitter 2 10
| _crPain cr > 0 = dojitter 1 1
| otherwise = w
where
dojitter x y =
let (p, g) = runState (randInCirc x) (_randGen w)
in w & cWorld . lWorld . creatures . ix (_crID cr) %~ crMvBy p
& cWorld . lWorld . creatures . ix (_crID cr) . crPastDamage -~ y
& cWorld . lWorld . creatures . ix (_crID cr) . crPain -~ y
& randGen .~ g
-- a loop going over all root inventory items