Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2009, 08:17 PM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default Get npc to follow another npc

I have been trying to figure out how to get some npcs to follow another one when they spawn, but I am not having any luck. The closest I got was when I did quest::settarget(npctype, 1412) but that just made them attack. None of my other ideas have come close so I won't bother posting them.
Reply With Quote
  #2  
Old 08-03-2009, 07:24 AM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Code:
sub EVENT_SAY {
  if($text=~/Hail/i){
    quest::emote("holds a cracked monocle up to his squinty eye.  'I say!!  A talking bear!!  Squire Fuzzmin, come and take a gander at this rare find.  The wonders never cease in the land of Kunark!!' ");
    quest::unique_spawn(84312,0,0,1985,-2243,-75);      # Spawn Squire_Fuzzmin for Wurmslayer quest
    quest::delglobal("hobble");                       
    quest::setglobal("hobble",$npc->GetID(),"3","F");   # Set global $hobble with Sir_Hobble's NPC ID so Squire_Fuzzmin can follow
    $hobble=undef;
  }
}
and

Code:
sub EVENT_SPAWN {
  quest::follow($hobble);
}
Only complaint I have about follow is that in some instances it is too close and I couldn't figure a way to control the distance... (POM My Finger/Not Yours for example and it will repeat again on Derakor)
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #3  
Old 08-03-2009, 07:20 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

You can do this:

Code:
sub EVENT_SPAWN {

#Set this to the NPCID you want the NPC to follow
my $OpponentID = 1010101;

#Get Target NPC
my $getmobbynpctype = $entity_list->GetMobByNpcTypeID($OpponentID);
#Get the NPC's Entity ID
my $follow_target = $getmobbynpctype->GetID();

quest::follow($follow_target);

}
By getting the NPC this way, you can set follow to happen from any event type including EVENT_TIMER and EVENT_SIGNAL. If you need anything else, feel free to ask.

And yeah, follow distance would be something awesome to be able to adjust. I could really use an adjustable setting for distance in the scripted event I have been working on lately.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 08-04-2009 at 03:27 AM..
Reply With Quote
  #4  
Old 08-03-2009, 07:48 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Damnit >< I was so close to gettin this to work that way and just missed it by a smidge.

Thanks Trev!
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #5  
Old 08-04-2009, 07:08 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Added a Distance option for quest::follow(entity_id, distance) to allow setting the distance for the NPC to follow at. Seems to work really well. I think this should make the follow command a bit more useful
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 08-04-2009, 11:49 AM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default

I tried using the quest you put and just changed the ID, but the mob still won't follow the other npc.
Reply With Quote
  #7  
Old 08-04-2009, 02:20 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Hmm, worked for me... I used mine with a signal however.
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #8  
Old 08-04-2009, 02:46 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Make sure that the npc you are spawning is not on a grid. The follow command won't work for npcs that are on a grid.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #9  
Old 08-04-2009, 10:21 PM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default

Wait, they can't follow a mob on a grid?
Reply With Quote
  #10  
Old 08-04-2009, 10:57 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

They can follow an NPC that is on a grid, they just can't be assigned to a grid themselves (the followers), which also includes a temporary grid. I think even if you use the quest::moveto command and try to make them follow something while they are on the way to that point still, it will fail because essentially it is treated like a grid with a single point in it.

Maybe you should post the whole script you are trying to make for one of these NPCs. It should be fairly easy to get it working.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #11  
Old 08-05-2009, 12:27 PM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default

This is the monster that spawns the other npcs

Code:
sub EVENT_SPAWN{
 quest::settimer("go", 5);
 quest::spawn(1412,0,0,-635,4,-10);
 quest::spawn(1412,0,0,-635,11,-10);
 quest::spawn(1412,0,0,-635,21,-10);
}
sub EVENT_COMBAT{
 if($combat_state ==1){
 quest::stop(19);
 }
 if ($combat_state ==0){
 quest::resume(19);
 }
}
sub EVENT_TIMER{
 if ($timer eq "go"){
 quest::start(19);
 quest::stoptimer("go");
}
}
and this is the npc I am trying to get to follow the first one

Code:
sub EVENT_SPAWN {
my $OpponentID = 1411;
my $getmobbynpctype = $entity_list->GetMobByNpcTypeID($OpponentID);
my $follow_target = $getmobbynpctype->GetID();
quest::follow($follow_target);
}
Reply With Quote
  #12  
Old 08-05-2009, 07:26 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

EVENT_SPAWN can sometimes be a bit flaky, because it is occurring while somethings are still being set on the spawn itself. For instance, EVENT_SPAWN cannot get the entity ID of the NPC that is being spawned, because it hasn't fully been set yet. At least that is my experience with it.

So, to get around possible issues with that, you could just use a timer like this for your spawned NPCs:

Code:
sub EVENT_SPAWN {
  quest::settimer("follow", 1);
}

sub EVENT_TIMER{
  if ($timer eq "follow"){
    my $OpponentID = 1411;
    my $getmobbynpctype = $entity_list->GetMobByNpcTypeID($OpponentID);
    my $follow_target = $getmobbynpctype->GetID();
    quest::follow($follow_target);
    quest::stoptimer("follow");
  }
}
Let me know if that works for you.

Also, if you are running the latest source code, you can play with the new follow distance setting to adjust how far/close they follow the NPC. Here is an example:

Code:
quest::follow($follow_target, 25);
The default distance is 10, so this would make them follow a bit further away. Not sure if you need this or not for what you are doing, but it definitely helps make the event I am currently working on much better looking
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #13  
Old 08-06-2009, 02:41 PM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default

Thanks Trev, that worked.
Reply With Quote
Reply


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 -4. The time now is 02:39 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3