View Single Post
  #19  
Old 06-03-2009, 05:44 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Since that quest, I have refined our armor scripts that use Arrays a bit to make them cleaner and a bit easier to manage. If done properly, I don't think the whole "if $class" stuff needs to be checked at all. Here is an example of the new format we use on Storm Haven for a bit more advanced Arrays for armor quests:

Code:
#Rough Defiant Armor Quests

%GetArmorType = (	#Convert each Class Name into an Armor Type Name
	"Warrior" => "Plate",
	"Rogue" => "Chain",
	"Monk" => "Leather",
	"Berserker" => "Chain",
	"Shadowknight" => "Plate",
	"Paladin" => "Plate",
	"Ranger" => "Chain",
	"Bard" => "Plate",
	"Beastlord" => "Leather",
	"Cleric" => "Plate",
	"Druid" => "Leather",
	"Shaman" => "Chain",
	"Wizard" => "Cloth",
	"Magician" => "Cloth",
	"Enchanter" => "Cloth",
	"Necromancer" => "Cloth"
);

%ArmorSlot = (	#Convert each Slot Name into a String for use in the Rewards Choosing
	"Bracer" => "_Bracer",
	"Gauntlets" => "_Gauntlets",
	"Boots" => "_Boots",
	"Helm" => "_Helm",
	"Vambraces" => "_Vambraces",
	"Greaves" => "_Greaves",
	"Breastplate" => "_Breastplate",
);

%SimpleArmor = (	#Name each item appropriately for use With the Armor Type And Armor Slot selections
"Plate_Bracer" => 50033,	#Simple Defiant Plate Bracer
"Plate_Gauntlets" => 50034,	#Simple Defiant Plate Gauntlets
"Plate_Boots" => 50035,		#Simple Defiant Plate Boots
"Plate_Helm" => 50036,		#Simple Defiant Plate Helm
"Plate_Vambraces" => 50037,	#Simple Defiant Plate Vambraces
"Plate_Greaves" => 50038,	#Simple Defiant Plate Greaves
"Plate_Breastplate" => 50039,	#Simple Defiant Breastplate

"Chain_Bracer" => 50040,	#Simple Defiant Chain Bracer
"Chain_Gauntlets" => 50041,	#Simple Defiant Chain Gauntlets
"Chain_Boots" => 50042,		#Simple Defiant Chain Boots
"Chain_Helm" => 50043,		#Simple Defiant Chain Coif
"Chain_Vambraces" => 50044,	#Simple Defiant Chain Sleeves
"Chain_Greaves" => 50045,	#Simple Defiant Chain Leggings
"Chain_Breastplate" => 50046,	#Simple Defiant Chain Tunic

"Leather_Bracer" => 50047,	#Simple Defiant Leather Bracer
"Leather_Gauntlets" => 50048,	#Simple Defiant Leather Gloves
"Leather_Boots" => 50049,	#Simple Defiant Leather Boots
"Leather_Helm" => 50050,	#Simple Defiant Leather Cap
"Leather_Vambraces" => 50051,	#Simple Defiant Leather Sleeves
"Leather_Greaves" => 50052,	#Simple Defiant Leather Trousers
"Leather_Breastplate" => 50053,	#Simple Defiant Leather Tunic

"Cloth_Bracer" => 50054,	#Simple Defiant Cloth Wristwrap
"Cloth_Gauntlets" => 50055,	#Simple Defiant Cloth Gloves
"Cloth_Boots" => 50056,		#Simple Defiant Cloth Sandals
"Cloth_Helm" => 50057,		#Simple Defiant Cloth Cap
"Cloth_Vambraces" => 50058,	#Simple Defiant Cloth Sleeves
"Cloth_Greaves" => 50059,	#Simple Defiant Cloth Pantaloons
"Cloth_Breastplate" => 50060,	#Simple Defiant Cloth Robe
);

%Rewards = (
"Plate_Bracer" => 50061,	#Rough Defiant Plate Bracer
"Plate_Gauntlets" => 50062,	#Rough Defiant Plate Gauntlets
"Plate_Boots" => 50063,		#Rough Defiant Plate Boots
"Plate_Helm" => 50064,		#Rough Defiant Plate Helm
"Plate_Vambraces" => 50065,	#Rough Defiant Plate Vambraces
"Plate_Greaves" => 50066,	#Rough Defiant Plate Greaves
"Plate_Breastplate" => 50067,	#Rough Defiant Breastplate

"Chain_Bracer" => 50068,	#Rough Defiant Chain Bracer
"Chain_Gauntlets" => 50069,	#Rough Defiant Chain Gauntlets
"Chain_Boots" => 50070,		#Rough Defiant Chain Boots
"Chain_Helm" => 50071,		#Rough Defiant Chain Coif
"Chain_Vambraces" => 50072,	#Rough Defiant Chain Sleeves
"Chain_Greaves" => 50073,	#Rough Defiant Chain Leggings
"Chain_Breastplate" => 50074,	#Rough Defiant Chain Tunic

"Leather_Bracer" => 50075,	#Rough Defiant Leather Bracer
"Leather_Gauntlets" => 50076,	#Rough Defiant Leather Gloves
"Leather_Boots" => 50077,	#Rough Defiant Leather Boots
"Leather_Helm" => 50078,	#Rough Defiant Leather Cap
"Leather_Vambraces" => 50079,	#Rough Defiant Leather Sleeves
"Leather_Greaves" => 50080,	#Rough Defiant Leather Trousers
"Leather_Breastplate" => 50081,	#Rough Defiant Leather Tunic

"Cloth_Bracer" => 50082,	#Rough Defiant Cloth Wristwrap
"Cloth_Gauntlets" => 50083,	#Rough Defiant Cloth Gloves
"Cloth_Boots" => 50084,		#Rough Defiant Cloth Sandals
"Cloth_Helm" => 50085,		#Rough Defiant Cloth Cap
"Cloth_Vambraces" => 50086,	#Rough Defiant Cloth Sleeves
"Cloth_Greaves" => 50087,	#Rough Defiant Cloth Pantaloons
"Cloth_Breastplate" => 50088,	#Rough Defiant Cloth Robe
);

