private void QuestCacheScript_Click(object sender, EventArgs e) { OpenFileDialog.FileName = ""; OpenFileDialog.Filter = "Lineage II config (quest_pch.txt)|quest_pch.txt|All files (*.*)|*.*"; if (OpenFileDialog.ShowDialog() == DialogResult.Cancel) { return; } string QuestDataDir = System.IO.Path.GetDirectoryName(OpenFileDialog.FileName); if (System.IO.File.Exists("quest_pch2.txt") == false) { MessageBox.Show("Required all files (quest_pch.txt and quest_pch2.txt) for generation", "quest_pch2.txt not found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Initialization ProgressBar.Value = 0; var inPchFile = new System.IO.StreamReader("quest_pch.txt", System.Text.Encoding.Default, true, 1); var inPch2File = new System.IO.StreamReader("quest_pch2.txt", System.Text.Encoding.Default, true, 1); var outData = new System.IO.StreamWriter("questcomp.txt", false, System.Text.Encoding.Unicode, 1); // Dim outData As New System.IO.StreamWriter(oFile, System.Text.Encoding.Unicode, 1) string ReadStr; string[] ReadSplitStr; // quest_pch.txt - 1 4 687 688 1079 1080 // quest_pch2.txt - [gourd_event] 997 // questcomp.txt - [0001] letters_of_love1 {687;688;1079;1080} ProgressBar.Value = 0; ProgressBar.Maximum = Conversions.ToInteger(inPchFile.BaseStream.Length); var QuestDB = new string[1001]; while (inPchFile.EndOfStream != true) { ReadStr = inPchFile.ReadLine().Replace((char)9, (char)32); if (ReadStr != null) { if ((Strings.Mid(ReadStr, 1, 2) ?? "") != "//") { ReadSplitStr = ReadStr.Trim().Split(); QuestDB[Conversions.ToInteger(ReadSplitStr[1])] = ReadSplitStr[0].Replace("[", "").Replace("]", ""); } } ProgressBar.Value = Conversions.ToInteger(inPchFile.BaseStream.Position * 100 / (double)inPchFile.BaseStream.Length); } // quest_pch.txt - 1 4 687 688 1079 1080 // quest_pch2.txt - [gourd_event] 997 // questcomp-e.txt - [0001] letters_of_love1 {687;688;1079;1080} ProgressBar.Maximum = Conversions.ToInteger(inPch2File.BaseStream.Length); ProgressBar.Value = 0; while (inPch2File.BaseStream.Position != inPch2File.BaseStream.Length) { ReadStr = inPch2File.ReadLine().Replace((char)9, (char)32); if (ReadStr != null) { if ((Strings.Mid(Strings.Trim(ReadStr), 1, 2) ?? "") != "//") { ReadSplitStr = ReadStr.Trim().Split((char)32); outData.Write("[" + Conversions.ToInteger(ReadSplitStr[0]).ToString().PadLeft(4, Conversions.ToChar("0")) + "]" + Conversions.ToString((char)9)); outData.Write(QuestDB[Conversions.ToInteger(ReadSplitStr[0])] + Conversions.ToString((char)9)); outData.Write("{"); int Marker; var loopTo = ReadSplitStr.Length - 1; for (Marker = 2; Marker <= loopTo; Marker++) { if (Marker > 2) { outData.Write(";"); } outData.Write(ReadSplitStr[Marker]); } outData.WriteLine("}"); } } ProgressBar.Value = Conversions.ToInteger(inPch2File.BaseStream.Position * 100 / (double)inPch2File.BaseStream.Length); } MessageBox.Show("questcomp-e Complete"); ProgressBar.Value = 0; inPchFile.Close(); inPch2File.Close(); outData.Close(); }
private void NpcCacheScript_Click(object sender, EventArgs e) { // 10 Felim Lizardman Scout OpenFileDialog.FileName = ""; OpenFileDialog.Filter = "Lineage II config (npcdata.txt)|npcdata.txt|All files (*.*)|*.*"; if (OpenFileDialog.ShowDialog() == DialogResult.Cancel) { return; } System.IO.StreamReader inEFile; try { inEFile = new System.IO.StreamReader(System.IO.Path.GetDirectoryName(OpenFileDialog.FileName) + @"\npcname-e.txt", System.Text.Encoding.Default, true, 1); } catch (Exception ex) { MessageBox.Show("You must have npcname-e.txt in work folder for generation npccache.txt file. Put and try again."); return; } // Initialization ProgressBar.Value = 0; var inFile = new System.IO.StreamReader(OpenFileDialog.FileName, System.Text.Encoding.Default, true, 1); System.IO.Stream oAiFile = new System.IO.FileStream(System.IO.Path.GetDirectoryName(OpenFileDialog.FileName) + @"\npccache.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write); var outAiData = new System.IO.StreamWriter(oAiFile, System.Text.Encoding.Unicode, 1); string ReadStr; ProgressBar.Value = 0; ProgressBar.Maximum = (int)(inEFile.BaseStream.Length); var NpcDB = new string[15001]; // 0- id, 1 - name, 2 - consume, 3 - type (for quest) int NpcDBMarker = 0; string CommentName; string[] ReadSplitStr; // Creating ID Table from NPCdata.txt while (inEFile.EndOfStream != true) { ReadStr = inEFile.ReadLine(); if (ReadStr != null) { if (!ReadStr.StartsWith("//")) { // ReadSplitStr = ReadStr.Split(Chr(9)) NpcDBMarker = Convert.ToInt32(Libraries.GetNeedParamFromStr(ReadStr, "id")); if (NpcDBMarker >= NpcDB.Length) { Array.Resize(ref NpcDB, NpcDBMarker + 1); } NpcDB[NpcDBMarker] = Libraries.GetNeedParamFromStr(ReadStr, "name"); // ReadSplitStr(4).Replace("name=[", "").Replace("]", "") } } ProgressBar.Value = (int)(inFile.BaseStream.Position * 100 / (double)inFile.BaseStream.Length); } ProgressBar.Maximum = (int)(inFile.BaseStream.Length); ProgressBar.Value = 0; while (inFile.BaseStream.Position != inFile.BaseStream.Length) { ReadStr = inFile.ReadLine(); ReadStr = ReadStr.Replace("\t", " "); if (!string.IsNullOrEmpty(ReadStr.Trim()) & ReadStr.StartsWith("//") == false) { // tabs and spaces correction while (ReadStr.IndexOf(" ") >= 0) { ReadStr = ReadStr.Replace(" ", " "); } ReadSplitStr = ReadStr.Split((char)32); // Find Npc in Npcname-e ReadSplitStr[3] = ReadSplitStr[3].Substring(1, ReadSplitStr[3].Length - 2); CommentName = ReadSplitStr[3]; NpcDBMarker = Convert.ToInt32(ReadSplitStr[2]); if (NpcDBMarker <= NpcDB.Length) { if (!string.IsNullOrEmpty(NpcDB[Convert.ToInt32(ReadSplitStr[2])])) { CommentName = NpcDB[Convert.ToInt32(ReadSplitStr[2])]; } } ReadStr = ReadSplitStr[2] + "\t" + CommentName; outAiData.WriteLine(ReadStr); } ProgressBar.Value = (int)(inFile.BaseStream.Position); } MessageBox.Show("npccache.txt Complete"); ProgressBar.Value = 0; inFile.Close(); outAiData.Close(); }