![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Архивный участник
Join Date: Nov 2006
Posts: 277
|
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. |
|
|
|
|
#2 |
|
Архивный участник
Join Date: Sep 2005
Posts: 150
|
Check those two :
func[InstantRandomTeleportInMyTerritory] func[InMyTerritory] |
|
|
|
|
#3 |
|
Архивный участник
Join Date: Jan 2006
Posts: 607
|
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);
}
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 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();
}
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: May 2006
Posts: 135
|
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 ? |
|
|
|
|
#5 |
|
Архивный участник
Join Date: Sep 2005
Posts: 150
|
You can check this way if (myself->InMyTerritory(myself.sm) == 0)
Code:
func_call 184615156 // func[InMyTerritory] shift_sp -1 push_const 0 equal Code:
if (myself->InMyTerritory(myself.sm) == 0)
{
myself->InstantTeleport(myself.sm,myself.start_x,myself.start_y,myself.start_z);
RemoveAllAttackDesire();
}
Code:
if (myself->InMyTerritory(attacker) == 0)
{
myself->RemoveAllAttackDesire(attacker->id);
myself->InstantTeleportInMyTerritory(start_x,start_y,start_z);
}
|
|
|
|
|
#6 |
|
Архивный участник
Join Date: Jan 2006
Posts: 607
|
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;
}
}
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 |
|
|
|
|