Add compass item

This commit is contained in:
2026-04-14 21:07:46 +01:00
parent ce8ddc6414
commit 02e26c368c
9 changed files with 31 additions and 4 deletions
+2 -1
View File
@@ -3,6 +3,7 @@
module Dodge.Data.ComposedItem where
import Color.Data
import Control.Lens
import Dodge.Data.AmmoType
import Dodge.Data.Item
@@ -26,7 +27,7 @@ data ItemSF -- Structural Function
| JoystickSF
| RemoteDetonatorSF
| SmokeReducerSF
| NoSF
| NoSF Color
| AmmoModifierSF AmmoType
| AmmoTargetingSF AmmoType
| AmmoPayloadSF AmmoType
+1
View File
@@ -33,6 +33,7 @@ data ItemType
| DETECTOR {_ibtDetector :: Detector}
| ARHUD
| LASER
| COMPASS
deriving (Eq, Ord, Show, Read)
data InventoryPathing
+16
View File
@@ -8,6 +8,7 @@ module Dodge.Inventory.SelectionList (
getItemValue,
) where
import Geometry.Vector
import Dodge.Creature.MaxHP
import Dodge.Data.Equipment.Misc
import Numeric
@@ -83,6 +84,7 @@ itemExternalValue :: Item -> World -> Creature -> Maybe (Either Int String)
itemExternalValue itm w cr
| EQUIP WRIST_ECG <- itm ^. itType = Just . Right .
displayPulse $ cr ^?! crType . avatarPulse . pulseProgress
| COMPASS <- itm ^. itType = Just . Right . radToCompass . normalizeAngle $ w ^. wCam . camRot
| Just t <- itm ^? itType . ibtIntroScanType = Just $ introScanValue cr t
| ITEMSCAN <- itm ^. itType
, Just ExamineInventory <- w ^? hud . subInventory
@@ -106,6 +108,20 @@ itemExternalValue itm w cr
Just . Left $ ugateCalc x y
| otherwise = mempty
radToCompass :: Float -> String
radToCompass x
| x > f 7 = "N"
| x > f 6 = "NE"
| x > f 5 = "E"
| x > f 4 = "SE"
| x > f 3 = "S"
| x > f 2 = "SW"
| x > f 1 = "W"
| x > f 0 = "NW"
| otherwise = "N"
where
f i = i * pi / 4 + pi/8
ugateCalc :: Int -> Int -> Int
ugateCalc x y = (x `div` ((2::Int) ^ (f y ::Int))::Int) `mod` 2
where
+1
View File
@@ -38,6 +38,7 @@ itemFromBase = \case
UNIGATE -> unigate
BINGATE -> bingate
LASER -> laser
COMPASS -> compass
itemFromAmmoMag :: AmmoMagType -> Item
itemFromAmmoMag at = case at of
+1
View File
@@ -82,6 +82,7 @@ itemBaseName = \case
UNIGATE -> "UNIGATE"
NULGATE -> "NULGATE"
LASER -> "LASER"
COMPASS -> "COMPASS"
showInventoryPathing :: InventoryPathing -> String
showInventoryPathing = \case
+1
View File
@@ -36,6 +36,7 @@ itemSPic it = case it ^. itType of
UNIGATE -> defSPic
NULGATE -> defSPic
LASER -> lasGunPic it
COMPASS -> defSPic
craftItemSPic :: CraftType -> Shape
craftItemSPic = \case
+4 -2
View File
@@ -9,6 +9,7 @@ module Dodge.Item.Grammar (
invIndents,
) where
import Color
import NewInt
import Dodge.Item.Orientation
import Dodge.ItemUseCondition
@@ -122,7 +123,7 @@ itemToFunction itm = case itm ^. itType of
_ | Just amtype <- magAmmoType itm-- ^? itConsumables . magType
, Just _ <- itm ^? itLocation . ilEquipSite . _Just ->
AmmoMagSF 0 amtype
AMMOMAG{} -> maybe NoSF (AmmoMagSF 0) $ magAmmoType itm -- ^? itConsumables . magType
AMMOMAG{} -> maybe (NoSF (greyN 0.5)) (AmmoMagSF 0) $ magAmmoType itm -- ^? itConsumables . magType
ATTACH REMOTESCREEN -> RemoteScreenSF
ATTACH JOYSTICK -> JoystickSF
ATTACH REMOTEDETONATOR -> RemoteDetonatorSF
@@ -143,7 +144,8 @@ itemToFunction itm = case itm ^. itType of
ATTACH CAPACITOR -> CapacitorSF
CRAFT TRANSFORMER -> TransformerSF
CRAFT PUMP -> PumpSF
_ -> NoSF
COMPASS -> NoSF white
_ -> NoSF $ greyN 0.5
treeToPotentialFunction :: DTree CItem -> S.Set ItemSF
treeToPotentialFunction ldt = case ldt ^. dtValue . _1 . itType of
+4
View File
@@ -2,6 +2,7 @@ module Dodge.Item.Held.BatteryGuns (
teslaCoil,
laser,
tractorGun,
compass,
) where
import Control.Lens
@@ -35,6 +36,9 @@ laser =
}
& itType .~ LASER
compass :: Item
compass = defHeldItem & itType .~ COMPASS
-- previous attractionPower values: 1, -1, -10, 0
tractorGun :: Item
tractorGun = defHeldItem & itType .~ HELD TRACTORGUN
+1 -1
View File
@@ -29,7 +29,7 @@ sfInvColor = \case
JoystickSF -> azure
RemoteDetonatorSF -> azure
SmokeReducerSF -> azure
NoSF -> greyN 0.5
NoSF c -> c
AmmoModifierSF{} -> orange
AmmoTargetingSF{} -> green
AmmoPayloadSF{} -> violet