diff --git a/src/Dodge/Debug/Terminal.hs b/src/Dodge/Debug/Terminal.hs index 9aeead348..90b5ba981 100644 --- a/src/Dodge/Debug/Terminal.hs +++ b/src/Dodge/Debug/Terminal.hs @@ -28,16 +28,13 @@ applyTerminalString ss = case ss of applyTerminalCommand :: String -> Universe -> Universe applyTerminalCommand s = case s of "NOCLIP" -> uvConfig . debug_booleans . at Noclip %~ toggleJust - '-': xs -> uvWorld %~ \w -> foldl' (flip createItemYou) w (inventoryX xs) --- (uvWorld . cWorld . lWorld %~ initSpecificCrItemLocations 0) --- . (uvWorld . cWorld . lWorld . creatures . ix 0 . crInv .~ IM.fromList (zip [0 ..] $ inventoryX x)) --- . (uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ 50) --- ['I','S',x,y] -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ read [x,y] "GODON" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Crystal "GODOFF" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Flesh - x -> fromMaybe id $ do + x -> fromMaybe (g x) $ do (ibt, n) <- parseItem [x] return $ uvWorld %~ flip (foldl' (&)) (replicate n ( createItemYou (itemFromBase ibt))) + where + g xs = uvWorld %~ \w -> foldl' (flip createItemYou) w (inventoryX xs) applyTerminalCommandArguments :: String -> [String] -> Universe -> Universe applyTerminalCommandArguments command args u = case command of diff --git a/src/Dodge/HeldUse.hs b/src/Dodge/HeldUse.hs index 1e538635d..813fb4386 100644 --- a/src/Dodge/HeldUse.hs +++ b/src/Dodge/HeldUse.hs @@ -641,8 +641,9 @@ loadMuzzle loc cr (b, w) mz = maybe (b, w) (True,) $ case mz ^. mzAmmoSlot of | x <= availableammo -> x | otherwise -> 0 guard $ usedammo > 0 - return $ useLoadedAmmo loc cr mz (Just (usedammo, mag)) $ - removeAmmoFromMag usedammo mid w + return $ + useLoadedAmmo loc cr mz (Just (usedammo, mag)) $ + removeAmmoFromMag usedammo mid w makeMuzzleFlare :: Muzzle -> LocationDT OItem -> Creature -> World -> World makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of @@ -720,7 +721,7 @@ useLoadedAmmo :: World -> World useLoadedAmmo loc cr mz m w = - makeMuzzleFlare mz loc cr $ case _mzEffect mz of + makeMuzzleFlare mz loc cr $ case _mzEffect mz of MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w MuzzleLaser -> creatureShootLaser loc cr mz w MuzzlePulseLaser -> creatureShootPulseLaser loc cr mz w @@ -737,7 +738,7 @@ useLoadedAmmo loc cr mz m w = mz cr w - MuzzleNozzle{} -> useGasParams mid mz loc cr $ walkNozzle mz itm w + MuzzleNozzle{} -> useGasParams mitid mz loc cr $ walkNozzle mz itm w MuzzleShatter -> shootShatter itm cr w MuzzleDetector -> itemDetectorEffect @@ -753,7 +754,7 @@ useLoadedAmmo loc cr mz m w = MuzzleScroller -> useTimeScrollGun itm cr w where itmtree = loc ^. locDT - mid = magtree ^? dtValue . _1 . itLocation . ilInvID + mitid = magtree ^. dtValue . _1 . itID itm = itmtree ^. dtValue . _1 (x, magtree) = fromJust m @@ -918,11 +919,7 @@ shootPulseBall p dir w = removeAmmoFromMag :: Int -> Int -> World -> World removeAmmoFromMag x magid = - cWorld . lWorld . items - . ix magid - . itConsumables - . _Just - -~ x + cWorld . lWorld . items . ix magid . itConsumables . _Just -~ x getBulletType :: DTree OItem -> Maybe Bullet getBulletType magtree = @@ -1113,13 +1110,13 @@ mcUseHeld hit = case hit of _ -> mcShootAuto useGasParams :: - Maybe (NewInt InvInt) -> + NewInt ItmInt -> Muzzle -> LocationDT OItem -> Creature -> World -> World -useGasParams mmagid mz loc cr w = +useGasParams (NInt magitid) mz loc cr w = w & createGas gastype pressure pos dir cr & randGen .~ g' @@ -1127,9 +1124,8 @@ useGasParams mmagid mz loc cr w = itm = loc ^. locDT . dtValue . _1 (pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w) gastype = fromMaybe (error "cannot find gas ammo") $ do - magid <- mmagid hit <- itm ^? itType . ibtHeld - fueltype <- cr ^? crInv . ix magid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= magAmmoParams >>= (^? ampCreateGas) + fueltype <- w ^? cWorld . lWorld . items . ix magitid >>= magAmmoParams >>= (^? ampCreateGas) gasType hit fueltype (V3 x y _, q) = locOrient loc cr diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 5e39b7481..51354e36d 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -620,10 +620,7 @@ updatePulseLaser pz = case pz ^. pzTimer of 5 -> (Endo f, [pz & pzTimer -~ 1]) _ -> (Endo g, [pz & pzTimer -~ 1]) where - f w = - dodam - thHit - w + f w = dodam thHit w & cWorld . lWorld . flares <>~ drawLaser cyan (sp : ps) where (thHit, ps) = reflectPulseLaserAlong phasev sp xp w @@ -645,7 +642,7 @@ updatePulseLaser pz = case pz ^. pzTimer of xp = sp +.+ 800 *.* unitVectorAtAngle dir g w = w & cWorld . lWorld . flares <>~ drawLaser cyan (sp : ps) where - (_, ps) = reflectLaserAlong phasev sp xp w + (_, ps) = reflectPulseLaserAlong phasev sp xp w randWallReflect :: RandomGen g => Float -> Wall -> State g Float randWallReflect a wl = randPeaked a1 outa a2