Allow triggering items using an ECG
This commit is contained in:
@@ -3,6 +3,7 @@ module Dodge.Creature.State (
|
||||
doDamage,
|
||||
) where
|
||||
|
||||
import Dodge.HeldUse
|
||||
import Control.Monad
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
@@ -176,7 +177,24 @@ invRootItemEffs cr =
|
||||
|
||||
invItemLocUpdate :: LocationLDT ItemLink ComposedItem -> World -> World
|
||||
invItemLocUpdate loc w = case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> fromMaybe w $ do
|
||||
ATTACH BULLETSYNTH -> trySynthBullet loc w
|
||||
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
|
||||
_ -> w
|
||||
where
|
||||
haspulse =
|
||||
w ^? cWorld . lWorld . creatures . ix 0 . crType . avatarPulse . pulseProgress
|
||||
== Just 0
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
|
||||
tryUseParent :: LocationLDT ItemLink ComposedItem -> World -> World
|
||||
tryUseParent loc w = fromMaybe w $ do
|
||||
t <- locUp loc
|
||||
let t' = bimap (_iatType) (^. _1) $ t ^. locLDT
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
return $ heldEffectNoHammerCheck t' cr w
|
||||
|
||||
trySynthBullet :: LocationLDT ItemLink ComposedItem -> World -> World
|
||||
trySynthBullet loc w = fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
x <- itm ^? itUse . uaParams . apInt
|
||||
if x < 100
|
||||
@@ -227,9 +245,9 @@ invItemLocUpdate loc w = case itm ^. itType of
|
||||
. amagLoadStatus
|
||||
. iaLoaded
|
||||
+~ 1
|
||||
_ -> w
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
|
||||
|
||||
updateHeldRootItem :: Creature -> World -> World
|
||||
updateHeldRootItem cr = fromMaybe id $ do
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
module Dodge.HeldUse (
|
||||
heldEffect,
|
||||
heldEffectNoHammerCheck,
|
||||
mcUseHeld,
|
||||
) where
|
||||
|
||||
@@ -32,7 +33,10 @@ import RandomHelp
|
||||
import qualified SDL
|
||||
|
||||
heldEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
heldEffect = hammerCheck $ useTimeCheck heldEffectMuzzles
|
||||
heldEffect = hammerCheck $ heldEffectNoHammerCheck
|
||||
|
||||
heldEffectNoHammerCheck :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
heldEffectNoHammerCheck = useTimeCheck heldEffectMuzzles
|
||||
|
||||
hammerCheck :: ChainEffect
|
||||
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
|
||||
|
||||
Reference in New Issue
Block a user