Inori/FuckGalEngine

AdvHD - new Willplus script pattern

mireado opened this issue · 42 comments

I'm trying to convert 見上げてごらん、夜空の星を 体験版 script to txt.
(unpacking arc works well)

command prompt looks working well.
but,
converted txt have 0 size or txt file doesn't existed output folder.
I think pattern might be changed.

this is Rio.arc file on 見上げてごらん、夜空の星を 体験版
http://www.mediafire.com/download/0u8puf8izancdal/Rio.arc

sgqy commented

Maybe you need this first:

ahdprc ror -n 2 *.ws2

But, this tool seems old and I did not write an English document, so sorry for that.
Here is my new code:

AdvHD/ws2.cpp

After you extracted the RIO.arc and get .ws2 files, you can use this code to deal with the text.
Here is some usage:

#define PROC 1 // ROR every byte with 2 bit in ws2 files to decrypt
#define PROC 2 // Export the text for translationg (output: Shift_JIS, the same as source)
//#define CCR // This is designed for anothor game, you should not enable it

You should compile with PROC==1, decrypt the ws2 files; then compile with PROC==2, export the text.
(This code should compiled by Microsoft Compiler / Visual Studio, for there is a "wmain" to support unicode filename.)

http://imgur.com/mQcpz42

build error... actually, I have small knowledge on programming...
can you please help me.. T_T

sgqy commented

1
Just check this option and it will work :)

THX >_<
btw.., i'm not sure building works well.
Imgur
http://www.mediafire.com/download/v36z66o1viebzrf/ws2.exe

I don't know what should i do.
is need some special step to compile with 'define PROC'?

... sorry to bother you again.. T_T

sgqy commented

This instruction uses a simple extract tool:
http://asmodean.reverse.net/pages/exoozoarc.html
My own codepage converter:
https://github.com/sgqy/wcpc/releases


Prepare the files:

all files in rio.arc will be put in ws2out
1

Filt the fiction

copy the story files into folder yozora
2

Decrypt files

you should compile ws2.exe with

#define PROC 1

3

Get the text

you should compile ws2.exe with

#define PROC 2

4
now what you want is put in the folder text

(Optional) Convert text to unicode

5
unicode can avoid garbled text
open text directly in codepage 1252:
6

How about korean encoding?

just select one of the two commands ~
7
some characters are not defined in korean encoding
maybe you need this operation after translating the story into korean
8

How to compile with...?

don't worry, just change the value and compile ~
9

god.... THX ><
thank you for detail explanation
it really works well. god... >
<
sorry for my poor english.. I don't have word that explain this kind explanation.

btw.,
when repackaging these file.
Is it OK using this command?

ahdprc ror -n 2 INFILE -o OUTFILE
ahdprc ws2 -i IN -t TXT0 -b BIN0
ahdprc rep -l LIST FILE1

sgqy commented

the outputed script format is new defined. it do not fit with adhprc.
but i have not written an importing code. (:з」∠)
for i have a translating project, so the importing code maybe later

aha. Ok.
anyway, thank you for kind explanation again >_<

@sgqy Thanks for your source...
Apparently you don't write a import string code correct?...
I write my own tool to translate this format, thanks for the info about this engine ^^
https://github.com/marcussacana/WillPlusManager

sgqy commented

@marcussacana nice work!
but there is an issue, appears in the script, which has route selection
1
2
i used spaces to fill the lines

    internal class CCRLine
    {
        public int order;

        public int offset_text = -1;
        public int srclen_text = -1;
        public string src_text;
        public string dst_text;

        public int offset_chara = -1;
        public int srclen_chara = -1;
        public string src_chara;
        public string dst_chara;

        public void ReplaceChara(Dictionary<string, string> dic)
        { try { dst_chara = dic[src_chara]; } catch { } }
    }
// ... ... ...
        private List<CCRLine> content = new List<CCRLine>();
        private static Encoding enc = Encoding.GetEncoding(936, new EncoderReplacementFallback("_"), new DecoderReplacementFallback("_"));
