Improve possible manipulation of equipment
This commit is contained in:
@@ -4,6 +4,7 @@ module Dodge.Creature.Property
|
||||
, crNearPoint
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Creature.HandPos
|
||||
import Geometry
|
||||
|
||||
import Data.Maybe
|
||||
@@ -13,18 +14,21 @@ import Control.Lens
|
||||
-- previous frame
|
||||
-- Not sure if it is a good idea
|
||||
crIsArmouredFrom :: Point2 -> Creature -> Bool
|
||||
crIsArmouredFrom p cr
|
||||
= p /= _crOldPos 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
|
||||
crIsArmouredFrom p cr = hasFrontArmour p cr
|
||||
|
||||
hasFrontArmour :: Creature -> Bool
|
||||
hasFrontArmour cr = fromMaybe False $ do
|
||||
hasFrontArmour :: Point2 -> Creature -> Bool
|
||||
hasFrontArmour p cr = fromMaybe False $ do
|
||||
invid <- cr ^? crEquipment . ix OnChest
|
||||
ittype <- cr ^? crInv . ix invid . itType
|
||||
return $ FRONTARMOUR == ittype
|
||||
&& p /= _crOldPos cr
|
||||
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection)) (p -.- _crOldPos cr) < pi/2
|
||||
-- even though angleVV can generate NaN, the comparison seems to deal with it
|
||||
where
|
||||
frontarmdirection
|
||||
| crInStance OneHand cr = 0.5
|
||||
| crInStance TwoHandTwist cr = negate 1
|
||||
| otherwise = 0
|
||||
|
||||
--crOnSeg :: Point2 -> Point2 -> Creature -> Bool
|
||||
--crOnSeg p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr)
|
||||
|
||||
Reference in New Issue
Block a user