Fix blinking bug, shrinker and shield broken
This commit is contained in:
@@ -2,8 +2,7 @@ module Dodge.Creature.Impulse.UseItem
|
|||||||
( useItem
|
( useItem
|
||||||
, tryUseItem
|
, tryUseItem
|
||||||
, useLeftItem
|
, useLeftItem
|
||||||
)
|
) where
|
||||||
where
|
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
|
|
||||||
@@ -12,28 +11,21 @@ import Control.Lens
|
|||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
useItem :: Int -> World -> World
|
useItem :: Int -> World -> World
|
||||||
useItem n w = itemEffect c it w
|
useItem cid w = itemEffect cr it w
|
||||||
where
|
where
|
||||||
c = _creatures w IM.! n
|
cr = _creatures w IM.! cid
|
||||||
it = _crInv c IM.! _crInvSel c
|
it = _crInv cr IM.! _crInvSel cr
|
||||||
|
|
||||||
tryUseItem
|
tryUseItem :: Creature -> World -> World
|
||||||
:: Creature
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
tryUseItem cr' w = case w ^? creatures . ix (_crID cr') of
|
tryUseItem cr' w = case w ^? creatures . ix (_crID cr') of
|
||||||
Just cr -> itemEffect cr (_crInv cr IM.! _crInvSel cr) w
|
Just cr -> itemEffect cr (_crInv cr IM.! _crInvSel cr) w
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
|
|
||||||
itemEffect
|
itemEffect :: Creature -> Item -> World -> World
|
||||||
:: Creature
|
|
||||||
-> Item
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w)
|
itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w)
|
||||||
itemEffect cr it w = case it ^? itUse of
|
itemEffect cr it w = case it ^? itUse of
|
||||||
Just (RightUse {_rUse = eff,_useMods = usemods}) -> foldr ($) eff usemods it cr w
|
Just RightUse {_rUse = eff,_useMods = usemods} -> foldr ($) eff usemods it cr w
|
||||||
Just (LeftUse {}) -> w & creatures . ix (_crID cr) . crLeftInvSel ?~ _crInvSel cr
|
Just LeftUse {} -> w & creatures . ix (_crID cr) . crLeftInvSel ?~ _crInvSel cr
|
||||||
_ -> w
|
_ -> w
|
||||||
|
|
||||||
--this is ugly
|
--this is ugly
|
||||||
|
|||||||
@@ -121,13 +121,14 @@ heldItemUpdate :: Item -> Item
|
|||||||
heldItemUpdate = invItemUpdate
|
heldItemUpdate = invItemUpdate
|
||||||
. (itUse %~ useupdate)
|
. (itUse %~ useupdate)
|
||||||
where
|
where
|
||||||
useupdate = (useDelay . rateTime %~ decreaseToZero)
|
useupdate = id
|
||||||
|
|
||||||
invItemUpdate :: Item -> Item
|
invItemUpdate :: Item -> Item
|
||||||
invItemUpdate = itUse %~ useupdate
|
invItemUpdate = itUse %~ useupdate
|
||||||
where
|
where
|
||||||
useupdate = (useHammer . hammerPosition %~ moveHammerUp)
|
useupdate = (useHammer . hammerPosition %~ moveHammerUp)
|
||||||
. (useDelay . warmTime %~ decreaseToZero)
|
. (useDelay . warmTime %~ decreaseToZero)
|
||||||
|
. (useDelay . rateTime %~ decreaseToZero)
|
||||||
moveHammerUp HammerDown = HammerReleased
|
moveHammerUp HammerDown = HammerReleased
|
||||||
moveHammerUp HammerReleased = HammerUp
|
moveHammerUp HammerReleased = HammerUp
|
||||||
moveHammerUp HammerUp = HammerUp
|
moveHammerUp HammerUp = HammerUp
|
||||||
|
|||||||
+3
-4
@@ -107,7 +107,6 @@ data World = World
|
|||||||
, _selLocation :: Int
|
, _selLocation :: Int
|
||||||
, _sideEffects :: World -> IO World
|
, _sideEffects :: World -> IO World
|
||||||
, _inventoryMode :: InventoryMode
|
, _inventoryMode :: InventoryMode
|
||||||
, _lClickHammer :: HammerPosition
|
|
||||||
, _distortions :: [Distortion]
|
, _distortions :: [Distortion]
|
||||||
, _worldBounds :: Bounds
|
, _worldBounds :: Bounds
|
||||||
, _gameRooms :: [GameRoom] -- consider using and IntMap
|
, _gameRooms :: [GameRoom] -- consider using and IntMap
|
||||||
@@ -342,9 +341,9 @@ data ItemAmmo
|
|||||||
}
|
}
|
||||||
data Item
|
data Item
|
||||||
= Weapon
|
= Weapon
|
||||||
{ _itName :: String
|
{ _itName :: String
|
||||||
, _wpAmmo :: ItemAmmo
|
, _wpAmmo :: ItemAmmo
|
||||||
, _itUse :: ItemUse
|
, _itUse :: ItemUse
|
||||||
, _wpSpread :: Float
|
, _wpSpread :: Float
|
||||||
, _wpRange :: Float
|
, _wpRange :: Float
|
||||||
, _itFloorPict :: Item -> SPic
|
, _itFloorPict :: Item -> SPic
|
||||||
|
|||||||
@@ -8,5 +8,8 @@ import Control.Lens
|
|||||||
applyTerminalString :: String -> World -> World
|
applyTerminalString :: String -> World -> World
|
||||||
applyTerminalString "NOCLIP" w = w & config . debug_noclip %~ not
|
applyTerminalString "NOCLIP" w = w & config . debug_noclip %~ not
|
||||||
applyTerminalString "LOADME" w = w & creatures . ix 0 . crInv .~ stackedInventory
|
applyTerminalString "LOADME" w = w & creatures . ix 0 . crInv .~ stackedInventory
|
||||||
|
applyTerminalString "LM" w = w & creatures . ix 0 . crInv .~ stackedInventory
|
||||||
applyTerminalString _ w = w
|
applyTerminalString _ w = w
|
||||||
|
|
||||||
|
loadme :: a
|
||||||
|
loadme = undefined
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ defaultWorld = World
|
|||||||
, _config = defaultConfig
|
, _config = defaultConfig
|
||||||
, _sideEffects = return
|
, _sideEffects = return
|
||||||
, _inventoryMode = TopInventory
|
, _inventoryMode = TopInventory
|
||||||
, _lClickHammer = HammerUp
|
|
||||||
, _foregroundShape = mempty
|
, _foregroundShape = mempty
|
||||||
, _distortions = []
|
, _distortions = []
|
||||||
, _gameRooms = []
|
, _gameRooms = []
|
||||||
|
|||||||
@@ -258,16 +258,14 @@ ammoUseCheck f item cr w
|
|||||||
Arbitrary inventory position. -}
|
Arbitrary inventory position. -}
|
||||||
hammerCheckL
|
hammerCheckL
|
||||||
:: (Creature -> Int -> World -> World) -- ^ Underlying effect
|
:: (Creature -> Int -> World -> World) -- ^ Underlying effect
|
||||||
-> Creature
|
-> Creature -> Int -> World -> World
|
||||||
-> Int
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
hammerCheckL f cr invid w = case (_crInv cr IM.! invid) ^? itUse . useHammer . hammerPosition of
|
hammerCheckL f cr invid w = case (_crInv cr IM.! invid) ^? itUse . useHammer . hammerPosition of
|
||||||
Just HammerUp -> f cr invid $ setHammerDown w
|
Just HammerUp -> f cr invid $ setHammerDown w
|
||||||
_ -> setHammerDown w
|
_ -> setHammerDown w
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
setHammerDown = creatures . ix cid . crInv . ix invid . itUse . useHammer . hammerPosition .~ HammerDown
|
setHammerDown = creatures . ix cid . crInv . ix invid
|
||||||
|
. itUse . useHammer . hammerPosition .~ HammerDown
|
||||||
{- | Applies a world effect after an ammo check.
|
{- | Applies a world effect after an ammo check.
|
||||||
Arbitrary inventory position. -}
|
Arbitrary inventory position. -}
|
||||||
shootL
|
shootL
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ useRewindGun _ _ w = case _rewindWorlds w of
|
|||||||
-- & creatures . ix (_crID cr) .~ cr
|
-- & creatures . ix (_crID cr) .~ cr
|
||||||
& upbuts
|
& upbuts
|
||||||
& rewindWorlds .~ ws
|
& rewindWorlds .~ ws
|
||||||
& lClickHammer .~ HammerUp
|
|
||||||
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
|
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
|
||||||
|
|
||||||
|
-- needs to shift this item to the current inventory slot
|
||||||
shrinkGun :: Item
|
shrinkGun :: Item
|
||||||
shrinkGun = defaultGun
|
shrinkGun = defaultGun
|
||||||
{ _itName = "SHRINKER"
|
{ _itName = "SHRINKER"
|
||||||
@@ -60,7 +60,8 @@ shrinkGun = defaultGun
|
|||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 20
|
, _wpReloadTime = 20
|
||||||
}
|
}
|
||||||
, _itUse = defaultlUse {_lUse = \cr invid -> useShrinkGun (_crInv cr IM.! invid) cr}
|
, _itUse = defaultlUse {_lUse = hammerCheckL $ \cr invid -> useShrinkGun (_crInv cr IM.! invid) cr}
|
||||||
|
& useHammer .~ upHammer
|
||||||
, _wpSpread = 0.05
|
, _wpSpread = 0.05
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = shrinkGunPic
|
, _itFloorPict = shrinkGunPic
|
||||||
@@ -90,10 +91,12 @@ blinkGun = defaultGun
|
|||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 20
|
, _wpReloadTime = 20
|
||||||
}
|
}
|
||||||
, _itUse = defaultlUse {_lUse = hammerCheckL $ shootL aSelfL}
|
, _itUse = defaultlUse
|
||||||
|
{_lUse = hammerCheckL $ shootL aSelfL
|
||||||
|
} & useHammer .~ upHammer
|
||||||
, _wpSpread = 0.05
|
, _wpSpread = 0.05
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2[(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
|
, _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ renderItemMapAt :: Float -> Float -> World -> IM.IntMap Item -> Picture
|
|||||||
renderItemMapAt tx ty w = concatMapPic (uncurry $ listItemAt tx ty w) . IM.toList
|
renderItemMapAt tx ty w = concatMapPic (uncurry $ listItemAt tx ty w) . IM.toList
|
||||||
|
|
||||||
displayInv :: Int -> World -> Picture
|
displayInv :: Int -> World -> Picture
|
||||||
displayInv n w = (renderItemMapAt 0 0 w $ _crInv cr)
|
displayInv n w = renderItemMapAt 0 0 w (_crInv cr)
|
||||||
<> equipcursor
|
<> equipcursor
|
||||||
where
|
where
|
||||||
equipcursor = case _crLeftInvSel cr of
|
equipcursor = case _crLeftInvSel cr of
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ room2 :: RandomGen g => Int -> State g (SubCompTree Room)
|
|||||||
room2 = lasCenSensEdge
|
room2 = lasCenSensEdge
|
||||||
|
|
||||||
startRoom :: RandomGen g => Int -> State g (SubCompTree Room)
|
startRoom :: RandomGen g => Int -> State g (SubCompTree Room)
|
||||||
startRoom i = join $ uncurry takeOneWeighted $ unzip
|
startRoom _ = join $ uncurry takeOneWeighted $ unzip
|
||||||
[ (,) (0.5::Float) $ chainUses <$> sequence [minigunFakeout,weaponRoom]
|
[ (,) (0.5::Float) $ chainUses <$> sequence [minigunFakeout,weaponRoom]
|
||||||
, (,) 1 rezBoxesWp
|
-- , (,) 1 rezBoxesWp
|
||||||
, (,) 1 rezBoxesThenWeaponRoom
|
-- , (,) 1 rezBoxesThenWeaponRoom
|
||||||
, (,) 1 rezBoxThenWeaponRoom
|
-- , (,) 1 rezBoxThenWeaponRoom
|
||||||
, (,) 1 rezBoxesWpCrit
|
-- , (,) 1 rezBoxesWpCrit
|
||||||
, (,) 1 $ runPastStart i
|
-- , (,) 1 $ runPastStart i
|
||||||
]
|
]
|
||||||
|
|
||||||
runPastStart :: RandomGen g => Int -> State g (SubCompTree Room)
|
runPastStart :: RandomGen g => Int -> State g (SubCompTree Room)
|
||||||
|
|||||||
@@ -19,18 +19,17 @@ updateUsingInput w = if _carteDisplay w
|
|||||||
updatePressedButtons :: S.Set MouseButton -> World -> World
|
updatePressedButtons :: S.Set MouseButton -> World -> World
|
||||||
updatePressedButtons pkeys w
|
updatePressedButtons pkeys w
|
||||||
| lbPressed && rbPressed
|
| lbPressed && rbPressed
|
||||||
= useItem (_yourID w) w & lClickHammer .~ HammerDown
|
= useItem (_yourID w) w
|
||||||
| lbPressed && canLeftClick = useLeftItem (_yourID w) w
|
| lbPressed = useLeftItem (_yourID w) w
|
||||||
| lbPressed = w
|
| lbPressed = w
|
||||||
| mbPressed = w & clickMousePos .~ _mousePos w
|
| mbPressed = w & clickMousePos .~ _mousePos w
|
||||||
& cameraRot -~ rotation
|
& cameraRot -~ rotation
|
||||||
| otherwise = w & lClickHammer .~ HammerUp
|
| otherwise = w
|
||||||
where
|
where
|
||||||
lbPressed = ButtonLeft `S.member` pkeys
|
lbPressed = ButtonLeft `S.member` pkeys
|
||||||
rbPressed = ButtonRight `S.member` pkeys
|
rbPressed = ButtonRight `S.member` pkeys
|
||||||
mbPressed = ButtonMiddle `S.member` pkeys
|
mbPressed = ButtonMiddle `S.member` pkeys
|
||||||
rotation = angleBetween (_mousePos w) (_clickMousePos w)
|
rotation = angleBetween (_mousePos w) (_clickMousePos w)
|
||||||
canLeftClick = _lClickHammer w == HammerUp
|
|
||||||
|
|
||||||
updatePressedButtonsCarte :: S.Set MouseButton -> World -> World
|
updatePressedButtonsCarte :: S.Set MouseButton -> World -> World
|
||||||
updatePressedButtonsCarte pkeys w
|
updatePressedButtonsCarte pkeys w
|
||||||
|
|||||||
Reference in New Issue
Block a user