Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- class BinaryRead
- {
- static void Main(string[] args)
- {
- // 出力テキストファイルのパス
- string outputTextFilePath = @"Nokturnus.txt";
- // 処理開始オフセット
- long startOffset = 0x7290;
- // 1回あたりの読み取りサイズ(24バイト)
- int recordSize = 24;
- // 処理回数(255回)
- int iterations = 255;
- // Boss を取得するための辞書
- Dictionary<long, string> bossDictionary = new Dictionary<long, string>
- {
- { 0x120, "Dragonlord" },
- { 0xA94, "Malroth" },
- { 0x1408, "Baramos" },
- { 0x1D7C, "Zoma" },
- { 0x26F0, "Psaro" },
- { 0x3064, "Estark" },
- { 0x39D8, "Nimzo" },
- { 0x434C, "Murdaw" },
- { 0x4CC0, "Mortamor" },
- { 0x5634, "Orgodemir" },
- { 0x5FA8, "Dhoulmagus" },
- { 0x691C, "Rhapthorn" },
- { 0x7290, "Nokturnus" }
- };
- string Boss = bossDictionary.ContainsKey(startOffset) ? bossDictionary[startOffset] : "Unknown";
- try
- {
- using (FileStream fs = new FileStream(@"param.pac", FileMode.Open, FileAccess.Read))
- using (StreamWriter writer = new StreamWriter(outputTextFilePath))
- {
- // オフセットに移動
- fs.Seek(startOffset, SeekOrigin.Begin);
- for (int i = 0; i < iterations; i++)
- {
- // バッファを用意して23バイト読み込む
- byte[] buffer = new byte[recordSize];
- int bytesRead = fs.Read(buffer, 0, recordSize);
- if (bytesRead < recordSize)
- {
- break;
- }
- // 読み取ったデータを解析
- var record = ParseRecord(buffer);
- // 結果を出力
- writer.WriteLine($"{Boss} Lv{i + 1}");
- writer.WriteLine($"");
- writer.WriteLine($" ID: {record.ID} Flag: {record.Flag}");
- writer.WriteLine($" HP: {record.HP} MP: {record.MP}");
- writer.WriteLine($" Atk: {record.Atk} Def: {record.Def} Agl: {record.Agl}");
- writer.WriteLine($" Exp: {record.Exp} Gold: {record.Gold}");
- writer.WriteLine($"");
- }
- }
- Console.WriteLine($"処理が完了しました。結果は {outputTextFilePath} に出力されました。");
- }
- catch (Exception ex)
- {
- Console.WriteLine($"エラーが発生しました: {ex.Message}");
- }
- }
- // レコード解析メソッド
- static Record ParseRecord(byte[] buffer)
- {
- return new Record(
- HP: BitConverter.ToUInt16(buffer, 0),
- MP: BitConverter.ToUInt16(buffer, 4),
- Agl: BitConverter.ToUInt16(buffer, 8),
- Atk: BitConverter.ToUInt16(buffer, 10),
- Def: BitConverter.ToUInt16(buffer, 12),
- ID: buffer[14],
- Exp: BitConverter.ToUInt32(buffer, 15),
- Gold: BitConverter.ToUInt32(buffer, 19),
- Flag: buffer[24-1]
- );
- }
- record Record(
- ushort HP,
- ushort MP,
- ushort Agl,
- ushort Atk,
- ushort Def,
- byte ID,
- uint Exp,
- uint Gold,
- byte Flag
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement