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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • https://www.l2jbrasil.com/topic/149147-daily-reward-tested-on-l2jsunrise/  to h5 sunrise
    • https://www.l2jbrasil.com/topic/149147-daily-reward-tested-on-l2jsunrise/   
    • A lot of people say L2 is dead, and ACIS is still in development. But seriously, you’ve got the skills and knowledge why not make your own game with a clean brand new client from scratch? The only thing missing is client devs, and you can find plenty here or on freelance sites. Stop treating it like a hobby and turn it into something that can actually make money and people happy, you have the name just move forward, even AI can help you script quests, me first I would totally play any game you made similar to l2 anyway 🍪 have one i know you like them
    • Would it be possible to update the guide? The images are offline! 😞
    • In the fast-paced world of digital marketing, having the right tools makes all the difference. If you're searching for a reliable SMM panel Nigeria, GoUpSocial is here to take your online presence to the next level. Built for influencers, marketers, startups, and content creators, our platform is the ultimate solution for smart and scalable social media growth. With GoUpSocial, you get more than just numbers—you get engagement that drives real impact. As a trusted Nigerian SMM panel, we help you gain visibility across top platforms like Instagram, TikTok, YouTube, Facebook, and Twitter—all at the most competitive prices in the market. Experience the Power of the Best SMM Panel in Nigeria We understand that quality matters just as much as affordability. That’s why GoUpSocial has become the go-to platform for users seeking the best SMM panel in Nigeria. Here’s what makes us the preferred choice: 🚀 Real-Time Delivery: Get your orders processed and completed in minutes, not hours. 💼 All-in-One Dashboard: Manage all your campaigns with ease from a clean, simple interface. 💡 Effective Strategies: Our tools are tailored for organic-looking growth and high user engagement. 🧾 Transparent Pricing: No hidden fees—just straightforward, affordable packages. 👩‍💻 Expert Support: Our team is available 24/7 to guide you through every step of the process. Whether you need more followers, likes, views, or overall engagement, our SMM panel Nigeria services deliver measurable and meaningful results. Why We’re the Nigeria Fastest and Cheapest SMM Panel GoUpSocial isn’t just another provider—it’s the Nigeria fastest and cheapest SMM panel built with performance and value in mind. We combine automation, intelligent targeting, and local market understanding to help you scale effortlessly. Need to boost a campaign today? Our platform supports instant order processing, real-time tracking, and localized engagement strategies—making it ideal for any influencer or business operating in Nigeria. Plus, as the cheapest SMM panel in Nigeria, we make sure that even clients with limited budgets can access top-quality services without compromise. A Nigerian SMM Panel Built for 2025 and Beyond As social media algorithms evolve, traditional methods of gaining reach and engagement no longer work. That’s why we’ve built the SMM panel Nigeria 2025—a next-gen platform optimized for today’s challenges. From smart delivery settings to niche-specific targeting, GoUpSocial provides you with every advantage in a competitive digital world. Our system adapts to the latest platform changes, helping you stay relevant, visible, and in control. Looking for a localized service? Our SMM panel for Nigerian followers helps you connect directly with your audience—boosting both credibility and conversions. All-in-One Online Panel in Nigeria for Every Social Goal No matter your objective—brand awareness, follower growth, or engagement improvement—GoUpSocial is the online panel in Nigeria that offers it all. With flexible services, dynamic campaigns, and secure systems, we give you the tools to succeed in a crowded online space. And because we’re committed to your growth, our platform is continually updated to reflect the best practices of modern digital marketing. Take the Leap with the Best Nigerian SMM Panel Ready to grow smarter? With GoUpSocial, you don’t just gain social proof—you build real influence. As the cheapest Nigeria SMM panel, we combine speed, quality, and affordability in one seamless platform. Whether you're an aspiring influencer, a marketing agency, or a brand aiming for greater reach, GoUpSocial is the ultimate Nigerian SMM panel to help you reach your full potential. 👉 Sign up today and unlock the next level of social media growth with GoUpSocial.
  • 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