Improve frontArmour equipment

This commit is contained in:
2022-05-21 19:30:51 +01:00
parent c5818271d8
commit e9cc7e64c9
9 changed files with 37 additions and 49 deletions
+3 -1
View File
@@ -60,6 +60,8 @@ armourChaseCrit = chaseCrit
,(1,medkit 200)
]
, _crMvType = defaultChaseMvType {_mvTurnRad = f}
}
}
& crEquipment . at OnChest .~ Just 0
& crInvEquipped . at 0 .~ Just OnChest
where
f _ = 0.05
+1 -24
View File
@@ -6,7 +6,7 @@ import Dodge.Data
import Dodge.Inventory
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
--import qualified Data.IntSet as IS
import Control.Lens
import Data.Maybe
@@ -68,29 +68,6 @@ eqSiteToPos cr es = case es of
Nothing -> OnLeftWrist
_ -> OnRightWrist
removeEquipmentUsingSite :: EquipSite -> Creature -> Creature
removeEquipmentUsingSite esite cr = case esite of
GoesOnSpecial -> cr
_ -> case cr ^? crEquipment . esiteToPoint of
Just invid -> cr & crInvEquipped . at invid .~ Nothing
_ -> cr
where
esiteToPoint = case esite of
GoesOnHead -> ix OnHead
GoesOnChest -> ix OnChest
GoesOnBack -> ix OnBack
GoesOnWrist -> ix OnLeftWrist
GoesOnLegs -> ix OnLegs
setEquipmentSite :: EquipSite -> Maybe Int -> Creature -> Creature
setEquipmentSite esite = case esite of
GoesOnHead -> set (crEquipment . at OnHead)
GoesOnChest -> set (crEquipment . at OnChest)
GoesOnBack -> set (crEquipment . at OnBack)
GoesOnWrist -> set (crEquipment . at OnLeftWrist)
GoesOnLegs -> set (crEquipment . at OnLegs)
GoesOnSpecial -> const id
useLeftItem :: Int -> World -> World
useLeftItem cid w
| _crInvLock cr = w
+9 -1
View File
@@ -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)
+1 -1
View File
@@ -22,7 +22,7 @@ import Picture
import qualified IntMapHelp as IM
--import StrictHelp
import qualified Data.IntSet as IS
--import qualified Data.IntSet as IS
--import Data.Maybe
import Data.Function
import Control.Lens