diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 97682f9b9..696aa94cd 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -3,7 +3,7 @@ module Dodge.Creature.Impulse.UseItem ( ) where import Control.Lens -import Control.Monad +--import Control.Monad import Data.Maybe import Dodge.Data.ComposedItem import Dodge.Data.DoubleTree @@ -36,10 +36,10 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb heldEffect (bimap _iatType fst3 usedloc) cr w & pointerToItem itm . itUse . heldHammer .~ HammerDown RemoteDetonatorSF -> do - guard (_crHammerPosition cr == HammerUp) return $ activateDetonator usedloc w + & pointerToItem itm . itUse . heldHammer .~ HammerDown _ | isJust $ itm ^? itUse . uequipEffect -> do - guard (_crHammerPosition cr == HammerUp) +-- guard (_crHammerPosition cr == HammerUp) invid' <- itm ^? itLocation . ilInvID return $ toggleEquipmentAt invid' cr w _ -> Nothing diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 104e14c00..40ed49b6a 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -123,8 +123,8 @@ poisonSPic = over _1 $ overColSH (mixColors 0.5 0.5 green . normalizeColor) internalCreatureUpdate :: Creature -> World -> World internalCreatureUpdate cr = cWorld . lWorld . creatures . ix (_crID cr) - %~ ( (crHammerPosition %~ moveHammerUp) - . updateMovement + %~ ( --(crHammerPosition %~ moveHammerUp). + updateMovement ) {- | Drop items according to the creature state. diff --git a/src/Dodge/Creature/YourControl.hs b/src/Dodge/Creature/YourControl.hs index 67b307d88..5adee9073 100644 --- a/src/Dodge/Creature/YourControl.hs +++ b/src/Dodge/Creature/YourControl.hs @@ -2,7 +2,6 @@ module Dodge.Creature.YourControl ( yourControl, ) where -import NewInt import Control.Monad import Data.Foldable import qualified Data.Map.Strict as M @@ -20,35 +19,34 @@ import Dodge.Item.Grammar import Dodge.WASD import Geometry import LensHelp +import NewInt import qualified SDL -- | The AI equivalent for your control. yourControl :: Creature -> World -> World yourControl _ w | inTextInputFocus w = w - | not intopinv = - w & cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w - | otherwise = + | Just NoSubInventory{} <- w ^? hud . hudElement . subInventory = w & cWorld . lWorld . creatures . ix 0 - %~ (wasdWithAiming w . mouseActionsCr (w ^. input . mouseButtons)) + %~ (wasdWithAiming w . mouseActionsCr pkeys) & pressedMBEffectsTopInventory pkeys & handleHotkeys + | otherwise = + w & cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w where pkeys = w ^. input . mouseButtons - intopinv = fromMaybe False $ do - subinv <- w ^? hud . hudElement . subInventory - Just $ case subinv of - NoSubInventory{} -> True - _ -> False handleHotkeys :: World -> World handleHotkeys w | SDL.ScancodeLShift `M.member` _pressedKeys (_input w) || SDL.ScancodeRShift `M.member` _pressedKeys (_input w) = foldl' tryAssignHotkey w allHotkeys - | otherwise = foldl' useHotkey w - (M.intersection thehotkeys (M.filter (== InitialPress) (w ^. input . pressedKeys))) + | otherwise = + foldl' + useHotkey + w + (M.intersection thehotkeys (M.filter (== InitialPress) (w ^. input . pressedKeys))) where thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys @@ -176,12 +174,13 @@ mouseActionsCr pkeys pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World pressedMBEffectsTopInventory pkeys w | Just ltime <- pkeys ^? ix SDL.ButtonLeft - , Just rtime <- pkeys ^? ix SDL.ButtonRight - , ltime <= rtime && inTopInv - = youhammerdown $ useSelectedItem 0 w + , Just rtime <- pkeys ^? ix SDL.ButtonRight + , ltime <= rtime && inTopInv = + --youhammerdown $ + useSelectedItem 0 w | otherwise = w 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 DisplayInventory{_subInventory = NoSubInventory{}} -> True _ -> False diff --git a/src/Dodge/Data/Creature.hs b/src/Dodge/Data/Creature.hs index 7fa798d21..e9721296b 100644 --- a/src/Dodge/Data/Creature.hs +++ b/src/Dodge/Data/Creature.hs @@ -66,7 +66,7 @@ data Creature = Creature , _crGroup :: CrGroup , _crIntention :: Intention , _crMvType :: CrMvType - , _crHammerPosition :: HammerPosition +-- , _crHammerPosition :: HammerPosition , _crName :: String , _crStatistics :: CreatureStatistics , _crDeathTimer :: Int diff --git a/src/Dodge/Data/Item/Use.hs b/src/Dodge/Data/Item/Use.hs index c8dd496f4..140c00c81 100644 --- a/src/Dodge/Data/Item/Use.hs +++ b/src/Dodge/Data/Item/Use.hs @@ -43,6 +43,7 @@ data ItemUse } | UseEquip { _uequipEffect :: EquipEffect } | UseAttach {_uaParams :: AttachParams} + | UseHammer {_heldHammer :: HammerPosition} | UseNothing | UseScope { _uScope :: Scope } | UseBulletMod { _ubMod :: BulletMod } diff --git a/src/Dodge/Default/Creature.hs b/src/Dodge/Default/Creature.hs index da87200c9..23eb21e59 100644 --- a/src/Dodge/Default/Creature.hs +++ b/src/Dodge/Default/Creature.hs @@ -52,7 +52,7 @@ defaultCreature = , _crIntention = defaultIntention , _crGroup = LoneWolf , _crMvType = defaultAimMvType - , _crHammerPosition = HammerUp +-- , _crHammerPosition = HammerUp , _crName = "DEFAULTCRNAME" , _crStatistics = CreatureStatistics 50 50 50 , _crDeathTimer = 0 diff --git a/src/Dodge/Item/Scope.hs b/src/Dodge/Item/Scope.hs index 8bfb51a47..cfb7b97b0 100644 --- a/src/Dodge/Item/Scope.hs +++ b/src/Dodge/Item/Scope.hs @@ -73,6 +73,7 @@ remoteScreen = makeAttach REMOTESCREEN remoteDetonator :: Item remoteDetonator = makeAttach REMOTEDETONATOR + & itUse .~ UseHammer HammerUp & itUse . uaParams .~ APProjectiles [] joystick :: Item diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 671c40c0a..c2ea02ae6 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -585,7 +585,7 @@ tryCombine (i, j) w = fromMaybe w $ do p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos return $ 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 & hud . hudElement . diSelection . _Just . _3 .~ mempty