Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 21.06.2007, 09:39   #1
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default AI Common commands

Handler
call_super
exit_handler

Variable definition type
fetch_f
fetch_i4
fetch_d
fetch_i

Stack using
push_const
push_string
add_string
push_parameter
push_property
push_reg_sp

Arithmetical commands
assign4
assign
add
sub
div
mul
negate
mod

Bit operation
bit_or
bit_and
xor
not

Functions
func_call

Logical
equal
greater
greater_equal
not_equal
less_equal
less
and
or

Stack using
shift_sp

Hyperlinks
jump
branch_false
branch_true

Labels
Lxxx
Sxxx

note. where * - increased number
HF is offline  
Old 21.06.2007, 09:45   #2
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Note. Guide for using all push_
Code:
push_const
push_string
add_string
push_parameter
push_property
Code:
push_const 1000
Push to stack value 1000
Code:
push_string S0
Read string data from label S0 to memory.
Code:
push_parameter fnHi
Same like push_const, but reading constant from 'parameter_define_begin' block.
Code:
push_property SellList0
Push property name for next using teleport list or buy/sell list from 'property_define_begin' block.
Code:
add_string 1025
split last event as string to previous stack string value
Code:
S973.   "crop_client_info"
        push_string S973
        push_parameter manor_id
        add_string 1025
S974.   ".htm"
        push_string S974
        add_string 1028
"crop_client_info" + manor_id + ".htm"
HF is offline  
Old 21.06.2007, 10:26   #3
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

How use commands:
push_event, push_const, add, fetch_i, push_string, func_call, shift_sp, Sxxx

Example
Code:
handler 4 13    //  TALK_SELECTED
        variable_begin
                "talker"
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end

        push_event      //  myself
        push_const 704
        add
        fetch_i
        push_event      //  talker
        push_const 40
        add
        fetch_i
S0.     "noquest.htm"
        push_string S0
        func_call 184680516     //  func[ShowPage]
        shift_sp -2
        shift_sp -1
handler_end
My commentary: i cant tell you full how work 'fetch_i' and 'add'. It no easy to tell on english. I can give you guide about common of working AI.

1) handler 4 13 // TALK_SELECTED

Some examples:
Handler 'TALK_SELECTED' uses when player select link 'Quest'.
Handler 'TALKED' uses if your npc can show dialoge for you (not attacked). Uses for checking PK player for open required dialog or etc.
Handler 'CREATED' uses for npc who create Privates around self.
Example, Pytan spawned. Server check handler 'CREATED' in 'pytan' ai class and start it. Next reading Private list and spawned privates from this handler.
Example 2, this handler uses for start walking npc to required point, for start timer and etc.


2) Variables
Code:
        variable_begin
                "talker"
                "myself"
                "_choiceN"
                "_code"
                "_from_choice"
        variable_end
Here handler will be use 2 variable 'talker' and 'myself' (note. 'myself' define always and everywhere)

3) Code
3.1)
Code:
        push_event      //  myself
        push_const 704
        add
        fetch_i
Show what server use event with ID 704 (myself) and save it to memory for next using (add).
Note. server save not integer 704, but real memory offcet for this event

Code:
        push_event      //  talker
        push_const 40
        add
        fetch_i
add to memory and event 'talker'

Code:
S0.     "noquest.htm"
        push_string S0
Label 'S0.' define parameter into code with label name S0.
push_string command read string data from label S0 to memory.

Function
Code:
        func_call 184680516     //  func[ShowPage]
Each function have required params list for running and output param (required params can by empty, and output can be empty, but cant be empty both)
Function 'ShowPage' have id in npcserver as 184680516.
Note. Retail pack (free share C4server retail pack) have bug value for fetch, event, func.
Function 'ShowPage' required 2 input parameter and 1 output. This function in decompiled mode:
Code:
myself->ShowPage(talker, fnHi);
What happening next. Before running, server read 2 params (it 'talker' and 'fnhi'). Function show server Html page (fnHi) to player ('talker').
Note. This decompiled format use C4Decompiler (by Sauron). Another developer can use another, like this:
Code:
ShowPage(talker.myself, fnHi);
Stack using
Code:
        shift_sp -2
        shift_sp -1
Clear (or shift offset marker) to -2 (because we use 2 input params)
Clear -1 stack because we used 1 output 'myself->' param.

handler_end
Required handler end definition. Check amount lines - 13.
HF is offline  
Old 21.06.2007, 10:43   #4
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Simple using Function.
Func_call, push_const, mul

