БС Лутер (Корысть) / использование скилла Greed

Общие вопросы по OpenKore обсуждаются здесь. Можно сказать, что это - основной раздел форума.
Возник вопрос? Вам сюда.

Модератор: 4epT

Правила форума
Все вопросы по OK не касающиеся плагинов и макросов публикуются в этом разделе.
Перед тем как что то писать, пожалуйста, удостоверьтесь что данная тема не поднималась, вы полностью изучили мануалы по конфигурационным файлам бота и не нашли там решения.
Аватара пользователя
4epT
macro-маньячина
Сообщения: 2792
Зарегистрирован: Чт дек 21, 2006 1:23 pm
Сервер RO:: 4game
Discord: ya4ept#8494
Контактная информация:

БС Лутер (Корысть) / использование скилла Greed

Сообщение 4epT »

Вообще это сейчас делается через конфиг: itemsTakeGreed

https://web.archive.org/web/20071011142 ... hp?t=28564
  1. ##########################################################################
  2. # This software is open source, licensed under the GNU General Public
  3. # License, version 2.
  4. # Basically, this means that you're allowed to modify and distribute
  5. # this software. However, if you distribute modified versions, you MUST
  6. # also distribute the source code.
  7. # See http://www.gnu.org/licenses/gpl.html for the full license.
  8. ##########################################################################
  9.  
  10. ###########################
  11. # greedPlugin V1.0.0b
  12. #
  13. # (c)2007 abt123
  14. # For OpenKore 1.9.4+
  15.  
  16. package greedPlugin;
  17.  
  18. use strict;
  19. use AI;
  20. use Misc;
  21. use Utils;
  22. use Skill;
  23. use Plugins;
  24. use Globals;
  25. use Network;
  26. use Settings;
  27. use Translation;
  28. use Task;
  29. use Task::UseSkill;
  30. use Task::ErrorReport;
  31. use Log qw(message warning error debug);
  32.  
  33. Plugins::register('greedPlugin', 'greedPlugin for greed people', \&onUnload);
  34. my $hook = Plugins::addHook('AI_post', \&processTake);
  35.  
  36. sub onUnload {
  37.         Plugins::delHook($hook);
  38. };
  39.  
  40. sub isSurroundedItemsEnough {
  41.         my $itemCounter = 0;
  42.         foreach (@itemsID) {
  43.                 next unless $_;
  44.                 my $item = $items{$_};
  45.                 next if (pickupitems($item->{name}) eq "0" || pickupitems($item->{name}) == -1);
  46.                 $itemCounter++ if (distance($item->{pos}, $char->{pos_to}) < 3);
  47.         }
  48.         return 0 if ($itemCounter < $config{surroundedItemsMin});
  49.         return 1;
  50. }
  51.  
  52. ##
  53. # modified process take
  54. sub processTake {
  55.         return if (!$config{greedPlugin});
  56.        
  57.         ##### TAKE #####
  58.  
  59.         if (AI::action eq "take" && AI::args->{suspended}) {
  60.                 AI::args->{ai_take_giveup}{time} += time - AI::args->{suspended};
  61.                 delete AI::args->{suspended};
  62.         }
  63.  
  64.         if (AI::action eq "take" && ( !$items{AI::args->{ID}} || !%{$items{AI::args->{ID}}} )) {
  65.                 AI::dequeue;
  66.  
  67.         } elsif (AI::action eq "take" && timeOut(AI::args->{ai_take_giveup})) {
  68.                 my $item = $items{AI::args->{ID}};
  69.                 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});
  70.                 $items{AI::args->{ID}}{take_failed}++;
  71.                 AI::dequeue;
  72.  
  73.         } elsif (AI::action eq "take") {
  74.                 my $ID = AI::args->{ID};
  75.                 my $myPos = $char->{pos_to};
  76.                 my $dist = distance($items{$ID}{pos}, $myPos);
  77.                 my $item = $items{AI::args->{ID}};
  78.                 debug "Planning to take $item->{name} ($item->{binID}), distance $dist\n", "drop";
  79.  
  80.                 if ($char->{sitting}) {
  81.                         stand();
  82.  
  83.                 } elsif ($dist > 2) {
  84.                         if (!$config{itemsTakeAuto_new}) {
  85.                                 my (%vec, %pos);
  86.                                 getVector(\%vec, $item->{pos}, $myPos);
  87.                                 moveAlongVector(\%pos, $myPos, \%vec, $dist - 1);
  88.                                 move($pos{x}, $pos{y});
  89.                         } else {
  90.                                 my $pos = $item->{pos};
  91.                                 message TF("Routing to (%s, %s) to take %s (%s), distance %s\n", $pos->{x}, $pos->{y}, $item->{name}, $item->{binID}, $dist);
  92.                                 ai_route($field{name}, $pos->{x}, $pos->{y}, maxRouteDistance => $config{'attackMaxRouteDistance'});
  93.                         }
  94.  
  95.                 } elsif (timeOut($timeout{ai_take})) {
  96.                         if (isSurroundedItemsEnough) {
  97.                                 my $skill = Skill->new(auto => 'greed');
  98.                                 my $skillTask = new Task::UseSkill(
  99.                                         target => $char,
  100.                                         skill => $skill,
  101.                                         priority => Task::USER_PRIORITY
  102.                                 );
  103.                                 my $task = new Task::ErrorReport(task => $skillTask);
  104.                                 $taskManager->add($task);
  105.                         } else {
  106.                                 my %vec;
  107.                                 my $direction;
  108.                                 getVector(\%vec, $item->{pos}, $myPos);
  109.                                 $direction = int(sprintf("%.0f", (360 - vectorToDegree(\%vec)) / 45)) % 8;
  110.                                 $messageSender->sendLook($direction, 0) if ($direction != $char->{look}{body});
  111.                                 $messageSender->sendTake($ID);
  112.                         }
  113.                         $timeout{ai_take}{time} = time;
  114.                 }
  115.         }
  116. }
  117.  
  118. return 1;
What does this plugin do?
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.
Быстро и качественно напишу конфиг (макрос)! Стучи!
¤ Свежий бот ¤ Config checker ¤ Manual ¤
Изображение
Изображение
Ответить