PDA

View Full Version : Finding teacher in AI.obj decompiling/compiling


HF
10.04.2007, 11:50
So, i start "AI Decompiler Project" and finding man who understund work AI.obj. I know and understund AI.obj code and can do new code, but... for developing need more knowledge.

This is first code :)


//---------------------------------------------------
// L2ScriptMaker AI Decompiler Project
//---------------------------------------------------
// Decompiling: xx.xx.2007 17:36:50
// Decompiler build is: 1.0.0.0
//---------------------------------------------------

SizeofPointer 8
SharedFactoryVersion 427
NPCHVersion 408
NASCVersion 235
NPCEventHVersion 125
Debug 0

class 1 default_npc : (null)
{
parameter_define_begin
int residence_id = 0;
int DesirePqSize = 50;
int FavorListSize = 30;
int MoveAroundSocial = 0;
int MoveAroundSocial1 = 0;
int MoveAroundSocial2 = 0;
float IdleDesire_DecayRatio = 0.000000;
string fnHi = "chi.htm";
parameter_define_end

handler NO_DESIRE ()
{
}

handler TALK_SELECTED (talker)
{
ShowPage(talker, "noquest.htm")->myself;
}
}

class 1 azit_contest_flag_b : siege_instant_teleporter
{
}

class 1 messenger_rogin : citizen
{

handler CREATED ()
{
AddMoveSuperPointDesire(name, 2, 2000)->sm;
ChangeMoveType(1)->myself;
super;
}

handler SCRIPT_EVENT (script_event_arg1script_event_arg2)
{
jump L207097
L207096
jump L207100
L207099
MakeFString(1010215, "", "", "", "", "")-> Say(myself)->myself;
...
}


If someone have wish to help me or work together, you are welcome :)

HF
12.04.2007, 18:32
Only one man help me. But good man. Results for free share no good :) I sure.
Current status of developing very good... ~20-40% code analysed and decoding w/o errors.
2 days of works.


//---------------------------------------------------
// L2ScriptMaker AI Decompiler Project
//---------------------------------------------------
// Decompiling: xx.xx.2007 0:23:42
// Decompiler build is: 1.0.0.0
//---------------------------------------------------


class 1 party_private : party_private_param
{
parameter_define_begin
int DDMagic = 1;
parameter_define_end

handler NO_DESIRE ()
{
if (myself.boss.alive)
{
myself->AddFollowDesire(myself.boss, 5);
}
else
{
myself->AddMoveAroundDesire(5, 5);
}
}

handler CREATED ()
{
myself->AddTimerEx(1005, 120 * 1000);
myself->AddTimerEx(1006, 20000);
super;
}

handler TIMER_FIRED_EX (timer_id)
{
if (timer_id == 1005)
{
if (myself->InMyTerritory(myself.sm) == 0 && myself.boss.alive != 0 && myself.p_state != 3)
{
myself->InstantTeleport(myself.sm, myself->FloatToInt(myself.boss.x), myself->FloatToInt(myself.boss.y), myself->FloatToInt(myself.boss.z));
}
myself->AddTimerEx(1005, 120 * 1000);
}
if (myself.p_state != 3 && myself.p_state != 10)
{
}
}
myself->AddTimerEx(1006, 20000);
}
super;
}

..

class 1 monster_parameter : default_npc
{
parameter_define_begin
int AttackLowLevel = 0;
int CreviceOfDiminsion = 0;
parameter_define_end

handler ATTACK_FINISHED (target)
{
if (target.alive == 0 && target.is_pc == 0)
{
if (myself->IsInCategory(11, target.npc_class_id) != 0)
{
myself->AddAttackDesire(target.master, 1, 500);
}
}
}
}

class 1 default_npc : (null)
{
parameter_define_begin
int residence_id = 0;
int DesirePqSize = 50;
float EffectAction_BoostValue = 0.000000;
float MoveToTarget_BoostValue = 0.000000;
parameter_define_end

handler NO_DESIRE ()
{
}

handler TALK_SELECTED (talker)
{
myself->ShowPage(talker, "noquest.htm");
}
}

Aikeleer
12.04.2007, 19:06
Feel free to PM me when you need help.

mcrabben7
13.04.2007, 05:26
I wish I could help but there are better people at AI than myself, and I'm really busy with my real life atm :) However, good luck with it. It's an awesome project.

