EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Using Or (https://www.eqemulator.org/forums/showthread.php?t=27659)

Aldest 03-10-2009 04:10 PM

Using Or
 
I'm trying to get a good grasp on item turn ins and I basically wanted to take the jboots example and go from AND to OR.

More or less I want to allow players to turn in hate/fear plate armor and get a token. Now I could create 40 different ifs for plate or couldn't I just do this?

Code:

sub EVENT_ITEM
        if ($faction >= 4) {
 {
  if(($itemcount{4861}) || ($itemcount{4862})  || ($itemcount{4863}) || ($itemcount{etc}) || ($itemcount{etc}) || ($itemcount{etc}) || ($itemcount{etc}) || ($itemcount{etc}))
    {
    quest::emote("takes the armor and offers you a figurine.");
    quest::say("Excellent! As promised, here is your figurine.");
    quest::summonitem("2493"); #Heavy Knight
    quest::exp(5000);
    quest::faction(485,5); # Elysian Wanderers
    }
  }

More or less if you're amiable or greater you can turn in any of those items and get the reward. Is this correct?

Also, this is more obscure but is there a way to cap how many times you can get the faction gain from this? would you do an if inside the if?

Aldest 03-11-2009 10:25 AM

Well
 
Alright, so that didn't quite work! Any thoughts on this?

Code:

sub EVENT_ITEM
        {
                  if($item1 == 4861 || 4862 || 4863 || 4864 || 4865 || 4866 || 4867 || 4911 || 4912 || 4913 || 4914 || 4915 || 4916 || 4917 || 4881 || 4882 || 4883 || 4884 || 4885 || 4886 || 4887 || 4851 || 4852 || 4843 || 4854 || 4855 || 4856 || 4857 || 4841 || 4842 || 4843 || 4844 || 4845 || 4846 || 4847)
            {
    quest::emote("takes the armor and offers you a figurine.");
    quest::say("Excellent! As promised, here is your figurine.");
    quest::summonitem("2493"); #Heavy Knight
    quest::exp(5000);
    quest::faction(485,5); # Elysian Wanderers
            }
    }


realityincarnate 03-11-2009 12:11 PM

That way won't work, you'd need to write the much more tedious method of:
Code:

if (($item1 == 4861) || ($item1 == 4862) || ($item1 == 4863) || etc...
Since most of the items you're looking at are in a sequence, you might try something like:
Code:


if ( (($item1 >= 4861) && ($item1 <= 4867)) || (($item1 >= 4911) && ($item1 <= 4917)) ) {

for each set of items to cut down on the work.

Aldest 03-11-2009 03:14 PM

OKay thank you so much!

I'm glad at least my logic was in the right place. It is tedious but much less so than doing an entire if for every piece.

I'll change my code to the && version and let you know!

Theeper 03-11-2009 10:20 PM

You could make an array of the turn-in items and loop through them. Something like this should work for you.

Code:

@items = (1001, 1002, 1003, 1004, 1005);

sub EVENT_ITEM {
  my $accepted_items = 0;

  foreach (@items) {
      if($itemcount{$_} == 1) ++$accepted_items;
  }

  if ($accepted_items > 0) {
      quest::summonitem(1006);
  } else {
      plugin::return_items(\%itemcount);
  }
}


Aldest 03-12-2009 06:20 PM

Thank you all for the advice!

I've now got it working with reality's idea. That is a load off my mind. I'm down to just getting one more quest npc in and figuring out how to lock them to a faction.


All times are GMT -4. The time now is 05:56 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.