Save Anywhere v1.8.1 - Casualties: Unknown


A BepInEx mod that lets you save your run anywhere, not just between layers.
It saves where you're standing and the whole layer around you, and loading
puts you right back there. Built for the full release of Casualties: Unknown
(Steam).

New in 1.8:
  - UPDATE NOTICE: the main menu tells you when a new Save Anywhere is out.
    GET IT opens mymods.smellypawz.com, which links to
    every site the mod is on. The mod never downloads or
    installs anything by itself.
  - SHARE A SAVE: send a run to a friend with an 8-character code (needs
    cloud saves on, for both of you). See "Share a save" under CLOUD SAVES.

New in 1.7: CLOUD SAVES (very experimental, off unless you turn them on).
Upload your save slots and continue your run on another PC or Steam Deck.
See CLOUD SAVES below.

The source code is public: https://opensource.smellypawz.com

Please keep backing up your save (see BACKING UP below) and report any bugs
in the Bugs tab on the Nexus page.


WHAT YOU NEED
-------------
- Casualties: Unknown, the full game (Windows, Steam version).
  The demo isn't supported: the mod turns itself off there and tells you.
- BepInEx 5 (x64): https://github.com/BepInEx/BepInEx/releases
  Pick "BepInEx_win_x64_5.4.x.x.zip" (version 5, NOT version 6).


HOW TO INSTALL
--------------
1. Open your game folder. In Steam: right-click Casualties Unknown > Manage >
   Browse local files.
2. Install BepInEx if you don't have it: unzip it into the game folder, start
   the game once, wait for the main menu, then close it.
3. Copy the "BepInEx" folder from this zip into the game folder and merge.
   The file should end up at:
     <game folder>\BepInEx\plugins\SaveAnywhere.dll
4. Open <game folder>\BepInEx\config\BepInEx.cfg in Notepad, change
   HideManagerGameObject = false  to  HideManagerGameObject = true, save.
5. Start the game. A popup on the main menu asks if you want cloud saves.
   Click "No thanks" to keep everything on this PC, like before.


HOW TO USE
----------
  F5                  Quick save into your current slot
  Pause menu          Three round buttons above the pause circle, next to
                      the game's own: Save (pick a slot), Save & Quit, and
                      Auto-save (greyed out with a line through it when off)

SAVE SLOTS
  Click Save in the pause menu to open the SAVE GAME screen and pick a slot
  (5 by default), plus one AUTO-SAVE slot. Each slot is a floppy disk showing the layer, character,
  run type (Tough, Relaxed, Paradise, Desolate, Unchipped, Endless or
  Custom), run time and when it was saved, on top of that layer's picture.
  Layer pictures appear once you've been in a run with v1.3.0, and the run
  type shows after the slot is saved again with v1.3.0.
  Empty slots say SAVE HERE; a slot with another save in it
  says OVERWRITE (click twice to confirm).
  The slot you saved into becomes your CURRENT slot. F5 and Save & Quit
  keep saving into that same slot, so they never fill up the other slots.
  Auto-save never touches your manual slots: it has its own AUTO-SAVE slot
  (the first card), which you can load or delete but not save into. To make a backup, pick a different slot with the Save button.
  If you haven't picked a slot yet, the first save goes into the first empty
  slot.
  On the main menu, click SAVE SLOTS (top-right) to see every slot. Click LOAD
  to start from a slot, or DELETE (click twice) to remove it. CONTINUE marks
  the save the Continue button loads. Loading a slot makes it your CURRENT
  slot. Loading the auto-save makes that run's newest manual slot your
  CURRENT slot (or none, so your next F5 goes into the first empty slot).
  When you give up or reach an ending, that run's slots are deleted.

