Major item refactor, still broken
This commit is contained in:
+15
-16
@@ -24,6 +24,7 @@ module Dodge.Creature.Test (
|
||||
crSafeDistFromTarg,
|
||||
) where
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Data.Equipment.Misc
|
||||
@@ -90,35 +91,33 @@ crAwayFromPost cr = case find sentinelGoal . _apGoal $ _crActionPlan cr of
|
||||
--crCanShoot :: Creature -> Bool
|
||||
--crCanShoot cr = crIsAiming cr && crWeaponReady cr
|
||||
|
||||
crInAimStance :: AimStance -> Creature -> Bool
|
||||
crInAimStance as cr = crIsAiming cr && mitstance == Just as
|
||||
crInAimStance :: AimStance -> IM.IntMap Item -> Creature -> Bool
|
||||
crInAimStance as m cr = crIsAiming cr && mitstance == Just as
|
||||
where
|
||||
mitstance = do
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
--itm <- invRootTrees' (cr ^. crInv) ^? ix i
|
||||
itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invIMDT (cr ^. crInv) ^? ix i
|
||||
itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invIMDT (fmap (\i -> m ^?! ix i) (cr ^. crInv)) ^? ix i
|
||||
return $ aimStance itm
|
||||
--cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||
|
||||
oneH :: Creature -> Bool
|
||||
oneH :: IM.IntMap Item -> Creature -> Bool
|
||||
oneH = crInAimStance OneHand
|
||||
|
||||
twoFlat :: Creature -> Bool
|
||||
twoFlat :: IM.IntMap Item -> Creature -> Bool
|
||||
twoFlat = crInAimStance TwoHandFlat
|
||||
|
||||
twists :: Creature -> Bool
|
||||
twists cr = crInAimStance TwoHandUnder cr || crInAimStance TwoHandOver cr
|
||||
twists :: IM.IntMap Item -> Creature -> Bool
|
||||
twists m cr = crInAimStance TwoHandUnder m cr || crInAimStance TwoHandOver m cr
|
||||
|
||||
-- the use of crOldPos is because the damage position is calculated on the
|
||||
-- previous frame
|
||||
-- Not sure if it is a good idea
|
||||
crIsArmouredFrom :: Point2 -> Creature -> Bool
|
||||
crIsArmouredFrom = hasFrontArmour
|
||||
|
||||
hasFrontArmour :: Point2 -> Creature -> Bool
|
||||
hasFrontArmour p cr = fromMaybe False $ do
|
||||
crIsArmouredFrom :: IM.IntMap Item -> Point2 -> Creature -> Bool
|
||||
crIsArmouredFrom m p cr = fromMaybe False $ do
|
||||
invid <- cr ^? crEquipment . ix OnChest
|
||||
ittype <- cr ^? crInv . ix invid . itType
|
||||
itid <- cr ^? crInv . ix invid
|
||||
ittype <- m ^? ix itid . itType
|
||||
return $
|
||||
EQUIP FRONTARMOUR == ittype
|
||||
&& p /= _crOldPos cr
|
||||
@@ -127,9 +126,9 @@ hasFrontArmour p cr = fromMaybe False $ do
|
||||
-- even though angleVV can generate NaN, the comparison seems to deal with it
|
||||
|
||||
frontarmdirection
|
||||
| crInAimStance OneHand cr = 0.5
|
||||
| crInAimStance TwoHandUnder cr = negate 1
|
||||
| crInAimStance TwoHandOver cr = negate 1
|
||||
| crInAimStance OneHand m cr = 0.5
|
||||
| crInAimStance TwoHandUnder m cr = negate 1
|
||||
| crInAimStance TwoHandOver m cr = negate 1
|
||||
| otherwise = 0
|
||||
|
||||
--crOnSeg :: Point2 -> Point2 -> Creature -> Bool
|
||||
|
||||
Reference in New Issue
Block a user