Continue inventory tweak
This commit is contained in:
@@ -190,7 +190,7 @@ dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid -- . maybe
|
||||
-- | Get your creature to drop the item under the cursor.
|
||||
youDropItem :: World -> World
|
||||
youDropItem w = fromMaybe w $ do
|
||||
curpos <- you w ^? crManipulation . isel . ispItem
|
||||
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||
guard $ not $ _crInvLock (you w) || cursed
|
||||
return $ w
|
||||
& dropItem cr curpos
|
||||
|
||||
@@ -47,7 +47,7 @@ followImpulse cr w imp = case imp of
|
||||
TurnTo p -> crup $ creatureTurnTo p cr
|
||||
ChangePosture post -> crup $ cr & crStance . posture .~ post
|
||||
UseItem -> (useItem cr, cr)
|
||||
SwitchToItem i -> crup $ cr & crManipulation .~ Manipulator (SelItem i NoInvSelAction)
|
||||
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ InInventory (SelItem i NoInvSelAction)
|
||||
Melee cid' ->
|
||||
( hitCr cid'
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20
|
||||
|
||||
@@ -23,7 +23,7 @@ import qualified SDL
|
||||
useItem :: Creature -> World -> World
|
||||
useItem cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
itRef <- cr ^? crManipulation . isel . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
it <- cr ^? crInv . ix itRef
|
||||
return $ itemEffect cr it w
|
||||
where
|
||||
@@ -39,7 +39,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
|
||||
CraftUse{} -> setuhamdown w
|
||||
where
|
||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w
|
||||
_ -> w & setuhamdown
|
||||
@@ -109,7 +109,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = _crInv cr IM.! i
|
||||
itm = itmat itRef
|
||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||
onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm'
|
||||
|
||||
@@ -117,7 +117,7 @@ useLeftItem :: Int -> World -> World
|
||||
useLeftItem cid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
guard . not $ _crInvLock cr
|
||||
let mitRef = cr ^? crManipulation . isel . ispItem
|
||||
let mitRef = cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itmIsConsumable = isJust $ do
|
||||
itRef <- mitRef
|
||||
cr ^? crInv . ix itRef . itUse . cUse
|
||||
|
||||
@@ -153,7 +153,7 @@ doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
||||
reloadOverride :: Creature -> Creature
|
||||
reloadOverride cr = fromMaybe cr $ do
|
||||
guard $ cr ^. crStance . posture == Aiming
|
||||
itRef <- cr ^? crManipulation . isel . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
guard $ cr ^? crInv . ix itRef . itUse . heldConsumption . laLoaded == Just 0
|
||||
return $ cr & crActionPlan . apStrategy .~ StrategyActions Reload reloadActions
|
||||
where
|
||||
|
||||
@@ -68,7 +68,7 @@ stateUpdate f =
|
||||
heldAimEffects :: Creature -> World -> World
|
||||
heldAimEffects cr = fromMaybe id $ do
|
||||
guard (crIsAiming cr)
|
||||
ipos <- cr ^? crManipulation . isel . ispItem
|
||||
ipos <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itm <- cr ^? crInv . ix ipos
|
||||
f <- itm ^? itEffect . ieWhileAiming
|
||||
return $ doInvEffect f itm cr
|
||||
@@ -263,7 +263,7 @@ itemUpdate cr i = updateAutoRecharge
|
||||
. (itLocation .~ InInv (_crID cr) i)
|
||||
. (itIsHeld .~ itmisheld)
|
||||
where
|
||||
itmisheld = Just i == (cr ^? crManipulation . isel . ispItem)
|
||||
itmisheld = Just i == (cr ^? crManipulation . manObject . inInventory . ispItem)
|
||||
|
||||
updateAutoRecharge :: Item -> Item
|
||||
updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
||||
@@ -279,12 +279,12 @@ crGetTargeting cr = do
|
||||
where
|
||||
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
|
||||
helditem = fromMaybe [] $ do
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itm <- cr ^? crInv . ix i
|
||||
return [itm]
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crManipulation . isel . iselAction of
|
||||
weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||
Just ReloadAction{_reloadAction = la} ->
|
||||
soundContinue
|
||||
(CrReloadSound cid)
|
||||
|
||||
@@ -37,6 +37,6 @@ crCurrentEquipment cr =
|
||||
strFromHeldItem :: Creature -> Int
|
||||
strFromHeldItem cr
|
||||
| _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
cr ^? crInv . ix i . itUse . heldAim . aimWeight
|
||||
| otherwise = 0
|
||||
|
||||
@@ -32,13 +32,13 @@ import Dodge.Data.World
|
||||
import Geometry
|
||||
|
||||
crIsReloading :: Creature -> Bool
|
||||
crIsReloading cr = case cr ^? crManipulation . isel . iselAction of
|
||||
crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||
Just ReloadAction{} -> True
|
||||
_ -> False
|
||||
|
||||
crWeaponReady :: Creature -> Bool
|
||||
crWeaponReady cr = fromMaybe False $ do
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
ic <- cr ^? crInv . ix i . itUse . heldConsumption
|
||||
return (_laLoaded ic > 0 && _laPrimed ic)
|
||||
|
||||
@@ -83,7 +83,7 @@ crInAimStance as cr =
|
||||
&& mitstance == Just as
|
||||
where
|
||||
mitstance = do
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||
|
||||
oneH :: Creature -> Bool
|
||||
|
||||
@@ -52,7 +52,7 @@ wasdWithAiming w speed cr
|
||||
& crDir +~ _crTwist cr'
|
||||
& crTwist .~ 0
|
||||
addAnyTwist = fromMaybe id $ do
|
||||
itRef <- cr ^? crManipulation . isel . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
let currenttwistamount = cr ^. crTwist
|
||||
case (astance,currenttwistamount) of
|
||||
@@ -73,7 +73,7 @@ wasdWithAiming w speed cr
|
||||
mouseDir = fromMaybe
|
||||
(argV (_mousePos (_input w)) + (w ^. cWorld . camPos . camRot) )
|
||||
$ do
|
||||
itRef <- cr ^? crManipulation . isel . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
_ <- cr ^? crInv . ix itRef . itScope . scopePos
|
||||
return . argV $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- _crPos cr
|
||||
|
||||
@@ -81,7 +81,7 @@ aimTurn :: Float -> Creature -> Creature
|
||||
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
||||
where
|
||||
x = fromMaybe 1 $ do
|
||||
itRef <- cr ^? crManipulation . isel . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
|
||||
|
||||
wasdM :: SDL.Scancode -> Point2
|
||||
@@ -104,5 +104,5 @@ mouseActionsCr pkeys cr
|
||||
where
|
||||
rbPressed = SDL.ButtonRight `M.member` pkeys
|
||||
noaction = fromMaybe True $ do
|
||||
theaction <- cr ^? crManipulation . isel . iselAction
|
||||
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||
return $ theaction == NoInvSelAction
|
||||
|
||||
Reference in New Issue
Block a user