Re: Macro Mods
Posted: 24 Dec 2008, 04:33
Oops,
Prompt development
![Smile :)](./images/smilies/icon_e_smile.gif)
For Macro v. 2.0.3-svn (27/7/52)
- add @ Npc(</regexp/i or "name">) for find npc by name (return binID)
becuz some server random position [can't find by @npc(xx yy)]
file ../plugins/Macro/Data.pm
find:replace with:Code: Select all
"npc" . "|" .
Code: Select all
"[Nn]pc" . "|" .
file ../plugins/Macro/Data.pm
find:replace with:Code: Select all
use Macro::Utilities qw(refreshGlobal getnpcID getItemIDs getItemPrice getStorageIDs getInventoryIDs getPlayerID getVenderID getRandom getRandomRange getInventoryAmount getCartAmount getShopAmount getStorageAmount getVendAmount getConfig getWord q4rx q4rx2 getArgFromList getListLenght);
find:Code: Select all
use Macro::Utilities qw(refreshGlobal getnpcID getnpcIDfromName getItemIDs getItemPrice getStorageIDs getInventoryIDs getPlayerID getVenderID getRandom getRandomRange getInventoryAmount getCartAmount getShopAmount getStorageAmount getVendAmount getConfig getWord q4rx q4rx2 getArgFromList getListLenght);
replace with:Code: Select all
if ($kw eq 'npc') {$ret = getnpcID($arg)} elsif ($kw eq 'cart') {($ret) = getItemIDs($arg, $::cart{'inventory'})}
file ../plugins/Macro/Utilities.pmCode: Select all
if ($kw eq 'npc') {$ret = getnpcID($arg)} elsif ($kw eq 'Npc') {$ret = getnpcIDfromName($arg)} elsif ($kw eq 'cart') {($ret) = getItemIDs($arg, $::cart{'inventory'})}
find:replace with:Code: Select all
our @EXPORT_OK = qw(ai_isIdle q4rx q4rx2 between cmpr match getArgs refreshGlobal getnpcID getPlayerID getVenderID getItemIDs getItemPrice getInventoryIDs getStorageIDs getSoldOut getInventoryAmount getCartAmount getShopAmount getStorageAmount getVendAmount getRandom getRandomRange getConfig getWord callMacro getArgFromList getListLenght sameParty);
find:Code: Select all
our @EXPORT_OK = qw(ai_isIdle q4rx q4rx2 between cmpr match getArgs refreshGlobal getnpcID getnpcIDfromName getPlayerID getVenderID getItemIDs getItemPrice getInventoryIDs getStorageIDs getSoldOut getInventoryAmount getCartAmount getShopAmount getStorageAmount getVendAmount getRandom getRandomRange getConfig getWord callMacro getArgFromList getListLenght sameParty);
add after:Code: Select all
use Macro::Data
find:Code: Select all
use Network;
add after:Code: Select all
sub getnpcID { my ($tmpx, $tmpy) = split(/ /,$_[0]); foreach my $npc (@{$npcsList->getItems()}) { return $npc->{binID} if ($npc->{pos}{x} == $tmpx && $npc->{pos}{y} == $tmpy) } return -1 }
Code: Select all
sub getnpcIDfromName { my $nameNPC = $_[0]; foreach my $npc (@{$npcsList->getItems()}) { if(my($re, $ci) = $nameNPC =~ /^\/(.+?)\/(i?)$/){ if(($ci && $npc->{name} =~ /$re/i) || (!$ci && $npc->{name} =~ /$re/)){ return $npc->{binID} } }elsif($nameNPC =~ /^"(.*?)"$/){ return $npc->{binID} if $npc->{name} eq $1 } } return -1 }