Use constructed laser as targeting scope

This commit is contained in:
2024-10-08 15:53:03 +01:00
parent da5a895f24
commit 9679f32618
21 changed files with 196 additions and 157 deletions
+35 -13
View File
@@ -1,14 +1,26 @@
module Dodge.Item.Ammo
where
module Dodge.Item.Ammo (
drumMag,
tinMag,
beltMag,
shellMag,
battery,
smallBattery,
chemFuelPouch,
bulletSynthesizer,
megaShellMag,
megaTinMag,
megaBattery,
) where
import Dodge.Item.Attach
import Control.Lens
import Dodge.Data.World
import Dodge.Default.Item
import Dodge.Item.Attach
import Dodge.Item.Weapon.Bullet
megaTinMag :: Int -> Item
megaTinMag x = tinMag
megaTinMag x =
tinMag
& itUse . amagLoadStatus . iaMax .~ x
& itUse . amagLoadStatus . iaLoaded .~ x
@@ -47,7 +59,8 @@ beltMag =
& itUse . amagType .~ BeltBulletAmmo
megaShellMag :: Item
megaShellMag = shellMag
megaShellMag =
shellMag
& itUse . amagLoadStatus . iaMax .~ 1000000
& itUse . amagLoadStatus . iaLoaded .~ 1000000
@@ -56,9 +69,10 @@ shellMag =
defaultHeldItem & itType .~ AMMOMAG SHELLMAG
& itUse
.~ UseAmmoMag
{ _amagParams = ProjectileParams
{ _ampPayload = ExplosionPayload
}
{ _amagParams =
ProjectileParams
{ _ampPayload = ExplosionPayload
}
, _amagLoadStatus =
ReloadStatus
{ _iaMax = 1
@@ -66,10 +80,18 @@ shellMag =
}
, _amagType = ProjectileAmmo
}
megaBattery :: Item
megaBattery = battery
& itUse . amagLoadStatus . iaMax .~ 1000000
& itUse . amagLoadStatus . iaLoaded .~ 1000000
megaBattery =
battery
& itUse . amagLoadStatus . iaMax .~ 1000000
& itUse . amagLoadStatus . iaLoaded .~ 1000000
smallBattery :: Item
smallBattery =
battery
& itUse . amagLoadStatus . iaMax .~ 999
& itUse . amagLoadStatus . iaLoaded .~ 999
battery :: Item
battery =
@@ -80,8 +102,8 @@ battery =
, _amagType = ElectricalAmmo
, _amagLoadStatus =
ReloadStatus
{ _iaMax = 10^ (9::Int)
, _iaLoaded = 10^ (9::Int)
{ _iaMax = 10 ^ (9 :: Int)
, _iaLoaded = 10 ^ (9 :: Int)
}
}
+9 -9
View File
@@ -200,7 +200,7 @@ heldItemSPic ht it = case ht of
BLOWTORCH -> flamerPic it
SPARKGUN -> teslaGunPic
TESLAGUN -> teslaGunPic
LASGUN -> lasGunPic it
LASER -> lasGunPic it
TRACTORGUN -> tractorGunPic it
LAUNCHER -> launcherPic it
LAUNCHERX _ -> launcherPic it
@@ -349,14 +349,14 @@ teslaGunPic :: SPic
teslaGunPic = shatterGunSPic
lasGunPic :: Item -> SPic
lasGunPic _ =
colorSH
blue
( upperBoxST 4 (rectNSWE 3 1 0 30)
<> upperBoxSU 4 (rectNSWE (-1) (-3) 0 30)
<> upperBoxSU 1 (rectNSWE 3 (-3) 0 30)
)
:!: mempty
lasGunPic _ = noPic $ colorSH blue $ upperPrismPolyST 3 $ square 4
-- colorSH
-- blue
-- ( upperBoxST 4 (rectNSWE 3 1 0 30)
-- <> upperBoxSU 4 (rectNSWE (-1) (-3) 0 30)
-- <> upperBoxSU 1 (rectNSWE 3 (-3) 0 30)
-- )
-- :!: mempty
--dualBeamPic :: Item -> SPic
--dualBeamPic it =
+9 -23
View File
@@ -1,7 +1,6 @@
module Dodge.Item.Grammar (
invLDT,
invTrees,
invIndentIM,
invAdj,
invRootMap,
invRootTrees,
@@ -89,7 +88,7 @@ pciToCI (x,y,_) = CItem x y
basePCI :: Item -> PartiallyComposedItem
basePCI itm = case _itType itm of
HELD LASGUN -> (itm, WeaponScopeSF, laserLinkTest itm)
HELD LASER -> (itm, WeaponTargetingSF, laserLinkTest itm)
_ -> (itm, itemToFunction itm, uncurry useBreakL $ itemToBreakLists itm)
laserLinkTest :: Item -> LinkTest
@@ -181,13 +180,6 @@ invAdj im = do
Right
$ itm ^? itLocation . ilInvID
invIndentIM :: IM.IntMap Item -> IM.IntMap (Item, Int, LabelDoubleTreeNodeType ComposeLinkType)
invIndentIM =
IM.fromDistinctAscList . zip [0 ..] . reverse . map (over _1 (^. _1))
. concatMap ldtToIndentList
. map (bimap _iatType (\(x, y, _) -> (x, y)))
. invLDT
-- returns an intmap with trees for all items
invTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ComposeLinkType Item)
invTrees = fmap (first _iatType) . invTrees'
@@ -200,23 +192,17 @@ invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . map (fmap (\(x,
fromMaybe (error "in invTrees try to get non-inventory item tree") $
i ^? itLocation . ilInvID
-- returns an intmap with trees for all items
--invTrees'' :: IM.IntMap Item -> [LocationLDT ItemLink ComposedItem]
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int,LocationLDT ItemLink ComposedItem)
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
where
f t = cldtPropagateFold h h g 0 t id
h x _ _ _ = x + 1
g x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x,ldt))
--invTrees'' = IM.unions . map (f . LocLDT TopLDT) . IM.elems . invRootTrees
-- where
-- f t = cldtPropagateFold h h g 0 t mempty
-- h x _ _ _ = x + 1
-- g x ldt = IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x,ldt)
-- returns an intmap with trees for root items, indexed by inventory position
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
invRootTrees = IM.fromDistinctAscList . reverse . map (getid . fmap (\(x, y, _) -> CItem x y)) . invLDT
where
getid :: LabelDoubleTree ItemLink ComposedItem -> (Int,LabelDoubleTree ItemLink ComposedItem)
getid t = (t ^?! ldtValue . cItem . itLocation . ilInvID, t)
-- returns an intmap with indents and locations for all items
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int,LocationLDT ItemLink ComposedItem)
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
where
f t = cldtPropagateFold h h g 0 t id
h x _ _ _ = x + 1
g x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x,ldt))
+1 -1
View File
@@ -54,7 +54,7 @@ itemFromHeldType ht = case ht of
BLOWTORCH -> blowTorch
SPARKGUN -> sparkGun
TESLAGUN -> teslaGun
LASGUN -> lasGun
LASER -> laser
-- LASCIRCLE -> lasCircle
-- DUALBEAM -> dualBeam
-- LASWIDE i -> lasWide i
+19 -7
View File
@@ -1,7 +1,7 @@
module Dodge.Item.Held.BatteryGuns
( sparkGun
, teslaGun
, lasGun
, laser
, tractorGun
) where
@@ -37,14 +37,14 @@ teslaGun =
& itUse . heldTriggerType .~ AutoTrigger
-- previous phaseV parameters: 0.2, 1, 5
lasGun :: Item
lasGun =
laser :: Item
laser =
defaultHeldItem
& itUse . heldParams .~ BeamShooterParams (Just (tone440sawtoothquietS,2))
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldDelay .~ NoDelay
& itUse . heldTriggerType .~ AutoTrigger
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 4 0
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ LasGunFlare
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleLaser
@@ -58,15 +58,27 @@ lasGun =
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandUnder
& itType .~ HELD LASGUN
& itType .~ HELD LASER
-- previous attractionPower values: 1, -1, -10, 0
tractorGun :: Item
tractorGun =
lasGun
& itUse . heldDelay .~ NoDelay
defaultHeldItem
& itUse . heldParams .~ BeamShooterParams (Just (tone440sawtoothquietS,2))
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldTriggerType .~ AutoTrigger
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itTargeting .~ ItTargeting
{ _itTgPos = Nothing
, _itTgID = Nothing
, _itTgActive = False
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ DefaultFlareType
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleTractor
& itType .~ HELD TRACTORGUN
+1 -4
View File
@@ -76,10 +76,7 @@ heldInfo hit = case hit of
BLOWTORCH -> "A weapon that produces a concentrated flame."
SPARKGUN -> "A weapon that produces an arc of electricity. The arc will attempt to discharge at a nearby object."
TESLAGUN -> "A weapon that discharges a sustained arc of electricity. The arc will attempt to discharge at a nearby object."
LASGUN -> "A weapon that continuously emits photons in a narrow beam."
-- LASCIRCLE -> "A extensive configuration of prisms and mirrors that produces multiple laser beams around its user."
-- DUALBEAM -> "A weapon that emits two beams that converge at a selectable point in front of the user."
-- LASWIDE _ -> "A weapon that continuously emits photons in a narrow beam. The beam expands as the weapon heats up."
LASER -> "A device that, when electrically powered, continuously emits photons in a narrow beam."
TRACTORGUN -> "An item that produces a beam of gravitons."
LAUNCHER -> "A large tube that can launch self propelled projectiles. Moving the tube after launch will cause the projectile to spin."
LAUNCHERX i -> over _head toUpper (showInt i) ++ " tubes that can launch self propelled projectiles. Tubes that do not face forward launch their projecitles at an angle."
+22 -1
View File
@@ -1,7 +1,9 @@
{-# LANGUAGE LambdaCase#-}
module Dodge.Item.InventoryColor
( itemInvColor
) where
--import Dodge.Data.Item.Use.Consumption.Ammo
import Dodge.Data.ComposedItem
import Color
import Control.Lens
@@ -9,7 +11,26 @@ import Control.Lens
itemInvColor :: ComposedItem -> Color
itemInvColor ci = case ci ^. cItemFunction of
WeaponPlatformSF -> white
_ -> greyN 0.8
WeaponScopeSF -> chartreuse
WeaponTargetingSF -> green
AugmentedHUDSF -> rose
AmmoMagSF {} -> red
RemoteScreenSF -> azure
UncomposableIsolateSF -> greyN 0.5
AmmoModifierSF {} -> orange
AmmoTargetingSF {} -> green
AmmoPayloadSF {} -> violet
AmmoEffectSF {} -> aquamarine
FunctionChangeSF -> yellow
--ammoTypeColor :: AmmoType -> Color
--ammoTypeColor = \case
-- BulletAmmo -> white
-- ProjectileAmmo -> red
-- BeltBulletAmmo -> orange
-- ElectricalAmmo -> blue
-- GasAmmo -> green
-- HELD {} -> white
-- LEFT {} -> cyan
-- EQUIP {} -> yellow
+1
View File
@@ -11,6 +11,7 @@ orientChild :: Item -> (Point3, Q.Quaternion Float)
orientChild itm = case _itType itm of
HELD TORCH -> (V3 0 5 0, Q.qID)
TARGETING TARGETLASER -> (V3 15 (-5) 0, Q.qID)
HELD LASER -> (V3 15 (-5) 0, Q.qID)
_ -> (0, Q.qID)
orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)