Start allowing for more granular control of remote projectiles, cleanup

This commit is contained in:
2024-12-26 10:16:18 +00:00
parent ae557f3fd4
commit 53c981718c
14 changed files with 273 additions and 218 deletions
+1
View File
@@ -247,6 +247,7 @@ inventoryX c = case c of
, megaShellMag , megaShellMag
, homingModule , homingModule
, remoteScreen , remoteScreen
, remoteController
, remoteDetonator , remoteDetonator
, launcherX 3 , launcherX 3
, megaShellMag , megaShellMag
+2
View File
@@ -21,6 +21,7 @@ data ComposeLinkType
| AmmoEffectLink | AmmoEffectLink
| WeaponScopeLink | WeaponScopeLink
| WeaponTargetingLink | WeaponTargetingLink
| RemoteControllerLink
| RemoteScreenLink | RemoteScreenLink
| RemoteDetonatorLink | RemoteDetonatorLink
| AugmentedHUDLink | AugmentedHUDLink
@@ -38,6 +39,7 @@ data ItemStructuralFunction
| AugmentedHUDSF | AugmentedHUDSF
| AmmoMagSF AmmoType | AmmoMagSF AmmoType
| RemoteScreenSF | RemoteScreenSF
| RemoteControllerSF
| RemoteDetonatorSF | RemoteDetonatorSF
| UncomposableIsolateSF | UncomposableIsolateSF
| AmmoModifierSF AmmoType | AmmoModifierSF AmmoType
+1
View File
@@ -70,6 +70,7 @@ data AttachType
= ZOOMSCOPE = ZOOMSCOPE
| BULLETSYNTH | BULLETSYNTH
| REMOTESCREEN | REMOTESCREEN
| REMOTECONTROLLER
| REMOTEDETONATOR | REMOTEDETONATOR
| HOMINGMODULE | HOMINGMODULE
| AUGMENTEDHUD | AUGMENTEDHUD
+4 -1
View File
@@ -33,7 +33,10 @@ data ProjectileUpdate
| ReduceSpinPU {_pjuReduceSpin :: Float} | ReduceSpinPU {_pjuReduceSpin :: Float}
| DestroyPU {_pjuScreenID :: Maybe (NewInt ItmInt), _pjuTimer :: Int} | DestroyPU {_pjuScreenID :: Maybe (NewInt ItmInt), _pjuTimer :: Int}
| TimePU | TimePU
| CollisionEffectPU {_pjuScreenID :: Maybe (NewInt ItmInt)} | CollisionEffectPU {_pjuControlID :: Maybe (NewInt ItmInt)
,_pjuDetonatorID :: Maybe (NewInt ItmInt)
,_pjuScreenID :: Maybe (NewInt ItmInt)
}
deriving (Show, Eq, Ord, Read) --Generic, Flat) deriving (Show, Eq, Ord, Read) --Generic, Flat)
data AmmoType data AmmoType
+6 -2
View File
@@ -593,7 +593,7 @@ determineProjectileTracking ::
LabelDoubleTree ComposeLinkType Item -> LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree ComposeLinkType Item -> LabelDoubleTree ComposeLinkType Item ->
ProjectileHoming ProjectileHoming
determineProjectileTracking magtree itmtree = case lookup RemoteScreenLink (magtree ^. ldtLeft) of determineProjectileTracking magtree itmtree = case lookup RemoteControllerLink (magtree ^. ldtLeft) of
Just screen -> HomeUsingRemoteScreen (screen ^. ldtValue . itID) Just screen -> HomeUsingRemoteScreen (screen ^. ldtValue . itID)
Nothing -> fromMaybe NoHoming $ do Nothing -> fromMaybe NoHoming $ do
_ <- lookup AmmoTargetingLink (magtree ^. ldtLeft) -- should not have to give a direction _ <- lookup AmmoTargetingLink (magtree ^. ldtLeft) -- should not have to give a direction
@@ -611,10 +611,14 @@ createProjectile magtree muz itmtree cr = fromMaybe failsound $ do
magid <- magtree ^? ldtValue . itLocation . ilInvID magid <- magtree ^? ldtValue . itLocation . ilInvID
ammoitem <- cr ^? crInv . ix magid ammoitem <- cr ^? crInv . ix magid
let homing = determineProjectileTracking magtree itmtree let homing = determineProjectileTracking magtree itmtree
rdetonate = fmap (^. ldtValue . itID) $
lookup RemoteDetonatorLink (magtree ^. ldtLeft)
rscreen = fmap (^. ldtValue . itID) $
lookup RemoteScreenLink (magtree ^. ldtLeft)
aparams <- ((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload)) aparams <- ((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
<|> ammoitem ^? itConsumables . magParams . ampPayload <|> ammoitem ^? itConsumables . magParams . ampPayload
return $ return $
createShell homing aparams muz cr createShell homing rdetonate rscreen aparams muz cr
. startthesound . startthesound
where where
-- the sound should be moved to the projectile firing -- the sound should be moved to the projectile firing
+1
View File
@@ -39,6 +39,7 @@ itemFromAttachType at = case at of
ZOOMSCOPE -> zoomScope ZOOMSCOPE -> zoomScope
BULLETSYNTH -> bulletSynthesizer BULLETSYNTH -> bulletSynthesizer
REMOTESCREEN -> remoteScreen REMOTESCREEN -> remoteScreen
REMOTECONTROLLER -> remoteController
REMOTEDETONATOR -> remoteDetonator REMOTEDETONATOR -> remoteDetonator
-- ROCKETHOMER -> rocketHomer -- ROCKETHOMER -> rocketHomer
HOMINGMODULE -> homingModule HOMINGMODULE -> homingModule
+19 -18
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Item.Display ( module Dodge.Item.Display (
itemDisplay, itemDisplay,
itemBaseName, itemBaseName,
@@ -13,6 +14,10 @@ import LensHelp
import Padding import Padding
import ShortShow import ShortShow
-- Principles: base names should identify an item, numbers can change based on a
-- variety of factors but typically don't depend on functional quality,
-- colour gives an indication of an item's function within a structure
itemDisplay :: Creature -> ComposedItem -> [String] itemDisplay :: Creature -> ComposedItem -> [String]
itemDisplay cr ci = itemDisplay cr ci =
zipWithDefaults zipWithDefaults
@@ -39,7 +44,7 @@ itemDisplayPad ls rs
basicItemDisplay :: Item -> [String] basicItemDisplay :: Item -> [String]
basicItemDisplay itm = basicItemDisplay itm =
Prelude.take (itInvHeight itm) $ Prelude.take (itInvHeight itm) $
itemBaseName itm : itemBaseName (itm ^. itType) :
--catMaybes [maybeWarmupStatus itm, maybeRateStatus itm] --catMaybes [maybeWarmupStatus itm, maybeRateStatus itm]
catMaybes [maybeWarmupStatus itm] catMaybes [maybeWarmupStatus itm]
++ repeat "*" ++ repeat "*"
@@ -47,36 +52,28 @@ basicItemDisplay itm =
itemString :: Item -> String itemString :: Item -> String
itemString = head . basicItemDisplay itemString = head . basicItemDisplay
itemBaseName :: Item -> String -- this should be immutable with the item type
itemBaseName itm = case _itType itm of itemBaseName :: ItemType -> String
itemBaseName = \case
CRAFT str -> show str CRAFT str -> show str
HELD hit -> case hit ^? xNum of HELD hit -> case hit ^? xNum of
Just i -> takeWhile (/= ' ') (show hit) ++ show i Just i -> takeWhile (/= ' ') (show hit) ++ show i
Nothing -> show hit Nothing -> show hit
EQUIP eit -> showEquipItem eit EQUIP eit -> showEquipItem eit
ATTACH ait -> showAttachItem ait itm ATTACH ait -> showAttachItem ait
AMMOMAG ait -> show ait AMMOMAG ait -> show ait
TARGETING tt -> show tt TARGETING tt -> show tt
-- BULLETMOD (BulletModTrajectory btt) -> show btt -- BULLETMOD (BulletModTrajectory btt) -> show btt
BULLETMOD (BulletModPayload btt) -> show btt BULLETMOD (BulletModPayload btt) -> show btt
BULLETMOD (BulletModEffect btt) -> show btt BULLETMOD (BulletModEffect btt) -> show btt
showAttachItem :: AttachType -> Item -> String showAttachItem :: AttachType -> String
showAttachItem t itm = case t of showAttachItem t = case t of
ZOOMSCOPE -> "ZOOMSCOPE" ZOOMSCOPE -> "ZOOMSCOPE"
BULLETSYNTH -> "BSYNTH" BULLETSYNTH -> "BSYNTH"
REMOTESCREEN -> REMOTESCREEN -> "REM.SCREEN"
"REMOTE SCREEN " REMOTECONTROLLER -> "REM.CONTR0LR"
++ maybe REMOTEDETONATOR -> "REM.DETONATR"
mempty
show
(itm ^? itUse . uaParams . apLinkedProjectile . _Just)
REMOTEDETONATOR ->
"REM.DETONATOR"
++ maybe
mempty
show
(itm ^? itUse . uaParams . apLinkedProjectile . _Just)
HOMINGMODULE -> "HOMING MOD" HOMINGMODULE -> "HOMING MOD"
AUGMENTEDHUD -> "AUGMENTED HUD" AUGMENTEDHUD -> "AUGMENTED HUD"
SHELLPAYLOAD x -> show x SHELLPAYLOAD x -> show x
@@ -86,6 +83,9 @@ showEquipItem eit = case eit of
INVISIBILITYEQUIPMENT esite -> "INVISIBILITY " ++ show esite INVISIBILITYEQUIPMENT esite -> "INVISIBILITY " ++ show esite
_ -> show eit _ -> show eit
-- this can change, but probably won't when (say) dropped and then picked up
-- again
-- that is to say, it should not change based on functional positioning
itemNumberDisplay :: Creature -> ComposedItem -> [String] itemNumberDisplay :: Creature -> ComposedItem -> [String]
itemNumberDisplay cr ci itemNumberDisplay cr ci
| EQUIP WRIST_ECG <- ci ^. _1 . itType = | EQUIP WRIST_ECG <- ci ^. _1 . itType =
@@ -98,6 +98,7 @@ itemNumberDisplay cr ci
["!TARG!"] ["!TARG!"]
| Just x <- ci ^? _1 . itConsumables . magLoadStatus . iaLoaded = [shortShow x] | Just x <- ci ^? _1 . itConsumables . magLoadStatus . iaLoaded = [shortShow x]
| UseAttach (APInt i) <- ci ^. _1 . itUse = [show i] | UseAttach (APInt i) <- ci ^. _1 . itUse = [show i]
| UseAttach (APLinkProjectile i) <- ci ^. _1 . itUse = [show i]
| UseScope OpticScope{_opticZoom = x} <- ci ^. _1 . itUse = [shortShow x] | UseScope OpticScope{_opticZoom = x} <- ci ^. _1 . itUse = [shortShow x]
| otherwise = mempty | otherwise = mempty
+2
View File
@@ -67,6 +67,7 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
let screenanddet = case atype of let screenanddet = case atype of
LauncherAmmo -> [ (RemoteScreenSF, RemoteScreenLink) LauncherAmmo -> [ (RemoteScreenSF, RemoteScreenLink)
, (RemoteDetonatorSF, RemoteDetonatorLink) , (RemoteDetonatorSF, RemoteDetonatorLink)
, (RemoteControllerSF, RemoteControllerLink)
] ]
_ -> [] _ -> []
return return
@@ -106,6 +107,7 @@ itemToFunction itm = case itm ^. itType of
AmmoMagSF amtype AmmoMagSF amtype
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType
ATTACH REMOTESCREEN -> RemoteScreenSF ATTACH REMOTESCREEN -> RemoteScreenSF
ATTACH REMOTECONTROLLER -> RemoteControllerSF
ATTACH REMOTEDETONATOR -> RemoteDetonatorSF ATTACH REMOTEDETONATOR -> RemoteDetonatorSF
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
ATTACH ZOOMSCOPE -> WeaponScopeSF ATTACH ZOOMSCOPE -> WeaponScopeSF
+1
View File
@@ -18,6 +18,7 @@ itemInvColor ci = case ci ^. _2 of
AugmentedHUDSF -> rose AugmentedHUDSF -> rose
AmmoMagSF{} -> red AmmoMagSF{} -> red
RemoteScreenSF -> azure RemoteScreenSF -> azure
RemoteControllerSF -> azure
RemoteDetonatorSF -> azure RemoteDetonatorSF -> azure
UncomposableIsolateSF -> greyN 0.5 UncomposableIsolateSF -> greyN 0.5
AmmoModifierSF{} -> orange AmmoModifierSF{} -> orange
+5
View File
@@ -3,6 +3,7 @@ module Dodge.Item.Scope (
zoomScope, zoomScope,
targetingScope, targetingScope,
remoteScreen, remoteScreen,
remoteController,
remoteDetonator, remoteDetonator,
homingModule, homingModule,
-- bulletTargetingModule, -- bulletTargetingModule,
@@ -61,3 +62,7 @@ remoteScreen = makeAttach REMOTESCREEN
remoteDetonator :: Item remoteDetonator :: Item
remoteDetonator = makeAttach REMOTEDETONATOR remoteDetonator = makeAttach REMOTEDETONATOR
& itUse . uaParams .~ APLinkProjectile Nothing & itUse . uaParams .~ APLinkProjectile Nothing
remoteController :: Item
remoteController = makeAttach REMOTECONTROLLER
& itUse . uaParams .~ APLinkProjectile Nothing
+15 -3
View File
@@ -2,6 +2,9 @@ module Dodge.Projectile.Create (
createShell, createShell,
) where ) where
import NewInt
--import Dodge.Data.ComposedItem
--import Dodge.Data.DoubleTree
import Dodge.Item.Location import Dodge.Item.Location
import Data.Maybe import Data.Maybe
import Dodge.Data.World import Dodge.Data.World
@@ -16,9 +19,13 @@ homingDrawType ht = case ht of
HomeUsingTargeting {} -> DrawRemoteShell HomeUsingTargeting {} -> DrawRemoteShell
-- assumes the mscreen is in your inventory -- assumes the mscreen is in your inventory
createShell :: ProjectileHoming -> Payload -> Muzzle -> Creature -> World -> World createShell :: ProjectileHoming
createShell homing payload muz cr w = w -> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt)
-> Payload -> Muzzle -> Creature -> World -> World
createShell homing mdetonator mscreen payload muz cr w = w
& updatescreen & updatescreen
& updatedetonator
& cWorld . lWorld . projectiles . at i & cWorld . lWorld . projectiles . at i
?~ Shell ?~ Shell
{ _prjPos = pos { _prjPos = pos
@@ -33,7 +40,7 @@ createShell homing payload muz cr w = w
, _prjPayload = payload , _prjPayload = payload
, _prjTimer = 350 , _prjTimer = 350
, _prjUpdates = , _prjUpdates =
[ CollisionEffectPU (homing ^? phRemoteID) --Just screenid) [ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen
, TimePU , TimePU
, StartSpinPU 335 (_crID cr) spinamount , StartSpinPU 335 (_crID cr) spinamount
, RemoteDirectionPU (350 - thrustdelay) 0 homing , RemoteDirectionPU (350 - thrustdelay) 0 homing
@@ -45,6 +52,11 @@ createShell homing payload muz cr w = w
spindrag = 1 spindrag = 1
spinamount = 2 spinamount = 2
thrustdelay = 20 thrustdelay = 20
updatedetonator = fromMaybe id $ do
screenid <- mdetonator
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
updatescreen = fromMaybe id $ do updatescreen = fromMaybe id $ do
screenid <- homing ^? phRemoteID screenid <- homing ^? phRemoteID
return $ pointerToItemID screenid . itUse . uaParams return $ pointerToItemID screenid . itUse . uaParams
+24 -8
View File
@@ -25,8 +25,8 @@ updateProjectile pj w = foldl' (\w' pu -> upProjectile pu pj w') w (_prjUpdates
upProjectile :: ProjectileUpdate -> Projectile -> World -> World upProjectile :: ProjectileUpdate -> Projectile -> World -> World
upProjectile pu pj = case pu of upProjectile pu pj = case pu of
CollisionEffectPU mscreenid -> shellCollisionCheck CollisionEffectPU mcontrolid mdetonatorid mscreenid -> shellCollisionCheck
mscreenid pj mcontrolid mdetonatorid mscreenid pj
TimePU -> decTimMvVel pj TimePU -> decTimMvVel pj
ThrustPU st et ThrustPU st et
| act st et -> doThrust pj | act st et -> doThrust pj
@@ -47,14 +47,17 @@ upProjectile pu pj = case pu of
act st et = time <= st && time >= et act st et = time <= st && time >= et
--shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World --shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
shellCollisionCheck :: Maybe (NewInt ItmInt) -> Projectile -> World -> World shellCollisionCheck :: Maybe (NewInt ItmInt)
shellCollisionCheck f pj w -> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt)
-> Projectile -> World -> World
shellCollisionCheck controlid detid screenid pj w
| time > 330 && circOnSomeWall oldPos 4 w = g | time > 330 && circOnSomeWall oldPos 4 w = g
| time <= 330 && anythingHitCirc 2 oldPos newPos w = g | time <= 330 && anythingHitCirc 2 oldPos newPos w = g
| time <= 0 = g | time <= 0 = g
| otherwise = w | otherwise = w
where where
g = explodeShell f pj w g = explodeShell controlid detid screenid pj w
time = _prjTimer pj time = _prjTimer pj
oldPos = _prjPos pj oldPos = _prjPos pj
newPos = oldPos +.+ _prjVel pj newPos = oldPos +.+ _prjVel pj
@@ -154,12 +157,25 @@ decTimMvVel pj =
vel = _prjVel pj vel = _prjVel pj
pjid = _prjID pj pjid = _prjID pj
explodeShell :: Maybe (NewInt ItmInt) -> Projectile -> World -> World explodeShell :: Maybe (NewInt ItmInt) ->
explodeShell mitid pj w = Maybe (NewInt ItmInt) ->
Maybe (NewInt ItmInt) ->
Projectile -> World -> World
explodeShell controlid mdetid screenid pj w =
w w
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU mitid 30] & cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU screenid 30]
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile & cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
& usePayload (_prjPayload pj) (_prjPos pj) (_prjVel pj) & usePayload (_prjPayload pj) (_prjPos pj) (_prjVel pj)
& stopSoundFrom (ShellSound pjid) & stopSoundFrom (ShellSound pjid)
& updatedetonator
& updatecontroller
where where
updatedetonator = fromMaybe id $ do
detid <- mdetid
return $ pointerToItemID detid . itUse . uaParams . apLinkedProjectile %~ deleteif
deleteif (Just x) | x == pjid = Nothing
deleteif x = x
updatecontroller = fromMaybe id $ do
cid <- controlid
return $ pointerToItemID cid . itUse . uaParams . apLinkedProjectile %~ deleteif
pjid = pj ^. prjID pjid = pj ^. prjID
+2 -2
View File
@@ -289,8 +289,8 @@ drawRBOptions cfig w = fromMaybe mempty $ do
| a == b - 1 = listCursorChooseBorderScale 0 1 (bc South) curpos 0 white 7 1 | a == b - 1 = listCursorChooseBorderScale 0 1 (bc South) curpos 0 white 7 1
| otherwise = mempty | otherwise = mempty
otheritem j = fromMaybe "" $ do otheritem j = fromMaybe "" $ do
itm <- you w ^? crInv . ix j itype <- you w ^? crInv . ix j . itType
return $ itemBaseName itm return $ itemBaseName ittype
equipAllocString :: EquipmentAllocation -> String equipAllocString :: EquipmentAllocation -> String
equipAllocString = \case equipAllocString = \case
+190 -184
View File
File diff suppressed because it is too large Load Diff