Handle warmdown of minigun with inventory effect
This commit is contained in:
+13
-15
@@ -3,8 +3,6 @@ module Dodge.Creature.State (
|
|||||||
doDamage,
|
doDamage,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
--import Dodge.Inventory.SelectionList
|
|
||||||
--import Dodge.Item.Location
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Dodge.HeldUse
|
import Dodge.HeldUse
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
@@ -69,7 +67,7 @@ crUpdate f =
|
|||||||
, internalCreatureUpdate
|
, internalCreatureUpdate
|
||||||
, f
|
, f
|
||||||
, footstepSideEffect
|
, footstepSideEffect
|
||||||
, updateInv -- upInv must be called before invSideEff 22.05.23
|
-- , updateInv -- upInv must be called before invSideEff 22.05.23
|
||||||
, invRootItemEffs
|
, invRootItemEffs
|
||||||
, invSideEff
|
, invSideEff
|
||||||
-- , equipmentEffects
|
-- , equipmentEffects
|
||||||
@@ -106,26 +104,25 @@ checkDeath cr w
|
|||||||
-- hack to get around player creature being killed but left with more than 0 hp
|
-- hack to get around player creature being killed but left with more than 0 hp
|
||||||
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
| 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 :: Creature -> World -> World
|
||||||
corpseOrGib cr = case maxDamageType (_csDamage (_crState cr)) of
|
corpseOrGib cr = case cr ^? crState . csDamage . to maxDamageType . _Just . _1 of
|
||||||
Just (FLAMING, _) -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
|
Just FLAMING -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
|
||||||
Just (ELECTRICAL, _) -> plNew (cWorld . lWorld . corpses) cpID thecorpse
|
Just ELECTRICAL -> plNew (cWorld . lWorld . corpses) cpID thecorpse
|
||||||
Just (POISONDAM, _) -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
|
Just POISONDAM -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
|
||||||
_ | _crPastDamage cr > 200 -> addCrGibs cr
|
_ | _crPastDamage cr > 200 -> addCrGibs cr
|
||||||
_ -> plNew (cWorld . lWorld . corpses) cpID thecorpse
|
_ -> plNew (cWorld . lWorld . corpses) cpID thecorpse
|
||||||
where
|
where
|
||||||
thecorpse = makeDefaultCorpse cr
|
thecorpse = makeDefaultCorpse cr
|
||||||
|
|
||||||
scorchSPic :: SPic -> SPic
|
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 :: 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 :: Creature -> World -> World
|
||||||
internalCreatureUpdate cr =
|
internalCreatureUpdate cr = cWorld . lWorld . creatures . ix (_crID cr) %~ updateMovement
|
||||||
cWorld . lWorld . creatures . ix (_crID cr)
|
|
||||||
%~ updateMovement
|
|
||||||
|
|
||||||
{- | Drop items according to the creature state.
|
{- | Drop items according to the creature state.
|
||||||
TODO make sure this doesn't mess up any ItemPosition
|
TODO make sure this doesn't mess up any ItemPosition
|
||||||
@@ -159,9 +156,10 @@ applyPastDamages cr w
|
|||||||
| otherwise = w
|
| otherwise = w
|
||||||
|
|
||||||
-- a map updating all inventory items
|
-- a map updating all inventory items
|
||||||
updateInv :: Creature -> World -> World
|
--updateInv :: Creature -> World -> World
|
||||||
updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv . each
|
--updateInv cr =id
|
||||||
. itUse . heldDelay . warmTime %~ (max 0 . subtract 1)
|
--updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv . each
|
||||||
|
-- . itUse . heldDelay . warmTime %~ (max 0 . subtract 1)
|
||||||
|
|
||||||
-- a loop going over all inventory items
|
-- a loop going over all inventory items
|
||||||
invSideEff :: Creature -> World -> World
|
invSideEff :: Creature -> World -> World
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ data ItInvEffect
|
|||||||
| ItemUseToggle BlBl
|
| ItemUseToggle BlBl
|
||||||
| ItemCancelExamineInventory
|
| ItemCancelExamineInventory
|
||||||
| ItemCopierUpdate
|
| ItemCopierUpdate
|
||||||
|
| ItemReduceWarmTime
|
||||||
|
| ItemSetWarmTime Int
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
data ItDropEffect = NoDropEffect
|
data ItDropEffect = NoDropEffect
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ doInvEffect = \case
|
|||||||
pointerToItemID (itm ^. itID) . itUse . useToggle %~ doBlBl f
|
pointerToItemID (itm ^. itID) . itUse . useToggle %~ doBlBl f
|
||||||
ItemCancelExamineInventory -> \_ _ -> cancelExamineInventory
|
ItemCancelExamineInventory -> \_ _ -> cancelExamineInventory
|
||||||
ItemCopierUpdate -> copierItemUpdate
|
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 :: Item -> Creature -> World -> World
|
||||||
copierItemUpdate itm cr w = fromMaybe w $ do
|
copierItemUpdate itm cr w = fromMaybe w $ do
|
||||||
|
|||||||
@@ -112,3 +112,5 @@ miniGunX i =
|
|||||||
& itUse . heldParams . randomOffset .~ 10
|
& itUse . heldParams . randomOffset .~ 10
|
||||||
& itUse . heldParams . rifling .~ UniRandFloat 0.8 0.9
|
& itUse . heldParams . rifling .~ UniRandFloat 0.8 0.9
|
||||||
& itType .~ HELD (MINIGUNX i)
|
& itType .~ HELD (MINIGUNX i)
|
||||||
|
& itEffect . ieInv .~ ItemReduceWarmTime
|
||||||
|
& itEffect . ieOnDrop .~ ItemSetWarmTime 0
|
||||||
|
|||||||
Reference in New Issue
Block a user