Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2008, 11:06 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default %Hash to Shorten Multiple Quests from 1 NPC - Not Working

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:



Code:
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:

Code:
#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,20,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
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 08-27-2008, 05:09 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Well, I was finally able to get it working with the hash properly! But, for some reason, I can't get the return items plugin working properly for it. The code below works perfectly if you turn in the correct items, but if you turn in the wrong items, it will just eat them. I commented out the return plugin section because it was breaking the script. Basically with the return items plugin set to be used, it causes the return text to be said 3 times and then just returns the item you turned in. This is the case for the first 2 items, but the 3rd (last) item in the hash will actually still turn in properly for some reason.

Code:
sub EVENT_ITEM {

my %turn_ins = (2667 => 3233, 2664 => 3230, 2662 => 3227);

  for my $turn_ins (sort keys %turn_ins) {
    if(defined($turn_ins)) {
      if (plugin::check_handin(\%itemcount, $turn_ins => 1)) {
        quest::say("I see you have turned in item $turn_ins");

        if(defined($turn_ins{$turn_ins})) {
          quest::say("Your reward is item $turn_ins{$turn_ins}");
          quest::summonitem($turn_ins{$turn_ins});
        }
      } 
#  else {
#    plugin::return_items(\%itemcount);
#    quest::say ("I have no use for this item, $name.");
#  }        
    } 
  }
}
Anyone know how to get the return plugin working properly for this? I am guessing that it has something to do with it checking the has with the sort once for each item in the hash and then failing some of the checks to it skips straight to the else before it finishes checking all of the keys in the hash for the turn in item ID.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #3  
Old 08-27-2008, 11:53 AM
Andrew80k
Dragon
 
Join Date: Feb 2007
Posts: 659
Default

Try putting the return_items outside of your for loop. Also check your brackets, they may not actually be in the order you intend.
Reply With Quote
  #4  
Old 08-27-2008, 12:43 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

or move it in right after the check_handin
Reply With Quote
  #5  
Old 08-27-2008, 12:50 PM
LordKahel
Fire Beetle
 
Join Date: Sep 2007
Posts: 22
Default

Here another way of doing it , without sorting the Hash..


Code:
my %turn_ins = (2667 => 3233, 2664 => 3230, 2662 => 3227);

while (($key, $value) = each %turn_ins)
  {
     if (plugin::check_handin(\%itemcount, $key => 1))
     {
        quest::summonitem($value);
        quest::emote("summons an Item . Here you go $name.");
     }
  }
I have a special return item that i can add to the end . That will return any item remaining in the itemcount hash after.
__________________
-----------
Pyronis / LordKahel
Dev Jest 4 server
Reply With Quote
  #6  
Old 08-27-2008, 04:55 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

Which looks and handles much better!
Reply With Quote
  #7  
Old 08-27-2008, 05:29 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Thanks for the help guys. I will try messing with it a bit more when I get home tonight. Here is the actual quest that I am using right now that completely works other than returning items not in the hash values:

Code:
sub EVENT_ITEM {

my %accessories = (
 2439 => 3236, #Amice
 2634 => 3249, #Cape
 2660 => 3295, #Charm
 2993 => 3536, #Contributor_Charm
 2445 => 3242, #Earring
 2443 => 3238, #Girdle
 2442 => 3237, #Mask
 2444 => 3239, #Necklace
 2451 => 3248, #Ring
 );


  if ($qglobals{cora_credits} >= 25) {  #used for my new credit system just in this zone
    for my $accessories (sort keys %accessories) {
      if(defined($accessories)) {
        if (plugin::check_handin(\%itemcount, $accessories => 1)) {

          if(defined($accessories{$accessories})) {
            quest::emote("recognizes your efforts and fashions an upgrade for your armor piece" );
            quest::say("Thank you, $name, here is your upgraded armor piece!");
            quest::exp(45000);
            quest::setglobal("cora_credits", $qglobals{cora_credits}-25, 1, "F"); #subtracting 25 credits
            quest::summonitem($accessories{$accessories});
my $total_credits = ($qglobals{cora_credits} - 25);
$client->Message(5, "You have spent 25 Corathus Credits and now have $total_credits remaining credits.");
          }
        } 
#    else { #these are commented out because they don't work
#      plugin::return_items(\%itemcount);
#      quest::say ("I have no use for this item, $name.");
#       }        
      } 
    }

  }
    else { #this works for returning items if they don't have enough credits
      plugin::return_items(\%itemcount);
      quest::say ("You don't have enough credits for that, sorry.");    
    }
}

So far I am very happy with the system. Once I get it working flawlessly with the return item, I will post all of the credit system quests, which includes quests for mobs that give credit when they die as well as these quests for rewards that credits can be used for (along with an item turn-in in this case). I think they could be useful to other custom servers.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:25 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3