Jump to content

Recommended Posts

Posted (edited)

https://github.com/madyanov/nasc-decompiler/releases

 

Decompiles ai.obj to AST, then converts AST to NASC (but can be converted to any other language, such as Java, etc).

Resulting NASC can be successfully compiled back with Eressea’s compiler.

 

To run, put ai.obj file to current folder and double click on run.bat.

Edited by verbrannt
  • Thanks 4
Posted

Hi, nice work,  but when I try decompile my ai.obj, I get  this:

C:\ep\git\nasc-decompiler>run.bat
Decompile ai_adiantum_skilluse
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
PHP Notice:  Undefined offset: 1 in C:\ep\git\nasc-decompiler\core\tokenizer.php on line 26
Decompile ai_agit02_dietrichPHP Notice:  Undefined index: S1 in C:\ep\git\nasc-decompiler\core\parser.php on line 442
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to StringExpression::__construct() must be of the type string, null given, called in C:\ep\git\nasc-decompiler\core\parser.php on line 442 and defined in C:\ep\git\nasc-decompiler\core\ast.php:195
Stack trace:
#0 C:\ep\git\nasc-decompiler\core\parser.php(442): StringExpression->__construct(NULL)
#1 C:\ep\git\nasc-decompiler\core\parser.php(116): Parser->parsePushString(Object(Token))
#2 C:\ep\git\nasc-decompiler\core\main.php(73): Parser->parseClass(Object(Token))
#3 {main}
  thrown in C:\ep\git\nasc-decompiler\core\ast.php on line 195

Press any key to continue . . .

Am I doing anything wrong? The AI part where it's failing is here http://download.l2shrine.com/ai.obj

 

Posted (edited)

KR symbols broken in DebugSay function (affected Freya, H5, GD), example class 'citizen' Event SPELLED

 

DebugSay(" NPC t < D| Xt|.");

Should be

DebugSay("난 NPC에게 감염이 되었으니 좀비를 소환해야겠다.");

 

Edited by ChaosPaladin
Posted
2 minutes ago, ChaosPaladin said:

KR symbols broken in DebugSay function (affected Freya, H5, GD), excample class 'citizen' Event SPELLED

 


DebugSay(" NPC t < D| Xt|.");

Should be


DebugSay("난 NPC에게 감염이 되었으니 좀비를 소환해야겠다.");

 

Known issue. Not critical, and wont be fixed, but you can make PR.

Posted (edited)

Thanks, now it works fine. As for utf-16le problem, this should be sufficient (I'm not PHP programmer, I've copied it from https://stackoverflow.com/questions/27551099/how-to-read-from-files-in-utf-16le-encoding-in-php):

...
$tokenizer = new Tokenizer();
$parser = new Parser($data);
$generator = new NASCGenerator();

class readutf16le_filter extends php_user_filter {
    function filter($in, $out, &$consumed, $closing) {
        while ($bucket = stream_bucket_make_writeable($in)) {
            $bucket->data = iconv('UTF-16LE', 'UTF-8',
                strlen($bucket->data) && substr($bucket->data, 0, 2) == "\xff\xfe"
                    ? substr($bucket->data, 2)
                    : $bucket->data);
            $consumed += $bucket->datalen;
            stream_bucket_append($out, $bucket);
        }
        return PSFS_PASS_ON;
    }
}

stream_filter_register('readutf16le', 'readutf16le_filter');

$file = fopen('ai.obj', 'r');
stream_filter_append($file, 'readutf16le');
$line = 0;

// write BOM
file_put_contents('ai.nasc', pack('S', 0xFEFF));
...

and just remove

    $string = preg_replace('/[^\s\x20-\x7E]/', '', $string); // remove non-ASCII characters

 

Edited by eressea
Posted

Hi, good job but you need fix other small bug on all classes than use  "skill_name_id / 256 * 256" you need change from :

 

Quote

/ 256 * 256  to  / (256 * 256)

 

Else some npc ai  doesn't work  as Treasure chest and more.

Posted
50 minutes ago, zconll said:

Hi, good job but you need fix other small bug on all classes than use  "skill_name_id / 256 * 256" you need change from :

 

 

Else some npc ai  doesn't work  as Treasure chest and more.

Thx. Fixed now, checkout the master branch.

Posted (edited)
14 minutes ago, eressea said:

May I ask what's the reason of ignoring classes guild_master_test_helper1 and public_wyvern?

 

Decompiler can’t build correct AST for these classes. It fails only with ai.obj from the leaked GF (l2off). With another ai.obj (e.g. from advext) it should work fine.

 

I’ll fix this after releasing support of the leaked Freya AI.

Edited by verbrannt
Posted (edited)

Ah, it compiles my classes without problem :)

 

