Improve starting weapon rooms

This commit is contained in:
2021-11-24 22:13:42 +00:00
parent 2c759cb40e
commit 4ad02f29b2
4 changed files with 16 additions and 21 deletions
+1
View File
@@ -35,6 +35,7 @@ data PSType = PutCrit {_unPutCrit :: Creature}
| PutNothing
| PutID { _putID :: Int}
-- maybe there is a monadic implementation of this?
-- add room effect for any placement spot?
data PlacementSpot
= PS { _psPos :: Point2 , _psRot :: Float }
| PSPos
+4
View File
@@ -17,6 +17,7 @@ module Dodge.Room.Link
, changeLinkFrom
, randomiseOutLinks
, chooseOneInLink
, restrictRMInLinksPD
) where
import Dodge.Placement.PlaceSpot
import Dodge.LevelGen.Data
@@ -35,6 +36,9 @@ import qualified Data.Set as S
chooseOneInLink :: RandomGen g => Room -> State g Room
chooseOneInLink r = restrictToFstInLink <$> shuffleLinks r
restrictRMInLinksPD :: ((Point2,Float) -> Bool) -> Room -> Room
restrictRMInLinksPD f = rmLinks %~ restrictLinkType InLink f
restrictToFstInLink :: Room -> Room
restrictToFstInLink = rmLinks %~ f
where
+1 -1
View File
@@ -70,7 +70,7 @@ roomRect x y xn yn = defaultRoom
lnks = m North nlnks ++ m East elnks ++ m West wlnks ++ m South slnks
m edge = map (lnkBothAnd (OnEdge edge))
pth = linksAndPath' lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
posps = map (+.+ V2 20 20) $ gridPoints xd xn yd yn
posps = map (+.+ V2 20 20) $ gridPoints xd (xn+1) yd (yn+1)
{- Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size. -}
-- it is not clear to me that this works for very small rooms (but it does seem
-- to do so)
+10 -20
View File
@@ -255,7 +255,6 @@ randFirstWeapon = do
++ replicate 2 autoGun
++ [launcher]
weaponEmptyRoom :: RandomGen g => State g (SubCompTree Room)
weaponEmptyRoom = do
w <- state $ randomR (220,300)
@@ -267,10 +266,9 @@ weaponEmptyRoom = do
--,sPS (V2 (w/2) (h/2)) 0 putLamp
,mntLightLnkCond unusedLnkToPS
]
treeFromTrunk [PassDown corridor]
<$> ((fmap singleUseAll . randomiseOutLinks) =<<
changeLinkTo ((\p -> dist p (V2 (w/2) 0) < 10) . fst) (set rmPmnts plmnts $ roomRect w h 2 2)
)
f (V2 x y,a) = (a == pi && x > 25 && x < w - 25) || (a /= 0 && y > w - 30)
rm <- shuffleLinks $ restrictRMInLinksPD f (roomRect w h 2 2 & rmPmnts .~ plmnts)
return $ treeFromTrunk [PassDown corridor] (singleUseAll rm )
weaponUnderCrits :: RandomGen g => State g (SubCompTree Room)
weaponUnderCrits = do
@@ -312,18 +310,10 @@ weaponBehindPillar = do
weaponBetweenPillars :: RandomGen g => State g (SubCompTree Room)
weaponBetweenPillars = do
wpPos <- takeOne [V2 x y | x <- [20,120,220], y <- [20,120,220]]
(ps,_) <- takeNMore 2 ([], [V2 x y | x <- [20,220], y <- [20,120,220]])
let crPos1:crPos2:_ = ps
d p = argV $ V2 120 120 -.- p
plmnts =
[sPS wpPos 0 $ RandPS randFirstWeapon
, sps (unusedSpotAwayFromInLink 150) randC1
, sps (unusedSpotAwayFromInLink 150) randC1
, sps (unusedSpotAwayFromInLink 150) randC1
, sps (unusedSpotAwayFromInLink 150) randC1
--,sPS crPos1 (d crPos1) randC1
--,sPS crPos2 (d crPos2) randC1
]
critPlacementSpots <- replicateM 2 $ randDirPS $ unusedSpotAwayFromInLink 100
let plmnts =
sPS wpPos 0 (RandPS randFirstWeapon) :
map (\ps -> sps ps randC1) critPlacementSpots
theRoom = roomPillars & rmPmnts %~ (++ plmnts)
(fmap singleUseAll . randomiseOutLinks) =<< filterLinks f theRoom
where
@@ -362,9 +352,9 @@ deadEndRoom = defaultRoom
weaponRoom :: RandomGen g => State g (SubCompTree Room)
weaponRoom = join $ takeOne
[-- weaponEmptyRoom
--, weaponUnderCrits
--, weaponBehindPillar
weaponBetweenPillars
weaponUnderCrits
-- weaponBehindPillar
-- weaponBetweenPillars
--, weaponLongCorridor
]