Remove creature hammer, may have broken equipment/combining

This commit is contained in:
2024-12-31 10:17:31 +00:00
parent ede08ff1db
commit 2fc960321e
8 changed files with 25 additions and 24 deletions
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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.
+15 -16
View File
@@ -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
+1 -1
View File
@@ -66,7 +66,7 @@ data Creature = Creature
, _crGroup :: CrGroup
, _crIntention :: Intention
, _crMvType :: CrMvType
, _crHammerPosition :: HammerPosition
-- , _crHammerPosition :: HammerPosition
, _crName :: String
, _crStatistics :: CreatureStatistics
, _crDeathTimer :: Int
+1
View File
@@ -43,6 +43,7 @@ data ItemUse
}
| UseEquip { _uequipEffect :: EquipEffect }
| UseAttach {_uaParams :: AttachParams}
| UseHammer {_heldHammer :: HammerPosition}
| UseNothing
| UseScope { _uScope :: Scope }
| UseBulletMod { _ubMod :: BulletMod }
+1 -1
View File
@@ -52,7 +52,7 @@ defaultCreature =
, _crIntention = defaultIntention
, _crGroup = LoneWolf
, _crMvType = defaultAimMvType
, _crHammerPosition = HammerUp
-- , _crHammerPosition = HammerUp
, _crName = "DEFAULTCRNAME"
, _crStatistics = CreatureStatistics 50 50 50
, _crDeathTimer = 0
+1
View File
@@ -73,6 +73,7 @@ remoteScreen = makeAttach REMOTESCREEN
remoteDetonator :: Item
remoteDetonator = makeAttach REMOTEDETONATOR
& itUse .~ UseHammer HammerUp
& itUse . uaParams .~ APProjectiles []
joystick :: Item
+1 -1
View File
@@ -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