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

    • L2 DEVS - HTML DESIGN (ALL NPC'S)    
    • I only share for free what they are reselling 🙂 You keep crying in all the publications, and if you are looking for h5 or gd wait for 5 or 6 years... cheers.... GENERAL Cached Extended to 8192kb IOBuffer Hair2SlotCache ItemBidAuctioner Clan Hall Current Olympiad Season Rank pages System (Shows Points/Games - Fully Configurable) Automatic Flag Around Raidboss System Offline Shop & Buffers Restore After Restart (Fixed location) Offline Buffer System PvP Auto Announce System Rebuilt with Extra Addons (Fully Configurable, Name, Zones, Rewards) Automatic Announce System Rebuilt with Extra Addons (Fully Configurable) ALT+B Augmentation House Shift+Click Droplist/Spoil List Epic Items Rank RB points Rank ChangeColorName ChangeColorTitle Change Skin (Race) Change Gender Custom Subclass (Acumulative) Achievements Item Delivery System  Augmentations/Enchants Automatic Announce System Auto Learn Skills PvP Reward Pk Reward War Reward Scheme buffer GlobalChatTrade Trade Augment Items Castle Announce Time Castle Standby Time Fix Spiritshots delay SpellbooksDrop Enable/Disable Drop custom Fully configurable, lvl min max allmobs, allrb, individual New cancel effect min,max BlessedarmorEnchantRate BlessedmagicWeaponEnchantRate BlessednormalWeaponEnchantRate MaxSlosChars MaxSlotsDwarfs Enable or disable all commands Fix fast loading npc OlympiadRestoreStatsOnFightStart OlympiadSystemSecondTimeEnabled OlympiadEnterLast10Minute OlympiadThirdClassSummons MinLevelTrade AnnounceSubClassMsg1 AnnounceSubClassMsg2 AnnounceSubClassMsg3 LimitedSubClassRace NoSellItems Change ID SealStones for AA NoPrivateBuyItems NoDropPlayerOnDie DisableSkillEnchantData Show Level Mobs Show npc clan flag DespawnSummonEnBattle SummonPetEnBattle RideSummonPetEnBattle DitanceToTargetMove EnterWorld_Undying EnterWorld_UnHide BlockWhispMessagePlayerToGM UseItemsWithHide CriticalSkillDamageBonusPer=4.0 Disable SSQSystem OnCastle Siege End Use any dyes Buy halls directly in auctioneer without waiting for the auction, configuration to change the item you consume MensajeEnterWorldServer Command .hero enable/disable hero aura Config vip global chat character, chat by systemsg Soulshots: NoSendSystemMessageUse Panel //admin Global vote reward Agathions system Anti Interface, control all patch files by md5 Command .menu configurable, last restart, name, maxusers, privatestores Spawn protection activate deactivate consume items to activate  Activate or deactivate autoloot for vip characters EVENTS Happy Hour Event reworked Configurable by announcements or systemsg Team VS Team Capture The Flag Death Match Last Man Standing Destroy The Base Korean Style Castle Siege Check if the player is inside the tvt event due to disconnection/critical error Top 1/5 killer reward/announce TimeAfk ResetReuseSkills ResetBuffsOnFinish Firework effect Reward win/lost Add Team Location Title custom Red/blue Open Door/Wall System BalanceBishops Show kills in title Invest positions Show Death To Top Delete Non-Subclass Skills     RELOADS Reload Enterworld Html Option Reload Faction System Reload Donate Shop Reload OfflineBuffer Reload Champion NPC Reload CliExt Reload AntiBot Reload Vip System Reload Auction Reload AutoLoot Reload CastleSiegeManager Reload CharacterLock Reload ClanPvPStatus Reload AutoLearn Reload ClanReputationRank Reload ClanSystem Reload CreatureAction Reload Customs.ini Reload L2server.ini Reload SkillData.txt Reload doordata.txt Reload decodata.txt Reload Multisell Reload DropList   Extender tested for more than 3 years. Assured stability. Possibility of adding MOD's upon request. (Not included, consult).
    • some peoples trash is another mans treasure, is that your treasure?   people might like the content but you are still the rat in the room     thats the community judging you.  
    • Keep reselling what I publish here for free!!! 🙂 GG  
  • Topics

×
×
  • Create New...