May I offer you a patch for reading UTF-16LE input, optional UTF-8 output support and optional tree structure output support? The last one seems to require newer PHP (works with 7.2.7 and enabled long win32 paths for me)

 

https://pastebin.com/Fir2ZTJd

Edited by eressea
Posted
4 minutes ago, eressea said:

Ah, it compiles my classes without problem :)

 

May I offer you a patch for reading UTF-16LE input, optional UTF-8 output support and optional tree structure output support? The last one seems to require newer PHP (works with 7.2.7 and enabled long win32 paths for me)

 

https://pastebin.com/Fir2ZTJd

Yea, thank you. I will apply your patch.

Only reason I’m using UTF-16LE is to be able to compile result code using your compiler. I though it only supports UTF-16LE.

Posted
2 minutes ago, verbrannt said:

Yea, thank you. I will apply your patch.

Only reason I’m using UTF-16LE is to be able to compile result code using your compiler. I though it only supports UTF-16LE.

 

Yes, it supports only UTF-16LE but I'm using tree structure with UTF-8 files and when I build the AI, I go through the directory structure (so I know which is the correct class order) and join all the files into one big UTF-16LE file, then I let it compile and then I split it again to directory structure (because my extender is able to work with directory structure with UTF-8 obj files).

 

Maybe I'll share the building script but it needs some polishing and cleaning...

Posted

Sorry for doublepost, one more question, I keep getting av_quest0 instead of myself.av_quest0, any idea what can be wrong?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Rosyk or rusik or whatever u blaim me that my mouth stinks but I assume you the one who stinks and your perfect pack will be now shared and you can suck a DICK )  https://eu2.contabostorage.com/d4b39866f6bb4084b6c969ec8fe20063:kita/Lucera_Classic_Remaster/Lucera Classic Remaster Server and Datapack files.rar  https://eu2.contabostorage.com/d4b39866f6bb4084b6c969ec8fe20063:kita/Lucera_Classic_Remaster/Lucera Classic Remaster Eng Client.rar Drama link    For this crap u need Lucera 2 classic license ) people paying 300 euros for this shit  lol Some Shit will come out soon mxc website need shake it a bit coz getting boring here )   
    • @Huggo Thank you for asking! When you join our Discord, on the Nexus Marketing section there is a #work-showcase channel. There you can see a little bit of what we are able to produce as a final ready-to-post product.  There is also this link in my new personal montage YouTube channel, in which I will be uploading every recent work: https://youtube.com/playlist?list=PLkzBKexKw8Wj8dC2diYndd5yOWOXUQCJW&si=-HGxlovqzvD4qqy2 Two more videos are coming up this week, and a #reviews channel has opened for our clients to let other people know about their experience working with us. Feel free to join our Hub in Discord, and for any inquries you might have don't hesitate to contact me or post your suggestion at #suggestions channel.  
    • Следи за своим вонючим языком, мудак.   Your mouth stinks, go wash your mouth, it's a dump) I don't know who you are or what you are, and I don't recommend buying anything from people outside of my network, as they may sell garbage under the guise of my work. There have been cases where my sales have been compromised. Additionally, reselling below the purchase price has been prohibited. I wish you all the best and peace. I kindly request that the moderators close this topic, as it is no longer relevant and the contact information is outdated.    
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock