This commit is contained in:
2022-03-01 22:52:06 +00:00
parent a2ffeaa852
commit b3ba0697b4
3 changed files with 23 additions and 33 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ itemCombinations =
, p [p 2 TUBE,o HARDWARE] launcher , p [p 2 TUBE,o HARDWARE] launcher
, po [MICROCHIP,TRANSMITTER,LAUNCHER] trackingLauncher , po [MICROCHIP,TRANSMITTER,LAUNCHER] trackingLauncher
, po [MICROCHIP,TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher , po [TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher
, po [LIGHTER,PIPE,CAN] flameStick , po [LIGHTER,PIPE,CAN] flameStick
, po [FLAMESTICK,CAN,PUMP] blowTorch , po [FLAMESTICK,CAN,PUMP] blowTorch
+1
View File
@@ -171,6 +171,7 @@ testInventory = IM.fromList $ zip [0..]
, bounceModule , bounceModule
, teleportModule , teleportModule
, makeTypeCraftNum 5 TUBE , makeTypeCraftNum 5 TUBE
, makeTypeCraftNum 5 CREATURESENSOR
, makeTypeCraftNum 3 PRISM , makeTypeCraftNum 3 PRISM
, makeTypeCraftNum 1 MAGNET , makeTypeCraftNum 1 MAGNET
, makeTypeCraftNum 5 HARDWARE , makeTypeCraftNum 5 HARDWARE
+21 -32
View File
@@ -134,7 +134,7 @@ pjTrack itid i pj w = pjEffTimeRange (st,et) rotateToTarget pj w
pjpos = _pjPos pj pjpos = _pjPos pj
rotateToTarget _ = fromMaybe id $ do rotateToTarget _ = fromMaybe id $ do
tpos <- w ^? itPoint . itTargeting . tgPos . _Just 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 itPoint = pointToItem $ _itemPositions w IM.! itid
doThrust :: Prop -> World -> World doThrust :: Prop -> World -> World
@@ -155,7 +155,6 @@ doThrust pj w = w
r1 = randInCirc 10 & evalState $ _randGen w r1 = randInCirc 10 & evalState $ _randGen w
aRocketWithItemParams :: Item -> Creature -> World -> World aRocketWithItemParams :: Item -> Creature -> World -> World
--aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
aRocketWithItemParams it cr w = over props addShell w aRocketWithItemParams it cr w = over props addShell w
where where
i = IM.newKey $ _props w i = IM.newKey $ _props w
@@ -176,7 +175,7 @@ moveShell pj w
| time > 40 = if circOnSomeWall oldPos 4 w | time > 40 = if circOnSomeWall oldPos 4 w
then doExplode then doExplode
else w else w
| isJust thingHit = doExplode | anythingHitCirc 2 oldPos newPos w = doExplode
| time > -300 = w | time > -300 = w
| otherwise = doExplode | otherwise = doExplode
where where
@@ -190,9 +189,6 @@ moveShell pj w
vel = _pjVel pj vel = _pjVel pj
projectileExplosion = _pjPayload pj projectileExplosion = _pjPayload pj
newPos = oldPos +.+ vel 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 :: Float -> Prop -> World -> World
reduceSpinBy x pj = props . ix (_pjID pj) . pjSpin *~ x reduceSpinBy x pj = props . ix (_pjID pj) . pjSpin *~ x
@@ -295,8 +291,9 @@ remoteLauncher = launcher
fireRemoteLauncher :: Item -> Creature -> World -> World fireRemoteLauncher :: Item -> Creature -> World -> World
fireRemoteLauncher it cr w = setLocation fireRemoteLauncher it cr w = setLocation
$ resetFire $ set (creatures . ix cid . crInv . ix j . itUse . rUse)
$ resetName (\_ _ -> explodeRemoteRocket itid i)
$ set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
$ over props addRemRocket w $ over props addRemRocket w
where where
i = IM.newKey $ _props w i = IM.newKey $ _props w
@@ -306,9 +303,6 @@ fireRemoteLauncher it cr w = setLocation
j = _crInvSel cr j = _crInvSel cr
newitid = IM.newKey $ _itemPositions w newitid = IM.newKey $ _itemPositions w
maybeitid = cr ^? crInv . ix j . itID . _Just 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 :: World -> World
setLocation w' = case maybeitid of setLocation w' = case maybeitid of
Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid 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 :: Int -> Int -> Prop -> World -> World
moveRemoteShell cid itid pj w moveRemoteShell cid itid pj w
| time > 40 = if circOnSomeWall oldPos 4 w | time > 40 = if circOnSomeWall oldPos 4 w
then doExplosion w then doExplosion
else w else w
| time >= 20 = case thingHit of | anythingHitCirc 2 oldPos newPos w = doExplosion
Just _ -> doExplosion w | time >= 20 = w & props . ix i . pjDir .~ newdir
Nothing -> w & props . ix i . pjDir .~ newdir | time > -99 = w & set randGen g
| time > -99 = case thingHit of
Just _ -> doExplosion $ stopSoundFrom (ShellSound i) w
Nothing -> w & set randGen g
& props . ix i %~ & props . ix i %~
( ( pjVel %~ ( (accel +.+) . (frict *.*) ) ) ( ( pjVel %~ ( (accel +.+) . (frict *.*) ) )
. ( pjDir .~ newdir ) . ( pjDir .~ newdir )
@@ -334,10 +325,8 @@ moveRemoteShell cid itid pj w
& soundContinue (ShellSound i) newPos missileLaunchS (Just 1) & soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
& smokeGen & smokeGen
& makeFlamelet oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10 & makeFlamelet oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10
| time > -200 = case thingHit of | time > -200 = w
Just _ -> doExplosion $ stopSoundFrom (ShellSound i) w | otherwise = doExplosion
Nothing -> w
| otherwise = doExplosion $ stopSoundFrom (ShellSound i) w
where where
time = _pjTimer pj time = _pjTimer pj
i = _pjID pj i = _pjID pj
@@ -352,31 +341,31 @@ moveRemoteShell cid itid pj w
accel = rotateV newdir (V2 2 0) accel = rotateV newdir (V2 2 0)
(frict,g) = randomR (0.6,0.9) $ _randGen w (frict,g) = randomR (0.6,0.9) $ _randGen w
(sparkD,_) = randomR (-0.5,0.5) $ _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) r1 = _randGen w & evalState (randInCirc 10)
smokeGen = shellTrailCloud $ addZ 20 $ oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos) 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 explodeRemoteRocket
:: Int -- ^ Item id :: Int -- ^ Item id
-> Int -- ^ Projectile id -> Int -- ^ Projectile id
-> World -> World
-> World -> World
explodeRemoteRocket itid pjid w 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 (props . ix pjid . prDraw) (const mempty)
$ set (itPoint . itUse . rUse) (\_ _ -> id) $ set (itPoint . itUse . rUse) (\_ _ -> id)
$ resetName $ set (itPoint . itName) "REMOTELAUNCHER"
$ makeExplosionAt (_pjPos (_props w IM.! pjid)) w $ makeExplosionAt (_pjPos (_props w IM.! pjid)) w
where where
resetName = set (itPoint . itName) "REMOTELAUNCHER"
itPoint = pointToItem $ _itemPositions w IM.! itid itPoint = pointToItem $ _itemPositions w IM.! itid
retireRemoteRocket :: Int -> Int -> Int -> World -> World
retireRemoteRocket = retireRemoteProj fireRemoteLauncher
fireTrackingLauncher :: Item -> Creature -> World -> World fireTrackingLauncher :: Item -> Creature -> World -> World
fireTrackingLauncher it cr w = setLocation fireTrackingLauncher it cr w = setLocation
$ over props addTrackRocket w $ over props addTrackRocket w