View Single Post
Old 02.05.2007, 19:41   #11
GMan
Архивный участник
 
Join Date: Sep 2005
Posts: 198
Default

hmm didnt know that. In that case just remove the parameter section and change myvar to i0 or what ever is not in use and i assume add it to the variable list.

here is what i came up with for an example

Code:
class 1 test : (null)
	parameter_define_begin
		int rand_num 3
	parameter_define_end
handler 1 12	//  ATTACKED
	variable_begin
		"attacker"
		"damage"
		"myself"
		"i1"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end
	
	push_event	//  i1
	push_const 264
	add
	push_reg_sp
	fetch_i
	push_event	//  gg
	push_const 632
	add
	push_parameter rand_num
	func_call 218169344	//  func[Rand]
	shift_sp -1
	assign4
	shift_sp -1
L1             
	push_event	//  i1
	push_const 264
	add
	fetch_i
	push_const 1
	equal
	branch_false L3
L2
	push_event	//  myself
	push_const 704
	add
	fetch_i
S16926.	"Message 1"
	push_string S16926
	func_call 184614973	//  func[Say]
	shift_sp -1
L3
	push_event	//  i1
	push_const 264
	add
	fetch_i
	push_const 2
	equal
	branch_false L5
L4
	push_event	//  myself
	push_const 704
	add
	fetch_i
S16926.	"Message 2"
	push_string S16926
	func_call 184614973	//  func[Say]
	shift_sp -1
	jump L6
L5
	push_event	//  myself
	push_const 704
	add
	fetch_i
S16926.	"Message 3"
	push_string S16926
	func_call 184614973	//  func[Say]
	shift_sp -1
L6
	shift_sp -1
handler_end

class_end
that equates to

Code:
class test : (null)
{
parameter:
	int	rand_num = 3;

handler:
	EventHandler ATTACKED(attacker,damage,i1)
	{
		i1 = gg->Rand(rand_num);
		if( i1 == 1 )
		{
			myself->Say("Message 1");
		}
		if( i1 == 2 )
		{
			myself->Say("Message 2");
		}
		else
		{
			myself->Say("Message 3");
		}
	}

}
i decided to leave the parameter option in so i could be changed easily and can be changed in the NPCDATA if wanted

Also thought about another method you could use that NCSoft uses, and that is to change he random number to like 100 and then do a few ifs to see if its <20 or >50 this way you get a slightly more random seeming system

anyway hope this helps, sorry to have kinda hijacked your topic but i learned a few things from this topic that i wasn't expecting
GMan is offline