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 04-22-2019, 10:17 AM
zack221
Fire Beetle
 
Join Date: Apr 2007
Posts: 9
Default Random Quest

Answered..
Reply With Quote
  #2  
Old 04-22-2019, 12:25 PM
Sturm
Hill Giant
 
Join Date: Dec 2015
Posts: 116
Default

You would have to define each possible turn-in combination.
__________________
Developer of the Imperium Server.
https://imperium-eq.com/
Reply With Quote
  #3  
Old 04-22-2019, 12:28 PM
zack221
Fire Beetle
 
Join Date: Apr 2007
Posts: 9
Default

ah right ok Thanks
Reply With Quote
  #4  
Old 04-23-2019, 09:37 AM
Sturm
Hill Giant
 
Join Date: Dec 2015
Posts: 116
Default

Not sure why you redacted your question, it might help someone in the future.

So he asked: How would you make a turn-in that could be 4 of any of the 10 items needed.
__________________
Developer of the Imperium Server.
https://imperium-eq.com/
Reply With Quote
  #5  
Old 04-23-2019, 03:47 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

Quote:
Originally Posted by Sturm View Post
You would have to define each possible turn-in combination.

What? No.

Code:
# list of 10 possible item ids
my @find = (
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9
);

# items found
my @found;

# items turned in (automatically exported in API)
# (item id => count)
my %itemcount = (
    1 => 1,
    3 => 1,
    7 => 2,
    a => 1
);

foreach my $item (keys %itemcount) {
    # validate item and make sure it is unique
    if ((grep /$item/, @find) && (!grep /$item/, @found)) {
        push @found, $item;
     }
    # only required if count will be less than 4 (max item ids that can be turned in)
    last if (@found == 4);
  }

print "found " . scalar @found . " of 4 required items ";

# minimum number of validated items
if (@found == 4) {
    print "(PASS)\n";
    # to accept only one of each validated item handed in - UNTESTED
    # plugin::check_handin(\%itemcount, map { $_ => 1 } @found);
} else {
    print "(FAIL)\n";
}
note: the above example assumes 4 unique item ids are required for success
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #6  
Old 04-23-2019, 04:23 PM
Sturm
Hill Giant
 
Join Date: Dec 2015
Posts: 116
Default

There ya go, if you're a wizard you can do it that way.

See, it pays to leave the original question.

There's always a different way to do things! haha
__________________
Developer of the Imperium Server.
https://imperium-eq.com/
Reply With Quote
  #7  
Old 04-23-2019, 04:41 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

Seeing the answer without knowing the question was bugging me.

There are always several ways to do something in Perl (using grep instead of the smart matching operator, for example).

Something similar to the example provided would be less error prone, especially if you ever intend to change the items that are required.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
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 09:52 AM.


 

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