Henrybk

Henry semantic betamacro patch

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