Allow for equipment items to set a minimum view distance

This commit is contained in:
2022-06-05 01:50:18 +01:00
parent 5e144b1cd5
commit 65fcea0f50
13 changed files with 76 additions and 61 deletions
+23 -23
View File
@@ -27,8 +27,8 @@ magShield = defaultEquipment
, _itID = Nothing
, _itAttachment = ItMInt Nothing
}
& itUse . eqUse .~ useMagShield
& itUse . eqSite .~ GoesOnWrist
& itUse . eqEq . eqUse .~ useMagShield
& itUse . eqEq . eqSite .~ GoesOnWrist
useMagShield :: Item -> Creature -> World -> World
useMagShield it cr w = w & magnets . at mgid ?~ themagnet
where
@@ -49,7 +49,7 @@ flameShield = defaultEquipment
, _itName = "FLAMESHIELD"
, _itEquipPict = \cr _ -> (,) emptySH $ setDepth 20 $ pictures [color cyan $ circle (_crRad cr+2)]
, _itID = Nothing
} & itUse . eqSite .~ GoesOnChest
} & itUse . eqEq . eqSite .~ GoesOnChest
{- | Slows you down, blocks forward projectiles. -}
frontArmour :: Item
frontArmour = defaultEquipment
@@ -61,7 +61,7 @@ frontArmour = defaultEquipment
])
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnChest
& itUse . eqEq . eqSite .~ GoesOnChest
where
thecol = yellow -- (greyN 0.1)
@@ -72,32 +72,32 @@ wristArmour = defaultEquipment
, _itEquipPict = spicForWrist mempty
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnWrist
& itUse . eqOnEquip .~ onEquipWristShield
& itUse . eqUse .~ setWristShieldPos
& itUse . eqOnRemove .~ onRemoveWristShield
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ onEquipWristShield
& itUse . eqEq . eqUse .~ setWristShieldPos
& itUse . eqEq . eqOnRemove .~ onRemoveWristShield
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w = w
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqParams .~ EquipID i
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqEq . eqParams .~ EquipID i
& walls . at i ?~ (shieldWall (_crID cr)) {_wlDraw = True,_wlID = i}
& setWristShieldPos (itm & itUse . eqParams .~ EquipID i) cr
& setWristShieldPos (itm & itUse . eqEq . eqParams .~ EquipID i) cr
where
i = IM.newKey (_walls w)
onRemoveWristShield :: Item -> Creature -> World -> World
onRemoveWristShield itm cr w = w
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqParams .~ NoEquipParams
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqEq . eqParams .~ NoEquipParams
& deleteWallID i
where
i = _eparamID $ _eqParams $ _itUse itm
i = _eparamID $ _eqParams $ _eqEq $ _itUse itm
setWristShieldPos :: Item -> Creature -> World -> World
setWristShieldPos itm cr w = w
& moveWallIDUnsafe i wlline
-- & testString .~ (\w' -> [shortShow $ _wlLine (_walls w' IM.! i)])
-- & tempLightSources .:~ tlsTimeRadColPos 1 200 0.7 (fst wlline `v2z` 40)
where
i = _eparamID $ _eqParams $ _itUse itm
i = _eparamID $ _eqParams $ _eqEq $ _itUse itm
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
invid = fromJust (_itInvPos itm)
--wlline = (V2 10 0, V2 (-10) 100)
@@ -222,7 +222,7 @@ jetPack = defaultEquipment
$ pictures [color yellow $ polygon $ rectNSEW 5 (-5) (-3) (-11) ]
, _itEffect = NoItEffect
, _itID = Nothing
} & itUse . eqSite .~ GoesOnBack
} & itUse . eqEq . eqSite .~ GoesOnBack
brainHat :: Item
brainHat = defaultEquipment
@@ -232,7 +232,7 @@ brainHat = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnHead
& itUse . eqEq . eqSite .~ GoesOnHead
headLamp1 :: Item
headLamp1 = defaultEquipment
@@ -246,8 +246,8 @@ headLamp1 = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqUse .~ createHeadLamp
& itUse . eqSite .~ GoesOnHead
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
headLamp :: Item
headLamp = defaultEquipment
{ _itType = HEADLAMP
@@ -256,8 +256,8 @@ headLamp = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqUse .~ createHeadLamp
& itUse . eqSite .~ GoesOnHead
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
headLampShape :: Shape
headLampShape = colorSH yellow $
@@ -278,7 +278,7 @@ powerLegs = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnLegs
& itUse . eqEq . eqSite .~ GoesOnLegs
speedLegs :: Item
speedLegs = powerLegs
{ _itType = SPEEDLEGS
@@ -297,9 +297,9 @@ wristInvisibility = defaultEquipment
, _itEquipPict = shapeForWrist (colorSH chartreuse $ upperPrismPoly 3 $ rectWH 2 2)
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnWrist
& itUse . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
& itUse . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
& itUse . eqEq . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
overCID f _ cr = creatures . ix (_crID cr) %~ f
+3 -3
View File
@@ -36,13 +36,13 @@ import qualified Data.Set as S
import qualified SDL
autoEffect :: (Item -> Creature -> World -> World) -> Int -> SoundID -> Item -> Creature -> World -> World
autoEffect eff t sid itm cr w
| _eparamInt (_eqParams (_itUse itm)) < 1 = eff itm cr w
| _eparamInt (_eqParams (_eqEq $ _itUse itm)) < 1 = eff itm cr w
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
. itUse . eqParams . eparamInt .~ t
. itUse . eqEq . eqParams . eparamInt .~ t
& soundStart OnceSound (_crPos cr) sid Nothing
| otherwise = w
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
. itUse . eqParams . eparamInt -~ 1
. itUse . eqEq . eqParams . eparamInt -~ 1
{- | Automatically send out radar pulses that detect walls. -}
autoRadarEffect :: Item -> Creature -> World -> World
+4 -3
View File
@@ -47,9 +47,10 @@ autoDetector dt = defaultEquipment
-- , _itEffect = autoRadarEffect
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnWrist
& itUse . eqUse .~ autoEffect (detectorEffect dt) 100 click1S
& itUse . eqParams .~ EquipCounter 0
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqUse .~ autoEffect (detectorEffect dt) 100 click1S
& itUse . eqEq . eqParams .~ EquipCounter 0
& itUse . eqEq . eqViewDist ?~ 350
detectorColor :: Detector -> Color
detectorColor dt = case dt of
+3 -2
View File
@@ -32,7 +32,7 @@ rewindGun = defaultGun
, _itEffect = ItRewindEffect rewindEffect []
, _itUse = defaultlUse
& lUse .~ useRewindGun
& eqSite .~ GoesOnChest
& eqEq . eqSite .~ GoesOnChest
}
rewindEffect :: Item -> Creature -> World -> World
rewindEffect itm cr w
@@ -106,7 +106,7 @@ blinkGun = defaultGun
, _itUse = defaultlUse
& lUse .~ hammerCheckL (shootL $ const blinkAction)
& useHammer .~ upHammer
& eqSite .~ GoesOnWrist
& eqEq . eqSite .~ GoesOnWrist
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
@@ -115,6 +115,7 @@ unsafeBlinkGun = blinkGun
& itName .~ "BLINKER-UNSAFE"
& itType .~ BLINKERUNSAFE
& itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . eqEq . eqViewDist ?~ 400
effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun