View Full Version : Multi-Quest support
Maze_EQ
12-16-2015, 03:21 PM
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?
Kingly_Krab
12-16-2015, 06:40 PM
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.
demonstar55
12-16-2015, 09:16 PM
check_mq_handin is for multi-questing, I'm not sure 100% how it works :P (PEQ has no examples)
Kingly_Krab
12-16-2015, 09:28 PM
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.
ghanja
12-17-2015, 04:43 AM
You probably have it figured out by now, but, just in case.
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);
}
}
ghanja
12-17-2015, 04:51 AM
Just to add, for on-lookers. The above example assumes you are running this version of /plugins/check_handin.pl
# 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;
}
image
12-17-2015, 02:53 PM
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_Power_of_Entity_Variables
Original changes are here: http://www.eqemulator.org/forums/showthread.php?t=35696
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.