This commit is contained in:
2025-06-20 17:50:49 +01:00
parent b920a2ec72
commit 4a84b70801
+6 -15
View File
@@ -3,9 +3,6 @@ module Dodge.Creature.State (
doDamage,
) where
import Dodge.Item.BackgroundEffect
import Dodge.Item.Location
import Dodge.Inventory.SelectionList
import Control.Applicative
import Control.Monad
import qualified Data.Map.Strict as M
@@ -26,8 +23,11 @@ import Dodge.Data.World
import Dodge.DoubleTree
import Dodge.Euse
import Dodge.HeldUse
import Dodge.Inventory.SelectionList
import Dodge.Item.BackgroundEffect
import Dodge.Item.Grammar
import Dodge.Item.HeldOffset
import Dodge.Item.Location
import Dodge.Item.MaxAmmo
import Dodge.Prop.Gib
import Dodge.SoundLogic
@@ -66,10 +66,8 @@ crUpdate f =
, checkDeath -- must be in this order 24/7/22
, updateWalkCycle
, f
, -- , updateInv -- upInv must be called before invSideEff 22.05.23
invRootItemEffs
, invSideEff
-- , equipmentEffects
, invRootItemEffs
, updateHeldRootItem
]
-- I have changed the ordering of item/equipment effects, which may have
@@ -127,9 +125,7 @@ dropAll :: Creature -> World -> World
dropAll cr w = foldl' (flip (dropItem cr)) w $ IM.keys $ _crInv cr
doDamage :: Creature -> World -> World
doDamage cr = applyPastDamages cr . applyCreatureDamage dams cr
where
dams = cr ^. crDamage
doDamage cr = applyPastDamages cr . applyCreatureDamage (cr ^. crDamage) cr
-- TODO generalise shake to arbitrary damage amounts
applyPastDamages :: Creature -> World -> World
@@ -145,10 +141,6 @@ applyPastDamages cr w
& cWorld . lWorld . creatures . ix (_crID cr) . crPastDamage -~ y
& randGen .~ g
-- a loop going over all inventory items
invSideEff :: Creature -> World -> World
invSideEff cr = updateHeldRootItem cr
-- a loop going over all root inventory items
invRootItemEffs :: Creature -> World -> World
invRootItemEffs cr =
@@ -183,7 +175,6 @@ copierItemUpdate itm cr w = fromMaybe w $ do
v <- getItemValue itm' w cr
return $ w & pointerToItem itm . itUse . uValue .~ v
doAnyEquipmentEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
Just _ -> equipBackgroundEffect loc cr