Henrybk

Macro semântica 6.0

Jul 7th, 2015
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 19.69 KB | None | 0 0
  1. Index: macro.pl
  2. ===================================================================
  3. --- macro.pl    (revision 168)
  4. +++ macro.pl    (working copy)
  5. @@ -123,11 +123,14 @@
  6.             if (!defined $load{'packet_skilluse'}) {$load{'packet_skilluse'} = 1}
  7.         }
  8.         if (defined $automacro{$a}->{areaSpell} && !defined $load{'packet_areaSpell'}) {$load{'packet_areaSpell'} = 1}
  9. -       if (defined $automacro{$a}->{pm} && !defined $load{'packet_privMsg'}) {$load{'packet_privMsg'} = 1}
  10. -       if (defined $automacro{$a}->{pubm} && !defined $load{'packet_pubMsg'}) {$load{'packet_pubMsg'} = 1}
  11. -       if (defined $automacro{$a}->{system} && !defined $load{'packet_sysMsg'}) {$load{'packet_sysMsg'} = 1;}
  12. -       if (defined $automacro{$a}->{party} && !defined $load{'packet_partyMsg'}) {$load{'packet_partyMsg'} = 1}
  13. -       if (defined $automacro{$a}->{guild} && !defined $load{'packet_guildMsg'}) {$load{'packet_guildMsg'} = 1}
  14. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^pm/ && !defined $load{'packet_privMsg'}) {$load{'packet_privMsg'} = 1}
  15. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^pub/ && !defined $load{'packet_pubMsg'}) {$load{'packet_pubMsg'} = 1}  
  16. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^sys/ && !defined $load{'packet_sysMsg'}) {$load{'packet_sysMsg'} = 1;}
  17. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^party/ && !defined $load{'packet_partyMsg'}) {$load{'packet_partyMsg'} = 1}
  18. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^guild/ && !defined $load{'packet_guildMsg'}) {$load{'packet_guildMsg'} = 1}
  19. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^npc/ && !defined $load{'npc_talk'}) {$load{'npc_talk'} = 1}
  20. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^self/ && !defined $load{'packet_selfChat'}) {$load{'packet_selfChat'} = 1}
  21. +       if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^local/ && !defined $load{'packet_localBroadcast'}) {$load{'packet_localBroadcast'} = 1}
  22.         if (defined $automacro{$a}->{mapchange} && !defined $load{'packet_mapChange'}) {$load{'packet_mapChange'} = 1}
  23.         if (defined $automacro{$a}->{hook} && !defined $load{$automacro{$a}->{hook}}) {$load{$automacro{$a}->{hook}} = 1}
  24.         if (defined $automacro{$a}->{console} && !defined $hookToLog) {$hookToLog = 1}
  25. Index: Macro/Automacro.pm
  26. ===================================================================
  27. --- Macro/Automacro.pm  (revision 168)
  28. +++ Macro/Automacro.pm  (working copy)
  29. @@ -7,8 +7,8 @@
  30.  our @ISA = qw(Exporter);
  31.  our @EXPORT_OK = qw(releaseAM lockAM recheckAM automacroCheck consoleCheckWrapper);
  32.  our @EXPORT = qw(checkLocalTime checkVar checkVarVar checkLoc checkPersonGuild checkLevel checkLevel checkClass
  33. -   checkPercent checkStatus checkItem checkPerson checkCond checkCast checkGround checkSpellsID
  34. -   checkEquip checkMsg checkMonster checkAggressives checkConsole checkMapChange);
  35. +   checkPercent checkStatus checkItem checkCond checkCast checkGround checkSpellsID
  36. +   checkEquip checkAggressives checkConsole checkMapChange checkMessage checkActor);
  37.    
  38.  use Misc qw(whenGroundStatus getSpellName getActorName);
  39.  use Utils;
  40. @@ -310,27 +310,6 @@
  41.     return $return;
  42.  }
  43.  
  44. -# checks for near person ##################################
  45. -sub checkPerson {
  46. -   my ($who, $dist) = $_[0] =~ /^(["\/].*?["\/]\w*)\s*,?\s*(.*)/;
  47. -
  48. -   foreach my $player (@{$playersList->getItems()}) {
  49. -       next unless match($player->name, $who);
  50. -       if ($dist > 0 && distance($char->{pos_to}, $player->{pos_to}) >= $dist) {
  51. -           return 0;
  52. -       }
  53. -       my $val = sprintf("%d %d %s", $player->{pos_to}{x}, $player->{pos_to}{y}, $field->baseName);
  54. -       $varStack{".lastPlayerName"} = $player->name;
  55. -       $varStack{".lastPlayerPos"} = $val;
  56. -       $varStack{".lastPlayerLevel"} = $player->{lv};
  57. -       $varStack{".lastPlayerJob"} = $player->job;
  58. -       $varStack{".lastPlayerAccountId"} = $player->{nameID};
  59. -       $varStack{".lastPlayerBinId"} = $player->{binID};
  60. -       return 1
  61. -   }
  62. -   return 0
  63. -}
  64. -
  65.  # checks arg1 for condition in arg3 #######################
  66.  # uses: cmpr (Macro::Utils)
  67.  sub checkCond {
  68. @@ -450,47 +429,6 @@
  69.     else {return 0}
  70.  }
  71.  
  72. -# checks for public, private, party or guild message ######
  73. -# uses calcPosition, distance (Utils?)
  74. -sub checkMsg {
  75. -   my ($var, $tmp, $arg) = @_;
  76. -   my $msg;
  77. -   if ($var eq '.lastpub') {
  78. -       ($msg, my $distance) = $tmp =~ /^([\/"].*?[\/"]\w*)\s*,?\s*(\d*)/;
  79. -       if ($distance ne '') {
  80. -           my $mypos = calcPosition($char);
  81. -           my $pos = calcPosition($::players{$arg->{pubID}});
  82. -           return 0 unless distance($mypos, $pos) <= $distance
  83. -       }
  84. -   } elsif ($var eq '.lastpm') {
  85. -       ($msg, my $allowed) = $tmp =~ /^([\/"].*?[\/"]\w*)\s*,?\s*(.*)/;
  86. -       my $auth;
  87. -       if (!$allowed) {
  88. -           $auth = 1
  89. -       } else {
  90. -           my @tfld = split(/,/, $allowed);
  91. -           for (my $i = 0; $i < @tfld; $i++) {
  92. -               next unless defined $tfld[$i];
  93. -               $tfld[$i] =~ s/(?:^ +| +$)//g;
  94. -               if ($arg->{privMsgUser} eq $tfld[$i]) {$auth = 1; last}
  95. -           }
  96. -       }
  97. -       return 0 unless $auth
  98. -   } elsif ($var eq '.lastsys') {
  99. -       ($msg) = $tmp =~ /^([\/"].*?[\/"]\w*)\s*,?\s*(.*)/;
  100. -       chomp($msg);
  101. -   } else {
  102. -       $msg = $tmp
  103. -   }  
  104. -   $arg->{Msg} =~ s/[\r\n]*$//g;
  105. -   if (match($arg->{Msg},$msg)){
  106. -       $varStack{$var} = $arg->{MsgUser};
  107. -       $varStack{$var."Msg"} = $arg->{Msg};
  108. -       return 1
  109. -   }
  110. -   return 0
  111. -}
  112. -
  113.  # checks for area spell
  114.  sub checkSpellsID {
  115.     my ($line, $args) = @_;
  116. @@ -523,83 +461,6 @@
  117.     return 0
  118.  }
  119.  
  120. -# checks for monster ...
  121. -sub checkMonster {
  122. -   my $line = $_[0];
  123. -   my $not = $_[1];
  124. -   my ($mercenary, $use, $monsterList, $cond);
  125. -   my $mondist = $config{clientSight} || 20;
  126. -
  127. -   if ($line =~ /^\s*(.*),?\s+([<>=!~]+)\s+(\d+|\d+\s*.{2}\s*\d+)\s*$/) {
  128. -       ($monsterList, $cond, $mondist) = ($1, $2, $3)
  129. -   } else {
  130. -       $monsterList = $line;
  131. -       $cond = "<="
  132. -   }
  133. -
  134. -   if (!$not && $monsterList =~ /^(not|mercenary)\s+(.*)\s*$/) {
  135. -       if ($1 eq "not") {$not = 1; $monsterList = $2}
  136. -       else {$mercenary = 1; $use = 1; $monsterList = $2}
  137. -   }
  138. -
  139. -   foreach (@monstersID) {
  140. -       next unless defined $_;
  141. -       if ($mercenary) {
  142. -           #Whose the mercenary's master,
  143. -           #update later ;p
  144. -           my $mypos = calcPosition($char);
  145. -           my $pos = calcPosition($monsters{$_});
  146. -           my $dist = sprintf("%.1f",distance($pos, $mypos));
  147. -           if (existsInList($monsterList, $monsters{$_}->{name}) && $dist < 3) {$use = 0; last}
  148. -       }
  149. -       elsif ($not) {
  150. -           next if existsInList($monsterList, $monsters{$_}->{name});
  151. -           my $mypos = calcPosition($char);
  152. -           my $pos = calcPosition($monsters{$_});
  153. -           my $dist = sprintf("%.1f",distance($pos, $mypos));
  154. -           my $val = sprintf("%d %d %s", $pos->{x}, $pos->{y}, $field->baseName);
  155. -           $varStack{".lastMonster"} = $monsters{$_}->{name};
  156. -           $varStack{".lastMonsterPos"} = $val;
  157. -           $varStack{".lastMonsterDist"} = $dist;
  158. -           $varStack{".lastMonsterID"} = $monsters{$_}->{binID};
  159. -           $varStack{".lastMonsterBinID"} = $monsters{$_}->{binType};
  160. -           return cmpr($dist, $cond, $mondist)
  161. -       } else {
  162. -           if (existsInList($monsterList, $monsters{$_}->{name})) {
  163. -               my $counter;
  164. -               my $mypos = calcPosition($char);
  165. -               my $pos = calcPosition($monsters{$_});
  166. -               my $dist = sprintf("%.1f", distance($mypos, $pos));
  167. -               my $val = sprintf("%d %d %s", $pos->{x}, $pos->{y}, $field->baseName);
  168. -               $varStack{".lastMonster"} = $monsters{$_}->{name};
  169. -               $varStack{".lastMonsterPos"} = $val;
  170. -               $varStack{".lastMonsterDist"} = $dist;
  171. -               $varStack{".lastMonsterID"} = $monsters{$_}->{binID};
  172. -               $varStack{".lastMonsterBinID"} = $monsters{$_}->{binType};
  173. -               for (my $i = 0; $i < @::monstersID; $i++) {
  174. -                   next if $::monstersID[$i] eq "";
  175. -                   my $monster = Actor::get($::monstersID[$i]);
  176. -                   if ($monster->name eq $monsters{$_}->{name}) {
  177. -                       if ($monster->{binID} eq $monsters{$_}->{binID}) {
  178. -                           $counter++;
  179. -                           next
  180. -                       } else {
  181. -                           my $monsToMonDist = sprintf("%.1f",distance($pos, $monster->{pos_to}));
  182. -                           $counter++ if $monsToMonDist < 12;
  183. -                           next
  184. -                       }
  185. -                   }
  186. -                   next
  187. -               }
  188. -               $varStack{".lastMonsterCount"} = $counter;
  189. -               return cmpr($dist, $cond, $mondist)
  190. -           }
  191. -       }
  192. -   }
  193. -   return 1 if ($use);
  194. -   return 0
  195. -}
  196. -
  197.  # checks for aggressives
  198.  sub checkAggressives {
  199.     my ($cond, $amount) = $_[0] =~ /([<>=!]+)\s+(\$[a-zA-Z][a-zA-Z\d]*|\d+|\d+\s*\.{2}\s*\d+)\s*$/;
  200. @@ -772,6 +633,96 @@
  201.     return 0
  202.  }
  203.  
  204. +# checks for near actor ##################################
  205. +sub checkActor {
  206. +   my ($actorType, $not, $who, $distCond, $dist) = $_[0] =~ /^(\w+)\s+(not|none)?\s*(["\/].*?["\/]\w*)?\s*,?\s*([<>=!~]+)?\s*(\d*)/;
  207. +   $distCond = "<=" if (!$distCond && $dist > 0);
  208. +   my %actorTypes = (
  209. +           npc => $npcsList->getItems(),
  210. +           player => $playersList->getItems(),
  211. +           monster => $monstersList->getItems(),
  212. +           pet => $petsList->getItems()
  213. +       );
  214. +   return 0 if (!exists($actorTypes{$actorType}));
  215. +   if ($not eq 'none' && !($dist > 0)) {
  216. +       return 1 if (!@{$actorTypes{$actorType}});
  217. +       return 0;
  218. +   }
  219. +   if ($who =~ /(?<!\\)\$\w+/) {
  220. +       my $valu;
  221. +       my @val = $who =~ /(?<!\\)(\$\w+)/g;
  222. +       foreach (@val) {
  223. +           $_ =~ s/^\$//;
  224. +           return 0 if (!$::Macro::Data::varStack{$_});
  225. +           $who =~ s/\$$_/$::Macro::Data::varStack{$_}/;
  226. +       }
  227. +   }
  228. +   foreach my $actor (@{$actorTypes{$actorType}}) {
  229. +       unless ($not) {
  230. +           next unless (match($actor->name, $who));
  231. +       }
  232. +       if ($dist > 0) {
  233. +           if (!cmpr(distance($char->{pos_to}, $actor->{pos_to}), $distCond, $dist)) {
  234. +               next;
  235. +           } elsif ($not eq 'none') {
  236. +               return 0;
  237. +           }
  238. +       }
  239. +       my $val = sprintf("%d %d %s", $actor->{pos_to}{x}, $actor->{pos_to}{y}, $field->baseName);
  240. +       if ($actorType eq 'npc') {
  241. +           $varStack{".lastNpcName"} = $actor->name;
  242. +           $varStack{".lastNpcPos"} = $val;
  243. +           $varStack{".lastNpcIndex"} = $actor->{binID};
  244. +           $varStack{".lastNPcID"} = $actor->{nameID};
  245. +       } elsif ($actorType eq 'player') {
  246. +           $varStack{".lastPlayerName"} = $actor->name;
  247. +           $varStack{".lastPlayerPos"} = $val;
  248. +           $varStack{".lastPlayerLevel"} = $actor->{lv};
  249. +           $varStack{".lastPlayerJob"} = $actor->job;
  250. +           $varStack{".lastPlayerAccountId"} = $actor->{nameID};
  251. +           $varStack{".lastPlayerBinId"} = $actor->{binID};
  252. +       } elsif ($actorType eq 'monster') {
  253. +           $varStack{".lastMonster"} = $actor->{name};
  254. +           $varStack{".lastMonsterPos"} = $val;
  255. +           $varStack{".lastMonsterDist"} = $dist;
  256. +           $varStack{".lastMonsterID"} = $actor->{binID};
  257. +           $varStack{".lastMonsterBinID"} = $actor->{binType};
  258. +       } elsif ($actorType eq 'pet') {
  259. +           $varStack{".lastPetName"} = $actor->name;
  260. +           $varStack{".lastPetPos"} = $val;
  261. +           $varStack{".lastPetIndex"} = $actor->{binID};
  262. +           $varStack{".lastPetType"} = $actor->{type};
  263. +       }
  264. +       return 1
  265. +   }
  266. +   return 1 if ($not eq 'none');
  267. +   return 0
  268. +}
  269. +
  270. +#cheks messages
  271. +sub checkMessage {
  272. +   my ($condition, $args) = @_;
  273. +   my ($message, $actorCondition, $actor);
  274. +   my ($sourceType, $not, $condition, $actorCondition, $distCond, $dist) = $condition =~ /^(\w+)\s+(not)?\s*([\/"].*?[\/"]\w*)\s*,?\s*([\/"].*?[\/"]\w*)?\s*,?\s*([<>=!~]+)?\s*(\d*)/;
  275. +   $sourceType =~ s/^(\w+)$/.last$1/;
  276. +   if ($sourceType eq '.lastnpc' || $sourceType eq '.lastself') { $message = $args->{msg}; } else { $message = $args->{Msg}; }
  277. +   if ($sourceType =~ /(pm|pub|party|guild)$/) { $actor = $args->{MsgUser}; } elsif ($sourceType eq '.lastnpc') { $actor = $args->{name}; } elsif ($sourceType eq '.lastself') { $actor = $args->{user}; }
  278. +   return 0 if ((!match($message, $condition) xor $not) || ($actorCondition && !match($actor, $actorCondition)));
  279. +   if ($dist > 0 && $playersList && $sourceType =~ /(pm|pub|party|guild)$/) {
  280. +       $distCond = "<=" if (!$distCond);
  281. +       foreach my $player (@{$playersList->getItems()}) {
  282. +           next if ($actor ne $player->name);
  283. +           return 0 if (!cmpr(distance($char->{pos_to}, $player->{pos_to}), $distCond, $dist));
  284. +           goto End;
  285. +       }
  286. +       return 0;
  287. +   }
  288. +   End:
  289. +   $varStack{$sourceType."Msg"} = $message;
  290. +   $varStack{$sourceType} = $actor if ($actor);
  291. +   return 1;
  292. +}
  293. +
  294.  # parses automacros and checks conditions #################
  295.  sub automacroCheck {
  296.     my ($trigger, $args) = @_;
  297. @@ -835,26 +786,18 @@
  298.             if ($trigger =~ /^(?:is_casting|packet_skilluse)$/) {
  299.             next CHKAM unless checkCast($automacro{$am}->{spell}, $args)
  300.             } else {next CHKAM}
  301. -       } elsif (defined $automacro{$am}->{pm}) {
  302. -           if ($trigger eq 'packet_privMsg') {
  303. -           next CHKAM unless checkMsg(".lastpm", $automacro{$am}->{pm}, $args)
  304. +       } elsif (defined $automacro{$am}->{message}) {
  305. +           if (($trigger eq 'npc_talk' && $automacro{$am}->{message} =~ /^npc/) ||
  306. +               ($trigger eq 'packet_privMsg' && $automacro{$am}->{message} =~ /^pm/) ||
  307. +               ($trigger eq 'packet_pubMsg' && $automacro{$am}->{message} =~ /^pub/) ||
  308. +               ($trigger eq 'packet_sysMsg' && $automacro{$am}->{message} =~ /^sys/) ||
  309. +               ($trigger eq 'packet_partyMsg' && $automacro{$am}->{message} =~ /^party/) ||
  310. +               ($trigger eq 'packet_selfChat' && $automacro{$am}->{message} =~ /^self/) ||
  311. +               ($trigger eq 'packet_localBroadcast' && $automacro{$am}->{message} =~ /^local/) ||
  312. +               ($trigger eq 'packet_guildMsg' && $automacro{$am}->{message} =~ /^guild/)
  313. +               ){
  314. +                   next CHKAM unless checkMessage($automacro{$am}->{message}, $args)
  315.             } else {next CHKAM}
  316. -       } elsif (defined $automacro{$am}->{pubm}) {
  317. -           if ($trigger eq 'packet_pubMsg') {
  318. -           next CHKAM unless checkMsg(".lastpub", $automacro{$am}->{pubm}, $args)
  319. -           } else {next CHKAM}
  320. -       } elsif (defined $automacro{$am}->{system}) {
  321. -           if ($trigger eq 'packet_sysMsg') {
  322. -           next CHKAM unless checkMsg(".lastsys", $automacro{$am}->{system}, $args)
  323. -           } else {next CHKAM}
  324. -       } elsif (defined $automacro{$am}->{party}) {
  325. -           if ($trigger eq 'packet_partyMsg') {
  326. -           next CHKAM unless checkMsg(".lastparty", $automacro{$am}->{party}, $args)
  327. -           } else {next CHKAM}
  328. -       } elsif (defined $automacro{$am}->{guild}) {
  329. -           if ($trigger eq 'packet_guildMsg') {
  330. -           next CHKAM unless checkMsg(".lastguild", $automacro{$am}->{guild}, $args)
  331. -           } else {next CHKAM}
  332.         } elsif (defined $automacro{$am}->{mapchange}) {
  333.             if ($trigger eq 'packet_mapChange') {
  334.             next CHKAM unless checkMapChange($automacro{$am}->{mapchange})
  335. @@ -872,11 +815,9 @@
  336.         next CHKAM if (defined $automacro{$am}->{map}    && $automacro{$am}->{map} ne $field->baseName);
  337.         next CHKAM if (defined $automacro{$am}->{class}  && !checkClass($automacro{$am}->{class}));
  338.         next CHKAM if (defined $automacro{$am}->{whenGround} && !checkGround($automacro{$am}->{whenGround}));
  339. -       next CHKAM if (defined $automacro{$am}->{notMonster} && !checkMonster($automacro{$am}->{notMonster}, 1));
  340.        
  341.         foreach my $i (@{$automacro{$am}->{eval}})       {next CHKAM unless checkEval($i)}
  342.         foreach my $i (@{$automacro{$am}->{action}})     {next CHKAM unless checkAction($i)}
  343. -       foreach my $i (@{$automacro{$am}->{monster}})    {next CHKAM unless checkMonster($i)}
  344.         foreach my $i (@{$automacro{$am}->{aggressives}}){next CHKAM unless checkAggressives($i)}
  345.         foreach my $i (@{$automacro{$am}->{location}})   {next CHKAM unless checkLoc($i)}
  346.         foreach my $i (@{$automacro{$am}->{localtime}})  {next CHKAM unless checkLocalTime($i, "")}
  347. @@ -894,9 +835,9 @@
  348.         foreach my $i (@{$automacro{$am}->{soldout}})    {next CHKAM unless checkCond(getSoldOut(), $i)}
  349.         foreach my $i (@{$automacro{$am}->{zeny}})       {next CHKAM unless checkCond($char->{zeny}, $i)}
  350.         foreach my $i (@{$automacro{$am}->{cash}})       {next CHKAM unless checkCond($cashShop{points}->{cash}?$cashShop{points}->{cash}:0, $i)}
  351. -       foreach my $i (@{$automacro{$am}->{player}})     {next CHKAM unless checkPerson($i)}
  352.         foreach my $i (@{$automacro{$am}->{equipped}})   {next CHKAM unless checkEquip($i)}
  353.         foreach my $i (@{$automacro{$am}->{status}})     {next CHKAM unless checkStatus($i)}
  354. +       foreach my $i (@{$automacro{$am}->{actor}})      {next CHKAM unless checkActor($i)}
  355.         foreach my $i (@{$automacro{$am}->{inventory}})  {next CHKAM unless checkItem("inv", $i)}
  356.         foreach my $i (@{$automacro{$am}->{storage}})    {next CHKAM unless checkItem("stor", $i)}
  357.         foreach my $i (@{$automacro{$am}->{shop}})       {next CHKAM unless checkItem("shop", $i)}
  358. Index: Macro/Data.pm
  359. ===================================================================
  360. --- Macro/Data.pm   (revision 168)
  361. +++ Macro/Data.pm   (working copy)
  362. @@ -26,12 +26,7 @@
  363.     'disabled' => 1,     # option: automacro disabled
  364.     'call' => 1,         # setting: macro to be called
  365.     'spell' => 1,        # check: cast sensor
  366. -   'notMonster' => 1,   # check: disallow monsters other than ~
  367. -   'pm' => 1,           # check: private message
  368. -   'pubm' => 1,         # check: public chat
  369. -   'system' => 1,       # check: system chat
  370. -   'guild' => 1,        # check: guild chat
  371. -   'party' => 1,        # check: party chat
  372. +   'message' => 1,      # check: all messages
  373.     'console' => 1,      # check: console message
  374.     'overrideAI' => 1,   # option: override AI
  375.     'orphan' => 1,       # option: orphan handling
  376. @@ -50,7 +45,6 @@
  377.     'eval' => 1,         # check : eval
  378.     'set' => 1,          # set: variable
  379.     'save' => 1,         # setting: save hook arguments
  380. -   'monster' => 1,      # check: monster on screen
  381.     'aggressives' => 1,  # check: aggressives
  382.     'location' => 1,     # check: player's location
  383.     'var' => 1,          # check: variable / value
  384. @@ -65,7 +59,6 @@
  385.     'soldout' => 1,      # check: sold out shop slots
  386.     'zeny' => 1,         # check: player's zeny
  387.     'cash' => 1,         # check: player's cash
  388. -   'player' => 1,       # check: player name near
  389.     'equipped' => 1,     # check: equipment
  390.     'status' => 1,       # check: player's status
  391.     'inventory' => 1,    # check: item amount in inventory
  392. @@ -75,6 +68,7 @@
  393.     'localtime' => 1,    # check: localtime
  394.     'config' => 1,       # check: config key
  395.     'quest' => 1,        # check: player quests
  396. +   'actor' => 1,        # check: actor near
  397.     'action' => 1        # check: action
  398.  );
  399.  
  400. Index: Macro/Parser.pm
  401. ===================================================================
  402. --- Macro/Parser.pm (revision 168)
  403. +++ Macro/Parser.pm (working copy)
  404. @@ -122,14 +122,52 @@
  405.                     warning "$file: ignoring '$_' in line $. (munch, munch, not a pair)\n";
  406.                     next
  407.                 }
  408. +               if ($key =~ /(player|monster|notMonster)/) {
  409. +                   $key = 'actor';
  410. +                   if ($1 eq "player") {
  411. +                       my ($who, $dist) = $value =~ /^(["\/].*?["\/]\w*)\s*,?\s*(.*)/;
  412. +                       if ($dist > 0) {
  413. +                           $value = "player $who $dist";
  414. +                       } else {
  415. +                           $value = "player $who";
  416. +                       }
  417. +                   } else {
  418. +                       my $not;
  419. +                       if ($value =~ /^not\s+/) {
  420. +                           $value =~ s/^not\s+//;
  421. +                           $not = "not ";
  422. +                       } elsif ($1 eq "notMonster") {
  423. +                           $not = "not ";
  424. +                       }  
  425. +                       my ($monsterList, $cond, $mondist);
  426. +                       if ($value =~ /^\s*(.*),?\s+([<>=!~]+)\s+(\d+|\d+\s*.{2}\s*\d+)\s*$/) {
  427. +                           ($monsterList, $cond, $mondist) = ($1, $2, $3);
  428. +                       } else {
  429. +                           $monsterList = $value;
  430. +                       }
  431. +                       my @monsterList2 = split(/\s*,\s*/,$monsterList);
  432. +                       my $newMonsterList = join ("|",@monsterList2);
  433. +                       if ($cond && $mondist) {
  434. +                           $value = "monster ".$not."/^($newMonsterList)".'$'."/ $cond $mondist";
  435. +                       } elsif ($mondist) {
  436. +                           $value = "monster ".$not."/^($newMonsterList)".'$'."/ $mondist";
  437. +                       } else {
  438. +                           $value = "monster ".$not."/^($newMonsterList)".'$'."/";
  439. +                       }
  440. +                   }
  441. +               } elsif ($key =~ /(pm|pub|party|guild|system)/) {
  442. +                   my $messageType;
  443. +                   if ($1 eq 'system') { $messageType = 'sys'; } else { $messageType = $1; }
  444. +                   $key = 'message';
  445. +                   $value = "$messageType $value";
  446. +               }
  447.                 if ($amSingle{$key}) {
  448. -                   $automacro{$block{name}}->{$key} = $value
  449. +                   $automacro{$block{name}}->{$key} = $value;
  450.                 } elsif ($amMulti{$key}) {
  451. -                   push(@{$automacro{$block{name}}->{$key}}, $value)
  452. +                   push(@{$automacro{$block{name}}->{$key}}, $value);
  453.                 } else {
  454.                     warning "$file: ignoring '$_' in line $. (munch, munch, unknown automacro keyword)\n"
  455. -               }
  456. -           }
  457. +               }           }
  458.            
  459.             next
  460.         }
Advertisement
Add Comment
Please, Sign In to add comment