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.
|
Code:
sub EVENT_SAY { Code:
sub EVENT_SPAWN { |
You can do this:
Code:
sub EVENT_SPAWN { 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. |
Damnit >< I was so close to gettin this to work that way and just missed it by a smidge.
Thanks Trev! |
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 :)
|
I tried using the quest you put and just changed the ID, but the mob still won't follow the other npc.
|
Hmm, worked for me... I used mine with a signal however.
|
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.
|
Wait, they can't follow a mob on a grid?
|
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. |
This is the monster that spawns the other npcs
Code:
sub EVENT_SPAWN{ Code:
sub EVENT_SPAWN { |
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 { 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); |
Thanks Trev, that worked.
|
All times are GMT -4. The time now is 02:43 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.