|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
12-16-2015, 03:21 PM
|
Demi-God
|
|
Join Date: Mar 2012
Posts: 1,103
|
|
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
|
12-16-2015, 06:40 PM
|
Administrator
|
|
Join Date: May 2013
Location: United States
Posts: 1,595
|
|
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.
|
12-16-2015, 09:16 PM
|
Demi-God
|
|
Join Date: Apr 2008
Location: MA
Posts: 1,164
|
|
check_mq_handin is for multi-questing, I'm not sure 100% how it works :P (PEQ has no examples)
|
12-16-2015, 09:28 PM
|
Administrator
|
|
Join Date: May 2013
Location: United States
Posts: 1,595
|
|
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.
|
12-17-2015, 04:43 AM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
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);
}
}
|
|
|
|
12-17-2015, 04:51 AM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
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;
}
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 12:26 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|