PDA

View Full Version : AI ch to eng quest name auto translator


astrid
19.08.2006, 03:43
Written in lack of time. will work long time (very unoptimised algoritm, i too lazy to rewrite) and not 100% accurate becouse some quest names are different. But result better than emty strings in quest selection. also you must do search&replace for (in progress) string.

usage: in C:\ai\ put your ai and 2 txt files from pack. start software and wait about 1.5 hour :). in c:\ will be generated fixed ai.

rapid:http://rapidshare.de/files/29937170/aifixer.rar.html

have fun :)


using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApplication3
{
public class Class1
{
public static void Main()
{
string[] AIArray=new string[4566333];
string path = @"c:\ai\ai.obj";
using (StreamReader sr = new StreamReader(path))
{
String line;
int i=0;
Console.WriteLine("Loading AI...");
while ((line = sr.ReadLine()) != null)
{
AIArray[i++]=line;
}
Console.WriteLine("Loading AI finished...");
}

string pathEN = @"c:\ai\QuestName-e.txt";
using (StreamReader sr = new StreamReader(pathEN))
{
String line;
string[] elements;
string buff="";
while ((line = sr.ReadLine()) != null)
{
elements=line.Split(" ".ToCharArray());
if (buff!=elements[3])
{
buff=elements[3];
string result=elements[3].Substring(7).TrimEnd("]".ToCharArray());
string source=GetCN(elements[1]).Substring(7).TrimEnd("]".ToCharArray());

//InAI(source,result);
int i=0;
foreach (string linei in AIArray)
{
if (AIArray[i]!=null)
{
if (Regex.IsMatch(AIArray[i],source))
{
AIArray[i]=Regex.Replace(AIArray[i],source,result);
}
}
++i;
}
Console.WriteLine("--- Quest "+elements[1]+" done ---");
}
}
//array to file
Console.WriteLine("Dumping fixed AI to file...");
FileStream fs=new FileStream("c:\\ai-fixed.txt", FileMode.Append, FileAccess.Write, FileShare.Write);
fs.Close();
StreamWriter sw=new StreamWriter("c:\\ai-fixed.txt", true, Encoding.Unicode);
foreach (string linei in AIArray)
{
sw.WriteLine(linei);
}
sw.Close();
Console.WriteLine("Done.");
}
}
public static string GetCN(string id)
{
string pathCN = @"c:\ai\QuestName-cn.txt";
using (StreamReader sr = new StreamReader(pathCN))
{
String line;
string[] elements;
while ((line = sr.ReadLine()) != null)
{
elements=line.Split(" ".ToCharArray());
if (elements[1]==id)
{
return elements[3];
}
}
return id;
}
}
}
}

darkwire
19.08.2006, 03:49
thanks too :) testing

czar
19.08.2006, 05:29
as of this moment ur ai must be 4566333 lines, or ull crash out like i was.

i think astrid is going to ul his ai, or u can change the value and recompile with the source.

just an fyi if ur crashing

Sakumi
19.08.2006, 05:56
You're awsome :)

IVB
23.08.2006, 09:47
Completely rewritten on php with different algorithm. Runs abut 5 minutes on P4 1.5GHz. Unpack archive into any dir, put ai.obj in same dir and run aitrans.php (tested on php 5.1.1). Replaces chinese quest names to english, also replaces "In Progress" and "Completes" from chinese to english. Has no limitations on number of lines in ai.obj.

Resulting file ai.obj.fixed creates in same dir.

Вложения из исходного сообщения (сами файлы в копии отсутствуют):
questfix.rar — 261979 байт

rodier
26.08.2006, 02:09
hmm.. tried IE/FF on dual xeon 3.0ghz in x64bit os .. not working ;(
it took 3 mins to "done" [show in browser].. but nothing.. no new file..

(I tried the questfix.rar)

php 5.1.4 / apache 2.0.58

the first .exe tool dont work because our ai too long

werstein
26.08.2006, 09:02
Change php.ini (max script execution time + memory for script)

IVB
26.08.2006, 09:23
hmm.. tried IE/FF on dual xeon 3.0ghz in x64bit os .. not working ;(
it took 3 mins to "done" [show in browser].. but nothing.. no new file..

(I tried the questfix.rar)

php 5.1.4 / apache 2.0.58

the first .exe tool dont work because our ai too longYou don't need run it under Apache! Just run it from commandline:

php.exe aitrans.php

;)