Make equipment indices point to item indices
This commit is contained in:
@@ -175,8 +175,9 @@ dropItem :: Creature -> Int -> World -> World
|
||||
dropItem cr invid w' =
|
||||
doanyitemdropeffect
|
||||
. maybeshiftseldown
|
||||
. rmInvItem (_crID cr) (NInt invid)
|
||||
. copyItemToFloor (_crPos cr) itm -- . mayberemoveequip
|
||||
. rmInvItem (_crID cr) (NInt invid) -- it is important
|
||||
-- to do this before copying the item to the floor!
|
||||
. soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing
|
||||
$ w'
|
||||
where
|
||||
|
||||
@@ -44,8 +44,8 @@ useItemLoc cr loc pt w
|
||||
return $ w & pointerToItem itm . itUse . useToggle .~ not b
|
||||
| isJust $ itm ^? itType . ibtEquip
|
||||
, pt == 0
|
||||
, Just invid' <- itm ^? itLocation . ilInvID =
|
||||
return $ toggleEquipmentAt invid' cr w
|
||||
, Just invid <- itm ^? itLocation . ilInvID =
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
| otherwise = (\loc' -> useItemLoc cr loc' pt w) =<< locUp' loc
|
||||
where
|
||||
aimuse
|
||||
@@ -68,26 +68,26 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation invid w of
|
||||
DoNotMoveEquipment -> w
|
||||
PutOnEquipment{_allocNewPos = newp} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crEquipment . at newp ?~ NInt itid
|
||||
& toitems . ix itid . itLocation . ilEquipSite ?~ newp
|
||||
& onequip itm cr
|
||||
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crEquipment . at newp ?~ NInt itid
|
||||
& crpoint . crEquipment . at oldp .~ Nothing
|
||||
& toitems . ix itid . itLocation . ilEquipSite ?~ newp
|
||||
SwapEquipment{_allocNewPos = newp, _allocOldPos = oldp, _allocSwapID = sid} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crEquipment . at newp ?~ NInt itid
|
||||
& crpoint . crEquipment . at oldp ?~ sid
|
||||
& toitems . ix itid . itLocation . ilEquipSite ?~ newp
|
||||
& toitems . ix (invidtoitid sid) . itLocation . ilEquipSite ?~ oldp
|
||||
& toitems . ix (_unNInt sid) . itLocation . ilEquipSite ?~ oldp
|
||||
ReplaceEquipment{_allocNewPos = newp, _allocRemoveID = rid} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crEquipment . at newp ?~ NInt itid
|
||||
& toitems . ix itid . itLocation . ilEquipSite ?~ newp
|
||||
& toitems . ix (invidtoitid rid) . itLocation . ilEquipSite .~ Nothing
|
||||
& onremove (itmat rid) cr
|
||||
& toitems . ix (_unNInt rid) . itLocation . ilEquipSite .~ Nothing
|
||||
& onremove (itmat' rid) cr
|
||||
& onequip itm cr
|
||||
RemoveEquipment{_allocOldPos = oldp} ->
|
||||
w
|
||||
@@ -101,6 +101,7 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation invid w of
|
||||
itid = invidtoitid invid
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = w ^?! cWorld . lWorld . items . ix (invidtoitid i)
|
||||
itmat' i = w ^?! cWorld . lWorld . items . ix (_unNInt i)
|
||||
itm = itmat invid
|
||||
onequip itm' = effectOnEquip itm'
|
||||
onremove itm' = effectOnRemove itm'
|
||||
|
||||
@@ -116,8 +116,7 @@ twists m cr = crInAimStance TwoHandUnder m cr || crInAimStance TwoHandOver m cr
|
||||
-- Not sure if it is a good idea
|
||||
crIsArmouredFrom :: IM.IntMap Item -> Point2 -> Creature -> Bool
|
||||
crIsArmouredFrom m p cr = fromMaybe False $ do
|
||||
invid <- cr ^? crEquipment . ix OnChest
|
||||
itid <- cr ^? crInv . ix invid
|
||||
NInt itid <- cr ^? crEquipment . ix OnChest
|
||||
ittype <- m ^? ix itid . itType
|
||||
return $
|
||||
EQUIP FRONTARMOUR == ittype
|
||||
|
||||
Reference in New Issue
Block a user