Fix aiming with no weapon crash

This commit is contained in:
2022-02-08 12:47:58 +00:00
parent 9ead5b3979
commit 0a860e6f68
39 changed files with 317 additions and 244 deletions
+7 -10
View File
@@ -34,18 +34,15 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
& crPos %~ (+.+ p)
& crMvDir .~ argV p
where
p = (*.*) (equipFactor * aimingFactor) p'
equipFactor
| _posture (_crStance cr) == Aiming
= product $ map equipAimSpeed $ IM.elems $ _crInv cr
| _posture (_crStance cr) == Reloading
= product $ map equipAimSpeed $ IM.elems $ _crInv cr
| otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr
p = (equipFactor * aimingFactor) *.* p'
isAiming = _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
invItSpeed
| isAiming = equipAimSpeed
| otherwise = equipSpeed
equipFactor = product $ invItSpeed <$> _crInv cr
aimingFactor
| _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
= fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
| isAiming = fromMaybe 1 $ cr ^? crInv . ix (_crInvSel cr) . itUse . useAim . aimSpeed
| otherwise = 1
it = _crInv cr IM.! _crInvSel cr
crMvForward
:: Float -- ^ Speed
+2 -2
View File
@@ -11,10 +11,10 @@ import Control.Lens
import Data.Maybe
useItem :: Int -> World -> World
useItem cid w = itemEffect cr it w
useItem cid w = tryUseItem cr w -- itemEffect cr it w
where
cr = _creatures w IM.! cid
it = _crInv cr IM.! _crInvSel cr
--it = _crInv cr IM.! _crInvSel cr
tryUseItem :: Creature -> World -> World
tryUseItem cr' w = fromMaybe w $ do
+10 -10
View File
@@ -101,13 +101,13 @@ movementSideEff cr w
| hasJetPack = case cr ^? crStance . carriage of
Just (Boosting v) -> w
& randGen .~ g
& makeFlameletTimed
(oldPos +.+ (_crRad cr + 3) *.* unitVectorAtAngle (_crDir cr + pi))
20
(momentum +.+ 1 *.* rotateV randDir (vInverse v))
Nothing
1
20
& makeFlamelet
(oldPos +.+ (_crRad cr + 3) *.* unitVectorAtAngle (_crDir cr + pi))
20
(momentum +.+ 1 *.* rotateV randDir (vInverse v))
Nothing
1
20
_ -> w
| otherwise = footstepSideEffect cr w
where
@@ -122,9 +122,9 @@ movementSideEff cr w
heldItemUpdate :: Item -> Item
heldItemUpdate = invItemUpdate
. (itUse %~ useupdate)
where
useupdate = id
-- . (itUse %~ useupdate)
-- where
-- useupdate = id
invItemUpdate :: Item -> Item
invItemUpdate = itUse %~ useupdate