humordwarf
13.04.2007, 07:48
HF: their official compiler did lot of bad mistakes in code, so it just impossible to recover ALL code into C-like stuff. Just dont get in stuck =) finish all common expressions, like switch, case, if, else, while. Make sure that all correct and add "Warnings" in all other cases.

Luck!

Bloodust
13.04.2007, 11:20
Sweet, keep up the good work mate!

HF
14.04.2007, 12:56
I do it... Main stage complete...
:santa:

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

Forcer
14.04.2007, 13:03
Very..very very good HF!
/rus/ Отличная работа, продолжай )

FidoW
14.04.2007, 13:45
I do it... Main stage complete...
:santa:

Look at line 211, there are a mistake with ( and )


if ((myself->GetPathfindFailCount() > 10 && speller == myself.top_desire_target)

And the next line have wrong tabulation on {.

Same on line 192-193, 161-162, 131-132 ....

HF
14.04.2007, 14:15
Look at line 211, there are a mistake with ( and )


if ((myself->GetPathfindFailCount() > 10 && speller == myself.top_desire_target)


fixed :)

}
if ((myself->GetPathfindFailCount() > 10) && (speller == myself.top_desire_target) && (myself->FloatToInt(myself.sm.hp) != myself->FloatToInt(myself.sm.max_hp)))
{
myself->InstantTeleport(myself.sm, myself->FloatToInt(speller.x), myself->FloatToInt(speller.y), myself->FloatToInt(speller.z));
}
}

FidoW
14.04.2007, 14:18
fixed :)

}
if ((myself->GetPathfindFailCount() > 10) && (speller == myself.top_desire_target) && (myself->FloatToInt(myself.sm.hp) != myself->FloatToInt(myself.sm.max_hp)))
{
myself->InstantTeleport(myself.sm, myself->FloatToInt(speller.x), myself->FloatToInt(speller.y), myself->FloatToInt(speller.z));
}
}


Amazing...

GJ HF :p

Sauron
14.04.2007, 23:56
if you need help pm me

HF
19.04.2007, 12:40
I DO IT!!! Omg

