View Single Post
  #10  
Old 07-23-2009, 03:40 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I put a little more work into this to trim it up a bit more. Now, you no longer need to do ifs for each zone, you just add them to the array. I am using quest::zone() to send them to the safe loc of the zone requested. If needed, you could either adjust the safe loc in the zone table, or you could probably add in some more ifs for specific zones.

This makes the script much easier to manage and tons easier to add more new zones to it. No more need to find a loc to send them to and add in another if statement.

Code:
#Translocator for Multiple Zones

#Array for all available zones to be sent to
@ZoneList = qw(
	cazicthule
	akanon
	bothunder
	befallen
	blackburrow
	cabeast
	cabwest
	mistmoore
	chardok
	thurgadina
	veksar
	cobaltscar
	crystal
	dalnir
	necropolis
	dreadlands
	dulak
	freporte
	echo
	erudnext
	unrest
	everfrost
	fieldofbone
	fungusgrove
	greatdivide
	grobb
	guktop
	halas
	highkeep
	charasis
	paw
	kael
	kaesora
	karnor
	kurn
	lakeofillomen
	nurga
	soldungb
	najena
	nexus
	freportn
	nro
	oggok
	sebilis
	permafrost
	airplane
	fearplane
	growthplane
	hateplane
	poinnovation
	poknowledge
	mischiefplane
	ponightmare
	postorms
	povalor
	qeytoqrg
	rivervale
	runnyeye
	shadowhaven
	skyshrine
	soldunga
	sro
	felwitheb
	ssratemple
	qrg
	acrylia
	arena
	burningwood
	citymist
	sharvahl
	nadox
	dawnshroud
	thegrey
	gunthak
	hole
	jaggedpine
	maiden
	overthere
	paludal
	podisease
	hateplaneb
	pojustice
	scarlet
	umbral
	frozenshadow
	poeartha
	velketor
	vexthal
	warrens
	warslikswood
	freportw
);

sub EVENT_SAY{

	my $all = quest::saylink("All", 1);

	#Spacer between Text messages to make them easier to read
	$client->Message(7, "-");
	my $NPCName = $npc->GetCleanName();

	if ($text =~/Hail/i)
	{
		$client->Message(315, "$NPCName whispers to you, 'If there is a zone you would like to go to, just tell me the short name of it and I will see if I have a spell to send you there. If you do not know the full name, just type part of the name to search my list of possible zones.  Or, I can list [$all] of them if you like.'");
	}

	#Counts each row for the While
	my $count = 1;

	#Counts each element in the Array for the While
	my $n = 0;

	
	if ($text !~ /Hail/i)
	{
		#Use scalar form of Array
		while ($ZoneList[$n])
		{
			#This uses the lc() function in perl to convert anything typed into all lowercase, since that is what the zone list is
			#If the zone name contains part of the text said, or if the player wants to list all possible zones we list them
			if (($ZoneList[$n] =~ lc($text) && $ZoneList[$n] ne lc($text)) || ($text =~ /^All$/i))
			{
				my $ZoneName = quest::saylink($ZoneList[$n]);
				$client->Message(315, "$NPCName whispers to you, 'Possible match is: $ZoneName");
			}
			#If they say the full name of one of the zones in the Array, or click one of the saylinks, port them to the safe loc there
			if ($ZoneList[$n] eq lc($text) && $text !~ /^All$/i)
			{
				$client->Message(315, "$NPCName whispers to you, 'Enjoy your adventure!'");
				$client->Message(6, "$NPCName casts a spell to translocate you to another place.");
				quest::zone("$ZoneList[$n]");
			}
			$n++;
			$count++;
		}
	}
}
Thanks, pfyon, for the idea. I was just being lazy to not put too much time into this simple script :P
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 07-27-2009 at 01:19 AM..
Reply With Quote