Tool for finding all the npcs and the images they use

Here is a nifty something that I threw together in Perl, that you can use to extract all the npcs, and the images they use, to files.

Note: I know this works in Windows, can’t speak for other OS’s

To use this tool :

  1. go to www.activestate.com and install ActivePerl on your computer. Its free.

  2. copy this code
    [php]
    use File::Find;
    use Cwd;
    $path=getcwd();
    $folder="/world";
    $path=$path.$folder;
    %img=();

find(\&x,$path);

open(OUT,">all_npc_images_used.txt");
foreach my $key (sort {$a cmp $b} keys %img)
{
print OUT "$key
";
}
close(OUT);

############################
sub x
{
#check each .nw file for npcs, and if we find one, export it to its own file
return if -d;
return unless m/\.nw$/;
$nwfile=$File::Find::name;
$nwfile=~s/$path\///;
$nwfile=~s/\.nw//;
$counter=0;
print “$nwfile
“;
open(FILE,”<$File::Find::name”);
$isnpc=0;
until (eof(FILE))
{
$line=;
chop($line);

	if ($isnpc==1)
	{
		$npcstring=$npcstring.$line."\

";
}

	if($line =~ /^NPC (.*?) /)
	{
		$img{$1}=1;
		$isnpc=1;
		#create filename
		$npcfile=$nwfile;
		$npcstring=""; #append to this while $isnpc is 1
	}

	if($line =~ /^NPCEND/)
	{
		$counter++;
		# write npc to file
		$isnpc=0;
		$outfile=$path."\\/$npcfile\\_npc".$counter."\\.txt";
		$outfile=~s/ /\\_/g;
		$outfile=~s/world/perl_npcs/g;
		open(OUT,">>$outfile");
		$npcstring=~s/NPCEND//;
		#print $npcstring;
		print OUT "$npcstring\

";
close(OUT);
unless (-e $outfile)
{
die "Unable to create $outfile!
";
}
}

}
close(FILE);

}
[/php]

  1. In your graal reborn server folder, go to the servers/default/ directory and create a new text file. Open the file and paste in the code. Save the file.

  2. rename the file to find_npcs.pl or something with the .pl extension. The icon for the file should change (indicating successfull file association with ActivePerl)

  3. create a new folder here in the servers/default directory called perl_npcs

  4. double click the find_npcs.pl file

then look in the perl_npcs folder and there you go! the all_npc_images_used.txt will appear in the servers/default directory.

Please feel free to provide any constructive feedback and enhancements. I plan to make more of these for finding all levels linked to (then make sure no levels are missing), presence of chests and what type (for example, determine how many full hearts, sword and shield levels, total rupees etc exist within your world) and other stuff

Where are all of these coders coming from? Why don’t they all go to a party, get drunk and make a new client?

Maybe we can get them to help with upgrades.

super sweet

well, for making a new client, my job is in publishing related stuff so most of what I am good at is text-like file processing. not so much on the ui side of things and not a lot of math.

what do you think of an account checking/reset tool for your gserver/servers/default/accounts folder, that would let you remove a single weapon if anyone has it, or report on anyone who has more fullhearts than they should, reset everyone to a particular level-x-y position and, well, anything you can do in the account files.

for example if you wanted to do an account reset on everyone, but let people keep their appearance so they didnt have to sethead, shield, sword, colors all over again … would that be good?

yes pls

get the listserver working again so I can connect … then i’ll think about it :wink:

This would be useful