Henrybk

Macro semântica 5.0

Jul 2nd, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 19.17 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,76 @@
  201.     return 0
  202.  }
  203.  
  204. +# checks for near actor ##################################
  205. +sub checkActor {
  206. +   my ($actorType, $not, $who, $distCond, $dist) = $_[0] =~ /^(\w+)\s+(not)?\s*(["\/].*?["\/]\w*)\s*,?\s*([<>=!~]+)?\s*(\d*)/;
  207. +   $distCond = "<=" if (!$distCond);
  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. +   foreach my $actor (@{$actorTypes{$actorType}}) {
  216. +       next unless (match($actor->name, $who) xor $not);
  217. +       if ($dist > 0 && !cmpr(distance($char->{pos_to}, $actor->{pos_to}), $distCond, $dist)) {
  218. +           next;
  219. +       }
  220. +       my $val = sprintf("%d %d %s", $actor->{pos_to}{x}, $actor->{pos_to}{y}, $field->baseName);
  221. +       if ($actorType eq 'npc') {
  222. +           $varStack{".lastNpcName"} = $actor->name;
  223. +           $varStack{".lastNpcPos"} = $val;
  224. +           $varStack{".lastNpcIndex"} = $actor->{binID};
  225. +           $varStack{".lastNPcID"} = $actor->{nameID};
  226. +       } elsif ($actorType eq 'player') {
  227. +           $varStack{".lastPlayerName"} = $actor->name;
  228. +           $varStack{".lastPlayerPos"} = $val;
  229. +           $varStack{".lastPlayerLevel"} = $actor->{lv};
  230. +           $varStack{".lastPlayerJob"} = $actor->job;
  231. +           $varStack{".lastPlayerAccountId"} = $actor->{nameID};
  232. +           $varStack{".lastPlayerBinId"} = $actor->{binID};
  233. +       } elsif ($actorType eq 'monster') {
  234. +           $varStack{".lastMonster"} = $actor->{name};
  235. +           $varStack{".lastMonsterPos"} = $val;
  236. +           $varStack{".lastMonsterDist"} = $dist;
  237. +           $varStack{".lastMonsterID"} = $actor->{binID};
  238. +           $varStack{".lastMonsterBinID"} = $actor->{binType};
  239. +       } elsif ($actorType eq 'pet') {
  240. +           $varStack{".lastPetName"} = $actor->name;
  241. +           $varStack{".lastPetPos"} = $val;
  242. +           $varStack{".lastPetIndex"} = $actor->{binID};
  243. +           $varStack{".lastPetType"} = $actor->{type};
  244. +       }
  245. +       return 1
  246. +   }
  247. +   return 0
  248. +}
  249. +
  250. +#cheks messages
  251. +sub checkMessage {
  252. +   my ($condition, $args) = @_;
  253. +   my ($message, $actorCondition, $actor);
  254. +   my ($sourceType, $not, $condition, $actorCondition, $distCond, $dist) = $condition =~ /^(\w+)\s+(not)?\s*([\/"].*?[\/"]\w*)\s*,?\s*([\/"].*?[\/"]\w*)?\s*,?\s*([<>=!~]+)?\s*(\d*)/;
  255. +   $sourceType =~ s/^(\w+)$/.last$1/;
  256. +   if ($sourceType eq '.lastnpc' || $sourceType eq '.lastself') { $message = $args->{msg}; } else { $message = $args->{Msg}; }
  257. +   if ($sourceType =~ /(pm|pub|party|guild)$/) { $actor = $args->{MsgUser}; } elsif ($sourceType eq '.lastnpc') { $actor = $args->{name}; } elsif ($sourceType eq '.lastself') { $actor = $args->{user}; }
  258. +   return 0 if ((!match($message, $condition) xor $not) || ($actorCondition && !match($actor, $actorCondition)));
  259. +   if ($dist > 0 && $playersList && $sourceType =~ /(pm|pub|party|guild)$/) {
  260. +       $distCond = "<=" if (!$distCond);
  261. +       foreach my $player (@{$playersList->getItems()}) {
  262. +           next if ($actor ne $player->name);
  263. +           return 0 if (!cmpr(distance($char->{pos_to}, $player->{pos_to}), $distCond, $dist));
  264. +           goto End;
  265. +       }
  266. +       return 0;
  267. +   }
  268. +   End:
  269. +   $varStack{$sourceType."Msg"} = $message;
  270. +   $varStack{$sourceType} = $actor if ($actor);
  271. +   return 1;
  272. +}
  273. +
  274.  # parses automacros and checks conditions #################
  275.  sub automacroCheck {
  276.     my ($trigger, $args) = @_;
  277. @@ -835,26 +766,18 @@
  278.             if ($trigger =~ /^(?:is_casting|packet_skilluse)$/) {
  279.             next CHKAM unless checkCast($automacro{$am}->{spell}, $args)
  280.             } else {next CHKAM}
  281. -       } elsif (defined $automacro{$am}->{pm}) {
  282. -           if ($trigger eq 'packet_privMsg') {
  283. -           next CHKAM unless checkMsg(".lastpm", $automacro{$am}->{pm}, $args)
  284. +       } elsif (defined $automacro{$am}->{message}) {
  285. +           if (($trigger eq 'npc_talk' && $automacro{$am}->{message} =~ /^npc/) ||
  286. +               ($trigger eq 'packet_privMsg' && $automacro{$am}->{message} =~ /^pm/) ||
  287. +               ($trigger eq 'packet_pubMsg' && $automacro{$am}->{message} =~ /^pub/) ||
  288. +               ($trigger eq 'packet_sysMsg' && $automacro{$am}->{message} =~ /^sys/) ||
  289. +               ($trigger eq 'packet_partyMsg' && $automacro{$am}->{message} =~ /^party/) ||
  290. +               ($trigger eq 'packet_selfChat' && $automacro{$am}->{message} =~ /^self/) ||
  291. +               ($trigger eq 'packet_localBroadcast' && $automacro{$am}->{message} =~ /^local/) ||
  292. +               ($trigger eq 'packet_guildMsg' && $automacro{$am}->{message} =~ /^guild/)
  293. +               ){
  294. +                   next CHKAM unless checkMessage($automacro{$am}->{message}, $args)
  295.             } else {next CHKAM}
  296. -       } elsif (defined $automacro{$am}->{pubm}) {
  297. -           if ($trigger eq 'packet_pubMsg') {
  298. -           next CHKAM unless checkMsg(".lastpub", $automacro{$am}->{pubm}, $args)
  299. -           } else {next CHKAM}
  300. -       } elsif (defined $automacro{$am}->{system}) {
  301. -           if ($trigger eq 'packet_sysMsg') {
  302. -           next CHKAM unless checkMsg(".lastsys", $automacro{$am}->{system}, $args)
  303. -           } else {next CHKAM}
  304. -       } elsif (defined $automacro{$am}->{party}) {
  305. -           if ($trigger eq 'packet_partyMsg') {
  306. -           next CHKAM unless checkMsg(".lastparty", $automacro{$am}->{party}, $args)
  307. -           } else {next CHKAM}
  308. -       } elsif (defined $automacro{$am}->{guild}) {
  309. -           if ($trigger eq 'packet_guildMsg') {
  310. -           next CHKAM unless checkMsg(".lastguild", $automacro{$am}->{guild}, $args)
  311. -           } else {next CHKAM}
  312.         } elsif (defined $automacro{$am}->{mapchange}) {
  313.             if ($trigger eq 'packet_mapChange') {
  314.             next CHKAM unless checkMapChange($automacro{$am}->{mapchange})
  315. @@ -872,11 +795,9 @@
  316.         next CHKAM if (defined $automacro{$am}->{map}    && $automacro{$am}->{map} ne $field->baseName);
  317.         next CHKAM if (defined $automacro{$am}->{class}  && !checkClass($automacro{$am}->{class}));
  318.         next CHKAM if (defined $automacro{$am}->{whenGround} && !checkGround($automacro{$am}->{whenGround}));
  319. -       next CHKAM if (defined $automacro{$am}->{notMonster} && !checkMonster($automacro{$am}->{notMonster}, 1));
  320.        
  321.         foreach my $i (@{$automacro{$am}->{eval}})       {next CHKAM unless checkEval($i)}
  322.         foreach my $i (@{$automacro{$am}->{action}})     {next CHKAM unless checkAction($i)}
  323. -       foreach my $i (@{$automacro{$am}->{monster}})    {next CHKAM unless checkMonster($i)}
  324.         foreach my $i (@{$automacro{$am}->{aggressives}}){next CHKAM unless checkAggressives($i)}
  325.         foreach my $i (@{$automacro{$am}->{location}})   {next CHKAM unless checkLoc($i)}
  326.         foreach my $i (@{$automacro{$am}->{localtime}})  {next CHKAM unless checkLocalTime($i, "")}
  327. @@ -894,9 +815,9 @@
  328.         foreach my $i (@{$automacro{$am}->{soldout}})    {next CHKAM unless checkCond(getSoldOut(), $i)}
  329.         foreach my $i (@{$automacro{$am}->{zeny}})       {next CHKAM unless checkCond($char->{zeny}, $i)}
  330.         foreach my $i (@{$automacro{$am}->{cash}})       {next CHKAM unless checkCond($cashShop{points}->{cash}?$cashShop{points}->{cash}:0, $i)}
  331. -       foreach my $i (@{$automacro{$am}->{player}})     {next CHKAM unless checkPerson($i)}
  332.         foreach my $i (@{$automacro{$am}->{equipped}})   {next CHKAM unless checkEquip($i)}
  333.         foreach my $i (@{$automacro{$am}->{status}})     {next CHKAM unless checkStatus($i)}
  334. +       foreach my $i (@{$automacro{$am}->{actor}})      {next CHKAM unless checkActor($i)}
  335.         foreach my $i (@{$automacro{$am}->{inventory}})  {next CHKAM unless checkItem("inv", $i)}
  336.         foreach my $i (@{$automacro{$am}->{storage}})    {next CHKAM unless checkItem("stor", $i)}
  337.         foreach my $i (@{$automacro{$am}->{shop}})       {next CHKAM unless checkItem("shop", $i)}
  338. Index: Macro/Data.pm
  339. ===================================================================
  340. --- Macro/Data.pm   (revision 168)
  341. +++ Macro/Data.pm   (working copy)
  342. @@ -26,12 +26,7 @@
  343.     'disabled' => 1,     # option: automacro disabled
  344.     'call' => 1,         # setting: macro to be called
  345.     'spell' => 1,        # check: cast sensor
  346. -   'notMonster' => 1,   # check: disallow monsters other than ~
  347. -   'pm' => 1,           # check: private message
  348. -   'pubm' => 1,         # check: public chat
  349. -   'system' => 1,       # check: system chat
  350. -   'guild' => 1,        # check: guild chat
  351. -   'party' => 1,        # check: party chat
  352. +   'message' => 1,      # check: all messages
  353.     'console' => 1,      # check: console message
  354.     'overrideAI' => 1,   # option: override AI
  355.     'orphan' => 1,       # option: orphan handling
  356. @@ -50,7 +45,6 @@
  357.     'eval' => 1,         # check : eval
  358.     'set' => 1,          # set: variable
  359.     'save' => 1,         # setting: save hook arguments
  360. -   'monster' => 1,      # check: monster on screen
  361.     'aggressives' => 1,  # check: aggressives
  362.     'location' => 1,     # check: player's location
  363.     'var' => 1,          # check: variable / value
  364. @@ -65,7 +59,6 @@
  365.     'soldout' => 1,      # check: sold out shop slots
  366.     'zeny' => 1,         # check: player's zeny
  367.     'cash' => 1,         # check: player's cash
  368. -   'player' => 1,       # check: player name near
  369.     'equipped' => 1,     # check: equipment
  370.     'status' => 1,       # check: player's status
  371.     'inventory' => 1,    # check: item amount in inventory
  372. @@ -75,6 +68,7 @@
  373.     'localtime' => 1,    # check: localtime
  374.     'config' => 1,       # check: config key
  375.     'quest' => 1,        # check: player quests
  376. +   'actor' => 1,        # check: actor near
  377.     'action' => 1        # check: action
  378.  );
  379.  
  380. Index: Macro/Parser.pm
  381. ===================================================================
  382. --- Macro/Parser.pm (revision 168)
  383. +++ Macro/Parser.pm (working copy)
  384. @@ -122,10 +122,49 @@
  385.                     warning "$file: ignoring '$_' in line $. (munch, munch, not a pair)\n";
  386.                     next
  387.                 }
  388. +               if ($key =~ /(player|monster|notMonster)/) {
  389. +                   $key = 'actor';
  390. +                   if ($1 eq "player") {
  391. +                       my ($who, $dist) = $value =~ /^(["\/].*?["\/]\w*)\s*,?\s*(.*)/;
  392. +                       if ($dist > 0) {
  393. +                           $value = "player $who $dist";
  394. +                       } else {
  395. +                           $value = "player $who";
  396. +                       }
  397. +                   } else {
  398. +                       my $not;
  399. +                       if ($value =~ /^not\s+/) {
  400. +                           $value =~ s/^not\s+//;
  401. +                           $not = "not ";
  402. +                       } elsif ($1 eq "notMonster") {
  403. +                           $not = "not ";
  404. +                       }  
  405. +                       my ($monsterList, $cond, $mondist);
  406. +                       if ($value =~ /^\s*(.*),?\s+([<>=!~]+)\s+(\d+|\d+\s*.{2}\s*\d+)\s*$/) {
  407. +                           ($monsterList, $cond, $mondist) = ($1, $2, $3);
  408. +                       } else {
  409. +                           $monsterList = $value;
  410. +                       }
  411. +                       my @monsterList2 = split(/\s*,\s*/,$monsterList);
  412. +                       my $newMonsterList = join ("|",@monsterList2);
  413. +                       if ($cond && $mondist) {
  414. +                           $value = "monster ".$not."/^($newMonsterList)".'$'."/ $cond $mondist";
  415. +                       } elsif ($mondist) {
  416. +                           $value = "monster ".$not."/^($newMonsterList)".'$'."/ $mondist";
  417. +                       } else {
  418. +                           $value = "monster ".$not."/^($newMonsterList)".'$'."/";
  419. +                       }
  420. +                   }
  421. +               } elsif ($key =~ /(pm|pub|party|guild|system)/) {
  422. +                   my $messageType;
  423. +                   if ($1 eq 'system') { $messageType = 'sys'; } else { $messageType = $1; }
  424. +                   $key = 'message';
  425. +                   $value = "$messageType $value";
  426. +               }
  427.                 if ($amSingle{$key}) {
  428. -                   $automacro{$block{name}}->{$key} = $value
  429. +                   $automacro{$block{name}}->{$key} = $value;
  430.                 } elsif ($amMulti{$key}) {
  431. -                   push(@{$automacro{$block{name}}->{$key}}, $value)
  432. +                   push(@{$automacro{$block{name}}->{$key}}, $value);
  433.                 } else {
  434.                     warning "$file: ignoring '$_' in line $. (munch, munch, unknown automacro keyword)\n"
  435.                 }
Advertisement
Add Comment
Please, Sign In to add comment