View Single Post
Old 11.11.2005, 16:42   #5
StaticVoid
Архивный участник
 
Join Date: Oct 2005
Posts: 18
Default

Code:
handler 17 // OUT_OF_TERRITORY 
variable_begin 
"myself" 
"_choiceN" 
"_code" 
"_from_choice" 
variable_end 

push_event // myself 
push_const 28 
add 
fetch_i // sm 
push_const 2400 
add 
fetch_i // hp 
push_const 344 
add 
fetch_d 
push_event // myself 
push_const 28 
add 
fetch_i // sm 
push_const 2400 
add 
fetch_i // max_hp 
push_const 1000 
add 
fetch_d 
push_const 1xx.xx0000 
div 
push_const xx.xx0000 
mul 
greater 
branch_false L75002 
L75001 
shift_sp 1 
push_event // myself 
push_const 28 
add 
fetch_i // start_x 
push_const 2428 
add 
fetch_i 
push_event // myself 
push_const 28 
add 
fetch_i // start_y 
push_const 2432 
add 
fetch_i 
push_event // myself 
push_const 28 
add 
fetch_i // start_z 
push_const 2436 
add 
fetch_i 
func_call 46 // func[InstantTeleport] 
shift_sp -4 
shift_sp -1 
L75002 
handler_end
You are calling function instant_teleport with only 3 legit arguments in the stack. If you look at the function references in my ai.obj Tutorial:

func_call 46 // func[InstantTeleport] (rv, event[myself][sm],int(x),int(y),int(z))

the function uses 4 arguments so the stack must be like this before you call it:
Quote:
z coord
y coord
x coord
event[myself][sm]
space kept for return value with shift_sp 1 (it has an arbitrary value)
instead the stack in your code is like thus:
Quote:
z coord
y coord
x coord
space kept for return value with shift_sp 1 (it has an arbitrary value)
with the shift_sp -1 you should get a stack underflow error in that handler (the boolean value is popped out of the stack after the branch check).


alter your code by adding the following after the label L75001:
L75001
shift_sp 1
[highlight=red:5a498c9f6d]push_event // myself
push_const 28
add
fetch_i // sm
push_const 2400
add
fetch_i
[/highlight:5a498c9f6d]
push_event // myself
push_const 28
add
fetch_i // start_x
push_const 2428
add
fetch_i
push_event // myself
push_const 28
add
fetch_i // start_y
push_const 2432
add
fetch_i
push_event // myself
push_const 28
add
fetch_i // start_z
push_const 2436
add
fetch_i
func_call 46 // func[InstantTeleport]
shift_sp -4
shift_sp -1
L75002
handler_end

I hope the above will solve your problem
StaticVoid is offline