Remove creature hammer, may have broken equipment/combining
This commit is contained in:
@@ -3,7 +3,7 @@ module Dodge.Creature.Impulse.UseItem (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
--import Control.Monad
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.ComposedItem
|
import Dodge.Data.ComposedItem
|
||||||
import Dodge.Data.DoubleTree
|
import Dodge.Data.DoubleTree
|
||||||
@@ -36,10 +36,10 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
|
|||||||
heldEffect (bimap _iatType fst3 usedloc) cr w
|
heldEffect (bimap _iatType fst3 usedloc) cr w
|
||||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||||
RemoteDetonatorSF -> do
|
RemoteDetonatorSF -> do
|
||||||
guard (_crHammerPosition cr == HammerUp)
|
|
||||||
return $ activateDetonator usedloc w
|
return $ activateDetonator usedloc w
|
||||||
|
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||||
_ | isJust $ itm ^? itUse . uequipEffect -> do
|
_ | isJust $ itm ^? itUse . uequipEffect -> do
|
||||||
guard (_crHammerPosition cr == HammerUp)
|
-- guard (_crHammerPosition cr == HammerUp)
|
||||||
invid' <- itm ^? itLocation . ilInvID
|
invid' <- itm ^? itLocation . ilInvID
|
||||||
return $ toggleEquipmentAt invid' cr w
|
return $ toggleEquipmentAt invid' cr w
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ poisonSPic = over _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)
|
cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
%~ ( (crHammerPosition %~ moveHammerUp)
|
%~ ( --(crHammerPosition %~ moveHammerUp).
|
||||||
. updateMovement
|
updateMovement
|
||||||
)
|
)
|
||||||
|
|
||||||
{- | Drop items according to the creature state.
|
{- | Drop items according to the creature state.
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ module Dodge.Creature.YourControl (
|
|||||||
yourControl,
|
yourControl,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import NewInt
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
@@ -20,34 +19,33 @@ import Dodge.Item.Grammar
|
|||||||
import Dodge.WASD
|
import Dodge.WASD
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
import NewInt
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
|
|
||||||
-- | The AI equivalent for your control.
|
-- | The AI equivalent for your control.
|
||||||
yourControl :: Creature -> World -> World
|
yourControl :: Creature -> World -> World
|
||||||
yourControl _ w
|
yourControl _ w
|
||||||
| inTextInputFocus w = w
|
| inTextInputFocus w = w
|
||||||
| not intopinv =
|
| Just NoSubInventory{} <- w ^? hud . hudElement . subInventory =
|
||||||
w & cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w
|
|
||||||
| otherwise =
|
|
||||||
w
|
w
|
||||||
& cWorld . lWorld . creatures . ix 0
|
& cWorld . lWorld . creatures . ix 0
|
||||||
%~ (wasdWithAiming w . mouseActionsCr (w ^. input . mouseButtons))
|
%~ (wasdWithAiming w . mouseActionsCr pkeys)
|
||||||
& pressedMBEffectsTopInventory pkeys
|
& pressedMBEffectsTopInventory pkeys
|
||||||
& handleHotkeys
|
& handleHotkeys
|
||||||
|
| otherwise =
|
||||||
|
w & cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w
|
||||||
where
|
where
|
||||||
pkeys = w ^. input . mouseButtons
|
pkeys = w ^. input . mouseButtons
|
||||||
intopinv = fromMaybe False $ do
|
|
||||||
subinv <- w ^? hud . hudElement . subInventory
|
|
||||||
Just $ case subinv of
|
|
||||||
NoSubInventory{} -> True
|
|
||||||
_ -> False
|
|
||||||
|
|
||||||
handleHotkeys :: World -> World
|
handleHotkeys :: World -> World
|
||||||
handleHotkeys w
|
handleHotkeys w
|
||||||
| SDL.ScancodeLShift `M.member` _pressedKeys (_input w)
|
| SDL.ScancodeLShift `M.member` _pressedKeys (_input w)
|
||||||
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w) =
|
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w) =
|
||||||
foldl' tryAssignHotkey w allHotkeys
|
foldl' tryAssignHotkey w allHotkeys
|
||||||
| otherwise = foldl' useHotkey w
|
| otherwise =
|
||||||
|
foldl'
|
||||||
|
useHotkey
|
||||||
|
w
|
||||||
(M.intersection thehotkeys (M.filter (== InitialPress) (w ^. input . pressedKeys)))
|
(M.intersection thehotkeys (M.filter (== InitialPress) (w ^. input . pressedKeys)))
|
||||||
where
|
where
|
||||||
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
|
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
|
||||||
@@ -177,11 +175,12 @@ pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World
|
|||||||
pressedMBEffectsTopInventory pkeys w
|
pressedMBEffectsTopInventory pkeys w
|
||||||
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||||
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
||||||
, ltime <= rtime && inTopInv
|
, ltime <= rtime && inTopInv =
|
||||||
= youhammerdown $ useSelectedItem 0 w
|
--youhammerdown $
|
||||||
|
useSelectedItem 0 w
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
where
|
where
|
||||||
youhammerdown = set (cWorld . lWorld . creatures . ix 0 . crHammerPosition) HammerDown
|
-- youhammerdown = set (cWorld . lWorld . creatures . ix 0 . crHammerPosition) HammerDown
|
||||||
inTopInv = case w ^. hud . hudElement of
|
inTopInv = case w ^. hud . hudElement of
|
||||||
DisplayInventory{_subInventory = NoSubInventory{}} -> True
|
DisplayInventory{_subInventory = NoSubInventory{}} -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ data Creature = Creature
|
|||||||
, _crGroup :: CrGroup
|
, _crGroup :: CrGroup
|
||||||
, _crIntention :: Intention
|
, _crIntention :: Intention
|
||||||
, _crMvType :: CrMvType
|
, _crMvType :: CrMvType
|
||||||
, _crHammerPosition :: HammerPosition
|
-- , _crHammerPosition :: HammerPosition
|
||||||
, _crName :: String
|
, _crName :: String
|
||||||
, _crStatistics :: CreatureStatistics
|
, _crStatistics :: CreatureStatistics
|
||||||
, _crDeathTimer :: Int
|
, _crDeathTimer :: Int
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ data ItemUse
|
|||||||
}
|
}
|
||||||
| UseEquip { _uequipEffect :: EquipEffect }
|
| UseEquip { _uequipEffect :: EquipEffect }
|
||||||
| UseAttach {_uaParams :: AttachParams}
|
| UseAttach {_uaParams :: AttachParams}
|
||||||
|
| UseHammer {_heldHammer :: HammerPosition}
|
||||||
| UseNothing
|
| UseNothing
|
||||||
| UseScope { _uScope :: Scope }
|
| UseScope { _uScope :: Scope }
|
||||||
| UseBulletMod { _ubMod :: BulletMod }
|
| UseBulletMod { _ubMod :: BulletMod }
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ defaultCreature =
|
|||||||
, _crIntention = defaultIntention
|
, _crIntention = defaultIntention
|
||||||
, _crGroup = LoneWolf
|
, _crGroup = LoneWolf
|
||||||
, _crMvType = defaultAimMvType
|
, _crMvType = defaultAimMvType
|
||||||
, _crHammerPosition = HammerUp
|
-- , _crHammerPosition = HammerUp
|
||||||
, _crName = "DEFAULTCRNAME"
|
, _crName = "DEFAULTCRNAME"
|
||||||
, _crStatistics = CreatureStatistics 50 50 50
|
, _crStatistics = CreatureStatistics 50 50 50
|
||||||
, _crDeathTimer = 0
|
, _crDeathTimer = 0
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ remoteScreen = makeAttach REMOTESCREEN
|
|||||||
|
|
||||||
remoteDetonator :: Item
|
remoteDetonator :: Item
|
||||||
remoteDetonator = makeAttach REMOTEDETONATOR
|
remoteDetonator = makeAttach REMOTEDETONATOR
|
||||||
|
& itUse .~ UseHammer HammerUp
|
||||||
& itUse . uaParams .~ APProjectiles []
|
& itUse . uaParams .~ APProjectiles []
|
||||||
|
|
||||||
joystick :: Item
|
joystick :: Item
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ tryCombine (i, j) w = fromMaybe w $ do
|
|||||||
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||||
return $
|
return $
|
||||||
snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))
|
snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))
|
||||||
& cWorld . lWorld . creatures . ix 0 . crHammerPosition .~ HammerDown
|
-- & cWorld . lWorld . creatures . ix 0 . crHammerPosition .~ HammerDown
|
||||||
& soundStart InventorySound p wrench1S Nothing
|
& soundStart InventorySound p wrench1S Nothing
|
||||||
& hud . hudElement . diSelection . _Just . _3 .~ mempty
|
& hud . hudElement . diSelection . _Just . _3 .~ mempty
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user