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.