// ... ... ...
        private void FitLength()
        {
            // 1. calculate the diff of every line
            var errorList = new List<int>();

            for (int i = 0; i < content.Count; ++i)
            {
                var charaError = 0;
                if (content[i].srclen_chara != -1)
                    charaError = content[i].srclen_chara - enc.GetByteCount(content[i].dst_chara);
                var textError = content[i].srclen_text - enc.GetByteCount(content[i].dst_text);
                errorList.Add(charaError + textError);
            }

            // 2. balance the diffs
            int fit = 0;
            for (int i = 0; i < errorList.Count; ++i)
            {
                if (errorList[i] >= (-fit))
                {
                    errorList[i] += fit;
                    fit = 0;
                }
                else
                {
                    fit += errorList[i];
                    errorList[i] = 0;
                }
            }

            // 3. check the total diff
            if (fit != 0) throw new Exception("Translation is too long");

            // 4. apply the modification
            for (int i = 0; i < content.Count; ++i)
            {
                content[i].dst_text += new string(' ', errorList[i]);
            }
        }

it seems ugly, right? xD
if the scenario is translated into english (lines longer than japanese), this solution is very... uh

so, here is another solution(?), AdvHD/dynamic
now debugging, dealing with memory leak xD
maybe i will write a version, which draw the modifyed text directly (results a multi-language game)

@sgqy you can send this script of the screenshot for me see here?

and this "values" is "jump point" in the script... shit... i don't know a way to detect this values...
is allways after or before a "bytecode"? or "route option string"?
this is bad... without edit this don't works...

sgqy commented

cocoro_com_004.zip
@marcussacana
Um... This file includes the branches.
I tried a bit to modify the address months ago, and game crashed xD.

Found this thread and try to understand what to do to extract the .ws2 script from Ensemble game... And... I can't understand, really. Maybe, because I'm zero in programming.

Can anyone explain me "for noobs"? (I just don't want to paste the every line of script from VNR, it's madness). Thanks!

otomelo_scenario.zip

sgqy commented

get_ws2_text.7z.pdf
@Veshurik You are just in time. I've packed the tools in a single 7z ball months ago.
Rename get_ws2_text.7z.pdf to get_ws2_text.7z then extract it.

@sgqy I tried to extract, but something goes wrong. The system cannot find the file specified. And (No such file or directory). And "pause"... And the folder "text" is empty.

@Veshurik In the readme of sgqy's archive, what you need to do is just drag your Rio.arc file to the gettext.bat and then in the text folder is your text. Be sure that the tools has privilege to write.
But I see you have already extract the Rio.arc and get the ws2 files. What you need to do next is decrypt the ws2 file and extract the text. How about this tool ?
https://github.com/marcussacana/WillPlusManager
My binary is here:
WillPlusManager.zip.pdf
rename the *.pdf to *.zip.

tried sgqy tools with veshurik game scenario,
ror the scenario seem fine, the file is readable with hex (rather that random gibberish from original file), but when the t command launched, its gave me error...
when i launch t it says: me infile outfile addrfile
so, what / which one is addr file?
also, @sgqy is your tools possible to revert back from txt to ws2?

@0xh3LL0 As I know, addr file is the output of the tools you used. You can read the code in this repo/AdvHD/ws2.cpp.

if (argc < 3)
{
#if PROC == 1
        printf("<me> <infile> <outfile>\n");
#elif PROC == 2
        printf("<me> <infile> <textfile> <addrfile>\n");
#endif
        return 0;
}

The reason why you met the error msg, is that you didn't run the program correctly.
t program is a commandline tool, you need launched it like:
t input.ws2 output.txt output.addr
to identify the output text and output addr file. Maybe the addr file is for reverting back. But as far as I know, ws2.cpp does not have revert feature.
Currently speaking, https://github.com/marcussacana/WillPlusManager will be a convenient tool according your demand.

About WillPlusManager - that's a good tool. But editing every line and save every time can be very exhaustingly. And I don't talk about font in game (will they support necessary letters or not). And names doesn't appear in text. It's like SCN Editor for Kirikiri - works but "dreary". Anyway, thanks.

@Veshurik Well, WillPlusManager is a good tool, but for me it's also not convenient. The most valuable part is the code. Like most code in this repo, it give us the clue about the game. Understanding others code and writing your own tool will be more comfortable.

