View Single Post
  #10  
Old 07-21-2008, 02:34 PM
Striat
Sarnak
 
Join Date: Aug 2006
Posts: 60
Wink

Decided to take a shot at cleaning up things;p I'm not exactly proficient at auto generating complex hash/array combos. And there is definitely redundancy in my example that could be cleaned up. But, here is an alternative method that may be easier for the average joe to pick up and change/add things that he wants with little quest scripting experience.

Code:
#############
#Quest Name: An Armor Quest for all Classes and Teleporter
#Author: Trevius
#NPCs Involved: The quest giver NPC can have any name you want.
#Items Involved: 7 notes made custom, and any class specific armor sets.
#################

my %itemturnins = (		#Hash of Hashes.  rewarditem is the reward given.  rewardmessage is the message given for each item turn in.
	"Bard" => { 1321=> { type => "boots", reward => 55607 }, 1323 => { type => "Greaves", reward => 55605 }, 1353 => { type => "boots", reward => 55603 }, 1372 => { type => "boots", reward => 55601 }, 1373 => { type => "boots", reward => 55604 },  1375 => { type => "boots", reward => 55606 }, 1377 => { type => "boots", reward => 55602 } },
	"Beastlord" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Berserker" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Cleric" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Druid" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Enchanter" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Magician" => { 1321=> { type => "boots", reward => 9829 }, 9830 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Monk" => { 1321=> { type => "boots", reward => 1206 }, 1323 => { type => "Greaves", reward => 1204 }, 1353 => { type => "boots", reward => 1202 }, 1372 => { type => "boots", reward => 1378 }, 1373 => { type => "boots", reward => 1203 },  1375 => { type => "boots", reward => 1205 }, 1377 => { type => "boots", reward => 1201 } },
	"Necromancer" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Paladin" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Ranger" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Rogue" => { 1321=> { type => "boots", reward => 4907 }, 1323 => { type => "Greaves", reward => 4905 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Shadowknight" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Shaman" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 4903 }, 1372 => { type => "boots", reward => 4901 }, 1373 => { type => "boots", reward => 4904 },  1375 => { type => "boots", reward => 4906 }, 1377 => { type => "boots", reward => 4902 } },
	"Wizard" => { 1321=> { type => "boots", reward => 9829 }, 1323 => { type => "Greaves", reward => 9829 }, 1353 => { type => "boots", reward => 9829 }, 1372 => { type => "boots", reward => 9829 }, 1373 => { type => "boots", reward => 9829 },  1375 => { type => "boots", reward => 9829 }, 1377 => { type => "boots", reward => 9829 } },
	"Warrior" => { 1321=> { type => "boots", reward => 4917 }, 1323 => { type => "Greaves", reward => 4915 }, 1353 => { type => "boots", reward => 4913 }, 1372 => { type => "boots", reward => 4911 }, 1373 => { type => "boots", reward => 4914 },  1375 => { type => "boots", reward => 4916 }, 1377 => { type => "boots", reward => 4912 } },
);

sub EVENT_SAY
{
if ($text =~/Hail/i)
 {
quest::say ("Hey there, $name. I can send you to [crusbone] if ya want.  That area is best suited for players of 1 to 20 season.  And if you do head that way, please see if you can find any of their instructions for [armor] crafting.  What say you?");
 }
elsif ($text =~/armor/i)
 {
quest::say ("Yes, it is said that some of the Orcs of Crushbone hold instructions for basic armor crafting.  I think they sound perfect for a novice crafter such as myself.  Would you like to hear more [rumors] about the instructions? ");
 }
elsif ($text =~/rumors/i)
 {
quest::say ("I hear the easier parts to make are kept by the common Orcs you will find there, but the harder leggings and chest instructions are only to be had by Emperor Crush himself, and his Ambassador.");
 }
elsif ($text =~/crushbone/i)
 {
quest::say ("Off ya go!");
quest::emote ("fumbles about trying to cast a spell.  Let's hope you arrive where you were heading safely...");
quest::movepc(58, 158,-644,4);
 }
}

sub EVENT_ITEM {
	my $gaveitem = 0;

foreach my $itemturnin ( sort keys %{ $itemturnins{$class} } ) {
	if (plugin::check_handin(\%itemcount, $itemturnin => 1)) {
	$gaveitem = 1;
      quest::summonitem($itemturnins{$class}{$itemturnin}{reward});
      quest::emote("Works to make a piece of armor from the instructions you provided to him." );
      quest::say ("Here you go $name.  Here is your new $itemturnins{$class}{$itemturnin}{type}");
    }
}
	if ($gaveitem == 0) {
		quest::say("I didn't ask for this! Take your garbage elsewhere!");
	}
		plugin::return_items(\%itemcount);

}
1321 and other numbers correspond to item turn ins. the type and reward correspond to item type (boots, greaves, etc) and reward corresponds to item id to be given as a reward.

One thing I'd like to point out is that when you see this much redundancy such as in my hash for item turn in for each class, rest assured that it could be optimized a little more
Reply With Quote