Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 16.06.2007, 17:29   #1
PyroMaker
Архивный участник
 
Join Date: Nov 2006
Posts: 277
Default [HELP] How to make NPCs stop chasing after a certain point.

Hi,

I've finally managed to make NPCs aggro correctly, and finished my Project Gondor, it works perfectly. Thank you all for your support.

However, I have a very last issue, people get NPCs to chase them and bring them to spawn point, since their AI has no movement at all (wanted to make them stand still) they don't go back to their original positions.

So I was wondering, is it possible to make an NPC chase you until a certain point and after that make it come back to its original position?

If that is so, can you gimme a hand here?

Thank you for your help and attention.

Best regards,
Mike Philippe.
PyroMaker is offline  
Old 16.06.2007, 17:32   #2
Sdw
Архивный участник
 
Join Date: Sep 2005
Posts: 150
Default

Check those two :

func[InstantRandomTeleportInMyTerritory]
func[InMyTerritory]
Sdw is offline  
Old 16.06.2007, 17:35   #3
m4rk
Архивный участник
 
Join Date: Jan 2006
Posts: 607
Default

This is not a solution for what you asked, read down
They may get stuck while trying to come back (I don't know) but try to add this to your gondor class

nasc code
Code:
	EventHandler NO_DESIRE()
	{
		myself->AddMoveToDesire(myself.start_x,myself.start_y,myself.start_z,30);
	}
basically copy pasting this into ur gondor class
Code:
handler 0 29	//  NO_DESIRE
	variable_begin
		"myself"
		"_choiceN"
		"_code"
		"_from_choice"
	variable_end

	push_event	//  myself
	push_const 704
	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
	push_const 30
	func_call 184811540	//  func[AddMoveToDesire]
	shift_sp -4
	shift_sp -1
handler_end
If you see they get stuck or something then just replace the addmovedesire by a instantteleport

OK, read now xD
edit: Ok, at first I did not read correctly what you wanted. What I've put up here only solves the problem once the gondor guard has nothing to (i.e. the char he was attacking too bsoed).

I guess a good solution would be using the func[InMyTerritory] this way:
Code:
if (myself->InMyTerritory(myself.sm))
{
}
else
{
			myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
			RemoveAllAttackDesire();
}
m4rk is offline  
Old 16.06.2007, 17:42   #4
Bloodust
Архивный участник
 
Join Date: May 2006
Posts: 135
Default

I answered PyroMaker in IRC with a lot more simplier answer
[20:31:07] <Bloodust> if distance from current position is higher than something, move to spawn point ?
[20:33:09] <Bloodust> is that possible ?
Bloodust is offline  
Old 16.06.2007, 18:10   #5
Sdw
Архивный участник
 
Join Date: Sep 2005
Posts: 150
Default

You can check this way if (myself->InMyTerritory(myself.sm) == 0)

Code:
	func_call 184615156	//  func[InMyTerritory]
	shift_sp -1
	push_const 0
	equal
So
Code:
if (myself->InMyTerritory(myself.sm) == 0)
{
			myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
			RemoveAllAttackDesire();
}
or

Code:
if (myself->InMyTerritory(attacker) == 0)
{
			myself->RemoveAllAttackDesire(attacker->id);
			myself->InstantTeleportInMyTerritory(start_x,start_y,start_z);
}
I would use func[InstantTeleportInMyTerritory] instead of InstantTeleport but, well, it's the very same.
Sdw is offline  
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  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 19:38.