Work on weapon positioning, analyser terminal positioning

This commit is contained in:
2026-03-31 13:16:24 +01:00
parent ab04516279
commit 6bcf03b30d
18 changed files with 252 additions and 178 deletions
+9
View File
@@ -3,8 +3,12 @@ module Dodge.Base.You
, yourInv
, yourSelectedItem
, yourRootItem
, yourRootItemDT
)where
import Dodge.Item.Grammar
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import NewInt
import Dodge.Data.World
--import qualified IntMapHelp as IM
@@ -25,6 +29,11 @@ yourRootItem w = do
j <- _crInv (you w) ^? ix i
w ^? cWorld . lWorld . items . ix j
yourRootItemDT :: World -> Maybe (DTree OItem)
yourRootItemDT w = do
i <- you w ^? crManipulation . manObject . imRootSelectedItem . unNInt
invIMDT ((\k -> w ^?! cWorld . lWorld . items . ix k) <$> you w ^. crInv) ^? ix i
yourInv :: World -> NewIntMap InvInt Item
yourInv w = fmap (\i -> w ^?! cWorld . lWorld . items . ix i) . _crInv . you $ w
+1 -1
View File
@@ -99,7 +99,7 @@ startCr =
& crInv .~ mempty
& crFaction .~ PlayerFaction
-- & crMvType .~ MvWalking yourDefaultSpeed
& crType .~ Avatar (PulseStatus 55 0) Flesh 50 50 50 3
& crType .~ Avatar (PulseStatus 55 0) Flesh 50 50 50 3 AvPosture
-- | Items you start with.
startInvList :: [Item]
+2
View File
@@ -65,6 +65,8 @@ rightHandPQ cr
| oneH cr = (V3 11 (-3) 20, Q.qID)
| twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 4 (-10) 0, Q.qz 1)
| twoFlat cr = (V3 4 (-8) 12, Q.qID)
-- | Just dt <- yourRootItemDT w
-- , Just as <- itemAimStance
| Just p <- crRightHandWall cr = (20 & _xy .~ p, Q.qID)
| otherwise = (handWalkingPos LeftForward (-8) cr, Q.qID)
-1
View File
@@ -5,7 +5,6 @@ import Dodge.Data.Creature.Misc
crMass :: CreatureType -> Float
crMass = \case
Avatar {} -> 10
AvatarDead -> 10
ChaseCrit {} -> 10
SwarmCrit -> 2
AutoCrit -> 10
-1
View File
@@ -8,7 +8,6 @@ import Dodge.Data.Material
crMaterial :: CreatureType -> Material
crMaterial = \case
Avatar{_avatarMaterial = mt} -> mt
AvatarDead -> Flesh
ChaseCrit {} -> Flesh
SwarmCrit -> Flesh
AutoCrit -> Flesh
-1
View File
@@ -6,7 +6,6 @@ import Dodge.Data.Creature.Misc
crMaxHP :: CreatureType -> Int
crMaxHP = \case
Avatar {} -> 15000
AvatarDead -> 0
ChaseCrit {} -> 150
SwarmCrit -> 50
AutoCrit -> 100
-1
View File
@@ -6,7 +6,6 @@ import Dodge.Data.Creature
crMvType :: Creature -> CrMvType
crMvType cr = case _crType cr of
Avatar {_avMoveSpeed = s} -> MvWalking s
AvatarDead -> defaultAimMvType
ChaseCrit {} -> defaultChaseMvType
SwarmCrit -> defaultChaseMvType
AutoCrit -> defaultAimMvType
-1
View File
@@ -8,7 +8,6 @@ crRad :: CreatureType -> Float
{-# INLINE crRad #-}
crRad = \case
Avatar {} -> 10
AvatarDead -> 10
ChaseCrit {} -> 10
SwarmCrit -> 2
AutoCrit -> 10
-1
View File
@@ -11,6 +11,5 @@ crShape = \case
ChaseCrit {} -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3) ChaseAI
SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3) SwarmAI
AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3) AutoAI
AvatarDead -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3) InanimateAI
BarrelCrit {} -> Barreloid
LampCrit {} -> NonDrawnCreature
-3
View File
@@ -19,7 +19,6 @@ import qualified Data.IntSet as IS
crDexterity :: Creature -> Int
crDexterity cr = case cr ^. crType of
Avatar { _avDexterity = x } -> x
AvatarDead -> 0
ChaseCrit {} -> 46
SwarmCrit -> 46
AutoCrit -> 46
@@ -29,7 +28,6 @@ crDexterity cr = case cr ^. crType of
crStrength :: Creature -> Int
crStrength cr = case cr ^. crType of
Avatar { _avStrength = x } -> x
AvatarDead -> 0
ChaseCrit {} -> 46
SwarmCrit -> 40
AutoCrit -> 46
@@ -39,7 +37,6 @@ crStrength cr = case cr ^. crType of
crIntelligence :: Creature -> Int
crIntelligence cr = case cr ^. crType of
Avatar { _avIntelligence = x } -> x
AvatarDead -> 0
ChaseCrit {} -> 20
SwarmCrit -> 20
AutoCrit -> 20
-1
View File
@@ -53,7 +53,6 @@ updateLivingCreature cr =
. yourControl cr
LampCrit{} -> updateLampoid cr
BarrelCrit bt -> updateBarreloid bt cr
AvatarDead -> id
ChaseCrit{} -> \w ->
crUpdate cid . performActions cid $
over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
-3
View File
@@ -16,7 +16,6 @@ import System.Random
crVocalizationSound :: Creature -> Maybe SoundID
crVocalizationSound cr = case cr ^. crType of
Avatar{} -> Nothing
AvatarDead -> Nothing
ChaseCrit{} -> Just seagullChatterS
SwarmCrit -> Nothing
AutoCrit -> Nothing
@@ -26,7 +25,6 @@ crVocalizationSound cr = case cr ^. crType of
crWarningSounds :: Creature -> [SoundID]
crWarningSounds cr = case cr ^. crType of
Avatar{} -> mempty
AvatarDead -> mempty
ChaseCrit{} ->
[ seagullBarkS
, seagullChatterS
@@ -45,7 +43,6 @@ crWarningSounds cr = case cr ^. crType of
crDeathSounds :: Creature -> DeathType -> [SoundID]
crDeathSounds cr dt = case cr ^. crType of
Avatar{} -> mempty
AvatarDead -> mempty
ChaseCrit{} -> defaultDeathSounds dt
SwarmCrit -> mempty
AutoCrit -> mempty
+4 -1
View File
@@ -63,14 +63,16 @@ data CreatureType
, _avDexterity :: Int
, _avIntelligence :: Int
, _avMoveSpeed :: Float
, _avPosture :: AvatarPosture
}
| AvatarDead
| ChaseCrit {_meleeCooldown :: Int}
| SwarmCrit
| AutoCrit
| BarrelCrit {_barrelType :: BarrelType}
| LampCrit {_lampHeight :: Float, _lampColor :: Point3, _lampLSID :: Maybe Int}
data AvatarPosture = AvPosture
data CreatureShape
= Humanoid
{ _skinHead :: Color
@@ -102,4 +104,5 @@ deriveJSON defaultOptions ''Vocalization
--deriveJSON defaultOptions ''CrMvType
deriveJSON defaultOptions ''HumanoidAI
deriveJSON defaultOptions ''BarrelType
deriveJSON defaultOptions ''AvatarPosture
deriveJSON defaultOptions ''CreatureType
+2 -2
View File
@@ -31,8 +31,8 @@ data RoomLink = RoomLink
data RoomType
= DefaultRoomType
| RectRoomType
{ _numLinkEW :: Int
, _numLinkNS :: Int
{ _numLinkEW :: Int -- note this is ONE LESS than might be expected
, _numLinkNS :: Int -- note this is ONE LESS than might be expected
, _linkGapEW :: Float
, _linkGapNS :: Float
, _rmWidth :: Float
+4 -1
View File
@@ -17,6 +17,7 @@ module Dodge.Room.LasTurret (
storeRoomID,
) where
import Dodge.Room.Warning
import Dodge.Room.Modify
import Color
import Control.Monad
@@ -112,13 +113,15 @@ analyserByNthLink :: Int -> ProximityRequirement -> Int -> Placement
analyserByNthLink n proxreq i =
analyser
(SensorWithRequirement proxreq)
-- (byNthLink n)
( atNthLnkOutShiftBy
n
( \(p, a) ->
((p +.+ rotateV a (V2 18.5 (-2.5)), a), S.singleton UsedPosLow)
)
)
(atNthLnkOutShiftBy n sensorshift)
(byNthLink n)
-- (atNthLnkOutShiftBy n sensorshift)
& plExternalID
?~ i
where
+112 -53
View File
@@ -2,9 +2,8 @@
module Dodge.Room.Tutorial where
import Dodge.Room.Foreground
import Data.Foldable
import Control.Monad
import Data.Foldable
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.Maybe
@@ -26,6 +25,7 @@ import Dodge.Room.Airlock
import Dodge.Room.Boss
import Dodge.Room.Corridor
import Dodge.Room.Door
import Dodge.Room.Foreground
import Dodge.Room.LasTurret
import Dodge.Room.Link
import Dodge.Room.LongDoor
@@ -55,33 +55,35 @@ tutAnoTree = do
foldMTRS
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
, corDoor
, loadAmmoTut
, corDoor
, tToBTree "slowCrush" . return . cleatOnward <$> pushCaverns
, corDoor
, chasmSpitTerminal
--a , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a , corDoor
--a , tToBTree "sdr" . return . cleatOnward
--a <$> (shuffleLinks =<< distributerRoom BulletAmmo 100000)
--a , -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a -- --, tToBTree "sdr" . return . cleatOnward <$> slowDoorRoom
--a ---- , tToBTree "sr" . return . cleatOnward <$> tanksRoom [] []
--a -- , return $ tToBTree "door" $ return $ cleatOnward door
--a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a -- , tToBTree "sdr" . return . cleatOnward <$>
--a -- (shuffleLinks =<< tanksPipesRoom)
--a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a return $ tToBTree "door" $ return $ cleatOnward door
--a , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a , tutHub
--a , chasmSpitTerminal
--a , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a , tutLight
--a , tutDrop
--a , return $ tToBTree "cor" $ return $ cleatOnward corridor
--a ---- , AnTree $ pickupTut
--a ---- , AnTree $ weaponTut
-- a , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a , corDoor
-- a , tToBTree "sdr" . return . cleatOnward
-- a <$> (shuffleLinks =<< distributerRoom BulletAmmo 100000)
-- a , -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a -- --, tToBTree "sdr" . return . cleatOnward <$> slowDoorRoom
-- a ---- , tToBTree "sr" . return . cleatOnward <$> tanksRoom [] []
-- a -- , return $ tToBTree "door" $ return $ cleatOnward door
-- a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a -- , tToBTree "sdr" . return . cleatOnward <$>
-- a -- (shuffleLinks =<< tanksPipesRoom)
-- a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a return $ tToBTree "door" $ return $ cleatOnward door
-- a , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a , tutHub
-- a , chasmSpitTerminal
-- a , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a , tutLight
-- a , tutDrop
-- a , return $ tToBTree "cor" $ return $ cleatOnward corridor
-- a ---- , AnTree $ pickupTut
-- a ---- , AnTree $ weaponTut
]
foldMTRS ::
@@ -240,8 +242,8 @@ sqPlatformChasm b a =
sqSpitChasm :: Float -> Float -> ([[Point2]], [[Point2]])
sqSpitChasm b a =
( [[ibr, obr, otr, itr], [itr, otr, otl, itl], [itl, otl, obl, ibl]]
-- ( earClip clfs
, [clfs]
, -- ( earClip clfs
[clfs]
)
where
clfs = [ibr, obr, otr, otl, obl, ibl, itl, itr]
@@ -253,6 +255,7 @@ sqSpitChasm b a =
ibl = V2 (-b) (-a)
itl = V2 (-b) b
itr = V2 b b
-- otl---------otr
-- | itl-itr |
-- obr-ibl ibr-obl
@@ -272,15 +275,19 @@ midChasmSpit = do
isMidEdgeLink r North rl
|| isMidEdgeLink r East rl
|| isMidEdgeLink r West rl
, \rl -> OnEdge North `S.member` (rl ^. rlType)
&& not (FromEdge East 0 `S.member` (rl ^. rlType))
&& not (FromEdge West 0 `S.member` (rl ^. rlType))
, \rl ->
OnEdge North `S.member` (rl ^. rlType)
&& not (FromEdge East 0 `S.member` (rl ^. rlType))
&& not (FromEdge West 0 `S.member` (rl ^. rlType))
]
shuffleLinks $
r
& rmLinks %~ setOutLinks foutlnks
& rmLinks %~ setInLinks (isMidEdgeLink r South)
& rmPmnts .~ cs
& rmLinks
%~ setOutLinks foutlnks
& rmLinks
%~ setInLinks (isMidEdgeLink r South)
& rmPmnts
.~ cs
where
censquare x y = do
z <- state $ randomR (40, 60)
@@ -300,26 +307,31 @@ chasmSpitTerminal = do
i1 <- nextLayoutInt
y <- midChasmSpit
shp <- takeOne [vShape, lShape, jShape, liShape]
let l1 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> f rp North East
let l1 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> f rp North East
l2 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> f rp North West
l3 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> f rp East North
l3 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> f rp East North
l4 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> f rp East South
ls <- takeOne [[l1,l2],[l3,l4]
-- ,[spanLightI (V2 120 0) (V2 120 300)]
-- , [spanLightI (V2 0 128) (V2 300 128)]
-- , [spanLightI (V2 300 0) (V2 0 300), sps0 $ putShape $ thinHighBar 95 0 300]
]
gh <- takeOne [55,75,97]
gird <- takeOne [girderZ gh 30 10,girder gh 30 10,girderV gh 30 10]
dec <- takeOne $ replicate 3 [] <>
[[sps0 $ putShape $ gird (V2 30 0) (V2 30 300)]
,[sps0 $ putShape $ gird (V2 270 0) (V2 270 300)]
,[sps0 $ putShape $ gird (V2 30 0) (V2 30 300),sps0 $ putShape $ gird (V2 270 0) (V2 270 300)]
,[sps0 $ putShape $ gird (V2 0 20) (V2 300 20)]
,[sps0 $ putShape $ gird (V2 0 200) (V2 300 200)]
,[sps0 $ putShape $ gird (V2 0 280) (V2 300 280)]
,[sps0 $ putShape $ gird (V2 0 20) (V2 300 20),sps0 $ putShape $ gird (V2 0 280) (V2 300 280)]
ls <-
takeOne
[ [l1, l2]
, [l3, l4]
-- ,[spanLightI (V2 120 0) (V2 120 300)]
-- , [spanLightI (V2 0 128) (V2 300 128)]
-- , [spanLightI (V2 300 0) (V2 0 300), sps0 $ putShape $ thinHighBar 95 0 300]
]
gh <- takeOne [55, 75, 97]
gird <- takeOne [girderZ gh 30 10, girder gh 30 10, girderV gh 30 10]
dec <-
takeOne $
replicate 3 []
<> [ [sps0 $ putShape $ gird (V2 30 0) (V2 30 300)]
, [sps0 $ putShape $ gird (V2 270 0) (V2 270 300)]
, [sps0 $ putShape $ gird (V2 30 0) (V2 30 300), sps0 $ putShape $ gird (V2 270 0) (V2 270 300)]
, [sps0 $ putShape $ gird (V2 0 20) (V2 300 20)]
, [sps0 $ putShape $ gird (V2 0 200) (V2 300 200)]
, [sps0 $ putShape $ gird (V2 0 280) (V2 300 280)]
, [sps0 $ putShape $ gird (V2 0 20) (V2 300 20), sps0 $ putShape $ gird (V2 0 280) (V2 300 280)]
]
let y' = y & rmPmnts <>~ ls <> dec
return $
tToBTree "chasmTerm" $
@@ -330,8 +342,9 @@ chasmSpitTerminal = do
, return $ cleatOnward $ triggerDoorRoom i1
]
where
f rp a b = FromEdge a 2 `S.member` fold (rp ^? rpType . rplsType)
&& OnEdge b `S.member` fold (rp ^? rpType . rplsType)
f rp a b =
FromEdge a 2 `S.member` fold (rp ^? rpType . rplsType)
&& OnEdge b `S.member` fold (rp ^? rpType . rplsType)
polyChasm :: Int -> Float -> State LayoutVars Room
polyChasm n x =
@@ -409,6 +422,52 @@ tutLight = do
)
_ -> Nothing
loadAmmoTut :: State LayoutVars (MetaTree Room String)
loadAmmoTut = do
i <- nextLayoutInt
amrm <-
putSingleLight
. analyserByDoor (RequireEquipment (AMMOMAG DRUMMAG)) i
=<< shuffleLinks
=<< roomRectAutoLights 100 100
j <- nextLayoutInt
wprm <-
putSingleLight
. addDoorAtNthLinkToggleInterrupt 0 ["DOOR LOCKDOWN ACTIVE"] j
=<< shuffleLinks
=<< roomRectAutoLights 100 100
return $
tToBTree "loadAmmoTest" $
treeFromPost
[amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
, triggerDoorRoom i
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt burstRifle)
] (triggerDoorRoom j)
putSingleLight :: Room -> State LayoutVars Room
putSingleLight rm = do
f <- case rm ^. rmType of
DefaultRoomType -> pure id
RectRoomType{_rmWidth = x, _rmHeight = y, _numLinkEW = nx, _numLinkNS = ny} -> do
x' <-
if odd nx
then pure $ x / 2
else takeOne [x / 2 + 21, x / 2 - 21]
y' <-
if odd ny
then pure $ y / 2
else takeOne [y / 2 + 21, y / 2 - 21]
ps <-
takeOne
[ (V2 x' 0, V2 x' y)
, (V2 0 y', V2 x y')
]
return $ rmPmnts .:~ uncurry spanLightI ps
RoomNgon{_rmngonSize = x} -> do
y <- takeOne [21, -21]
return $ rmPmnts .:~ spanLightI (V2 (-x) y) (V2 x y)
return . f $ removeLights rm
tutHub :: State LayoutVars (MetaTree Room String)
tutHub = do
(is, wbp) <- setTreeInts =<< critsRoom 1
+5 -1
View File
@@ -5,6 +5,7 @@ module Dodge.Room.Warning (
addDoorToggleTerminal',
addDoorAtNthLinkToggleTerminal,
addDoorAtNthLinkToggleInterrupt,
byNthLink,
) where
import Dodge.LevelGen.PlacementHelper
@@ -40,6 +41,9 @@ warningRooms str n = do
addDoorToggleTerminal :: [TerminalLine] -> Int -> Room -> Room
addDoorToggleTerminal = addDoorAtNthLinkToggleTerminal 0
byNthLink :: Int -> PlacementSpot
byNthLink = rprShift . moveToSideNthOutLink (S.singleton UsedPosLow)
addDoorAtNthLinkToggleInterrupt :: Int -> [String] -> Int -> Room -> Room
addDoorAtNthLinkToggleInterrupt j x i =
(rmName .++~ "doorInterrupt-")
@@ -47,7 +51,7 @@ addDoorAtNthLinkToggleInterrupt j x i =
where
outplace =
extTrigLitPos
(atNthLnkOutShiftBy j (\(p, a) -> ((p +.+ rotateV a (V2 18.5 (-2.5)), a), S.singleton UsedPosLow)))
(atNthLnkOutShiftBy j (\(p, a) -> ((p + rotateV a (V2 18.5 (-2.5)), a), S.singleton UsedPosLow)))
( Just . set plSpot (rprShift (moveToSideNthOutLink (S.singleton UsedPosLow) j))
. putInterrupt
)