Handle warmdown of minigun with inventory effect

This commit is contained in:
2025-01-08 16:18:44 +00:00
parent a843a1c9c0
commit 91f11e43c8
4 changed files with 21 additions and 15 deletions
+13 -15
View File
@@ -3,8 +3,6 @@ module Dodge.Creature.State (
doDamage,
) where
--import Dodge.Inventory.SelectionList
--import Dodge.Item.Location
import Control.Applicative
import Dodge.HeldUse
import Control.Monad
@@ -69,7 +67,7 @@ crUpdate f =
, internalCreatureUpdate
, f
, footstepSideEffect
, updateInv -- upInv must be called before invSideEff 22.05.23
-- , updateInv -- upInv must be called before invSideEff 22.05.23
, invRootItemEffs
, invSideEff
-- , equipmentEffects
@@ -106,26 +104,25 @@ checkDeath cr w
-- hack to get around player creature being killed but left with more than 0 hp
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
-- could look at the amount of damage here (given by maxDamage) too
corpseOrGib :: Creature -> World -> World
corpseOrGib cr = case maxDamageType (_csDamage (_crState cr)) 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)
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)
_ | _crPastDamage cr > 200 -> addCrGibs cr
_ -> plNew (cWorld . lWorld . corpses) cpID thecorpse
where
thecorpse = makeDefaultCorpse cr
scorchSPic :: SPic -> SPic
scorchSPic = over _1 $ overColSH (mixColors 0.9 0.1 black . normalizeColor)
scorchSPic = _1 %~ overColSH (mixColors 0.9 0.1 black . normalizeColor)
poisonSPic :: SPic -> SPic
poisonSPic = over _1 $ overColSH (mixColors 0.5 0.5 green . normalizeColor)
poisonSPic = _1 %~ overColSH (mixColors 0.5 0.5 green . normalizeColor)
internalCreatureUpdate :: Creature -> World -> World
internalCreatureUpdate cr =
cWorld . lWorld . creatures . ix (_crID cr)
%~ updateMovement
internalCreatureUpdate cr = cWorld . lWorld . creatures . ix (_crID cr) %~ updateMovement
{- | Drop items according to the creature state.
TODO make sure this doesn't mess up any ItemPosition
@@ -159,9 +156,10 @@ applyPastDamages cr w
| otherwise = w
-- a map updating all inventory items
updateInv :: Creature -> World -> World
updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv . each
. itUse . heldDelay . warmTime %~ (max 0 . subtract 1)
--updateInv :: Creature -> World -> World
--updateInv cr =id
--updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv . each
-- . itUse . heldDelay . warmTime %~ (max 0 . subtract 1)
-- a loop going over all inventory items
invSideEff :: Creature -> World -> World
+2
View File
@@ -30,6 +30,8 @@ data ItInvEffect
| ItemUseToggle BlBl
| ItemCancelExamineInventory
| ItemCopierUpdate
| ItemReduceWarmTime
| ItemSetWarmTime Int
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data ItDropEffect = NoDropEffect
+4
View File
@@ -25,6 +25,10 @@ doInvEffect = \case
pointerToItemID (itm ^. itID) . itUse . useToggle %~ doBlBl f
ItemCancelExamineInventory -> \_ _ -> cancelExamineInventory
ItemCopierUpdate -> copierItemUpdate
ItemReduceWarmTime -> \itm _ -> pointerToItem itm . itUse . heldDelay . warmTime
%~ (max 0 . subtract 1)
ItemSetWarmTime x -> \itm _ -> pointerToItem itm . itUse . heldDelay . warmTime
.~ x
copierItemUpdate :: Item -> Creature -> World -> World
copierItemUpdate itm cr w = fromMaybe w $ do
+2
View File
@@ -112,3 +112,5 @@ miniGunX i =
& itUse . heldParams . randomOffset .~ 10
& itUse . heldParams . rifling .~ UniRandFloat 0.8 0.9
& itType .~ HELD (MINIGUNX i)
& itEffect . ieInv .~ ItemReduceWarmTime
& itEffect . ieOnDrop .~ ItemSetWarmTime 0