Refactor damages

This commit is contained in:
2025-06-07 14:26:00 +01:00
parent 7a192e7631
commit 81a7dcd962
24 changed files with 271 additions and 277 deletions
+3 -3
View File
@@ -21,7 +21,7 @@ defaultApplyDamage ds cr w =
& cWorld . lWorld . creatures . ix (_crID cr) %~ doPoisonDam
where
(ps, ds') = partition isPoison ds
isPoison Damage{_dmType = POISONDAM} = True
isPoison Poison{} = True
isPoison _ = False
poisonDam = quot (max 0 (sum (map _dmAmount ps))) 10
doPoisonDam = crHP -~ poisonDam
@@ -49,7 +49,7 @@ applyIndividualDamage :: Creature -> World -> Damage -> World
applyIndividualDamage cr w dm = applyIndividualDamage' cr w dm
applyIndividualDamage' :: Creature -> World -> Damage -> World
applyIndividualDamage' cr w dm = case _dmType dm of
applyIndividualDamage' cr w dm = case dm of
Piercing{} -> applyPiercingDamage cr dm w
_ -> w & damageHP cr (_dmAmount dm)
@@ -61,7 +61,7 @@ applyPiercingDamage cr dm
f = cWorld . lWorld . creatures . ix (_crID cr) . crPos -~ _dmVector dm
/ V2 x x
x = crMass (_crType cr)
p = _dmAt dm
p = _dmPos dm
p1 = p +.+ 2 *.* squashNormalizeV (p -.- _crPos cr)
damageHP :: Creature -> Int -> World -> World
+1 -1
View File
@@ -87,6 +87,6 @@ followImpulse cr w imp = case imp of
rr a = randomR (- a, a) $ _randGen w
hitCr i =
( cWorld . lWorld . creatures . ix i . crState . csDamage
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i)-- (PushBackDamage 5)
.:~ Blunt 100 (posFromID i) (posFromID i-cpos)-- (PushBackDamage 5)
)
. soundStart (CrSound cid) cpos hitS Nothing
+3 -3
View File
@@ -108,9 +108,9 @@ checkDeath cr w
-- could look at the amount of damage here (given by maxDamage) too
corpseOrGib :: Creature -> World -> World
corpseOrGib cr = case cr ^? crState . csDamage . to maxDamageType . _Just . _1 of
Just FLAMING -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
Just ELECTRICAL -> plNew (cWorld . lWorld . corpses) cpID thecorpse
Just POISONDAM -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
Just Flaming{} -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
Just Electrical{} -> plNew (cWorld . lWorld . corpses) cpID thecorpse
Just Poison{} -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
_ | _crPastDamage cr > 200 -> addCrGibs cr
_ -> plNew (cWorld . lWorld . corpses) cpID thecorpse
where