PDA

View Full Version : Method for automaticly generating locs for quest spawned NPC's


kayen85
02-12-2009, 02:43 PM
Maybe there is a better way that people use. But for the longest time when I was quest spawning NPC via scripts I would always manually enter the locs, using #loc then just writing that down into the file. Obviously this is time consuming and tedious when you need to generate a large number. So here is a small script I wrote that will automatically do it for you.

In short. You spawn the mob. It automatically saves its location to a text file. Then despawn. For added control you can alter the code to let you use say for when you want to store the locs. Then you can directly copy and paste the entire quest spawn from. Its very efficient.

- First create an NPC call it whatever you want. I used the name ####LOC
- Then create a quest file for this NPC in the zone you will be generating the locations
- Then just dbspawn the NPC your using for this (in this case I used ####LOC ). It will spawn store the loc and depop.
- Go to txt file and copy and paste out your spawn2 information


Basically the most important part for customizing the NPCid in this.
quest::write("LocGen.txt","quest::spawn2(888183,0,0, $LocX, $LocY, $LocZ , $LocH);");

# Mob name: ####LOC ID: 888184
#This generates and saves locations for copy and paste.
#Yes = save
#No = Depop
#Break = Line break in .txt

sub EVENT_SAY {
if ($text=~/hail/i) {
quest::say("[Yes] or [No]. [Break]");
}

if ($text=~/Yes/i) {
my $LocX = $npc->GetX();
my $LocY = $npc->GetY();
my $LocZ = $npc->GetZ();
my $LocH = $npc->GetHeading();
quest::say( "quest::spawn2(ReplaceID,0,0, $LocX, $LocY, $LocZ , $LocH);") ;
quest::write("LocGen.txt","quest::spawn2(888183,0,0, $LocX, $LocY, $LocZ , $LocH);");
quest::depop();
}

if ($text=~/No/i) {
quest::depop();
}

if ($text=~/Break/i) {
quest::write("LocGen.txt"," ");
}

}

### Disable this if you want more detailed control ###
sub EVENT_SPAWN {
my $LocX = $npc->GetX();
my $LocY = $npc->GetY();
my $LocZ = $npc->GetZ();
my $LocH = $npc->GetHeading();
quest::say( "quest::spawn2(ReplaceID,0,0, $LocX, $LocY, $LocZ , $LocH);") ;
quest::write("LocGen.txt","quest::spawn2(888183,0,0, $LocX, $LocY, $LocZ , $LocH);");
quest::settimer("depop",1);
}

sub EVENT_TIMER {
if ($timer eq "depop") {
quest::stoptimer("depop");
quest::depop()
}
}

I wish I thought of this along time ago. Makes my life easier.

Kayen
GM Stormhaven