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 12-16-2015, 03:21 PM
Maze_EQ
Demi-God
 
Join Date: Mar 2012
Posts: 1,106
Default Multi-Quest support

Alright, so I see sometime back in 2012 Cavedude added multi-quest support from image's code.

rev 2203 or something.

Now what I'm trying to figure out, is why multiquesting is not taking effect here.

I've tried it on multiple different npcs, qglobals on etc.

Not sure about LUA (tested on Stanos for rogue epic, doesn't seem to be MQ'able.)

Tested perl on Hasten, again, not mq'able. If I hand all the items in together, they work just fine.

Separately and they eat the items.

hmm.

Any explanations on plugin::check_mq_handin?
__________________
"No, thanks, man. I don't want you fucking up my life, too."

Skype:
Comerian1
Reply With Quote
  #2  
Old 12-16-2015, 06:40 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

I don't think the 'mq' in that method stands for multi-quest, I believe it is safe handin for MacroQuest users, as there apparently used to be crashes related to handins and stuff in the past.
Reply With Quote
  #3  
Old 12-16-2015, 09:16 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

check_mq_handin is for multi-questing, I'm not sure 100% how it works :P (PEQ has no examples)
Reply With Quote
  #4  
Old 12-16-2015, 09:28 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Ah fun, I've never used it myself, didn't assume it was for multi-questing, MacroQuest just seems more fitting for stuff that isn't used, haha.
Reply With Quote
  #5  
Old 12-17-2015, 04:43 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

You probably have it figured out by now, but, just in case.

Code:
sub EVENT_ITEM {
	plugin::mq_process_items(\%itemcount); ## Place all items from the hash %itemcount into MQ entity variable (if a MQ'able quest)
	
	if (plugin::check_handin(\%itemcount, 1001 => 1)) { ## Did they give you a cloth cap as the MQ item?
		plugin::mq_process_items(1001 => 1); ## They did so lets add that 1 cloth cap to the MQ entity variable
	}
	elsif (plugin::check_mq_handin(1001 => 1, 1002 => 1)) { ## lets check entire MQ entity var to see if all expected items are in it
		quest::say("Yay you did it, you completed the MQ cycle!");
		plugin::clear_mq_handin();
    } else {
		plugin::return_items(\%itemcount);	
	}
}
Reply With Quote
  #6  
Old 12-17-2015, 04:51 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Just to add, for on-lookers. The above example assumes you are running this version of /plugins/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};
         }
     }
     return 1;
}

sub return_items {    
        my $hashref = plugin::var('$itemcount');
        my $client = plugin::val('$client');
        my $name = plugin::val('$name');
        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]);
                                        quest::say("I have no need for this $name, you can have it back.");
                                        $items_returned = 1;
                                }
                                else
                                {
                                        # This shouldn't be needed, but just in case
                                        quest::summonitem($k, 0);
                                        $items_returned = 1;
                                }
                                $rcount--;
                        }
                }
                delete $hashref->{$k};
        }
        # Return true if items were returned
        return $items_returned;

}

sub mq_process_items {
        my $hashref = shift;
        my $npc = plugin::val('$npc');
        my $trade = undef;
        
        if($npc->EntityVariableExists("_mq_trade")) {
                $trade = decode_eqemu_item_hash($npc->GetEntityVariable("_mq_trade")); 
        } else {
                $trade = {};
        }
        
        foreach my $k (keys(%{$hashref})) {
                next if($k == 0);
                
                if(defined $trade->{$k}) {
                        $trade->{$k} = $trade->{$k} + $hashref->{$k};
                } else {
                        $trade->{$k} = $hashref->{$k};
                }
        }
        
        my $str = encode_eqemu_item_hash($trade);
        $npc->SetEntityVariable("_mq_trade", $str);
}

sub check_mq_handin {
        my %required = @_;
        my $npc = plugin::val('$npc');
        my $trade = undef;
        
        if($npc->EntityVariableExists("_mq_trade")) {
                $trade = decode_eqemu_item_hash($npc->GetEntityVariable("_mq_trade"));
        } else {
                return 0;
        }
        
        foreach my $req (keys %required) {
                if((!defined $trade->{$req}) || ($trade->{$req} < $required{$req})) {
                                return 0;
                }
        }
        
        foreach my $req (keys %required) {
                if ($required{$req} < $trade->{$req}) {
                        $trade->{$req} -= $required{$req};
                } else {
                        delete $trade->{$req};
                }
        }
        
        $npc->SetEntityVariable("_mq_trade", encode_eqemu_item_hash($trade));
        return 1;
}

sub clear_mq_handin {
        my $npc = plugin::val('$npc');
        $npc->SetEntityVariable("_mq_trade", "");
}

sub encode_eqemu_item_hash {
        my $hashref = shift;
        my $str = "";
        my $i = 0;
        
        foreach my $k (keys(%{$hashref})) {
                if($i != 0) {
                        $str .= ",";
                } else {
                        $i = 1;
                }
                
                $str .= $k;
                $str .= "=";
                $str .= $hashref->{$k};
        }
        
        return $str;
}

sub decode_eqemu_item_hash {
        my $str = shift;
        my $hashref = { };
        
        my @vals = split(/,/, $str);
        my $val_len = @vals;
        for(my $i = 0; $i < $val_len; $i++) {
                my @subval = split(/=/, $vals[$i]);
                my $subval_len = @subval;
                if($subval_len == 2) {
                        my $key = $subval[0];
                        my $value = $subval[1];
                        
                        $hashref->{$key} = $value;
                }
        }
        
        return $hashref;
}
Reply With Quote
  #7  
Old 12-17-2015, 02:53 PM
image
Demi-God
 
Join Date: Jan 2002
Posts: 1,290
Default

KLS rewrote the multiquest functionality and integrated it all into perl: http://www.eqemulator.org/forums/showthread.php?t=37008

its also not documented but that change also had them remove #printquestitems, so you can't see what the NPC is storing for multiquest I guess. You would have to pull out the entity variable, but I don't know if there is a # command for it: http://wiki.eqemulator.org/p?The_Pow...tity_Variables

Original changes are here: http://www.eqemulator.org/forums/showthread.php?t=35696
__________________
www.eq2emu.com
EQ2Emu Developer
Former EQEMu Developer / GuildWars / Zek Seasons Servers
Member of the "I hate devn00b" club.
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 04:40 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