Code:
       push_event      //  myself
       push_const 704
       add
       fetch_i
       push_const 1005
       push_const 120
       push_const 1000
       mul
       func_call 184680487     //  func[AddTimerEx]
       shift_sp -2
       shift_sp -1
Make all by step-by-step (1,2,3- stack value's in stack)
  1. add myself event to stack (1)
  2. add value 1005 stack (2)
  3. add value 120 to stack (3)
  4. add value 1000 to stack (4)
  5. use 'mul'. Mul - arithmetical command for * two value. Read 2 last stack value and made operation - 120* 1000. Save to stack (120*1000) (3)
  6. start funtion AddTimerEx with use 2 params and 1 output
    Code:
    myself->AddTimerEx(1005, (120 * 1000));
  7. clear this unused stack values from stack -2 (1)
  8. clear this unused stack values from stack -1 (0)
HF is offline  
Old 21.06.2007, 10:49   #5
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

Quote:
Originally Posted by HF View Post
Logical commands
sub
div
mul
negate
- Also:
add
xor
mod
bit_or
bit_and
not
--------

Class 1
Class 2
Type 1 for NPCs, Type 2 for Npc Maker (defines spawning rules)

--------

Are you sure that labels are not counted in handlers lenght? Cos from original AI I can tell that they are counted.
ateh is offline  
Old 21.06.2007, 11:00   #6
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Quote:
Originally Posted by ateh View Post
- Also:
add
xor
mod
bit_or
bit_and
not
Can give how it to see in decompiled mode?

add = +
xor = xor
mod = /
...

Quote:
Are you sure that labels are not counted in handlers lenght? Cos from original AI I can tell that they are counted.
Yes. It question has been discussed some month ago. But.. i told only what i find in retail AI.obj. All handlers have value equal amount line into handler without Lxx, Empty lines and Variables block. Maybe you know "NCSoft real true" or have retail Compiler?
HF is offline  
Old 21.06.2007, 11:11   #7
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Use 'assign'

Code:
class 1 undead_priest : warrior_pa_slow_type2
handler 10 329	//  MY_DYING
	variable_begin
		"always_list"
		"c1"
		"code_info"
		"i9"
		"last_attacker"
		"lparty"
		"member"
		"random1_list"
		"target"
		"myself"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end

	push_event	//  always_list
	push_const 688
	add
	push_reg_sp
	fetch_i
	push_event	//  gg
	push_const 632
	add
	fetch_i
	func_call 218103812	//  func[AllocCodeInfoList]
	assign
	shift_sp -1
- two last stack values
always_list (1) and gg->AllocCodeInfoList() (2) uses in
- operation is value assignment 'gg->AllocCodeInfoList()' for variable 'always_list'

Code:
                always_list = gg->AllocCodeInfoList();
---------
Short and easy example:

Code:
L2269
        push_event      //  i0
        push_const 260
        add
        push_reg_sp
        fetch_i
        push_event      //  i0
        push_const 260
        add
        fetch_i4
        push_const 1000322
        add
        assign4
        shift_sp -1
show like this
Code:
        i0 = i0 + 1000322;
HF is offline  
Old 21.06.2007, 16:10   #8
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

Quote:
Originally Posted by HF View Post
Can give how it to see in decompiled mode?

add = +
xor = xor
mod = /
...
That's what I added to Sauron's decompiler:
Code:
			case 'mul':
				$stack[$sp-1] =  $stack[$sp-1].' * '.$stack[$sp];
				if($sp != 0) $stack[$sp-1] = '( '.$stack[$sp-1].' )';
				$sp--; array_pop($stack);
				break;
			case 'xor':
				$stack[$sp-1] =  $stack[$sp-1].' ^ '.$stack[$sp];
				if($sp != 0) $stack[$sp-1] = '( '.$stack[$sp-1].' )';
				$sp--; array_pop($stack);
				break;
			case 'mod':
				$stack[$sp-1] =  $stack[$sp-1].' % '.$stack[$sp];
				if($sp != 0) $stack[$sp-1] = '( '.$stack[$sp-1].' )';
				$sp--; array_pop($stack);
				break;
			case 'bit_or':
				$stack[$sp-1] =  $stack[$sp-1].' | '.$stack[$sp];
				if($sp != 0) $stack[$sp-1] = '( '.$stack[$sp-1].' )';
				$sp--; array_pop($stack);
				break;
			case 'bit_and':
				$stack[$sp-1] =  $stack[$sp-1].' & '.$stack[$sp];
				if($sp != 0) $stack[$sp-1] = '( '.$stack[$sp-1].' )';
				$sp--; array_pop($stack);
				break;
			case 'negate':
				$stack[$sp] *= -1;
				break;
			case 'not':
				$stack[$sp] = '~('.$stack[$sp].')';
				break;
Well, some of this lines were already there, so check which you don't have.

Quote:
Originally Posted by HF View Post
Yes. It question has been discussed some month ago. But.. i told only what i find in retail AI.obj. All handlers have value equal amount line into handler without Lxx, Empty lines and Variables block. Maybe you know "NCSoft real true" or have retail Compiler?
Well, I don't have retail compiler ;P But I was sure I had original AI from begining and there Lxxx were counted into handler... Gonna try with lowering this number by count of Lxxx and see what happens
ateh is offline  
Old 21.06.2007, 16:24   #9
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Quote:
Originally Posted by ateh View Post
That's what I added to Sauron's decompiler:
Code:
...
Well, some of this lines were already there, so check which you don't have.

Well, I don't have retail compiler ;P But I was sure I had original AI from begining and there Lxxx were counted into handler... Gonna try with lowering this number by count of Lxxx and see what happens

1) maybe you can more changes in decompiler? "New unoffical release"


