Touhou Luna Nights

Touhou Luna Nights

53 ratings
Save Editing
By LVL99
This guide will explain how you can edit your save files.
   
Award
Favorite
Favorited
Unfavorite
TLDR
Open your save file in C:\Users\[Your user name]\AppData\Local\touhou_luna_nights in a text editor. Each of the three save slots is a different file, game0.sav, game1.sav and game2.sav respectively.

Each line of your save file is a variable encoded in base64. Check out FearJudge's guide for a complete list of variables: https://pastebin.com/pZXsY6w0

Alternatively, use Firebingo's save editor[github.com].

If you want a more verbose explanation about how to edit your save file, read on.
Introduction
In this guide I will explain how you can edit your save files to change things like your character's EXP, max HP/MP or spawn location.

In Windows, your save files are located in C:\Users\[Your user name]\AppData\Local\touhou_luna_nights. (You can copy-paste
%userprofile%\AppData\Local\touhou_luna_nights
into the address bar of any Windows Explorer window to get there.) The files are named game0.sav, game1.sav and game2.sav for the first, second and third save slot, respectively.

To edit save files you will need a text editor – yes you read that correctly, not a hex editor (a hex editor would just make things more complicated). I used Notepad++ for all of my editing, but I also tried the standard Windows Editor and WordPad and they both seem to work just fine. You should absolutely make your text editor display line numbers if it doesn't do that by default.

The only other tool you need is a Base64 decoder/encoder. I used the following free online tool:
https://www.base64decode.org
https://www.base64encode.org
Back up Your Files
Before you make any changes, back up your save files in case anything goes wrong!
Editing Basics
Each line in the save file contains a specific value. These values are encoded in Base64, so you need the decoder in order to be able to read them.

Copy-paste any line from the file into the decoder[www.base64decode.org] tool, for example line 111 of your save file. This is your current amount of purple gems, in my case "MjA1". Click DECODE. The decoded value would be "205". To change this value, go to the encoder[www.base64encode.org] tool and enter the new amount of purple gems you want, then click ENCODE.

I'm greedy and I want 9999 gems. The encoded value for that would be "OTk5OQ==". Copy-paste the new encoded value back into your file and save. That is all there is to it.

