mirror of
https://github.com/ProjectEQ/projecteqquests
synced 2026-08-12 00:26:10 -04:00
* [Handin] Item handin overhaul * Update items.lua * No-op guild tome hand-in * swap methods
77 lines
No EOL
2.6 KiB
Perl
77 lines
No EOL
2.6 KiB
Perl
# plugin::check_handin($item1 => #required_amount,...);
|
|
# autoreturns extra unused items on success
|
|
sub check_handin {
|
|
my $hashref = shift;
|
|
my %required = @_;
|
|
my $client = plugin::val('client');
|
|
my $npc = plugin::val('npc');
|
|
my @currencies = ("platinum", "gold", "silver", "copper");
|
|
|
|
foreach my $currency (@currencies) {
|
|
my $value = plugin::val("\$$currency");
|
|
if ($value > 0) {
|
|
$hashref->{$currency} = $value;
|
|
}
|
|
}
|
|
|
|
my @item_insts = (plugin::val('item1_inst'), plugin::val('item2_inst'), plugin::val('item3_inst'), plugin::val('item4_inst'));
|
|
return $npc->CheckHandin($client, \%{$hashref}, \%required, @item_insts);
|
|
}
|
|
|
|
sub return_items {
|
|
}
|
|
|
|
sub return_bot_items {
|
|
my $bot = plugin::val('bot');
|
|
if (!$bot->GetOwner() || !$bot->GetOwner()->IsClient()) {
|
|
return;
|
|
}
|
|
|
|
my $client = $bot->GetOwner()->CastToClient();
|
|
my $hashref = plugin::var('itemcount');
|
|
my $name = plugin::val('name');
|
|
my $items_returned = 0;
|
|
|
|
my %item_data = (
|
|
0 => [ plugin::val('item1'), plugin::val('item1_charges'), plugin::val('item1_attuned'), plugin::val('item1_inst') ],
|
|
1 => [ plugin::val('item2'), plugin::val('item2_charges'), plugin::val('item2_attuned'), plugin::val('item2_inst') ],
|
|
2 => [ plugin::val('item3'), plugin::val('item3_charges'), plugin::val('item3_attuned'), plugin::val('item3_inst') ],
|
|
3 => [ plugin::val('item4'), plugin::val('item4_charges'), plugin::val('item4_attuned'), plugin::val('item4_inst') ],
|
|
4 => [ plugin::val('item5'), plugin::val('item5_charges'), plugin::val('item5_attuned'), plugin::val('item5_inst') ],
|
|
5 => [ plugin::val('item6'), plugin::val('item6_charges'), plugin::val('item6_attuned'), plugin::val('item6_inst') ],
|
|
6 => [ plugin::val('item7'), plugin::val('item7_charges'), plugin::val('item7_attuned'), plugin::val('item7_inst') ],
|
|
7 => [ plugin::val('item8'), plugin::val('item8_charges'), plugin::val('item8_attuned'), plugin::val('item8_inst') ],
|
|
);
|
|
|
|
foreach my $k (keys(%{$hashref})) {
|
|
next if ($k == 0);
|
|
my $rcount = $hashref->{$k};
|
|
my $r;
|
|
for ($r = 0; $r < 8; $r++) {
|
|
if ($rcount > 0 && $item_data{$r}[0] && $item_data{$r}[0] == $k) {
|
|
if ($client) {
|
|
# remove delivered task items from return for this slot
|
|
my $inst = $item_data{$r}[3];
|
|
my $return_count = $inst->RemoveTaskDeliveredItems();
|
|
|
|
if ($return_count > 0) {
|
|
$client->SummonItem($k, $inst->GetCharges(), $item_data{$r}[2]);
|
|
$items_returned = 1;
|
|
}
|
|
} else {
|
|
quest::summonitem($k, 0);
|
|
$items_returned = 1;
|
|
}
|
|
$rcount--;
|
|
}
|
|
}
|
|
|
|
delete $hashref->{$k};
|
|
}
|
|
|
|
if ($items_returned) {
|
|
$bot->OwnerMessage("I have no need for this $name, you can have it back.");
|
|
}
|
|
|
|
return $items_returned;
|
|
} |