-
-
Save the-byte-bender/a41e413e3ef92c3c9aa0cc5c106cd660 to your computer and use it in GitHub Desktop.
import 'dart:io'; | |
import 'dart:convert'; | |
List<int> applyXOR(List<int> data, int soundId) { | |
List<int> XOR_KEY = [8, 5, 13, 5, 97, 4, 63, 27]; | |
XOR_KEY[0] ^= (soundId & 0xFF); | |
XOR_KEY[6] ^= ((soundId >> 8) & 0xFF); | |
for (int i = 0; i < data.length; i += 32) { | |
data[i] = data[i] ^ XOR_KEY[(i >> 5) & 7]; | |
} | |
return data; | |
} | |
Future<void> main(List<String> args) async { | |
if (args.isEmpty) { | |
print('Usage: ${Platform.resolvedExecutable} file1 [file2 ...]'); | |
return; | |
} | |
for (var fileName in args) { | |
String outFileExt = filename.endsWith(".ab") ? ".ogg" : ".ab"; | |
if (fileName.endsWith('.ab') || filename.endsWith(".ogg")) { | |
String soundIdStr = fileName.split('.').first; | |
int soundId = int.tryParse(soundIdStr) ?? 0; | |
List<int> fileData = await File(fileName).readAsBytes(); | |
List<int> decryptedData = applyXOR(fileData, soundId); | |
String outputPath = fileName.replaceFirst( | |
filename.endsWith(".ab") ? '.ab' : ".ogg", outFileExt); | |
await File(outputPath).writeAsBytes(decryptedData); | |
print('Operation done for $fileName and saved to $outputPath'); | |
} else { | |
print('Skipping $fileName: Invalid file format'); | |
} | |
} | |
} |
@blindninja97 Hi!
You need to be just a bit familiar with the command line:
cd
to where the game's installed, to its "sound" folder. On a default installation, this would beC:\Mist World\sound\
- now, you will need to move the .dart file in this sound folder, you can do this through your file explorer.
- in your command line window, run
dart script.dart <file>
. Replace with any file from here, such as 1000.ab. This will output 1000.ogg, which is the decrypted version of 1000.ab. - to replace 1000.ab, rename your replacement to 1000.ogg, move it to the sound folder, and run
dart script.dart 1000.ogg
. This will output 1000.ab, which is the encrypted version of 1000.ogg, so the game could play it.
Let me know if you need any other help! By the way, on the decrypted files, most of them have chinese metadata that says what they are for, or you can just listen. :)
Thanks! I'm semi-familiar with command line use, but I guess I was just doing something wrong. I'll try again a little later.
Is there any way to use this script to batch convert? What I would like to do is replace all of the English voice lines with the original Chinese ones, but I would rather not have to do every single sound one at a time, then search through them to find only the voicelines and repackage them.
@blindninja97 Sadly, not on windows; not unless you modify the code. However, I did that for you. The following is a link to an archive containing all the sounds in their decrypted form, with their ID's intact. I think it is just what you want.
https://www.dropbox.com/scl/fi/4wn3p6er6liqu37cz6k5i/oggs.7z?rlkey=t686ubepb3xj1bbrj7q2bnj8d&dl=1
Sorry for the late reply, and I hope that helps
This is going to be a dumb question, but considering I'm a complete non-programmer. How do I run this thing? lol Any help you can give would be much appreciated. Considering the .dart extension, I Googled, downloaded the SDK, opened a CMD and attempted to run this through that, but that doesn't seem to be the way.