View Single Post
Old 16.06.2007, 18:24   #6
m4rk
Архивный участник
 
Join Date: Jan 2006
Posts: 607
Default

This should work:
It checks every 5 seconds if it's in his territory...
Remember that the territory is defined in npcpos, so if you've done a little territory for each npc you'll have to change it to the area you want it to be their territory!

nasc
Code:
/***************************************************************************
*                                Change Log
*                            ------------------
*   xx.xx.2007
*   Script Decompiled by SauDecompiler build 102306.2
*
***************************************************************************/

class gondor : whatever
{
handler:
	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( myself->InMyTerritory(myself.sm) == 0 )
		{
			myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
			RemoveAllAttackDesire();
		}
		myself->AddTimerEx(1234,5000);
		super;
	}

	EventHandler CREATED()
	{
		myself->AddTimerEx(1234,5000);
		super;
	}

}
ai
Code:
class 1 gondor : whatever

handler 12 77	//  TIMER_FIRED_EX
	variable_begin
		"timer_id"
		"myself"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end

	push_event	//  timer_id
	push_const 236
	add
	fetch_i4
	push_const 3001
	equal
	branch_false L4
	push_event	//  myself
	push_const 704
	add
	fetch_i
	push_event	//  myself
	push_const 704
	add
	fetch_i	//  sm
	push_const 544
	add
	fetch_i
	func_call 184615156	//  func[InMyTerritory]
	shift_sp -1
	push_const 0
	equal
	branch_false L2

L1
	push_event	//  myself
	push_const 704
	add
	fetch_i
	push_event	//  myself
	push_const 704
	add
	fetch_i	//  sm
	push_const 544
	add
	fetch_i
	push_event	//  myself
	push_const 704
	add
	fetch_i	//  start_x
	push_const 588
	add
	fetch_i4
	push_event	//  myself
	push_const 704
	add
	fetch_i	//  start_y
	push_const 592
	add
	fetch_i4
	push_event	//  myself
	push_const 704
	add
	fetch_i	//  start_z
	push_const 596
	add
	fetch_i4
	func_call 184811596	//  func[InstantTeleport]
	shift_sp -4
	shift_sp -1
	push_event	//  myself
	push_const 704
	add
	fetch_i
	func_call 184549401	//  func[RemoveAllAttackDesire]
	shift_sp -1
L2
L3
	push_event	//  myself
	push_const 704
	add
	fetch_i
	push_const 1234
	push_const 5000
	func_call 184680487	//  func[AddTimerEx]
	shift_sp -2
	shift_sp -1
L4
  call_super
handler_end

handler 13 10	//  CREATED
	variable_begin
		"myself"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end

	push_event	//  myself
	push_const 704
	add
	fetch_i
	push_const 1234
	push_const 5000
	func_call 184680487	//  func[AddTimerEx]
	shift_sp -2
	shift_sp -1
	call_super
handler_end


class_end
m4rk is offline