Remove targeting bugs
This commit is contained in:
@@ -235,10 +235,10 @@ equipmentEffects cr = flip (foldl' $ flip $ useEquipment cr) (IM.keys $ _crInvEq
|
||||
-- a loop going over all inventory items
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w =
|
||||
crDoTargeting cr $
|
||||
updateTargeting (crGetTargeting cr) cr $
|
||||
weaponReloadSounds cr $
|
||||
over (cWorld . lWorld . creatures . ix (_crID cr)) crSetTargeting $
|
||||
IM.foldl' f w (_crInv cr)
|
||||
-- be careful with side effects that affect creature targeting
|
||||
where
|
||||
f w' it =
|
||||
itemInvSideEffect cr it $
|
||||
@@ -275,11 +275,10 @@ updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
||||
| l < m -> it & itUse . leftConsumption . arProgress -~ 1
|
||||
_ -> it
|
||||
|
||||
crSetTargeting :: Creature -> Creature
|
||||
crSetTargeting cr = fromMaybe cr $ do
|
||||
crGetTargeting :: Creature -> Maybe TargetType
|
||||
crGetTargeting cr = do
|
||||
itm <- find hastargeting $ helditem ++ IM.elems (getCrEquipment cr)
|
||||
tt <- itm ^? itUse . useTargeting . _Just
|
||||
return $ cr & crTargeting . ctType ?~ tt
|
||||
itm ^? itUse . useTargeting . _Just
|
||||
where
|
||||
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
|
||||
helditem = fromMaybe [] $ do
|
||||
@@ -287,16 +286,6 @@ crSetTargeting cr = fromMaybe cr $ do
|
||||
itm <- cr ^? crInv . ix i
|
||||
return [itm]
|
||||
|
||||
crDoTargeting :: Creature -> World -> World
|
||||
crDoTargeting cr = fromMaybe id $ do
|
||||
tt <- cr ^? crTargeting . ctType . _Just
|
||||
return $ updateTargeting tt cr
|
||||
|
||||
doItemTargeting :: Int -> Creature -> World -> World
|
||||
doItemTargeting invid cr w = case cr ^? crInv . ix invid . itUse . useTargeting . _Just of
|
||||
Nothing -> w
|
||||
Just t -> updateTargeting t cr w
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crInvSel . iselAction of
|
||||
Just ReloadAction{_reloadAction = la} ->
|
||||
|
||||
Reference in New Issue
Block a user