My tool is intentionally not convenient.
I wrote them keeping in mind "If you want to translate your games, work on them!".
You can see that my tools come separately in a DLL and an EXE, why this? Why I want the one who want translate learn how to create your tool to edit the scripts, I gave the DLL that does all the dirty work ... he needs to simply observe the GUI Source Code and write a tool to export to .txt...
...Why I do this? First as an attempt to promote newbies in the programming world, creating new hackers and consequently generating new tools for the community... but all I see is this... people giving up for this silly limitation...
If your problem is the GUI just try wrote your tool you need in the max 10 basic commands to make my DLL import the strings and your code export to .txt! it's very easy, try learn, this is what i want...

WillPlusManager don't can extend strings length, i really don't like of this my tool :/

Agh... Eroge engines never be such easy for translations. Japanese is really sadists.

@sgqy 想问一下菊苣上面用的hex editor具体叫什么名字?

Inori commented

@Neroldy
CrystalTile2

sgqy commented

@Veshurik Sorry for late reply.
You can make a folder named rel beside of gettext.bat and copy the ws2 files into it.
then double hit gettext.bat

@sgqy You're the best! It works! Brilliant! Hah, finally! Now I wonder, why every line in script has a second copy (with ##). And how to translate them - just copy or leave one of line.
Anyway, thanks!

sgqy commented

@Veshurik Using double line format is because we let translating work go 2-pass.
Many translators do first pass, then experienced do second, with original text in the file.

(##) label is used to fit this editor: https://github.com/regomne/lneditor (No English version)
They can also be deleted by wildcard/regex replacing.

@sgqy Like that?
23

sgqy commented

@Veshurik That is!

@sgqy i used your "get text" tool , works perfectly well. The only issue is that i dont know how to make these .txt files back .ws2. I need to do the opposite process otherwise the game i'm trying to translate won't read changed file, i suppose. Would be grateful for your help or advice

you can just overwrite the .ws2 strings, but looks he don't update the jump points, generating corrupted scripts... this is the reason to my tool don't allow extend the length size.
To this engine, in my projects i create soft-translation patchs

@marcussacana your VNX+ tool seems to be working well but I have some questions.

What does the "/n" mean ? This "N" letter shows almost in every line of the text. IDK if I can delete it or not.

Also , Im still looking for a way to do the opposite proсess (.txt convert to .ws2) because it's not convenient for me to translate the text from your tool , it would be cool for me to convert these .ws2 file to .txt then translate them and finally convert them back to .ws2. Is this possible?

@PurpleGeeZ
/n = new line
This is a/nsample
In game:

this is a
sample

Idk if anyone is still active here but i need a favor.... Can anyone fix me these scripts to be actually readable? They are also .ws2 and use the same engine as yr talking about but they are from an append disk, which tend to come as a folder with them in it instead of an archive.. http://www.mediafire.com/file/dm84i00y0pztvv9/Golden+Marriage+Append+Scripts.rar

Eh, well... I need a help again.

If I create folder "rel" and gettext.bat, then files becomes 0Kb...

And... if I drag Rio.arc on .bat, it shows /pause and "click on any button"... That is all. What is wrong?

sgqy commented

@KiritoCy

get_ws2_text.7z.pdf

extract the pack, make folder rel in it. put the content of the folder into rel folder, invoke gettext.bat.
it maybe works, i have not tried.

@Veshurik see content of gettext.bat, maybe you should go step by step in it.
the file does extract(exoozoarc) -> decrypt(ror.exe) -> filt text(t.exe)
after ror.exe:
if open ws2 by CP932, you can see clear text, but get 0KB text, maybe it is using different style.
if open ws2 by CP932 but no clear text, it may using different encrypt.

jpo05 commented

i am pretty new to these stuff, I don't know if it's too late....

i was able to get the txt files, made some translation fix (For personal use) but i'm struck on how to change the txt files back to ws2?

Can someone please be kind and explain me 2 things

1)How to get the txt files back to ws2?
2)How to put the ws2 files back into the Rio.arc file?