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 02-04-2008, 10:39 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default Perl Question with "my $item" using an OR statement

Ok, here is the basic script I am wanting to do. This isn't exactly what I have it as, it is only an example. The only line I am concerned about is the one with "$item2" in it.

Code:
sub_EVENT_ITEM {
my $item1 = 1200;
my $item2 = 1201 || 1202 || 1203;

  if (plugin::check_handin(\%itemcount, $item1 => 1, $item2 => 1)){
  quest::summonitem(1300);
}
}
What I am trying to do is make an armor quest that multiple classes can use to upgrade their current armor to another set. They will need 1 item drop (1200), but the other item for the turn in is their existing armor piece (1201, 1202, 1203, etc) like bracer, robe, whatever. This script example is trimmed down a lot from what I am actually doing, but I am only concerned with 1 part. I have it set to give different rewards for each class in the actual script, but that is not an issue. If I can't get OR to work for "my $item", this quest script is going to be very long lol. I will have to do a section for each individual armor piece for every single class (7 X 16).

This is what I have tried so far and the comments are what happens when I tried them:

my $item2 = 1201 || 1202 || 1203; #Turning in 1200 and 1201 result in a reward, but 1200 and 1202 or 1203 do not.
my $item2 = (1201 || 1202 || 1203); #Same
my $item2 = 1201,1202,1203; #Turning in 1200 and 1203 result in a reward, but 1200 and 1201 or 1202 do not.
my $item2 = (1201,1202,1203); #same
my $item2 = 1201 Or 1202 Or 1203; #Eats all items turned in
my $item2 = (1201 Or 1202 Or 1203); #Same

Also tried:
my $item1 == 1200;
my $item2 == 1201 || 1202 || 1203;
And for that one, ANY 2 items I turn in result in the reward, but it is any 2 items in the game, as in a short sword and tattered note, or a ration and water. That doesn't work at all!

I think what I want should be doable and I imagine it is just a minor change to format or something. Any help would be greatly appreciated. I will probably mess with it more tonight, but if I don't get an answer I may just have to do it the long way :(

Thanks in advance.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 02-04-2008, 11:57 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Maybe I am just incorrect in how I think $item works. I don't know if it would even work properly if I made a $item definition for all 7 armor slot pieces. From what I am reading, $item is mainly for slots 1-4 on turn in, so you would normally only use $item1 to $item4.

I tried experimenting a little with it last night and I think I was able to get it to work with any variable I defined. For example, if I wanted to set it to:

Code:
sub_EVENT_ITEM {
my $drop = 1200;
my $helm = 1201 || 1202 || 1203;
my $bracer = 1204 || 1205 || 1206;
#etc for the rest of the armor set, and each line would really have 16 options.  1 for each class.

  if (plugin::check_handin(\%itemcount, $drop => 1, $helm => 1)){
  quest::summonitem(1300); #summons upgraded helm
}
}
It seemed to take any "$something" name, but setting it this way had the same results as using $item1, $item2, etc. So, I still need to know where I am going wrong in trying to make the variable equal multiple possible items using ORs.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #3  
Old 02-04-2008, 12:14 PM
Theeper
Discordant
 
Join Date: May 2004
Posts: 290
Default

I wouldn't use $item1, $item2 etc. as variables, they are already defined when an item is handed in.

You could do it by creating a hash of the possible "$item2" handins and loop through it to see if any of that item was turned in.

Something like this should work for you. Where the keys in the hash represent the itemID's of the handed-in item, and the values are the item to give back to the player.

Code:
sub EVENT_ITEM {

   my $item_1 = 12345;
   %items = (
      11111 => 22222,
      33333 => 44444,
      55555 => 66666,
   );
  
   if (plugin::check_handin(\%itemcount, $item_1 => 1)) {

      for my $items ( sort keys %items) {

         if (plugin::check_handin(\%itemcount, $items => 1)) {
            quest::summonitem($items{$items}); 
         }

      }

   }

}
Of course you'd need some extra logic to make sure only one item is returned back to the player.

Last edited by Theeper; 02-04-2008 at 08:17 PM..
Reply With Quote
  #4  
Old 02-04-2008, 06:08 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Thanks for the response! And, I am using "plugin::return_items(\%itemcount);" at the end of my sub EVENT_ITEM to return all handed in items if they don't match any of the quest turn ins. Will that still work with the hash? I don't know a ton about perl (obviously), so I have to experiment a lot to get things working properly.

I am not sure if I am reading your script correctly, but here is how I think my script would apply if I used what you supplied:

