Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02.05.2007, 10:35   #1
forsage
Архивный участник
 
Join Date: Oct 2006
Posts: 17
Default ai.obj coding question

Hello
I'm new in ai coding.
For example, I take elpy with class warrior_flee
I want , that after each kick (attack) , elpy say random some phrases...

So, I modified ai code:

Code:
class warrior_flee : warrior
{
handler:
	EventHandler NO_DESIRE()
	{
		AddMoveAroundDesire(40, 20);
	}

	EventHandler ATTACKED(attacker, damage)
	{
		
		if ( Rand(2) == 1 )
		{
			Say("test");
		}else{
			Say("test1");
		}

		AddFleeDesire(attacker, 30);
	}	
}
and ai.obj:

Code:
class 1 warrior_flee : warrior
handler 0 9	//  NO_DESIRE
	variable_begin
		"myself"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end

	push_event	
	push_const 704  //  myself
	add
	fetch_i
	push_const 40
	push_const 20
	func_call 184680455	//  func[AddMoveAroundDesire]
	shift_sp -2
	shift_sp -1
handler_end

handler 1 38	//  ATTACKED
	variable_begin
		"attacker"
		"damage"
		"myself"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end

	push_event	
	push_const 704  //  myself
	add
	fetch_i
	shift_sp 1
	push_const 2
	func_call 218169344    //  func[Rand]
	shift_sp -1
	push_const 1
	equal
	branch_false L2480
L2479
	shift_sp 1
S325.	"test"
	push_string S325
	func_call 184614973	//  func[Say]
	shift_sp -1
	shift_sp -1
	jump L2481
L2480
	shift_sp 1
S326.	"test1"
	push_string S326
	func_call 184614973	//  func[Say]
	shift_sp -1
	shift_sp -1
L2481
	shift_sp 1
	push_event	
	push_const 48  //  attacker
	add
	fetch_i
	push_const 30
	func_call 184680461	//  func[AddFleeDesire]
	shift_sp -2
	shift_sp -1
handler_end

class_end
Is it correct ?
forsage is offline  
 


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 15:32.