From b3ba0697b4e6e36f90471bffae4ef173b25b6e2f Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 1 Mar 2022 22:52:06 +0000 Subject: [PATCH] Cleanup --- src/Dodge/Combine/Combinations.hs | 2 +- src/Dodge/Creature.hs | 1 + src/Dodge/Item/Weapon/Launcher.hs | 53 ++++++++++++------------------- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index f2d56c799..4dfda162c 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -56,7 +56,7 @@ itemCombinations = , p [p 2 TUBE,o HARDWARE] launcher , po [MICROCHIP,TRANSMITTER,LAUNCHER] trackingLauncher - , po [MICROCHIP,TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher + , po [TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher , po [LIGHTER,PIPE,CAN] flameStick , po [FLAMESTICK,CAN,PUMP] blowTorch diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index b52ac8486..c839ce92d 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -171,6 +171,7 @@ testInventory = IM.fromList $ zip [0..] , bounceModule , teleportModule , makeTypeCraftNum 5 TUBE + , makeTypeCraftNum 5 CREATURESENSOR , makeTypeCraftNum 3 PRISM , makeTypeCraftNum 1 MAGNET , makeTypeCraftNum 5 HARDWARE diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index 4f098f6c0..e3d769753 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -134,7 +134,7 @@ pjTrack itid i pj w = pjEffTimeRange (st,et) rotateToTarget pj w pjpos = _pjPos pj rotateToTarget _ = fromMaybe id $ do tpos <- w ^? itPoint . itTargeting . tgPos . _Just - return $ (props . ix (_pjID pj) . pjSpin .~ turnToAmount 0.15 pjpos tpos (argV $ _pjAcc pj)) + return $ props . ix (_pjID pj) . pjSpin .~ turnToAmount 0.15 pjpos tpos (argV $ _pjAcc pj) itPoint = pointToItem $ _itemPositions w IM.! itid doThrust :: Prop -> World -> World @@ -155,7 +155,6 @@ doThrust pj w = w r1 = randInCirc 10 & evalState $ _randGen w aRocketWithItemParams :: Item -> Creature -> World -> World ---aRocketWithItemParams it cr w = over props (IM.insert i theShell) w aRocketWithItemParams it cr w = over props addShell w where i = IM.newKey $ _props w @@ -176,7 +175,7 @@ moveShell pj w | time > 40 = if circOnSomeWall oldPos 4 w then doExplode else w - | isJust thingHit = doExplode + | anythingHitCirc 2 oldPos newPos w = doExplode | time > -300 = w | otherwise = doExplode where @@ -190,9 +189,6 @@ moveShell pj w vel = _pjVel pj projectileExplosion = _pjPayload pj newPos = oldPos +.+ vel - hitCr = fst <$> collideCircCrsPoint oldPos newPos 4 (_creatures w) - hitWl = fst <$> collideCircWalls oldPos newPos 2 (wallsNearPoint newPos w) - thingHit = hitCr <|> hitWl reduceSpinBy :: Float -> Prop -> World -> World reduceSpinBy x pj = props . ix (_pjID pj) . pjSpin *~ x @@ -295,8 +291,9 @@ remoteLauncher = launcher fireRemoteLauncher :: Item -> Creature -> World -> World fireRemoteLauncher it cr w = setLocation - $ resetFire - $ resetName + $ set (creatures . ix cid . crInv . ix j . itUse . rUse) + (\_ _ -> explodeRemoteRocket itid i) + $ set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET" $ over props addRemRocket w where i = IM.newKey $ _props w @@ -306,9 +303,6 @@ fireRemoteLauncher it cr w = setLocation j = _crInvSel cr newitid = IM.newKey $ _itemPositions w maybeitid = cr ^? crInv . ix j . itID . _Just - resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse) - $ \_ _ -> explodeRemoteRocket itid i - resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET" setLocation :: World -> World setLocation w' = case maybeitid of Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid @@ -319,14 +313,11 @@ fireRemoteLauncher it cr w = setLocation moveRemoteShell :: Int -> Int -> Prop -> World -> World moveRemoteShell cid itid pj w | time > 40 = if circOnSomeWall oldPos 4 w - then doExplosion w + then doExplosion else w - | time >= 20 = case thingHit of - Just _ -> doExplosion w - Nothing -> w & props . ix i . pjDir .~ newdir - | time > -99 = case thingHit of - Just _ -> doExplosion $ stopSoundFrom (ShellSound i) w - Nothing -> w & set randGen g + | anythingHitCirc 2 oldPos newPos w = doExplosion + | time >= 20 = w & props . ix i . pjDir .~ newdir + | time > -99 = w & set randGen g & props . ix i %~ ( ( pjVel %~ ( (accel +.+) . (frict *.*) ) ) . ( pjDir .~ newdir ) @@ -334,10 +325,8 @@ moveRemoteShell cid itid pj w & soundContinue (ShellSound i) newPos missileLaunchS (Just 1) & smokeGen & makeFlamelet oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10 - | time > -200 = case thingHit of - Just _ -> doExplosion $ stopSoundFrom (ShellSound i) w - Nothing -> w - | otherwise = doExplosion $ stopSoundFrom (ShellSound i) w + | time > -200 = w + | otherwise = doExplosion where time = _pjTimer pj i = _pjID pj @@ -352,31 +341,31 @@ moveRemoteShell cid itid pj w accel = rotateV newdir (V2 2 0) (frict,g) = randomR (0.6,0.9) $ _randGen w (sparkD,_) = randomR (-0.5,0.5) $ _randGen w - hitCr = fst <$> collideCircCrsPoint oldPos newPos 4 (_creatures w) - hitWl = fst <$> collideCircWalls oldPos newPos 2 (wallsNearPoint newPos w) - thingHit = hitCr <|> hitWl r1 = _randGen w & evalState (randInCirc 10) smokeGen = shellTrailCloud $ addZ 20 $ oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos) - doExplosion = explodeRemoteRocket itid i + doExplosion = explodeRemoteRocket itid i $ stopSoundFrom (ShellSound i) w +anythingHitCirc :: Float -> Point2 -> Point2 -> World -> Bool +anythingHitCirc rad sp ep w = isJust $ hitCr <|> hitWl + where + hitCr = fst <$> collideCircCrsPoint sp ep rad (_creatures w) + hitWl = fst <$> collideCircWalls sp ep rad (wallsNearPoint ep w) + -- this should probably be wallsOnLine or something + explodeRemoteRocket :: Int -- ^ Item id -> Int -- ^ Projectile id -> World -> World explodeRemoteRocket itid pjid w - = set (props . ix pjid . pjUpdate) (\_ -> retireRemoteRocket itid 30 pjid) + = set (props . ix pjid . pjUpdate) (\_ -> retireRemoteProj fireRemoteLauncher itid 30 pjid) $ set (props . ix pjid . prDraw) (const mempty) $ set (itPoint . itUse . rUse) (\_ _ -> id) - $ resetName + $ set (itPoint . itName) "REMOTELAUNCHER" $ makeExplosionAt (_pjPos (_props w IM.! pjid)) w where - resetName = set (itPoint . itName) "REMOTELAUNCHER" itPoint = pointToItem $ _itemPositions w IM.! itid -retireRemoteRocket :: Int -> Int -> Int -> World -> World -retireRemoteRocket = retireRemoteProj fireRemoteLauncher - fireTrackingLauncher :: Item -> Creature -> World -> World fireTrackingLauncher it cr w = setLocation $ over props addTrackRocket w