AUTO-SAVE (on by default)
  - Saves into the AUTO-SAVE slot every 5 minutes of play (paused time doesn't count).
  - Also saves about 10 seconds after you arrive on a new layer.
  - If it isn't safe to save right then (falling, enemy nearby, ...), it waits
    and saves as soon as it is. An orange "Auto-saving..." pill
    with a spinner shows at the top of the screen.
  - Turn it on or off with the Auto-save button in the pause menu, or change
    the interval in the config.

To load, click Continue on the main menu like normal. You come back at the
exact spot you saved.

The save is kept after loading, so if the game crashes or you quit without
saving, you can Continue again from your last save. Saving again overwrites it.
If you die, your save is kept: click Continue to try again from your last
save. Giving up (the quit button pressed 4 times) or reaching an ending
deletes the save, just like the normal game. If you reach the next layer and use the
game's own save there, that save is used instead (the normal way).


CLOUD SAVES (VERY EXPERIMENTAL)
-------------------------------
Cloud saves upload your save slots to a server run by the mod author
(casualexpie), so you can continue your run on another PC or Steam Deck.
They're OFF unless you say yes to the popup, or click "Cloud saves: OFF"
under SAVE SLOTS on the main menu.

  - This is a VERY EXPERIMENTAL feature. It may break, lose cloud saves, or
    stop working.
  - The mod author can switch cloud saving off at any time, for example if
    hosting costs get too high. If that happens, your saves on this PC keep
    working normally.
  - KEEP BACKING UP YOUR SAVE ANYWHERE SAVES YOURSELF ANYWAY. Don't rely on
    the cloud as your only copy.

How it works
  - After every save (F5, Save, Save & Quit and auto-save), that slot is
    uploaded in the background. A pill says "Uploaded to the cloud".
  - On the SAVE SLOTS screen, each card shows if it's synced to the cloud.
    A slot that's only in the cloud shows IN THE CLOUD with a DOWNLOAD button.
  - The CLOUD button on a card shows the last 6 cloud copies of that slot.
    You can bring back an older one, upload, or delete it from the cloud.
  - Deleting a slot on this PC, or ending a run, deletes that run's cloud
    copies too.

Another device (PC or Steam Deck)
  1. On this PC: main menu > CLOUD SETTINGS > GET A LINK CODE.
  2. On the other device (with cloud saves on): CLOUD SETTINGS, type the code
     under "Code from another device" and click LINK THIS PC (twice).
     The code works for 10 minutes. Up to 5 devices can share your saves.
  3. Your cloud slots now show up there. Click DOWNLOAD, then LOAD.

Share a save
  1. SAVE SLOTS > CLOUD on the slot you want to share > SHARE THIS SAVE.
     You get a code like K7QX-2M9P. COPY puts it on your clipboard.
  2. Your friend (cloud saves on) clicks SHARE CODE at the bottom of their
     SAVE SLOTS screen, types the code and clicks LOAD. The run goes into
     their first empty slot. Their own saves are never overwritten.
  - A code works for 7 days. You can have up to 5 codes running at once.
  - The code is a copy of the slot at that moment. Saving again later
    doesn't change what your friend gets.
  - Anyone you give the code to can load that run, nothing else of yours.

Recovery key
  CLOUD SETTINGS > MAKE A RECOVERY KEY gives you a 24-character key. Write
  it down or keep it somewhere safe. If you lose this PC or reinstall
  Windows, type it under "Use a recovery key" to get your cloud saves back.
  Tick "Also sign out every other device" if a PC was lost or stolen.
  Anyone with your key can get into your cloud saves, so don't share it.

Your data
  - What's uploaded: your save slots and their details (layer, character,
    run type, run time, when it was saved). No name, email or password.
  - This PC's cloud login is in SaveAnywhere\cloud.json in your save folder.
    Don't share that file.
  - CLOUD SETTINGS > DELETE MY CLOUD DATA deletes every cloud save, every
    old copy and your cloud account. Saves on this PC aren't touched.
  - INACTIVE ACCOUNTS ARE DELETED: if your cloud account isn't used for
    14 days, it's deleted automatically, with ALL its cloud saves and old
    copies. This can't be undone, not even with a recovery key. If you open
    the game after 7+ days away, a popup warns you. Playing with cloud saves
    on keeps your account active. Saves on your PC are never deleted.
  - Limits: 40 MB per account (about 100 saves), 4 MB per save.
  - Cloud saves only work with the newest version of Save Anywhere. If
    the mod says it needs an update, download the latest version from Nexus.
  - Every upload is checked by the server, and only real Save Anywhere saves
    are accepted.

Cloud saves are hosted on Cloudflare. Save Anywhere is not affiliated with
or endorsed by Cloudflare.


