From ee47ee8e95f8c9557fe6ef3e4b487db0e8f4aef2 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 22 Jun 2022 21:03:06 +0100 Subject: [PATCH] Require weapon also primed on ammo check --- src/Dodge/Creature/Action.hs | 11 ++++++----- src/Dodge/Event.hs | 4 ++-- src/Dodge/Item/Weapon/TriggerType.hs | 9 +++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index a13534d78..06893f09e 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -64,7 +64,7 @@ performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos) aimSp = case cr ^? crMvType . mvAimSpeed of Just f -> f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos) Nothing -> error "creature without aiming type" - tpos | canSee' = _crPos (_creatures w IM.! tcid) + tpos | canSee' = _crPos (_creatures w IM.! tcid) | otherwise = p performPathTo :: Creature -> World -> Point2 -> OutAction @@ -243,7 +243,9 @@ stripNoItems cr = organiseInvKeys (_crID cr) . organiseInvKeys :: Int -> World -> World organiseInvKeys cid w = w & creatures . ix cid %~ - ( ( crInvSel . iselPos .~ newSelKey ) . (crInv .~ newInv ) ) + ( ( crInvSel . iselPos .~ newSelKey ) + . ( crInv .~ newInv ) + . ( crInvSel . iselAction .~ NoInvSelAction) ) where cr = _creatures w IM.! cid pairs = IM.toList (_crInv cr) @@ -281,13 +283,13 @@ youDropItem' w = case yourItem w ^? _Just . itCurseStatus of _ -> w where cr = you w + {- | Copy an inventory item to the floor. -} copyInvItemToFloor :: Creature -> Int -> World -> World copyInvItemToFloor cr i = copyItemToFloor (_crPos cr) - (_crInv cr IM.! i + $ _crInv cr IM.! i & itInvPos .~ Nothing & itIsHeld .~ False - ) sizeSelf :: Float -> Creature -> World -> Maybe World sizeSelf x cr w @@ -314,7 +316,6 @@ sizeSelf x cr w pickUpItemID :: Int -> Int -> World -> World pickUpItemID cid flid w = pickUpItem cid (_floorItems w IM.! flid) w - {- | Pick up a specific item. -} pickUpItem :: Int -> FloorItem -> World -> World pickUpItem cid flit w = maybe w (soundStart (CrSound cid) (_flItPos flit) pickUpS Nothing . snd) diff --git a/src/Dodge/Event.hs b/src/Dodge/Event.hs index 4edb8dbd8..abda15237 100644 --- a/src/Dodge/Event.hs +++ b/src/Dodge/Event.hs @@ -144,8 +144,8 @@ wheelEvent y w = case _hudElement $ _hud w of (Nothing,_) -> closeObjScrollDir y w (Just f,_) -> w & creatures . ix 0 . crInv . ix (crSel $ you w) %~ f y (you w) | lbDown -> w & cameraZoom +~ y - | invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeSwapInvSel yi w - | otherwise -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w + | invKeyDown -> changeSwapInvSel yi w + | otherwise -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w DisplayInventory TweakInventory | invKeyDown && rbDown -> w & moveTweakSel yi | invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeInvSel yi w diff --git a/src/Dodge/Item/Weapon/TriggerType.hs b/src/Dodge/Item/Weapon/TriggerType.hs index 5f9bff37c..d80f11153 100644 --- a/src/Dodge/Item/Weapon/TriggerType.hs +++ b/src/Dodge/Item/Weapon/TriggerType.hs @@ -124,10 +124,11 @@ withThickSmokeI eff item cr w = eff item cr -- TODO create a trigger that does different things on first and continued -- fire. ammoCheckI :: ChainEffect -ammoCheckI eff item cr w - | _laLoaded (_itConsumption item) <= 0 = w -- fromMaybe w (startReloadingWeapon cr w) --- | _reloadState (_itConsumption item) /= Nothing' = w - | otherwise = eff item cr $ w & creatures . ix (_crID cr) %~ crCancelReloading +ammoCheckI eff itm cr w + | _laLoaded ic <= 0 || not (_laPrimed ic) = w + | otherwise = eff itm cr $ w & creatures . ix (_crID cr) %~ crCancelReloading + where + ic = _itConsumption itm -- combined ammo and hammer check: want to be able to auto-reload even if the -- hammer is down?