Improve pulse laser/ball hit detection
This commit is contained in:
@@ -150,7 +150,6 @@ chasmTestLiving cr w
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
--f = circInPolygon (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
f = pointInPoly (cr ^. crPos . _xy)
|
||||
|
||||
chasmTestCorpse :: Creature -> World -> World
|
||||
@@ -163,13 +162,11 @@ chasmTestCorpse cr w
|
||||
w
|
||||
& soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
|
||||
& tocr . crPos . _xy +~ normalizeV (vNormal (x - y))
|
||||
& chasmRotate cr (x - y)
|
||||
| any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5
|
||||
| otherwise = w
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
--f = circInPolygon (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
f = pointInPoly (cr ^. crPos . _xy)
|
||||
|
||||
chasmRotate :: Creature -> Point2 -> World -> World
|
||||
|
||||
@@ -54,7 +54,7 @@ itemBelowAttachables :: CItem -> [ItemSF]
|
||||
itemBelowAttachables (itm,sf) = case (itm ^. itType, sf) of
|
||||
(LASER, WeaponTargetingSF) -> getAmmoLinks itm
|
||||
(LASER, LaserWeaponSF) -> [PulseBallSF] <> getAmmoLinks itm
|
||||
(LASER, PulseBallSF) -> [PulseBallSF]
|
||||
-- (LASER, PulseBallSF) -> [PulseBallSF]
|
||||
--(HELD LASER, _) -> [PulseBallSF]
|
||||
(HELD LED, _) -> getAmmoLinks itm
|
||||
(ATTACH CAPACITOR, _) -> [AmmoMagSF 0 ElectricalAmmo]
|
||||
|
||||
@@ -65,7 +65,7 @@ refract phasev x y wl p
|
||||
reflectPulseLaserAlong ::
|
||||
Float -> Point2 -> Point2 -> World -> ([(Point2, Object)], [Point2])
|
||||
{-# INLINE reflectPulseLaserAlong #-}
|
||||
reflectPulseLaserAlong phasev sp ep w = f $ filter (isunshad . snd) $ crWlPbHit sp ep w
|
||||
reflectPulseLaserAlong phasev sp ep w = f $ filter (isunshad . snd) $ crWlPbHitZ 20 sp ep w
|
||||
where
|
||||
f = \case
|
||||
((p, OWall wl) : _)
|
||||
|
||||
@@ -25,13 +25,13 @@ lockRoomMultiItems =
|
||||
|
||||
lockRoomKeyItems :: [(Int -> State LayoutVars (MetaTree Room String), State LayoutVars ItemType)]
|
||||
lockRoomKeyItems =
|
||||
-- [ (lasCenSensEdge, takeOne [LASER,HELD TESLACOIL, HELD FLATSHIELD])
|
||||
-- , (sensorRoomRunPast LaserSensor, return LASER)
|
||||
-- [ (const slowDoorRoomRunPast, return $ HELD (MINIGUNX 3))
|
||||
-- [ (const longRoomRunPast, takeOne [HELD SNIPERRIFLE, HELD FLATSHIELD])
|
||||
-- [ (const glassLessonRunPast, takeOne [LASER])
|
||||
[ (const $ lasTunnelRunPast 400, takeOne [HELD FLATSHIELD])
|
||||
-- , (keyCardRoomRunPast 0, return (HELD $ KEYCARD 0))
|
||||
[ (lasCenSensEdge, takeOne [LASER,HELD TESLACOIL, HELD FLATSHIELD])
|
||||
, (sensorRoomRunPast LaserSensor, return LASER)
|
||||
, (const slowDoorRoomRunPast, return $ HELD (MINIGUNX 3))
|
||||
, (const longRoomRunPast, takeOne [HELD SNIPERRIFLE, HELD FLATSHIELD])
|
||||
, (const glassLessonRunPast, takeOne [LASER])
|
||||
, (const $ lasTunnelRunPast 400, takeOne [HELD FLATSHIELD])
|
||||
, (keyCardRoomRunPast 0, return (HELD $ KEYCARD 0))
|
||||
]
|
||||
|
||||
keyCardRunPastRand :: RandomGen g => [(Int -> State g (MetaTree Room String), State g ItemType)]
|
||||
|
||||
@@ -15,8 +15,7 @@ import Geometry
|
||||
import Linear
|
||||
|
||||
putDoubleDoor :: Wall -> Point2 -> Point2 -> Door -> Placement
|
||||
putDoubleDoor wl a b dr =
|
||||
putDoubleDoorThen wl 1 a b dr (const $ const Nothing)
|
||||
putDoubleDoor wl a b dr = putDoubleDoorThen wl 1 a b dr (const $ const Nothing)
|
||||
|
||||
putDoubleDoorThen ::
|
||||
Wall ->
|
||||
|
||||
@@ -24,8 +24,6 @@ import Geometry
|
||||
import LensHelp
|
||||
import RandomHelp
|
||||
|
||||
-- TODO fix case where the sensor created by sensInsideDoor blocks another door
|
||||
-- for roomRectAutoLinks-- make the locked door a center door?
|
||||
sensorRoom :: SensorType -> Int -> State LayoutVars (Tree Room)
|
||||
sensorRoom senseType n = do
|
||||
rm <-
|
||||
@@ -49,7 +47,7 @@ sensorRoom senseType n = do
|
||||
| isclose = rl & rlType . at BlockedLink ?~ ()
|
||||
| otherwise = rl
|
||||
where
|
||||
p' = p +.+ rotateV d (V2 0 (negate 100))
|
||||
p' = p + rotateV d (V2 0 (negate 100))
|
||||
isclose = dist (_rlPos rl) p' < 30
|
||||
|
||||
nonCornerLinks :: RoomLink -> Bool
|
||||
|
||||
@@ -377,8 +377,8 @@ chasmSimpleMaze =
|
||||
|
||||
tutLight :: State LayoutVars (MetaTree Room String)
|
||||
tutLight = do
|
||||
x <- shuffleRoomPos =<< chasmSimpleMaze
|
||||
y <- shuffleRoomPos =<< chasmSimpleMaze
|
||||
x <- rmPos shuffle =<< chasmSimpleMaze
|
||||
y <- rmPos shuffle =<< chasmSimpleMaze
|
||||
z <- chasmSimpleMaze
|
||||
return $
|
||||
tToBTree "TutLight" $
|
||||
|
||||
@@ -33,9 +33,8 @@ import Data.Monoid
|
||||
import RandomHelp
|
||||
|
||||
testStringInit :: Universe -> [String]
|
||||
testStringInit _ = mempty
|
||||
--testStringInit u = [show $ u ^? uvWorld . input . mouseContext . mcoRotateDist]
|
||||
-- (fmap show $ u ^.. uvWorld . cWorld . lWorld . machines . each . mcType . _McDamSensor . sensAmount)
|
||||
testStringInit u =
|
||||
(fmap show $ u ^.. uvWorld . cWorld . lWorld . creatures . each . crHP . _HP)
|
||||
-- <> (fmap show $ u ^.. uvWorld . cWorld . lWorld . machines . each . mcMaterial)
|
||||
--testStringInit u = map show (u ^.. uvWorld . cWorld . lWorld . machines . traverse . mcDir)
|
||||
--testStringInit u = map show
|
||||
|
||||
@@ -42,6 +42,7 @@ positionRoomsFromTree (Node (r, i) ts) =
|
||||
where
|
||||
r' = r & rmMID ?~ i
|
||||
|
||||
-- implement a heuristic for "better" room links?
|
||||
posRms ::
|
||||
PosRooms ->
|
||||
RoomInt ->
|
||||
|
||||
+2
-1
@@ -342,6 +342,7 @@ functionalUpdate =
|
||||
pushYouOutFromWalls :: World -> World
|
||||
pushYouOutFromWalls w = w & cWorld . lWorld . creatures . ix 0 %~ muzzleWallCheck w
|
||||
|
||||
-- rotate creature as well? behaviour on ledges?
|
||||
muzzleWallCheck :: World -> Creature -> Creature
|
||||
muzzleWallCheck w cr = fromMaybe cr $ do
|
||||
invid <- cr ^? crManipulation . manObject . imRootSelectedItem . unNInt
|
||||
@@ -540,7 +541,7 @@ updatePulseBall pb w
|
||||
thedam = Lasering 100 ep (pb ^. pzbVel)
|
||||
sp = pb ^. pzbPos
|
||||
ep = sp + pb ^. pzbVel
|
||||
thit = thingHit sp ep w
|
||||
thit = listToMaybe $ thingsHitZ 20 sp ep w
|
||||
|
||||
pbFlicker :: PulseBall -> World -> World
|
||||
pbFlicker pt =
|
||||
|
||||
@@ -23,7 +23,7 @@ colCrWall :: World -> Creature -> Creature
|
||||
colCrWall w c = cornpush . wallpush $ pushthrough c
|
||||
where
|
||||
cornpush = crPos . _xy %~ pushOutFromCorners r ls'
|
||||
wallpush = pushCr' wls
|
||||
wallpush = pushCr wls
|
||||
pushthrough = crPos . _xy %~ fst . flip (collidePoint p1) wls -- check push throughs
|
||||
r = crRad (c ^. crType) + wallBuffer
|
||||
p1 = c ^. crOldPos . _xy
|
||||
@@ -33,8 +33,8 @@ colCrWall w c = cornpush . wallpush $ pushthrough c
|
||||
wls = filter notff $ wlsNearCirc p2 r w
|
||||
notff x = x ^. wlMaterial /= ForceField
|
||||
|
||||
pushCr' :: [Wall] -> Creature -> Creature
|
||||
pushCr' wls cr
|
||||
pushCr :: [Wall] -> Creature -> Creature
|
||||
pushCr wls cr
|
||||
| dist ep sp > r && dist ep ap > r =
|
||||
ecr
|
||||
& crDamage <>~ [Crushing 1000 0]
|
||||
|
||||
@@ -14,6 +14,7 @@ module Dodge.WorldEvent.ThingsHit (
|
||||
wlHitPos,
|
||||
crHit,
|
||||
crWlPbHit,
|
||||
crWlPbHitZ,
|
||||
wlsHitUnsorted,
|
||||
isWalkable,
|
||||
) where
|
||||
@@ -66,6 +67,20 @@ crWlPbHit sp ep w =
|
||||
toobj (Left cr) = OCreature cr
|
||||
toobj (Right wl) = OWall wl
|
||||
|
||||
crWlPbHitZ :: Float -> Point2 -> Point2 -> World -> [(Point2, Object)]
|
||||
crWlPbHitZ z sp ep w =
|
||||
List.mergeOn
|
||||
(dist sp . fst)
|
||||
(map (fmap toobj) (thingsHitZ z sp ep w))
|
||||
pballs
|
||||
where
|
||||
-- slightly arbitrary
|
||||
pballs
|
||||
| z > 15 && z < 25 = map (fmap OPulseBall) (pbsHit sp ep w)
|
||||
| otherwise = mempty
|
||||
toobj (Left cr) = OCreature cr
|
||||
toobj (Right wl) = OWall wl
|
||||
|
||||
crsHit :: Point2 -> Point2 -> World -> [(Point2, Creature)]
|
||||
crsHit sp ep w
|
||||
| sp == ep = mempty
|
||||
|
||||
Reference in New Issue
Block a user