Code:
sub_EVENT_ITEM {

my $drop = 1200;
%helms = (
	1201 => 1,
	1202 => 1,
	1203 => 1
	);

if (
 $class eq 'Warrior' ||
 $class eq 'Rogue' ||
 $class eq 'Monk' ||
 $class eq 'Berserker' ||
 $class eq 'Shadowkight' ||
 $class eq 'Paladin' ||
 $class eq 'Ranger' ||
 $class eq 'Bard' ||
 $class eq 'Beastlord' ||
 $class eq 'Cleric' ||
 $class eq 'Druid' ||
 $class eq 'Shaman' ||
 $class eq 'Wizard' ||
 $class eq 'Mage' ||
 $class eq 'Enchanter' ||
 $class eq 'Necromancer'
	) {

  if (plugin::check_handin(\%itemcount, $drop => 1)) {

	for my $helms (sort keys %helms) {

my %rewards = (
 "Warrior" => 4917,
 "Rogue" => 4907,
 "Monk" => 1206,
 "Berserker" => 55607,
 "Shadowknight" => 9829,
 "Paladin" => 9829,
 "Ranger" => 9829,
 "Bard" => 9829,
 "Beastlord" => 9829,
 "Cleric" => 9829,
 "Druid" => 9829,
 "Shaman" => 9829,
 "Wizard" => 9829,
 "Mage" => 9829,
 "Enchanter" => 9829,
 "Necromancer" => 9829
    );

    if(defined($rewards{$class})) {
    quest::summonitem($rewards{$class});
}
}
}
}
else 
plugin::return_items(\%itemcount);
}
I realize that it is pretty sloppy, but that is as close as I can figure given the example you gave me. I am probably not reading your script properly, but I don't think this would work at all. This script has pretty much everything I want to do. So it will award each class with a specific item.

Writing that did give me an idea of how to get it working like I want. I will try it when I get home and post here if I get it working or not. Thanks again.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 02-05-2008 at 02:11 AM..
Reply With Quote
  #5  
Old 02-04-2008, 10:47 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Here is the current armor quest I use for 1 single slot. I am wanting to make a similar one that lets them turn in their class armor and 1 item for an upgraded armor piece. I am putting this here as a reference, and this does work fine:

Code:
sub EVENT_ITEM {
if ($class == 'Warrior' || $class == 'Rogue' || $class == 'Monk' || $class == 'Berserker' || $class == 'Shadowkight' || $class == 'Paladin' || $class == 'Ranger' || $class == 'Bard' || $class == 'Beastlord' || $class == 'Cleric' || $class == 'Druid' || $class == 'Shaman' || $class == 'Wizard' || $class == 'Mage' || $class == 'Enchanter' || $class == 'Necromancer') {
  if (plugin::check_handin(\%itemcount, 1319 => 1)) {
    my %rewards = (
"Warrior" => 4917, "Rogue" => 4907, "Monk" => 1206, "Berserker" => 55607, "Shadowknight" => 9829, "Paladin" => 9829, "Ranger" => 9829, "Bard" => 9829, "Beastlord" => 9829, "Cleric" => 9829, "Druid" => 9829, "Shaman" => 9829, "Wizard" => 9829, "Mage" => 9829, "Enchanter" => 9829, "Necromancer" => 9829
    );

    if(defined($rewards{$class})) {
      quest::summonitem($rewards{$class});
      quest::emote("Works to make a piece of armor from the instructions you provided to him." );
      quest::say ("Here you go $name.");
    }
}
 	else {
 	    plugin::return_items(\%itemcount);
    	quest::say("I have no use for this item, $name.  Take it back.");
	}  
}
}

I tried using Theeper's script, but it just eats my items. The items in this are 1577 (main drop), 1579, 1581, and 1582 (which I want any to work for turn in along with main drop), and 1658 which is supposed to be the reward. Of course, if I could get this working, the reward would be different for each possible turn in combo. So, if a paladin turns in a bracer and the 1577 drop, he would get an upgraded bracer. Here is exactly what I used as a test:
Code:
sub EVENT_ITEM {

   my $item_1 = 1577;
   %items = (
      1579 => 1658,
      1581 => 1658,
      1582 => 1658,
   );
  
   if (plugin::check_handin(\%itemcount, $item_1 => 1)) {

      For my $items (sort keys %items) {

         if (plugin::check_handin(\%itemcount, $items => 1)) {
            quest::summonitem($items{$items}); 
         }
      }
   }
}
If anyone knows of a way that will work, or anything I am missing, I would greatly appreciate the help lol. I have already spent hours on this, but I just don't want to do it the long way. Much more room for error and much harder to read through if I do each turn in individually with it's own reward, even though it would be an easy script to write.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 02-05-2008, 01:29 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Woot, I finally figured it out by trying something I was already using in some of my previous armor quests! It was a little tricky, but it is flawless now as far as I can tell!

I posted the entire quest in the quest submissions forum here. As it is written now, it is fully complete with itemids for armor upgrades from Elemental Armor Class Sets to GoD Armor Class Sets. There are 4 custom quest items I have in my quest, but that could easily be replaced by 1 item, or as many as you like.

I hope someone finds this thread useful if they ever want to do something similar to this
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 02-05-2008, 01:31 AM
Theeper
Discordant
 
Join Date: May 2004
Posts: 290
Default

Uncapitalize the F in "For". It must be all lower case. Otherwise, that script works fine for me.
Reply With Quote
  #8  
Old 02-05-2008, 08:53 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Quote:
Originally Posted by Theeper View Post
Uncapitalize the F in "For". It must be all lower case. Otherwise, that script works fine for me.
I use GeorgeS Quest tool for all scripts I write, and his tool automatically makes all "for"s and "or"s into "For"s and "Or"s. Same thing happens if you use all caps. Maybe someone who knows 100% for sure how it currently works in perl should post in the tool section in Georges thread for his Quest tool. I would post about it there, but I don't know perl well enough to tell him how to fix his tool :P
__________________
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 10:59 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