handler MENU_SELECTED (talker, ask, reply, state, fhtml0, i0, i1, i2)
{
if (ask == -231)
{
if (reply == 1)
{
myself->ShowSellSeedList(talker, manor_id);
}
elseif (reply == 2)
{
myself->ShowProcureCropList(talker, manor_id);
}
elseif (reply == 3)
{
myself->FHTML_SetFileName(fhtml0, ("seed_client_info" + state + ".htm"));
for (i2 = 1; i2 <= 25; i2 = i2 + 1 )
{
myself->FHTML_SetInt(fhtml0, ("CurrentSeedCount" + i2), (myself->GetCurrentSeedSellCountSet(state, i2)));
myself->FHTML_SetInt(fhtml0, ("CurrentSeedPrice" + i2), (myself->GetCurrentSeedPrice(state, i2)));
myself->FHTML_SetInt(fhtml0, ("CurrentSeedRemain" + i2), (myself->GetCurrentSeedRemainCount(state, i2)));
}
myself->ShowFHTML(talker, fhtml0);
}

khelben
19.04.2007, 14:52
HF, that's so frickin' sweet!

adriahu
24.04.2007, 23:54
some (all :P) c4 handlers from my analysis

0|NO_DESIR
1|ATTACKED
2|SPELLED
3|TALKED
4|TALK_SELECTED
5|SEE_CREATURE
6|DISAPPEAR_CREATURE
7|SEE_ITEM
8|DISAPPEAR_ITEM
9|MASTER_ATTACK
10|MY_DYING
11|TIMER_FIRED
12|TIMER_FIRED_EX
13|CREATED
14|TIME
15|SEE_ATTACK
16|SEE_SPELL
17|OUT_OF_TERRITORY
18|DESIRE_MANIPULATION
19|PARTY_ATTACKED
20|PARTY_SPELLED
21|PARTY_DIED
22|FRIEND_ATTACKED
23|CLAN_ATTACKED
24|CLAN_SPELLED
25|STATIC_OBJECT_CLAN_ATTACKED
26|STATIC_OBJECT_CLAN_SPELLED
27|HOLYTHING_SPELLED
28|TELEPORT_REQUESTED
29|BUY_REQUESTED
30|SELL_REQUESTED
31|QUEST_ACCEPTED
32|MENU_SELECTED
33|LEARN_SKILL_REQUESTED
34|ENCHANT_SKILL_REQUESTED
35|ONE_SKILL_SELECTED
36|ONE_ENCHANT_SKILL_SELECTED
37|SKILL_QUEST_ACCEPTED
38|CLASS_CHANGE_REQUESTED
39|MANOR_MENU_SELECTED
40|CMD_FOLLOW_ME
41|CMD_ATTACK
42|GOD_SHOUT
43|GOD_SELL_GOODS
44|GOD_BUY_GOODS
45|CREATE_PLEDGE
46|DISMISS_PLEDGE
47|REVIVE_PLEDGE
48|LEVEL_UP_PLEDGE
49|ATTACKED_BY_PLEDGE
50|MANAGE_CASTLE_SIEGE
51|CREATE_ALLIANCE
52|SCRIPT_EVENT
53|TUTORIAL_EVENT
54|QUESTION_MARK_CLICKED
55|USER_CONNECTED
56|IDLE_FINISHED
57|MOVE_AROUND_FINISHED
58|ATTACK_FINISHED
59|CHASE_FINISHED
60|FLEE_FINISHED
61|GET_ITEM_FINISHED
62|DECAYING_FINISHED
63|FOLLOW_FINISHED
64|MOVE_TO_WAY_POINT_FINISHED
65|USE_SKILL_FINISHED
66|MOVE_TO_FINISHED
67|IDLE_INTRRUPTED
68|MOVE_AROUND_INTERRUPTED
69|ATTACK_INTERRUPTED
70|CHASE_INTERRUPTED
71|FLEE_INTERRUPTED
72|GET_ITEM_INTERRUPTED
73|DECAYING_INTERRUPTED
74|FOLLOW_INTERRUPTED
75|MOVE_TO_WAY_POINT_INTERRUPTED
76|USE_SKILL_INTERRUPTED
77|MOVE_TO_INTERRUPTED
78|DOOR_HP_LEVEL_INFORMED
79|CONTROLTOWER_LEVEL_INFORMED
80|TB_REGISTER_PLEDGE_RETURNED
81|TB_REGISTER_MEMBER_RETURNED
82|TB_GET_NPC_TYPE_INFORMED
83|TB_SET_NPC_TYPE_RETURNED
84|TB_GET_PLEDGE_REGISTER_STATUS_INFORMED
85|TB_GET_BATTLE_ROYAL_PLEDGE_LIST_INFORMED
86|SUBJOB_LIST_INFORMED
87|SUBJOB_CREATED
88|SUBJOB_CHANGED
89|SUBJOB_RENEWED
90|ON_SSQ_SYSTEM_EVENT
91|SET_AGIT_DECO_RETURNED
92|RESET_AGIT_DECO_RETURNED
93|CLAN_DIED
94|SET_NOBLESS_RETURNED
95|SET_HERO_RETURNED
96|DELETE_PREVIOUS_OLYMPIAD_POINT_RETURNED
97|PSTATE_IDLE
98|PSTATE_MOVE_AROUND
99|PSTATE_DO_NOTHING
100|PSTATE_ATTACK
101|PSTATE_CHASE
102|PSTATE_FLEE
103|PSTATE_GET_ITEM
104|PSTATE_FOLLOW
105|PSTATE_DECAYING
106|PSTATE_MOVE_TO_WAY_POINT
107|PSTATE_USE_SKILL
108|PSTATE_MOVE_TO
109|PSTATE_EFFECT_ACTION
110|PSTATE_PET_DEFAULT
111|PSTATE_MOVE_TO_TARGET
112|PSTATE_MOVE_SUPERPOINT
113|MSTATE_NORMAL
114|MSTATE_BERSERK
115|MS_SILENCE
116|FRIEND
117|SAME_PARTY
118|SAME_BLOODPLEDGE

HF
25.04.2007, 19:12
Next step... if, elseif, for... Complete. (i hope)


//---------------------------------------------------
// L2ScriptMaker AI Decompiler Project
//---------------------------------------------------
// Decompiling: xx.xx.2007 1:07:56
// Decompiler build is: 1.0.0.41533
//---------------------------------------------------
....

elseif ((reply == 3))
{
myself->FHTML_SetFileName(fhtml0, ("seed_client_info" + state + ".htm"));
for ( i2 = 1; i2 <= 25; i2 = i2 + 1)
{
myself->FHTML_SetInt(fhtml0, ("CurrentSeedCount" + i2), (myself->GetCurrentSeedSellCountSet(state, i2)));
myself->FHTML_SetInt(fhtml0, ("CurrentSeedPrice" + i2), (myself->GetCurrentSeedPrice(state, i2)));
myself->FHTML_SetInt(fhtml0, ("CurrentSeedRemain" + i2), (myself->GetCurrentSeedRemainCount(state, i2)));
}
myself->ShowFHTML(talker, fhtml0);
}
....
handler SUBJOB_LIST_INFORMED (talker, ask, i0, i1, i2, i3, i4, i5, i6, i7, i8, fhtml0)
{
if ((ask == 1))
{
if ((i8 == 0))
{
if ((i2 == -1) && myself->GetOneTimeQuestFlag(talker, 235) || (i2 != -1) && (i3 >= 75) && (i4 == -1) || (i4 != -1) && (i5 >= 75) && (i6 == -1) && (i0 != 16) && (i0 != 97) && (i2 != 16) && (i2 != 97) && (i4 != 16) && (i4 != 97) && (i6 == -1) && myself->IsInCategory(7, i0) || myself->IsInCategory(8, i0))
{
myself->CreateSubJob(talker, 16);
}
else.
{
myself->ShowPage(talker, "master_lv3_hec_04.htm");
}
}
elseif ((i0 != 16) && (i0 != 97) && (i2 != 16) && (i2 != 97) && (i4 != 16) && (i4 != 97))
{
if ((i8 == 1) && (i3 < 40))
{
myself->ShowPage(talker, "master_lv3_hef_19.htm");


Next step... case, while...

Lirix
25.04.2007, 19:33
cool. good job.

hhk31257
25.04.2007, 23:23
ownage dude! keep up your work.

HF
05.06.2007, 07:57
have problem in decompiling this part of code

original ai.obj code

push_event // myself
push_const 704
add
fetch_i
push_event // target
push_const 96
add
fetch_i
push_const 1170
func_call 184680579 // func[OwnItemCount]
shift_sp -2
push_const 1
equal
push_reg_sp
fetch_i
branch_false L118403
L118402
push_event // always_list
push_const 688
add
fetch_i
push_const 0
push_event // target
push_const 96
add
fetch_i
func_call 251789313 // func[SetInfo]
shift_sp -2
shift_sp -1
L118403
L118404
push_event // gg
push_const 632
add
fetch_i
push_event // code_info
push_const 696
add
push_reg_sp
fetch_i
push_event // always_list
push_const 688
add
fetch_i
func_call 251658240 // func[Next]
assign
fetch_i
func_call 218169355 // func[IsNull]
shift_sp -1
push_const 0
equal
branch_false L118405
push_event // code_info
push_const 696
add
fetch_i // code
push_const 60
add
fetch_i4
push_reg_sp
fetch_i
push_const 0
equal
branch_false L118408
L118407



my decompiling

if (myself->OwnItemCount(target, 1170) == 1)
{
always_list->SetInfo(0, target);
}
gg = code_info + always_list->Next();
if (code_info.code == 0)
{
myself->SetCurrentQuestID(402);


sauron decompiling

if( myself->OwnItemCount(target,1170) == 1 )
{
always_list->SetInfo(0,target);
}
while( code_info = always_list->Next()->() == 0 )
{
if( code_info.code == 0 )


Questions:
- how you think - how must be decompiled code here
- maybe ai.obj code have errors

Problem. I cant decompile this code... Im crazy.

Freeman
05.06.2007, 17:19
Why label L118404 are in the code? Is there any link on it? I think that the answers to this Q will make decompilation understandable.

Mistakes in AI? I do not exclude, but rather on a logical level, not compiler errors, whem label appear without meaning.

HF
07.06.2007, 09:36
Why label L118404 are in the code? Is there any link on it? I think that the answers to this Q will make decompilation understandable.

Mistakes in AI? I do not exclude, but rather on a logical level, not compiler errors, whem label appear without meaning.
I dont know why label in code :) Maybe because it made in NCSoft?!
With and without - result is one. Problem in code. What must be in source?

Ehheehe...

m4rk
07.06.2007, 09:47
there's a jump L118404 in that ai class, so L118404 is needed.

HF
09.06.2007, 09:44
AIDecompiler complete 98%
Final conclusion: NCSoft AI.obj code is made shoddily, dishonestly.

madar
09.06.2007, 11:07
and AI Compiler? :P

HF
09.06.2007, 11:34
and AI Compiler? :P
no yet
next