trevius
08-26-2008, 11:06 PM
After working on this for a few days with no luck, I am posting here to see if anyone can help. I have been trying to figure it out by learning Perl on my own, but I just can't get it working.
What I am trying to do is to have 1 NPC that has multiple quests, where each quest is just a simple turn in X and get reward Y. But in this case, I have over 40 turn ins and 40 rewards, so I am hoping to figure out how to write the quest without making each turn in and reward the long way. I am pretty sure that this can be done with hashes, but I just don't know enough about it yet to get it functioning at all.
Here is a small example of what I am trying to do:
sub EVENT_ITEM {
#defining the hash for Item IDs that are turned in
my %turn_ins = ("Plate_Boots" => 2667, "Plate_Bracer" => 2664, "Plate_Breastplate" => 2662);
#defining the hash for rewarded Item IDs for the turn ins
my %rewards = ("Plate_Boots" => 3233, "Plate_Bracer" => 3230, "Plate_Breastplate" => 3227);
#defining each armor type to use for matching the $turn_ins with the $rewards
my $armor = ("Plate_Boots" || "Plate_Bracer" || "Plate_Breastplate'");
#checking if the $turn_ins hash is defined with an armor piece
if(defined($turn_ins{$armor})) {
if (plugin::check_handin(\%itemcount, ($turn_ins{$armor}) => 1)) {
quest::say("I see you have turned in item $turn_ins{$armor}"); #here to test if it is working
#checking if the $rewards hash is defined with an armor piece
if(defined($rewards{$armor})) {
quest::say("Your reward is item $rewards{$armor}"); #here to test if it is working
quest::summonitem($rewards{$armor});
}
}
}
}
Some of the other things I have tried that don't work either:
#my $value = 0;
#my @turn_ins = (2667, 2664, 2662, 2665, 2666, 2661, 2663);
#if ($turn_ins == 2667 || $turn_ins == 2664 || $turn_ins == 2662);
#my @armor = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2 0,21);
#my ($1,$2,$3,$4,$5,$6,$7) = @armor;
#my %turn_ins = ("test" => 2667);
#my %rewards = (1 => 3233);
#my $Timeless_Plate_Boots = 2667;
#my $Timeless_Plate_Boots;
#my %turn_ins = (2667 => 2667);
#my %rewards = ("Corathus_Plate_Boots" => 3233);
#my %armor = ("Timeless_Plate_Boots" => "Corathus_Plate_Boots");
#my %armor = (2667 => 3233);
#my %turn_ins = ("Plate_Boots" => 2667, "Plate_Bracer" => 2664, "Plate_Breastplate" => 2662);
I imagine for some of you perl gurus this probably won't be too hard to figure out. But, it has me stumped and I just can't seem to understand why it isn't working. Sure, I could do it the long way easily, but I am trying to keep from having a horribly long quest file and also maybe learn something in the process :)
What I am trying to do is to have 1 NPC that has multiple quests, where each quest is just a simple turn in X and get reward Y. But in this case, I have over 40 turn ins and 40 rewards, so I am hoping to figure out how to write the quest without making each turn in and reward the long way. I am pretty sure that this can be done with hashes, but I just don't know enough about it yet to get it functioning at all.
Here is a small example of what I am trying to do:
sub EVENT_ITEM {
#defining the hash for Item IDs that are turned in
my %turn_ins = ("Plate_Boots" => 2667, "Plate_Bracer" => 2664, "Plate_Breastplate" => 2662);
#defining the hash for rewarded Item IDs for the turn ins
my %rewards = ("Plate_Boots" => 3233, "Plate_Bracer" => 3230, "Plate_Breastplate" => 3227);
#defining each armor type to use for matching the $turn_ins with the $rewards
my $armor = ("Plate_Boots" || "Plate_Bracer" || "Plate_Breastplate'");
#checking if the $turn_ins hash is defined with an armor piece
if(defined($turn_ins{$armor})) {
if (plugin::check_handin(\%itemcount, ($turn_ins{$armor}) => 1)) {
quest::say("I see you have turned in item $turn_ins{$armor}"); #here to test if it is working
#checking if the $rewards hash is defined with an armor piece
if(defined($rewards{$armor})) {
quest::say("Your reward is item $rewards{$armor}"); #here to test if it is working
quest::summonitem($rewards{$armor});
}
}
}
}
Some of the other things I have tried that don't work either:
#my $value = 0;
#my @turn_ins = (2667, 2664, 2662, 2665, 2666, 2661, 2663);
#if ($turn_ins == 2667 || $turn_ins == 2664 || $turn_ins == 2662);
#my @armor = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2 0,21);
#my ($1,$2,$3,$4,$5,$6,$7) = @armor;
#my %turn_ins = ("test" => 2667);
#my %rewards = (1 => 3233);
#my $Timeless_Plate_Boots = 2667;
#my $Timeless_Plate_Boots;
#my %turn_ins = (2667 => 2667);
#my %rewards = ("Corathus_Plate_Boots" => 3233);
#my %armor = ("Timeless_Plate_Boots" => "Corathus_Plate_Boots");
#my %armor = (2667 => 3233);
#my %turn_ins = ("Plate_Boots" => 2667, "Plate_Bracer" => 2664, "Plate_Breastplate" => 2662);
I imagine for some of you perl gurus this probably won't be too hard to figure out. But, it has me stumped and I just can't seem to understand why it isn't working. Sure, I could do it the long way easily, but I am trying to keep from having a horribly long quest file and also maybe learn something in the process :)