Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2012, 09:15 AM
Gameross
Fire Beetle
 
Join Date: Jan 2004
Posts: 21
Default

Wow! It's about time someone got around to adding this! It's long overdue and amazingly small # of changes. Good job Image!


PS Live didn't return items as I recall either, so that's more like live too.
Reply With Quote
  #2  
Old 09-02-2012, 12:43 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Thanks for sharing this image!

I've added it to SVN r2197. I included the required plugin in the EQEmu SVN, but it's also on PEQ quest SVN and I'll post here it so to be sure everybody sees it.

Basically, if you want to continue using our current system, you do nothing different. plugin::check_handin and return_items will both work as they always have, with the added addition of clearing the NPC's quest item list (no need to have non-MQ handins use up additional memory.)

If you wish to use MQ, there is a new plugin called check_mq_handin that will handle that. As image has said, do not use return_items with that.

check_handin.pl
Code:
# plugin::check_handin($item1 => #required_amount,...);
# autoreturns extra unused items on success
sub check_handin {
    my $hashref = shift;
    my %required = @_;
    foreach my $req (keys %required) {
	if ((!defined $hashref->{$req}) || ($hashref->{$req} != $required{$req})) {
            return(0);
	}
    }
     foreach my $req (keys %required) {
         if ($required{$req} < $hashref->{$req}) {
             $hashref->{$req} -= $required{$req};
         } else {
             delete $hashref->{$req};
         }
     }
     quest::clearhandin();
     return 1;
}

sub check_mq_handin {
    my $hashref = shift;
    my %required = @_;
    	quest::resethandin();
    foreach my $req (keys %required) {
	$charges = $required{$req};
	if ( !quest::handleturnin($req,$charges) )
	{
		return(0);
	}
    }
     quest::completehandin();
     return 1;
}

sub return_items {    
	my $hashref = plugin::var('$itemcount');
	my $client = plugin::val('$client');
	my $items_returned = 0;

	my %ItemHash = (
		0 => [ plugin::val('$item1'), plugin::val('$item1_charges'), plugin::val('$item1_attuned') ],
		1 => [ plugin::val('$item2'), plugin::val('$item2_charges'), plugin::val('$item2_attuned') ],
		2 => [ plugin::val('$item3'), plugin::val('$item3_charges'), plugin::val('$item3_attuned') ],
		3 => [ plugin::val('$item4'), plugin::val('$item4_charges'), plugin::val('$item4_attuned') ],
	);
	
	foreach my $k (keys(%{$hashref}))
	{
		next if($k == 0);
		my $rcount = $hashref->{$k};
		my $r;
		for ($r = 0; $r < 4; $r++)
		{
			if ($rcount > 0 && $ItemHash{$r}[0] && $ItemHash{$r}[0] == $k)
			{
				if ($client)
				{
					$client->SummonItem($k, $ItemHash{$r}[1], $ItemHash{$r}[2]);
					$items_returned = 1;
				}
				else
				{
					# This shouldn't be needed, but just in case
					quest::summonitem($k, 0);
					$items_returned = 1;
				}
				$rcount--;
			}
		}
		delete $hashref->{$k};
	}
	quest::clearhandin();
	# Return true if items were returned
	return $items_returned;

}
Reply With Quote
  #3  
Old 09-03-2012, 09:12 AM
image
Demi-God
 
Join Date: Jan 2002
Posts: 1,292
Default

hey cavedude thanks for handling that merge. Only additional suggestion I think I should make is you mentioned that non mq hand in's should not store in memory.

I think you could just have a rule that enables/disables MQ capabilities. The reason I mention this is right now it just checks if the NPC has a EVENT_ITEM sub function and if so then it loads the items into memory via StoreTurnInItems(tradingWith); in trading.cpp.

Obviously if you don't use the appropriate mq check handin it won't matter that the NPC's have that special item list.

I don't think people will have to worry about memory too much though. Right now the hand ins only last till the zone shuts down. I was thinking later this could be integrated into the zonestate dump and maybe some like 7 day expiration could exist for the items.
__________________
www.eq2emu.com
EQ2Emu Co-Founder / EQ2Emu Developer
EQEMu Co-Founder / Former EQEMu Developer / GuildWars / Zek Seasons Servers
Reply With Quote
  #4  
Old 09-04-2012, 11:36 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Good suggestion, added in Rev2203.
Reply With Quote
Reply

Thread Tools
Display Modes

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:48 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 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3