sub EVENT_SAY {

# Get the Armor Type of the Character character currently speaking With this NPC
my $ArmorType = $GetArmorType{$class};

#Create the full name of each item for the Rewards array
my $Bracer = "$ArmorType$ArmorSlot{Bracer}";
my $Gauntlets = "$ArmorType$ArmorSlot{Gauntlets}";
my $Boots = "$ArmorType$ArmorSlot{Boots}";
my $Helm = "$ArmorType$ArmorSlot{Helm}";
my $Vambraces = "$ArmorType$ArmorSlot{Vambraces}";
my $Greaves = "$ArmorType$ArmorSlot{Greaves}";
my $Breastplate = "$ArmorType$ArmorSlot{Breastplate}";

#Create the Item Links from the Rewards Array for use in say messages
my $Bracer_Link = quest::varlink($Rewards{$Bracer});
my $Gauntlets_Link = quest::varlink($Rewards{$Gauntlets});
my $Boots_Link = quest::varlink($Rewards{$Boots});
my $Helm_Link = quest::varlink($Rewards{$Helm});
my $Vambraces_Link = quest::varlink($Rewards{$Vambraces});
my $Greaves_Link = quest::varlink($Rewards{$Greaves});
my $Breastplate_Link = quest::varlink($Rewards{$Breastplate});

	if($text=~/hail/i)
	{
		quest::say("What a fine looking $class you are.  
		You look Like you could use some new $ArmorType [armor], though.");
	}

	if($text=~/armor/i)
	{
		quest::say("I can provide you with the following if you are [interested]:");
		quest::say("A $Bracer_Link");
		quest::say("A $Gauntlets_Link");
		quest::say("A $Boots_Link");
		quest::say("A $Helm_Link");
		quest::say("A $Vambraces_Link");
		quest::say("A $Greaves_Link");
		quest::say("A $Breastplate_Link");
	}

	if($text=~/interested/i)
	{
		quest::say("You will need to collect some items for me.  
		But, I don't have a list of those needed item yet. 
		(quest is still in progress of being finished)");
	}

}

sub EVENT_ITEM {

# Get the Armor Type of the Character character currently speaking With this NPC
my $ArmorType = $GetArmorType{$class};

#Create the full name of each item for the Rewards array
my $Bracer = "$ArmorType$ArmorSlot{Bracer}";
my $Gauntlets = "$ArmorType$ArmorSlot{Gauntlets}";
my $Boots = "$ArmorType$ArmorSlot{Boots}";
my $Helm = "$ArmorType$ArmorSlot{Helm}";
my $Vambraces = "$ArmorType$ArmorSlot{Vambraces}";
my $Greaves = "$ArmorType$ArmorSlot{Greaves}";
my $Breastplate = "$ArmorType$ArmorSlot{Breastplate}";

	#Reward for turning in the Bracer piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Bracer} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Bracer});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}

	#Reward for turning in the Gauntlets piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Gauntlets} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Gauntlets});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}

	#Reward for turning in the Boots piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Boots} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Boots});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}

	#Reward for turning in the Helm piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Helm} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Helm});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}

	#Reward for turning in the Vambraces piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Vambraces} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Vambraces});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}

	#Reward for turning in the Greaves piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Greaves} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Greaves});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}

	#Reward for turning in the Breastplate piece
	if (plugin::check_handin(\%itemcount, $SimpleArmor{$Breastplate} => 1, 1001 => 1)) {
		quest::summonitem($Rewards{$Breastplate});
		quest::exp(450);
		quest::say ("There you go, $name.  You're looking tougher already!");
	}
	
	else
	{
	plugin::return_items(\%itemcount);
	}

}
Of course, this script takes it a step further and defines the armor type for each class and then uses that to find which classes should get which piece of armor. This script could be simplified to just map each piece of armor to a specific class, which shouldn't be too hard to figure out for people wanting to do that.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote