Correctly update root status of item in _ilIsRoot
This commit is contained in:
@@ -25,7 +25,7 @@ import qualified IntMapHelp as IM
|
||||
useRootItem :: Int -> World -> World
|
||||
useRootItem crid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itRef <- cr ^? crManipulation . manObject . imRootItem
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
it <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
return $
|
||||
itemUseEffect' cr it w
|
||||
|
||||
@@ -166,7 +166,7 @@ invSideEff cr = alaf Endo foldMap f (_crInv cr) . updateHeldRootItem cr
|
||||
|
||||
updateHeldRootItem :: Creature -> World -> World
|
||||
updateHeldRootItem cr = fromMaybe id $ do
|
||||
invid <- cr ^? crManipulation . manObject . imRootItem
|
||||
invid <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix invid
|
||||
return $ updateAttachedItems itmtree cr
|
||||
|
||||
|
||||
@@ -38,6 +38,6 @@ strFromHeldItem :: Creature -> Int
|
||||
strFromHeldItem cr
|
||||
--x--- | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
|
||||
| _posture (_crStance cr) == Aiming = negate $ fromMaybe 0 $ do
|
||||
i <- cr ^? crManipulation . manObject . imRootItem
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
cr ^? crInv . ix i . itUse . heldAim . aimWeight
|
||||
| otherwise = 0
|
||||
|
||||
@@ -86,12 +86,10 @@ crAwayFromPost cr = case find sentinelGoal . _apGoal $ _crActionPlan cr of
|
||||
--crCanShoot cr = crIsAiming cr && crWeaponReady cr
|
||||
|
||||
crInAimStance :: AimStance -> Creature -> Bool
|
||||
crInAimStance as cr =
|
||||
crIsAiming cr
|
||||
&& mitstance == Just as
|
||||
crInAimStance as cr = crIsAiming cr && mitstance == Just as
|
||||
where
|
||||
mitstance = do
|
||||
i <- cr ^? crManipulation . manObject . imRootItem
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||
|
||||
oneH :: Creature -> Bool
|
||||
|
||||
@@ -114,7 +114,7 @@ wasdAim inp cam cr
|
||||
wasdTwist :: Creature -> Creature
|
||||
wasdTwist cr
|
||||
| _posture (_crStance cr) == Aiming = fromMaybe cr $ do
|
||||
itRef <- cr ^? crManipulation . manObject . imRootItem
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
case (astance, cr ^. crTwist) of
|
||||
(TwoHandUnder, 0) ->
|
||||
@@ -144,7 +144,7 @@ aimTurn :: Float -> Creature -> Creature
|
||||
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
||||
where
|
||||
x = fromMaybe 1 $ do
|
||||
itRef <- cr ^? crManipulation . manObject . imRootItem
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
|
||||
|
||||
{- | Set posture according to mouse presses.
|
||||
|
||||
Reference in New Issue
Block a user