Improve frontArmour equipment
This commit is contained in:
@@ -6,6 +6,7 @@ module Dodge.Creature.Property
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
|
||||
-- the use of crOldPos is because the damage position is calculated on the
|
||||
@@ -14,10 +15,17 @@ import Control.Lens
|
||||
crIsArmouredFrom :: Point2 -> Creature -> Bool
|
||||
crIsArmouredFrom p cr
|
||||
= p /= _crOldPos cr
|
||||
&& any (\it -> it ^? itType == Just FRONTARMOUR) (_crInv cr)
|
||||
-- && any (\it -> it ^? itType == Just FRONTARMOUR) (_crInv cr)
|
||||
&& hasFrontArmour cr
|
||||
&& angleVV (unitVectorAtAngle $ _crDir cr) (p -.- _crOldPos cr) < pi/2
|
||||
-- even though angleVV can generate NaN, the comparison seems to deal with it
|
||||
|
||||
hasFrontArmour :: Creature -> Bool
|
||||
hasFrontArmour cr = fromMaybe False $ do
|
||||
invid <- cr ^? crEquipment . ix OnChest
|
||||
ittype <- cr ^? crInv . ix invid . itType
|
||||
return $ FRONTARMOUR == ittype
|
||||
|
||||
--crOnSeg :: Point2 -> Point2 -> Creature -> Bool
|
||||
--crOnSeg p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user