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 03-29-2013, 11:55 PM
Zamthos
Discordant
 
Join Date: Jan 2013
Posts: 284
Default Charm Up-grader.

My charm up-grader will upgrade you from Rank 1 to Rank 2, but after that he just gives back your items, any ideas? Code below:

Code:
sub EVENT_SAY
{
	my $charm = quest::saylink("Charm", 1);
	my $token = quest::varlink(140226);
	
	if($text=~/Hail/i)
	{
		plugin::Whisper("Hello, young $class, would you like a $charm?");
		plugin::Whisper("To upgrade your charm you must hand me the charm and an $token.");
		#plugin::Whisper("In development, try again later.");
	}
	
	if($text=~/Charm/i)
	{
		quest::summonitem(140126);
	}
}

sub EVENT_ITEM
{
	@charmlist = qw(
	140126    
    140127    
    140128    
    140129    
    140130    
    140131    
    140132    
    140133    
    140134    
    140135    
    140136    
    140137    
    140138    
    140139    
    140140    
    140141    
    140142    
    140143    
    140144    
    140145    
    140146    
    140147    
    140148    
    140149    
    140150    
    140151    
    140152    
    140153    
    140154    
    140155    
    140156    
    140157    
    140158    
    140159    
    140160    
    140161    
    140162    
    140163    
    140164    
    140165    
    140166    
    140167    
    140168    
    140169    
    140170    
    140171    
    140172    
    140173    
    140174    
    140175    
    140176    
    140177    
    140178    
    140179    
    140180    
    140181    
    140182    
    140183    
    140184    
    140185    
    140186    
    140187    
    140188    
    140189    
    140190    
    140191    
    140192    
    140193    
    140194    
    140195    
    140196    
    140197    
    140198    
    140199    
    140200    
    140201    
    140202    
    140203    
    140204    
    140205    
    140206    
    140207    
    140208    
    140209    
    140210    
    140211    
    140212    
    140213    
    140214    
    140215    
    140216    
    140217    
    140218    
    140219    
    140220    
    140221    
    140222    
    140223    
    140224    
    140225    
	);
	my $n = 0; 
	while ($charmlist[$n])
	{
		my $charmid = $charmlist[$n];
		
		if (plugin::check_handin(\%itemcount, $charmid => 1, 140226 => 1))
		{
			plugin::Whisper("Here is your upgraded charm!");
			quest::summonitem($charmid+1, 1); 
		}
		else
		{
			plugin::return_items(\%itemcount);
			quest::givecash($copper,$silver,$gold,$platinum);
		}
		$n++;		
	}
}
Reply With Quote
  #2  
Old 03-30-2013, 12:26 AM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

Think about the logic there. Check if the first item matches, if it does give the upgrade, otherwise return the items. By the time you get to checking the second item you've already given everything back.

I'm no expert, but it seems to me you would want to check the whole list for matches before giving anything back.
Reply With Quote
  #3  
Old 03-30-2013, 01:14 AM
sorvani
Dragon
 
Join Date: May 2010
Posts: 965
Default

improper use of return items.
see: http://www.peqtgc.com/phpBB3/viewtop...p=65083#p65083
Reply With Quote
  #4  
Old 03-30-2013, 02:30 AM
Zamthos
Discordant
 
Join Date: Jan 2013
Posts: 284
Default

Revised version, haven't tested, is this the way mentioned in that post?

Code:
sub EVENT_SAY
{
	my $charm = quest::saylink("Charm", 1);
	my $token = quest::varlink(140226);
	
	if($text=~/Hail/i)
	{
		plugin::Whisper("Hello, young $class, would you like a $charm?");
		plugin::Whisper("To upgrade your charm you must hand me the charm and an $token.");
		#plugin::Whisper("In development, try again later.");
	}
	
	if($text=~/Charm/i)
	{
		quest::summonitem(140126);
	}
}

sub EVENT_ITEM
{
	@charmlist = qw(
	140126    
    140127    
    140128    
    140129    
    140130    
    140131    
    140132    
    140133    
    140134    
    140135    
    140136    
    140137    
    140138    
    140139    
    140140    
    140141    
    140142    
    140143    
    140144    
    140145    
    140146    
    140147    
    140148    
    140149    
    140150    
    140151    
    140152    
    140153    
    140154    
    140155    
    140156    
    140157    
    140158    
    140159    
    140160    
    140161    
    140162    
    140163    
    140164    
    140165    
    140166    
    140167    
    140168    
    140169    
    140170    
    140171    
    140172    
    140173    
    140174    
    140175    
    140176    
    140177    
    140178    
    140179    
    140180    
    140181    
    140182    
    140183    
    140184    
    140185    
    140186    
    140187    
    140188    
    140189    
    140190    
    140191    
    140192    
    140193    
    140194    
    140195    
    140196    
    140197    
    140198    
    140199    
    140200    
    140201    
    140202    
    140203    
    140204    
    140205    
    140206    
    140207    
    140208    
    140209    
    140210    
    140211    
    140212    
    140213    
    140214    
    140215    
    140216    
    140217    
    140218    
    140219    
    140220    
    140221    
    140222    
    140223    
    140224    
    140225    
	);
	my $n = 0; 
	while ($charmlist[$n])
	{
		my $charmid = $charmlist[$n];
		
		if (plugin::check_handin(\%itemcount, $charmid => 1, 140226 => 1))
		{
			plugin::Whisper("Here is your upgraded charm!");
			quest::summonitem($charmid+1, 1); 
		}
		$n++;		
	}
	plugin::return_items(\%itemcount);
	quest::givecash($copper,$silver,$gold,$platinum);
}
Reply With Quote
  #5  
Old 03-30-2013, 06:28 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

very inefficient to loop through the entire list of valid charms (100?) instead of just checking the item ids that were turned in (max of 4).
put this at the top of your file to be able to use the ~~ operator:
Code:
use 5.012;
Code:
foreach my $itemid (%itemcount)
{
    next unless $itemid ~~ [140126..140225];
    if (plugin::check_handin(\%itemcount, $charmid => 1, 140226 => 1))
    {
        plugin::Whisper("Here is your upgraded charm!");
        quest::summonitem($itemid+1, 1); 
    }
}
plugin::return_items(\%itemcount);
quest::givecash($copper, $silver, $gold, $platinum);
__________________
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 03-30-2013, 11:14 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

oops. that should read:
Code:
foreach my $itemid (keys %itemcount)
__________________
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
  #7  
Old 03-30-2013, 04:16 PM
Zamthos
Discordant
 
Join Date: Jan 2013
Posts: 284
Default

The one you gave me actually doesn't work, in the fact that he just eats the items, the second one I posted, the revised one, works correctly.
Reply With Quote
  #8  
Old 03-30-2013, 06:33 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

that $charmid should be $itemid. was half asleep both times i posted.
__________________
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 01:55 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3