https://web.archive.org/web/20071011142 ... hp?t=28564
- ##########################################################################
- # This software is open source, licensed under the GNU General Public
- # License, version 2.
- # Basically, this means that you're allowed to modify and distribute
- # this software. However, if you distribute modified versions, you MUST
- # also distribute the source code.
- # See http://www.gnu.org/licenses/gpl.html for the full license.
- ##########################################################################
- ###########################
- # greedPlugin V1.0.0b
- #
- # (c)2007 abt123
- # For OpenKore 1.9.4+
- package greedPlugin;
- use strict;
- use AI;
- use Misc;
- use Utils;
- use Skill;
- use Plugins;
- use Globals;
- use Network;
- use Settings;
- use Translation;
- use Task;
- use Task::UseSkill;
- use Task::ErrorReport;
- use Log qw(message warning error debug);
- Plugins::register('greedPlugin', 'greedPlugin for greed people', \&onUnload);
- my $hook = Plugins::addHook('AI_post', \&processTake);
- sub onUnload {
- Plugins::delHook($hook);
- };
- sub isSurroundedItemsEnough {
- my $itemCounter = 0;
- foreach (@itemsID) {
- next unless $_;
- my $item = $items{$_};
- next if (pickupitems($item->{name}) eq "0" || pickupitems($item->{name}) == -1);
- $itemCounter++ if (distance($item->{pos}, $char->{pos_to}) < 3);
- }
- return 0 if ($itemCounter < $config{surroundedItemsMin});
- return 1;
- }
- ##
- # modified process take
- sub processTake {
- return if (!$config{greedPlugin});
- ##### TAKE #####
- if (AI::action eq "take" && AI::args->{suspended}) {
- AI::args->{ai_take_giveup}{time} += time - AI::args->{suspended};
- delete AI::args->{suspended};
- }
- if (AI::action eq "take" && ( !$items{AI::args->{ID}} || !%{$items{AI::args->{ID}}} )) {
- AI::dequeue;
- } elsif (AI::action eq "take" && timeOut(AI::args->{ai_take_giveup})) {
- my $item = $items{AI::args->{ID}};
- message TF("Failed to take %s (%s) from (%s, %s) to (%s, %s)\n", $item->{name}, $item->{binID}, $char->{pos}{x}, $char->{pos}{y}, $item->{pos}{x}, $item->{pos}{y});
- $items{AI::args->{ID}}{take_failed}++;
- AI::dequeue;
- } elsif (AI::action eq "take") {
- my $ID = AI::args->{ID};
- my $myPos = $char->{pos_to};
- my $dist = distance($items{$ID}{pos}, $myPos);
- my $item = $items{AI::args->{ID}};
- debug "Planning to take $item->{name} ($item->{binID}), distance $dist\n", "drop";
- if ($char->{sitting}) {
- stand();
- } elsif ($dist > 2) {
- if (!$config{itemsTakeAuto_new}) {
- my (%vec, %pos);
- getVector(\%vec, $item->{pos}, $myPos);
- moveAlongVector(\%pos, $myPos, \%vec, $dist - 1);
- move($pos{x}, $pos{y});
- } else {
- my $pos = $item->{pos};
- message TF("Routing to (%s, %s) to take %s (%s), distance %s\n", $pos->{x}, $pos->{y}, $item->{name}, $item->{binID}, $dist);
- ai_route($field{name}, $pos->{x}, $pos->{y}, maxRouteDistance => $config{'attackMaxRouteDistance'});
- }
- } elsif (timeOut($timeout{ai_take})) {
- if (isSurroundedItemsEnough) {
- my $skill = Skill->new(auto => 'greed');
- my $skillTask = new Task::UseSkill(
- target => $char,
- skill => $skill,
- priority => Task::USER_PRIORITY
- );
- my $task = new Task::ErrorReport(task => $skillTask);
- $taskManager->add($task);
- } else {
- my %vec;
- my $direction;
- getVector(\%vec, $item->{pos}, $myPos);
- $direction = int(sprintf("%.0f", (360 - vectorToDegree(\%vec)) / 45)) % 8;
- $messageSender->sendLook($direction, 0) if ($direction != $char->{look}{body});
- $messageSender->sendTake($ID);
- }
- $timeout{ai_take}{time} = time;
- }
- }
- }
- return 1;
This plugin scan for wanted items around you within 2 block radian(5x5). if number of item enough then use skill "Greed", instead of taking single item at a time. This useful when you kill looter.
How to use this thing?
1. There are 2 options for this plugin. Add them to config.txt
- greedPlugin <boolean flag> Enable/Disable plugin.
- surroundedItemsMin <num> least number of item to use skill.
2. Greed skill gather all kinds of items. so you must config pickupitems.txt to drop item that you don't want.(like a rough with auto steal)
Requirement
- OpenKore 1.9.4+
- Blacksmith/Whitesmith/Mastersmith with Greed skill.