Does anyone have a quest script that could act as the basis for an idea I have? I would like a certain key npc, who has a valuable item, to “wander” randomly from zone to zone such that players who are in need of this item could not predict where he will be next and much actively search for him. I assume this would entail a global quest that depops the npc from one zone (based on a timer) and simultaneously spawns him in another. I can envision many directions I could take in this, but I'm not confident they are the most efficient.
I seem to recall there is a mob who spawns in one of three or four zones, but never in two zones at once. Maybe I can use the code for this as a template for what I am trying to do. Does anyone know who this mob is? Thanks.
ltflyr
10-04-2008, 01:11 PM
I think you're talking about the Sleeper event. I know when he was awakened he would travel to other zones.
Okay, I think I have this working, but with one outstanding issue. Here's the code for the wanderer, placed in two different zones:
sub EVENT_SPAWN
{
quest::delglobal("wanderer");
quest::shout("I'm in the zone now");
quest::settimer("depop",300);
}
sub EVENT_TIMER
{
if($timer eq "depop")
{
quest::shout("I'm leaving the zone now");
quest::stoptimer("depop");
quest::depop();
quest::setglobal("wanderer", (quest::ChooseRandom(1, 2)), 7, "F");
}
}
Here's my watcher code that checks for the global, placed in one zone:
sub EVENT_WAYPOINT
{
if (defined($qglobals{wanderer}))
{
my $x;
my $y;
my $z;
my $h;
$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
$h = $npc->GetHeading();
if ($qglobals{wanderer} == 1)
{
quest::spawn2(999228,0,0,$x+5,$y+5,$z,$h);
}
}
}
And here is the watcher code placed in the other zone:
sub EVENT_WAYPOINT
{
if (defined($qglobals{wanderer}))
{
my $x;
my $y;
my $z;
my $h;
$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
$h = $npc->GetHeading();
if ($qglobals{wanderer} == 2)
{
quest::spawn2(999228,0,0,$x+5,$y+5,$z,$h);
}
}
}
The wanderer spawns in Zone A, then after 5 minutes depops and repops either in Zone A or Zone B. As you can see from the codes, the global sets a random number between 1 and 2. One Zone A's watcher looks for global setting 1, and Zone B's watcher looks for global setting 2. This works as far as it goes (when the wanderer depops from one Zone A I can find him in the Zone B, and vice versa). The problem is, when I find him in Zone B and then check his location in Zone A before the 5 minutes is up, I find he is also in Zone A (at his original spawn point before I introduced the "wandering" script).
His spawn limit is set to 1, so that's not the problem. I tried changing his spawn2 entry to 0% chance, but now he doesn;t spawn at all. I think the problem may be that Zone A is his original spawn zone (the loc where I find him is his original spawn point, not next to the Watcher like he should be); so I'm thinking if I remove him from Zone A it might work. But I wanted to get feedback on this first. Any better suggestions out there? What is the best command to remove him from the zone without removing him from the DB? Is it npcspawn remove?
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.