WHAT GETS SAVED
---------------
- Your position on the layer
- Everything the game normally saves: health, injuries, limbs, stats, skills,
  inventory, worn items, recipes, run settings
- The layer itself: terrain (including what you dug or blew up), water and
  other liquids, the layer modifier (Foggy, Flooded, ...)
- Items lying on the ground, including containers and what's inside them
- Structures, traps, mines, crates, creatures and enemies with their health
- Survivors (traders) with their stock, credit, reputation and mood
- Climbable veins and climbing ropes, at their full length (ropes stay
  grabbable after loading)
- Time spent on the layer, fog and rain


WHEN YOU CAN'T SAVE
-------------------
Saving is blocked, with a message saying why, when:
- you're falling, in the air, climbing or knocked down
- you're unconscious or asleep
- an earthquake is happening (and for a few seconds after it calms down)
- the radiation line is close above you, or fungal rain is falling on you
- the end lab escape countdown is running
- you're bleeding badly, short of breath, freezing or overheating
- you're caught in a bear trap, held by a grabber plant, or a bloodsucker
  is attached to you
- a mine is about to go off, lit dynamite is nearby, or an unstable crystal
  is about to explode
- a hostile survivor is close
- you're in critical condition (bleeding out, starving, dehydrated, septic,
  overheating, freezing, heart trouble, ...), so your last save is always
  from before things went bad
- a living enemy is close (15m by default)
- the layer is still loading, or you gave up on the run
- you're on the last layers (WHERE WE MUST REACH and beyond) or in the
  tutorial, same as the game's own rule


SINGLE-PLAYER ONLY (MULTIPLAYER LOCK)
-------------------------------------
Save Anywhere turns itself off completely if it finds a multiplayer mod, like
Casualties Together (KrokMP) and its add-ons, because saving and loading in
multiplayer can badly break your save. Networking libraries (like LiteNetLib)
that other mods use don't count on their own.
A popup tells you what it found. Saving won't work that session and Continue
loads the game's normal save.
To use Save Anywhere again, you don't have to remove Casualties Together:
switch it off in its own menu (MP Mod Menu > Settings > General > Deactivate
Multiplayer Mod). When it's switched off, Save Anywhere ignores it and its
add-ons. Switch it back on and the lock comes back. Other multiplayer mods
still have to be removed.
If you DON'T have a multiplayer mod installed, it's a false alarm: please
send a bug report right away on the Nexus page (Bugs tab), with the
"Found" line from the popup and your BepInEx\LogOutput.log file.


BACKING UP
----------
Your save is in:
  C:\Users\<you>\AppData\LocalLow\Orsoniks\CasualtiesUnknown\
The cloud saves popup has an "Open save folder" button that opens it.
Copy save.sv, saveanywhere.sav and the SaveAnywhere folder (your save slots)
somewhere safe.


SETTINGS
--------
<game folder>\BepInEx\config\saveanywhere.cfg
  SaveKey       hotkey for saving (default F5)
  EnemyRadius   how close an enemy blocks saving (0 turns the check off)
  [AutoSave] Enabled          auto-save on/off (default on)
  [AutoSave] IntervalMinutes  minutes between auto-saves (default 5, min 1)
  [AutoSave] SaveOnNewLayer   auto-save after arriving on a new layer
  [Slots] SlotCount           how many manual save slots there are (1-10, default 5)
  [Cloud] Enabled             cloud saves on/off (default off)
  [Cloud] Asked               set to false to see the cloud saves popup again
  [Debug] ShowCheatedFlag     show "Cheated: TRUE/FALSE" on each save slot and for the
                              game's own save file (default on). TRUE means the game
                              marked that save as cheated (achievements off when loaded)


LIMITATIONS
-----------
- Enemies come back where they were, but they restart what they were doing
  (a guard chasing you starts out calm again).
- Dead creatures and corpses you already destroyed are not brought back.
- Projectiles, blood, particles and a few decorations aren't saved.
- A game update can break the mod. Check BepInEx\LogOutput.log for errors.


UNINSTALL
---------
Delete <game folder>\BepInEx\plugins\SaveAnywhere.dll. Your save.sv still
works with the plain game, but it starts at the beginning of the layer.
If you used cloud saves and want them gone too, use CLOUD SETTINGS >
DELETE MY CLOUD DATA first.
