Improve left use equipment interaction with general equipment
This commit is contained in:
@@ -22,7 +22,7 @@ itemEffect :: Creature -> Item -> World -> World
|
|||||||
itemEffect cr it w = case it ^? itUse of
|
itemEffect cr it w = case it ^? itUse of
|
||||||
Just RightUse {_rUse = eff,_useMods = usemods}
|
Just RightUse {_rUse = eff,_useMods = usemods}
|
||||||
-> hammerTest $ foldr ($) eff usemods it cr
|
-> hammerTest $ foldr ($) eff usemods it cr
|
||||||
Just LeftUse {} -> setuhamdown $ lhammer setEquipLeftItem
|
Just LeftUse {} -> setuhamdown $ lhammer (setEquipLeftItem)
|
||||||
Just EquipUse{} -> setuhamdown $ lhammer $ toggleEquipmentAt (_crInvSel cr) it
|
Just EquipUse{} -> setuhamdown $ lhammer $ toggleEquipmentAt (_crInvSel cr) it
|
||||||
-- ConsumeUse will cause problems if the item is not selected
|
-- ConsumeUse will cause problems if the item is not selected
|
||||||
Just (ConsumeUse eff) -> setuhamdown $ hammerTest $ eff it cr . rmInvItem (_crID cr) (_crInvSel cr)
|
Just (ConsumeUse eff) -> setuhamdown $ hammerTest $ eff it cr . rmInvItem (_crID cr) (_crInvSel cr)
|
||||||
@@ -37,7 +37,15 @@ itemEffect cr it w = case it ^? itUse of
|
|||||||
_ -> id
|
_ -> id
|
||||||
setEquipLeftItem cr' = case _crLeftInvSel cr' of
|
setEquipLeftItem cr' = case _crLeftInvSel cr' of
|
||||||
Just i | i == _crInvSel cr' -> cr' & crLeftInvSel .~ Nothing
|
Just i | i == _crInvSel cr' -> cr' & crLeftInvSel .~ Nothing
|
||||||
|
& crInvEquipped . at i .~ Nothing
|
||||||
|
-- if the following causes an exception we have reached a state that
|
||||||
|
-- should not be possible
|
||||||
|
& crEquipment . at (_crInvEquipped cr' IM.! i) .~ Nothing
|
||||||
|
-- Just i -> cr' & crLeftInvSel ?~ _crInvSel cr'
|
||||||
|
-- should left use equipment be removed if replaced by left use
|
||||||
|
-- equipment that uses a different site?
|
||||||
_ -> cr' & crLeftInvSel ?~ _crInvSel cr'
|
_ -> cr' & crLeftInvSel ?~ _crInvSel cr'
|
||||||
|
& equipUsingSiteCheck (_crInvSel cr') it
|
||||||
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||||
|
|
||||||
toggleEquipmentAt :: Int -> Item -> Creature -> Creature
|
toggleEquipmentAt :: Int -> Item -> Creature -> Creature
|
||||||
@@ -46,6 +54,12 @@ toggleEquipmentAt invid itm cr = case cr ^? crInvEquipped . ix invid of
|
|||||||
& crEquipment . at epos .~ Nothing
|
& crEquipment . at epos .~ Nothing
|
||||||
Nothing -> equipUsingSite invid itm cr
|
Nothing -> equipUsingSite invid itm cr
|
||||||
|
|
||||||
|
-- | First check if the item is already equiped, then do nothing
|
||||||
|
equipUsingSiteCheck :: Int -> Item -> Creature -> Creature
|
||||||
|
equipUsingSiteCheck invid itm cr
|
||||||
|
| isJust (cr ^? crInvEquipped . ix invid) = cr
|
||||||
|
| otherwise = equipUsingSite invid itm cr
|
||||||
|
|
||||||
equipUsingSite :: Int -> Item -> Creature -> Creature
|
equipUsingSite :: Int -> Item -> Creature -> Creature
|
||||||
equipUsingSite invid itm cr = cr
|
equipUsingSite invid itm cr = cr
|
||||||
& crInvEquipped . at invid ?~ epos
|
& crInvEquipped . at invid ?~ epos
|
||||||
@@ -55,7 +69,10 @@ equipUsingSite invid itm cr = cr
|
|||||||
epos = eqSiteToPos cr (_eqSite $ _itUse itm)
|
epos = eqSiteToPos cr (_eqSite $ _itUse itm)
|
||||||
removeOtherEquipment = case cr ^? crEquipment . ix epos of
|
removeOtherEquipment = case cr ^? crEquipment . ix epos of
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
Just oid -> crInvEquipped . at oid .~ Nothing
|
Just oid -> (crInvEquipped . at oid .~ Nothing) . removeIfLUse oid
|
||||||
|
removeIfLUse oid
|
||||||
|
| _crLeftInvSel cr == Just oid = crLeftInvSel .~ Nothing
|
||||||
|
| otherwise = id
|
||||||
|
|
||||||
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
|
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
|
||||||
eqSiteToPos cr es = case es of
|
eqSiteToPos cr es = case es of
|
||||||
@@ -80,5 +97,7 @@ useLeftItem cid w
|
|||||||
where
|
where
|
||||||
cr = _creatures w IM.! cid
|
cr = _creatures w IM.! cid
|
||||||
itmShouldBeUsed = isJust (cr ^? crInv . ix (_crInvSel cr) . itUse . cUse)
|
itmShouldBeUsed = isJust (cr ^? crInv . ix (_crInvSel cr) . itUse . cUse)
|
||||||
|| isJust (cr ^? crInv . ix (_crInvSel cr) . itUse . eqUse)
|
|| ( isJust (cr ^? crInv . ix (_crInvSel cr) . itUse . eqUse)
|
||||||
|
&& _crLeftInvSel cr /= Just (_crInvSel cr)
|
||||||
|
)
|
||||||
-- TODO determine itmShouldBeUsed with reference to config options
|
-- TODO determine itmShouldBeUsed with reference to config options
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ data ItemUse
|
|||||||
, _useDelay :: UseDelay
|
, _useDelay :: UseDelay
|
||||||
, _useHammer :: HammerType
|
, _useHammer :: HammerType
|
||||||
, _eqSite :: EquipSite
|
, _eqSite :: EquipSite
|
||||||
|
, _eqUse :: Creature -> Int -> World -> World
|
||||||
}
|
}
|
||||||
| ConsumeUse
|
| ConsumeUse
|
||||||
{ _cUse :: Item -> Creature -> World -> World
|
{ _cUse :: Item -> Creature -> World -> World
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ defaultlUse = LeftUse
|
|||||||
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
|
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
|
||||||
, _useHammer = NoHammer
|
, _useHammer = NoHammer
|
||||||
, _eqSite = GoesOnSpecial
|
, _eqSite = GoesOnSpecial
|
||||||
|
, _eqUse = \_ _ -> id
|
||||||
}
|
}
|
||||||
|
|
||||||
luseInstantNoH :: (Item -> Creature -> World -> World) -> ItemUse
|
luseInstantNoH :: (Item -> Creature -> World -> World) -> ItemUse
|
||||||
@@ -74,6 +75,7 @@ luseInstantNoH f = LeftUse
|
|||||||
, _useDelay = NoDelay
|
, _useDelay = NoDelay
|
||||||
, _useHammer = NoHammer
|
, _useHammer = NoHammer
|
||||||
, _eqSite = GoesOnSpecial
|
, _eqSite = GoesOnSpecial
|
||||||
|
, _eqUse = \_ _ -> id
|
||||||
}
|
}
|
||||||
defaultAimParams :: AimParams
|
defaultAimParams :: AimParams
|
||||||
defaultAimParams = AimParams
|
defaultAimParams = AimParams
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import Dodge.Default.Weapon
|
|||||||
--import Sound.Data
|
--import Sound.Data
|
||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
import qualified IntMapHelp as IM
|
--import qualified IntMapHelp as IM
|
||||||
import Shape
|
import Shape
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
|
||||||
@@ -27,7 +27,9 @@ rewindGun = defaultGun
|
|||||||
, _wpCharge = 0
|
, _wpCharge = 0
|
||||||
}
|
}
|
||||||
, _itEffect = ItRewindEffect rewindEffect []
|
, _itEffect = ItRewindEffect rewindEffect []
|
||||||
, _itUse = defaultlUse {_lUse = useRewindGun}
|
, _itUse = defaultlUse
|
||||||
|
& lUse .~ useRewindGun
|
||||||
|
& eqSite .~ GoesOnChest
|
||||||
}
|
}
|
||||||
rewindEffect :: Item -> Creature -> World -> World
|
rewindEffect :: Item -> Creature -> World -> World
|
||||||
rewindEffect itm cr w
|
rewindEffect itm cr w
|
||||||
@@ -38,7 +40,7 @@ rewindEffect itm cr w
|
|||||||
where
|
where
|
||||||
invid = fromJust $ _itInvPos itm
|
invid = fromJust $ _itInvPos itm
|
||||||
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
||||||
maxcharge = _wpMaxCharge . _itConsumption $ _crInv cr IM.! invid
|
maxcharge = _wpMaxCharge . _itConsumption $ itm
|
||||||
w' = w & rewindWorlds .~ []
|
w' = w & rewindWorlds .~ []
|
||||||
& timeFlow .~ NormalTimeFlow
|
& timeFlow .~ NormalTimeFlow
|
||||||
|
|
||||||
@@ -99,8 +101,9 @@ blinkGun = defaultGun
|
|||||||
, _reloadTime = 20
|
, _reloadTime = 20
|
||||||
}
|
}
|
||||||
, _itUse = defaultlUse
|
, _itUse = defaultlUse
|
||||||
{_lUse = hammerCheckL $ shootL aSelfL
|
& lUse .~ hammerCheckL (shootL aSelfL)
|
||||||
} & useHammer .~ upHammer
|
& useHammer .~ upHammer
|
||||||
|
& eqSite .~ GoesOnWrist
|
||||||
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
|
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user