2) Oh.. yes... I wrong. Wrong only in thread. Yes. Need count all and Lxxx labels too. I can confirm it - my tool, im always counting with Labels.
But another developers have different openition. You can find thread about "C4 compiler" service.
I'll fix everywhere in this thread all my errors.
HF is offline  
Old 21.06.2007, 17:24   #10
DeKoth
Архивный участник
 
Join Date: Apr 2006
Posts: 236
Default

This thread is amazing, great work HF im impressed, I hope you build on this further.
DeKoth is offline  
Old 21.06.2007, 18:24   #11
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

Quote:
Originally Posted by HF View Post
1) maybe you can more changes in decompiler? "New unoffical release"
I think this was all that I added there myself. Plus changes some data files as some IDs were not matching NPC server I use...
Or maybe you are interested in version for C1? I made one by changing Sauron's C4 version.
ateh is offline  
Old 21.06.2007, 18:42   #12
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Quote:
Originally Posted by ateh View Post
I think this was all that I added there myself. Plus changes some data files as some IDs were not matching NPC server I use...
Or maybe you are interested in version for C1? I made one by changing Sauron's C4 version.
No no. I mean C4. For C1 i used HDDecompiler
HF is offline  
Old 21.06.2007, 20:01   #13
FidoW
Архивный участник
 
Join Date: Sep 2005
Posts: 1,014
Default

Quote:
Originally Posted by HF View Post
2) Oh.. yes... I wrong. Wrong only in thread. Yes. Need count all and Lxxx labels too. I can confirm it - my tool, im always counting with Labels.
But another developers have different openition. You can find thread about "C4 compiler" service.
I dont know what discussion are you talking about but i dont remember nothing like that, there is only one way to get the second parameter of a handler declaration, the number of lines include labels, you need to count lines beggining after the var declaration... example...

Code:
	handler 0 0	//  NO_DESIRE
		variable_begin
			"myself"
			"_choiceN"
			"_code"
			"_from_choice"
		variable_end

	handler_end
No one... 0

Code:
	handler 4 13	//  TALK_SELECTED
		variable_begin
			"talker"
			"myself"
			"_choiceN"
			"_code"
			"_from_choice"
		variable_end

1		push_event	//  myself
2		push_const 704
3		add
4		fetch_i
5		push_event	//  talker
6		push_const 40
7		add
8		fetch_i
9	S0.	"noquest.htm"
10		push_string S0
11		func_call 184680516	//  func[ShowPage]
12		shift_sp -2
13		shift_sp -1
	handler_end
Code:
	handler 3 38	//  TALKED
		variable_begin
			"talker"
			"myself"
			"_choiceN"
			"_code"
			"_from_choice"
		variable_end

1		push_event	//  talker
2		push_const 40
3		add
4		fetch_i	//  karma
5		push_const 468
6		add
7		fetch_i4
8		push_const 0
9		greater
10		branch_false L2
11	L1
12		push_event	//  myself
13		push_const 704
14		add
15		fetch_i
16		push_event	//  talker
17		push_const 40
18		add
19		fetch_i
20		push_parameter fnYouAreChaotic
21		func_call 184680516	//  func[ShowPage]
22		shift_sp -2
23		shift_sp -1
24		jump L3
25	L2
26		push_event	//  myself
27		push_const 704
28		add
29		fetch_i
30		push_event	//  talker
31		push_const 40
32		add
33		fetch_i
34		push_parameter fnHi
35		func_call 184680516	//  func[ShowPage]
36		shift_sp -2
37		shift_sp -1
38	L3
	handler_end
FidoW is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 18:58.