You can edit save files while in the main menu of the game (the game doesn't have to be closed). Changes will take effect when you load a save slot.
Variable Locations
Stat enhancers
The following lines contain the values for items that permanently increase your stats.

Line 105: Extra HP (10 additional max HP per unit)
Line 106: Extra MP (10 additional max MP per unit)
Line 109: Extra daggers (3 additional max daggers per unit)
Line 110: Extra time (15 additional max time per unit)

Experience/level
Your character's level depends on your current experience. FearJudge's pastebin file[pastebin.com] contains a chart with EXP thresholds for each level (see [&ATT_1] ).

Line 107: Experience

Skill Tree
Your current abilities (e.g. Double Jump). It's a number from 0–5. The number you set will activate the respective power-up and all the previous ones. For example, setting it to 2 will give you the Slide Knife and the Double Jump.

Line 118: Skill Tree
Ability
Number
Encoded Number
Nothing
0
MA==
Slide Knife
1
MQ==
Double Jump
2
Mg==
Grip Knives
3
Mw==
Screw Knives
4
NA==
Dash
5
NQ==

Money and gems
Money used in the shop and gems that are dropped by enemies.

Lines 111–117: Gems (in the order in which they are displayed in the game)
Line 119: Money
Line 228: Gems sold to Nitori (total monetary value)

Time and date
The time and date of the last time you saved is just an encoded text string.

Line 108: Time and date of your last save (format is "21:12 07/03/2019")

Event switches
There are many true/false switches in the save file, indicating whether an event has already taken place or an item has been collected etc. "1" means true/yes, "0" means false/no. The following list contains only the switches for boss fights.

If the value for a certain boss is set to "1" (MQ==), then the boss will not appear in their respective room (i.e. you have already defeated them). "0" (MA==) means that the boss fight will trigger upon entering the room. By changing these values you can revive bosses that you have already beaten.

Line 205: First boss fight (Meiling)
Line 221: Second boss fight (Marisa)
Line 222: Third boss fight (Patchouli)
Line 226: Fourth boss fight (Remilia)
Line 227: Fifth boss fight (Nitori/Flandre)

Character location
Your character's spawn location upon loading a save slot is stored in the form of coordinates. The following variables are used for this:

Line 101: X coordinate (horizontal position, from left to right)
Line 102: Y coordinate (vertical position, from high to low)
Line 103: Stage number (stage 1 = "5", stage 2 = "6", ... stage 5 = "9")

The spawn location is stored using specific coordinates, so you can indeed spawn at any spot on the map, it doesn't have to be in front of a telephone. The width of a room is 640 units, so if you were to save the game at a telephone and then add 640 to the X coordinate in line 101, your character would appear in the room to the right, but at the same position within that room.

However, be aware that each stage/area is a separate map, which is what line 103 is for. You need to set the correct stage in order to spawn in it. If you were to save your game in the first area and then set your X/Y coordinates to some spot in area two, Sakuya would just keep falling until the bottom of the map, whereupon the game crashes. Also note that if you spawn within a wall, you will most likely be unable to get out of there.

For your convenience, I have mapped the locations of all the telephones in the game. Simply copy the encoded values and replace lines 101 to 103 in your save file:

SPOILERS AHEAD, the following picture shows the full map of the game.


Telephone #
Lines 101–103
Phone 1
MjI0MA==
Njcy
OQ==
Phone 2
NDI4OA==
MTIxNg==
OQ==
Phone 3
NTQ0MA==
MjExMg==
OQ==
Phone 4
MzUyMA==
OTYw
OA==
Phone 5
MjA5Ng==
MTM0NA==
OA==
Phone 6
MTYwMA==
MzUyMA==
OQ==
Phone 7
NTQ0MA==
MTcyOA==
OA==
Phone 8
MjM2OA==
OTky
Ng==
Phone 9
MzEwNA==
OTYw
Nw==
Phone 10
Njg4MA==
OTky
Nw==
Phone 11
NDIyNA==
MTY5Ng==
NQ==
Phone 12
MTA4MDA=
MTY5Ng==
NQ==
Phone 13
MjQ2NA==
MTY5Ng==
Ng==
Phone 14
NjgwMA==
MTcyOA==
Nw==
Phone 15
NjMwNA==
MjA4MA==
NQ==
Phone 16
NDE2MA==
MjA0OA==
Ng==
Phone 17
ODIwOA==
MjQzMg==
NQ==
Phone 18
MjM3Ng==
MjgxNg==
Ng==
Phone 19
MjI4OA==
Mjc4NA==
Nw==
Phone 20
NDg2NA==
Njcy
MTA=
Phone 21
MzA0MA==
MjA4MA==
MTA=
Phone 22
OTI4
MjQ2NA==
MTA=
Phone 23
NTAwMA==
Mjc2OA==
MTA=
Revealing the Map
For each tile of the map, a line with a boolean value is stored in the save file, with true/false (1/0) indicating whether you have discovered it. So if the value is 1, the tile will show up on your map, if it is 0, then it won't.

As of v1.0.0.5, the full map has 250-ish actual rooms, although I believe the game stores a boolean value for each tile on the map grid, regardless of whether a room exists in that tile. So the amount of tiles could be within a range of roughly 660 to 750.

This is what the remainder of the save file is for (I think). You can see that, starting at line 255, each line displays either "MA==" (0, not discovered) or "MQ==" (1, discovered). If you replace all the "MA=="s from line 255 to 1000 with "MQ=="s then the full map will be available in the game (including future rooms that might be added to a certain tile).
Additional Offsets
FearJudge did an amazing job mapping out the entire save file, so for anything you cannot find in this guide, check out this pastebin file: https://pastebin.com/pZXsY6w0
Save Editor
Don't want to edit your saves in a text editor? Check out Firebingo's save editor[github.com], which allows you to edit the most important things of your save file (Skills, Gems, EXP etc.) in a GUI.
13 Comments
Curu Jun 28, 2023 @ 11:05am 
have a suggestion for a app to decote the files?
SafetySkull Apr 27, 2022 @ 5:47pm 
instructions unclear, tried to make a joke and failed, have to repeat Clown College :pimpi:
Garwinium Feb 17, 2022 @ 1:33pm 
instructions unclear, i got 20 error messages and my default search engine got set to bing
D҉us̷k͠ S̡hλde Jul 9, 2019 @ 6:13pm 
Instructions unclear, attempts to open save file resulted in L4D2 being launched
LVL99  [author] Jun 24, 2019 @ 2:14pm 
This is really impressive, thanks a lot. I added the Abilities variable to the guide and updated the link to your pastebin file.
FearJudge Jun 23, 2019 @ 1:24pm 
I waited on this for a while to let people play the update.

Here's pretty much the completed save file explained line by line as well as other stuff.
OP, if you want to update or add anything on your guide from it, feel free.
https://pastebin.com/pZXsY6w0

For everyone: please use it responsibly.
LVL99  [author] Mar 24, 2019 @ 11:14am 
Thanks a lot to both of you. I started looking into more lines of the save file, but eventually lost motivation.

FearJudge, your list is amazing, so I linked it directly in the guide. Good job!

By the way, line 104 seems to be Sakuya's orientation when walking into a save point (-1 for left, 1 for right). However, this doesn't seem to have any effect on loaded games, as she always looks to the right at the beginning.
FearJudge Mar 24, 2019 @ 9:10am 
I've done some sleuthing after seeing this post, but I kind of forgot about it for awhile. Here's a pastebin of all the lines I found use for:
https://pastebin.com/LNNdxSNa
And a pastebin of a savefile that is as close to a proper fresh game start as I could make one:
https://pastebin.com/fMnPiFvu
Hope this helps.
Mechaxk Mar 24, 2019 @ 8:33am 
As of v1.0.0.5 these are the lines for the following that I've found:

91 - 95 Keys:
91 - OTA= for Stage 1 key
92 - OTE= for Stage 2 key
93 - OTI= for Stage 3 key
94 - OTM= for Stage 4 key
95 - OTQ= for Stage 5 key

118 and 120 Cards and equipment:
118 is equipment. 1 for slide. 2 for double jump. 3 for the stand-on knives. 4 for screw knives.
120 is Cards. I don't know the exact values, but 10(MTA=) will give you all + 0 of each card in the shop (It'll say 0, but you can use it. once)

131 - 135 Items:
I think just change them to however many you want. Didn't map which is which.

Keep in mind that they won't show up on the item map thing. Those are on different lines.
Mechaxk Mar 24, 2019 @ 7:07am 
Thanks for this, now a sort of NG+ is possible. If I can just find the values for items, maybe then I can do a real NG+