View Single Post
  #8  
Old 03-21-2010, 05:10 PM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

It's hardly for lazy people.

For examples, NPC ID 214001 belongs to 6 different spawn2 groups. Certainly a lot easier for someone to find 1 NPC ID over finding the 6 spawn groups it belongs to.

Multiply this by the 50ish NPC IDs who I'm prevent from spawning, it's a lot of looking up.

PS. How does this look?
Code:
# This is a work in progress.  Do NOT use.

sub GetSpawn2GroupIDs
{
use DBI;

my $npcID = shift;
printf("Parms 1 = %d\n", $npcID);

my $confile = "eqemu_config.xml"; #default
my $zonen = "potactics"; #only for testing
my $db = "eq";
my $user = "eq";
my $pass = "eq";
my $host = "localhost";

open(F, "<$confile") or die "Unable to open config: $confile\n";
my $indb = 0;

while(<F>) {
	s/\r//g;
	if(/<database>/i) {
		$indb = 1;
	}
	next unless($indb == 1);
	if(/<\/database>/i) {
		$indb = 0;
		last;
	}
	if(/<host>(.*)<\/host>/i) {
		$host = $1;
	} elsif(/<username>(.*)<\/username>/i) {
		$user = $1;
	} elsif(/<password>(.*)<\/password>/i) {
		$pass = $1;
	} elsif(/<db>(.*)<\/db>/i) {
		$db = $1;
	}
}
if(!$db || !$user || !$pass || !$host) {
	die "Invalid database info, missing one of: host, user, password, database\n";
}

my $source = "DBI:mysql:database=$db;host=$host";
my $dbh = DBI->connect($source, $user, $pass) || die "Could not create db handle\n";

my $spawngroupIDs = $dbh->prepare("SELECT * FROM  spawnentry WHERE npcID=$npcID");

$spawngroupIDs->execute(); #run the query on the db to get list of spawngroupIDs using NPC ID that Spawn2 uses

my($val2, $spawn2id, @spawn2groupsIDs); #define some variables, cause we're cool like that

while (my $val = $spawngroupIDs->fetch()) {
	$spawn2id = $dbh->prepare("SELECT * FROM spawn2 WHERE spawngroupID=@$val[0] AND zone='$zonen'");
	$spawn2id->execute();
	$val2 = $spawn2id->fetch();
	if(@$val2[0]) {
		push(@spawn2groupsIDs, @$val2[0]);
		}
}
return @spawn2groupsIDs;
}
Literally working on this right now. Got it finding all the spawn 2 IDs for a NPCs ID, now going to work on having it accept X, Y and Z perimeters.

PS I wasn't able to find any script that use Disable_Spawn2 and I'm guessing part of the reason is because it is to much of a hassle to write whole lists of spawn2 points.
Reply With Quote