diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index fa06d9781..a4b4078fe 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -170,6 +170,17 @@ inventoryA = IM.fromList $ zip [0..] , makeTypeCraftNum 2 CAN , makeTypeCraftNum 2 PIPE ] +inventoryB :: IM.IntMap Item +inventoryB = IM.fromList $ zip [0..] + [ autoRifle + , smg + , makeTypeCraftNum 4 MICROCHIP + , makeTypeCraftNum 2 TIN + , makeTypeCraftNum 2 HARDWARE + , makeTypeCraftNum 2 CAN + , makeTypeCraftNum 2 PIPE + , makeTypeCraftNum 1 CREATURESENSOR + ] testInventory :: IM.IntMap Item testInventory = IM.fromList $ zip [0..] diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index b2a2b7212..7d96401a4 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -51,7 +51,7 @@ foldCr xs cr w = foldr f w xs -- This should be made more sensible: should the movement side effects apply to -- the creature before or after it has moved? -- at what point invSideEffects is applied wrt to when the creature moves --- may effect whether the shield moves correctly +-- may affect whether the shield moves correctly stateUpdate :: (Creature -> World -> World) -> Creature -> World -> World stateUpdate f = foldCr [ doDamage @@ -138,10 +138,10 @@ movementSideEff cr w (randAng,_) = randomR (0,2*pi) $ _randGen w heldItemUpdate :: Int -> Item -> Item -heldItemUpdate invid = (itUse %~ useUpdate) . (itIsHeld .~ True) . (itInvPos ?~ invid) +heldItemUpdate invid = (itUse %~ useUpdate) . (itInvPos ?~ invid) . (itIsHeld .~ True) invItemUpdate :: Int -> Item -> Item -invItemUpdate invid = (itUse %~ useUpdate) . (itIsHeld .~ False) . (itInvPos ?~ invid) +invItemUpdate invid = (itUse %~ useUpdate) . (itInvPos ?~ invid) . (itIsHeld .~ False) useUpdate :: ItemUse -> ItemUse useUpdate = (useHammer . hammerPosition %~ moveHammerUp) @@ -156,15 +156,21 @@ invSideEff cr w = weaponReloadSounds cr . flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped cr) $ IM.foldrWithKey f w (_crInv cr) where - f i it w' = doitemupdate w' & case it ^? itEffect . itInvEffect of + --upitemsw = w & creatures . ix (_crID cr) . crInv %~ IM.mapWithKey (itemUpdate cr) + f i it w' = (doItemTargeting i cr . doitemupdate) w' & case it ^? itEffect . itInvEffect of Nothing -> id Just g -> g (heldItemUpdate i it) cr -- this is done twice! where doitemupdate - | i == _crInvSel cr = doItemTargeting i cr . (itpointer %~ heldItemUpdate i) - | otherwise = doItemTargeting i cr . (itpointer %~ invItemUpdate i) + | i == _crInvSel cr = (itpointer %~ heldItemUpdate i) + | otherwise = (itpointer %~ invItemUpdate i) itpointer = creatures . ix (_crID cr) . crInv . ix i +itemUpdate :: Creature -> Int -> Item -> Item +itemUpdate cr i + | i == _crInvSel cr = heldItemUpdate i + | otherwise = invItemUpdate i + doItemTargeting :: Int -> Creature -> World -> World doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of Nothing -> w diff --git a/src/Dodge/Debug/Terminal.hs b/src/Dodge/Debug/Terminal.hs index 4bf420640..589907cc9 100644 --- a/src/Dodge/Debug/Terminal.hs +++ b/src/Dodge/Debug/Terminal.hs @@ -23,6 +23,8 @@ applyTerminalString "LOADME" = (uvWorld . creatures . ix 0 . crInv .~ stackedInv . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) applyTerminalString "LA" = (uvWorld . creatures . ix 0 . crInv .~ inventoryA) . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) +applyTerminalString "LB" = (uvWorld . creatures . ix 0 . crInv .~ inventoryB) + . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) applyTerminalString "GODON" = uvWorld . creatures . ix 0 . crApplyDamage .~ applyNoDamage applyTerminalString "GODOFF" = uvWorld . creatures . ix 0 . crApplyDamage .~ defaultApplyDamage applyTerminalString "LOADTEST" = (uvWorld . creatures . ix 0 . crInv .~ testInventory) diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index f8a5ca760..174a0c63b 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -308,7 +308,7 @@ updateCloud w c -- the following only tests for the first collision with a wall hitWl = collidePointAnyWallsReflect oldPos2 newPos2 $ wallsNearPoint newPos2 w finalPos = addZ (min 74 npz) $ maybe newPos2 fst hitWl - -- allowing clouds to height 75 causes graphical glitches 22.05.23 + -- allowing clouds at/above height 75 causes graphical glitches 22.05.23 finalVel = addZ nvz $ maybe newVel2 snd hitWl --updateCloud :: World -> Cloud -> Maybe Cloud