Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: macro.pl
- ===================================================================
- --- macro.pl (revision 168)
- +++ macro.pl (working copy)
- @@ -123,11 +123,12 @@
- if (!defined $load{'packet_skilluse'}) {$load{'packet_skilluse'} = 1}
- }
- if (defined $automacro{$a}->{areaSpell} && !defined $load{'packet_areaSpell'}) {$load{'packet_areaSpell'} = 1}
- - if (defined $automacro{$a}->{pm} && !defined $load{'packet_privMsg'}) {$load{'packet_privMsg'} = 1}
- - if (defined $automacro{$a}->{pubm} && !defined $load{'packet_pubMsg'}) {$load{'packet_pubMsg'} = 1}
- - if (defined $automacro{$a}->{system} && !defined $load{'packet_sysMsg'}) {$load{'packet_sysMsg'} = 1;}
- - if (defined $automacro{$a}->{party} && !defined $load{'packet_partyMsg'}) {$load{'packet_partyMsg'} = 1}
- - if (defined $automacro{$a}->{guild} && !defined $load{'packet_guildMsg'}) {$load{'packet_guildMsg'} = 1}
- + if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^pm/ && !defined $load{'packet_privMsg'}) {$load{'packet_privMsg'} = 1}
- + if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^pub/ && !defined $load{'packet_pubMsg'}) {$load{'packet_pubMsg'} = 1}
- + if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^sys/ && !defined $load{'packet_sysMsg'}) {$load{'packet_sysMsg'} = 1;}
- + if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^party/ && !defined $load{'packet_partyMsg'}) {$load{'packet_partyMsg'} = 1}
- + if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^guild/ && !defined $load{'packet_guildMsg'}) {$load{'packet_guildMsg'} = 1}
- + if (defined $automacro{$a}->{message} && $automacro{$a}->{message} =~ /^npc/ && !defined $load{'npc_talk'}) {$load{'npc_talk'} = 1}
- if (defined $automacro{$a}->{mapchange} && !defined $load{'packet_mapChange'}) {$load{'packet_mapChange'} = 1}
- if (defined $automacro{$a}->{hook} && !defined $load{$automacro{$a}->{hook}}) {$load{$automacro{$a}->{hook}} = 1}
- if (defined $automacro{$a}->{console} && !defined $hookToLog) {$hookToLog = 1}
- Index: Macro/Automacro.pm
- ===================================================================
- --- Macro/Automacro.pm (revision 168)
- +++ Macro/Automacro.pm (working copy)
- @@ -7,8 +7,8 @@
- our @ISA = qw(Exporter);
- our @EXPORT_OK = qw(releaseAM lockAM recheckAM automacroCheck consoleCheckWrapper);
- our @EXPORT = qw(checkLocalTime checkVar checkVarVar checkLoc checkPersonGuild checkLevel checkLevel checkClass
- - checkPercent checkStatus checkItem checkPerson checkCond checkCast checkGround checkSpellsID
- - checkEquip checkMsg checkMonster checkAggressives checkConsole checkMapChange);
- + checkPercent checkStatus checkItem checkCond checkCast checkGround checkSpellsID
- + checkEquip checkAggressives checkConsole checkMapChange checkMessage checkActor);
- use Misc qw(whenGroundStatus getSpellName getActorName);
- use Utils;
- @@ -310,27 +310,6 @@
- return $return;
- }
- -# checks for near person ##################################
- -sub checkPerson {
- - my ($who, $dist) = $_[0] =~ /^(["\/].*?["\/]\w*)\s*,?\s*(.*)/;
- -
- - foreach my $player (@{$playersList->getItems()}) {
- - next unless match($player->name, $who);
- - if ($dist > 0 && distance($char->{pos_to}, $player->{pos_to}) >= $dist) {
- - return 0;
- - }
- - my $val = sprintf("%d %d %s", $player->{pos_to}{x}, $player->{pos_to}{y}, $field->baseName);
- - $varStack{".lastPlayerName"} = $player->name;
- - $varStack{".lastPlayerPos"} = $val;
- - $varStack{".lastPlayerLevel"} = $player->{lv};
- - $varStack{".lastPlayerJob"} = $player->job;
- - $varStack{".lastPlayerAccountId"} = $player->{nameID};
- - $varStack{".lastPlayerBinId"} = $player->{binID};
- - return 1
- - }
- - return 0
- -}
- -
- # checks arg1 for condition in arg3 #######################
- # uses: cmpr (Macro::Utils)
- sub checkCond {
- @@ -450,47 +429,6 @@
- else {return 0}
- }
- -# checks for public, private, party or guild message ######
- -# uses calcPosition, distance (Utils?)
- -sub checkMsg {
- - my ($var, $tmp, $arg) = @_;
- - my $msg;
- - if ($var eq '.lastpub') {
- - ($msg, my $distance) = $tmp =~ /^([\/"].*?[\/"]\w*)\s*,?\s*(\d*)/;
- - if ($distance ne '') {
- - my $mypos = calcPosition($char);
- - my $pos = calcPosition($::players{$arg->{pubID}});
- - return 0 unless distance($mypos, $pos) <= $distance
- - }
- - } elsif ($var eq '.lastpm') {
- - ($msg, my $allowed) = $tmp =~ /^([\/"].*?[\/"]\w*)\s*,?\s*(.*)/;
- - my $auth;
- - if (!$allowed) {
- - $auth = 1
- - } else {
- - my @tfld = split(/,/, $allowed);
- - for (my $i = 0; $i < @tfld; $i++) {
- - next unless defined $tfld[$i];
- - $tfld[$i] =~ s/(?:^ +| +$)//g;
- - if ($arg->{privMsgUser} eq $tfld[$i]) {$auth = 1; last}
- - }
- - }
- - return 0 unless $auth
- - } elsif ($var eq '.lastsys') {
- - ($msg) = $tmp =~ /^([\/"].*?[\/"]\w*)\s*,?\s*(.*)/;
- - chomp($msg);
- - } else {
- - $msg = $tmp
- - }
- - $arg->{Msg} =~ s/[\r\n]*$//g;
- - if (match($arg->{Msg},$msg)){
- - $varStack{$var} = $arg->{MsgUser};
- - $varStack{$var."Msg"} = $arg->{Msg};
- - return 1
- - }
- - return 0
- -}
- -
- # checks for area spell
- sub checkSpellsID {
- my ($line, $args) = @_;
- @@ -523,83 +461,6 @@
- return 0
- }
- -# checks for monster ...
- -sub checkMonster {
- - my $line = $_[0];
- - my $not = $_[1];
- - my ($mercenary, $use, $monsterList, $cond);
- - my $mondist = $config{clientSight} || 20;
- -
- - if ($line =~ /^\s*(.*),?\s+([<>=!~]+)\s+(\d+|\d+\s*.{2}\s*\d+)\s*$/) {
- - ($monsterList, $cond, $mondist) = ($1, $2, $3)
- - } else {
- - $monsterList = $line;
- - $cond = "<="
- - }
- -
- - if (!$not && $monsterList =~ /^(not|mercenary)\s+(.*)\s*$/) {
- - if ($1 eq "not") {$not = 1; $monsterList = $2}
- - else {$mercenary = 1; $use = 1; $monsterList = $2}
- - }
- -
- - foreach (@monstersID) {
- - next unless defined $_;
- - if ($mercenary) {
- - #Whose the mercenary's master,
- - #update later ;p
- - my $mypos = calcPosition($char);
- - my $pos = calcPosition($monsters{$_});
- - my $dist = sprintf("%.1f",distance($pos, $mypos));
- - if (existsInList($monsterList, $monsters{$_}->{name}) && $dist < 3) {$use = 0; last}
- - }
- - elsif ($not) {
- - next if existsInList($monsterList, $monsters{$_}->{name});
- - my $mypos = calcPosition($char);
- - my $pos = calcPosition($monsters{$_});
- - my $dist = sprintf("%.1f",distance($pos, $mypos));
- - my $val = sprintf("%d %d %s", $pos->{x}, $pos->{y}, $field->baseName);
- - $varStack{".lastMonster"} = $monsters{$_}->{name};
- - $varStack{".lastMonsterPos"} = $val;
- - $varStack{".lastMonsterDist"} = $dist;
- - $varStack{".lastMonsterID"} = $monsters{$_}->{binID};
- - $varStack{".lastMonsterBinID"} = $monsters{$_}->{binType};
- - return cmpr($dist, $cond, $mondist)
- - } else {
- - if (existsInList($monsterList, $monsters{$_}->{name})) {
- - my $counter;
- - my $mypos = calcPosition($char);
- - my $pos = calcPosition($monsters{$_});
- - my $dist = sprintf("%.1f", distance($mypos, $pos));
- - my $val = sprintf("%d %d %s", $pos->{x}, $pos->{y}, $field->baseName);
- - $varStack{".lastMonster"} = $monsters{$_}->{name};
- - $varStack{".lastMonsterPos"} = $val;
- - $varStack{".lastMonsterDist"} = $dist;
- - $varStack{".lastMonsterID"} = $monsters{$_}->{binID};
- - $varStack{".lastMonsterBinID"} = $monsters{$_}->{binType};
- - for (my $i = 0; $i < @::monstersID; $i++) {
- - next if $::monstersID[$i] eq "";
- - my $monster = Actor::get($::monstersID[$i]);
- - if ($monster->name eq $monsters{$_}->{name}) {
- - if ($monster->{binID} eq $monsters{$_}->{binID}) {
- - $counter++;
- - next
- - } else {
- - my $monsToMonDist = sprintf("%.1f",distance($pos, $monster->{pos_to}));
- - $counter++ if $monsToMonDist < 12;
- - next
- - }
- - }
- - next
- - }
- - $varStack{".lastMonsterCount"} = $counter;
- - return cmpr($dist, $cond, $mondist)
- - }
- - }
- - }
- - return 1 if ($use);
- - return 0
- -}
- -
- # checks for aggressives
- sub checkAggressives {
- my ($cond, $amount) = $_[0] =~ /([<>=!]+)\s+(\$[a-zA-Z][a-zA-Z\d]*|\d+|\d+\s*\.{2}\s*\d+)\s*$/;
- @@ -772,6 +633,66 @@
- return 0
- }
- +# checks for near actor ##################################
- +sub checkActor {
- + my ($actorType, $not, $who, $distCond, $dist) = $_[0] =~ /^(\w+)\s+(not)?\s*(["\/].*?["\/]\w*)\s*,?\s*([<>=!~]+)?\s*(\d*)/;
- + $distCond = "<=" if (!$distCond);
- + my %actorTypes = (
- + npc => $npcsList->getItems(),
- + player => $playersList->getItems(),
- + monster => $monstersList->getItems(),
- + pet => $petsList->getItems()
- + );
- + return 0 if (!exists($actorTypes{$actorType}));
- + foreach my $actor (@{$actorTypes{$actorType}}) {
- + next unless (match($actor->name, $who) xor $not);
- + if ($dist > 0 && !cmpr(distance($char->{pos_to}, $actor->{pos_to}), $distCond, $dist)) {
- + next;
- + }
- + my $val = sprintf("%d %d %s", $actor->{pos_to}{x}, $actor->{pos_to}{y}, $field->baseName);
- + if ($actorType eq 'npc') {
- + $varStack{".lastNpcName"} = $actor->name;
- + $varStack{".lastNpcPos"} = $val;
- + $varStack{".lastNpcIndex"} = $actor->{binID};
- + $varStack{".lastNPcID"} = $actor->{nameID};
- + } elsif ($actorType eq 'player') {
- + $varStack{".lastPlayerName"} = $actor->name;
- + $varStack{".lastPlayerPos"} = $val;
- + $varStack{".lastPlayerLevel"} = $actor->{lv};
- + $varStack{".lastPlayerJob"} = $actor->job;
- + $varStack{".lastPlayerAccountId"} = $actor->{nameID};
- + $varStack{".lastPlayerBinId"} = $actor->{binID};
- + } elsif ($actorType eq 'monster') {
- + $varStack{".lastMonster"} = $actor->{name};
- + $varStack{".lastMonsterPos"} = $val;
- + $varStack{".lastMonsterDist"} = $dist;
- + $varStack{".lastMonsterID"} = $actor->{binID};
- + $varStack{".lastMonsterBinID"} = $actor->{binType};
- + } elsif ($actorType eq 'pet') {
- + $varStack{".lastPetName"} = $actor->name;
- + $varStack{".lastPetPos"} = $val;
- + $varStack{".lastPetIndex"} = $actor->{binID};
- + $varStack{".lastPetType"} = $actor->{type};
- + }
- + return 1
- + }
- + return 0
- +}
- +
- +#cheks messages
- +sub checkMessage {
- + my ($condition, $args) = @_;
- + my ($message, $actorCondition, $actor);
- + my ($sourceType, $condition, $actorCondition) = $condition =~ /^(\w+)\s+([\/"].*?[\/"]\w*)\s*,?\s*([\/"].*?[\/"]\w*)?/;
- + $sourceType =~ s/^(\w+)$/.last$1/;
- + if ($sourceType eq '.lastnpc') { $message = $args->{msg}; } else { $message = $args->{Msg}; }
- + if ($sourceType ne '.lastnpc' && $sourceType ne '.lastsys') { $actor = $args->{MsgUser}; } elsif ($sourceType eq '.lastnpc') { $actor = $args->{name}; }
- + return 0 if (!match($message, $condition) || ($actorCondition && !match($actor, $actorCondition)));
- + $varStack{$sourceType."Msg"} = $message;
- + $varStack{$sourceType} = $actor if ($actor);
- + return 1;
- +}
- +
- # parses automacros and checks conditions #################
- sub automacroCheck {
- my ($trigger, $args) = @_;
- @@ -835,26 +756,16 @@
- if ($trigger =~ /^(?:is_casting|packet_skilluse)$/) {
- next CHKAM unless checkCast($automacro{$am}->{spell}, $args)
- } else {next CHKAM}
- - } elsif (defined $automacro{$am}->{pm}) {
- - if ($trigger eq 'packet_privMsg') {
- - next CHKAM unless checkMsg(".lastpm", $automacro{$am}->{pm}, $args)
- + } elsif (defined $automacro{$am}->{message}) {
- + if (($trigger eq 'npc_talk' && $automacro{$am}->{message} =~ /^npc/) ||
- + ($trigger eq 'packet_privMsg' && $automacro{$am}->{message} =~ /^pm/) ||
- + ($trigger eq 'packet_pubMsg' && $automacro{$am}->{message} =~ /^pub/) ||
- + ($trigger eq 'packet_sysMsg' && $automacro{$am}->{message} =~ /^sys/) ||
- + ($trigger eq 'packet_partyMsg' && $automacro{$am}->{message} =~ /^party/) ||
- + ($trigger eq 'packet_guildMsg' && $automacro{$am}->{message} =~ /^guild/)
- + ){
- + next CHKAM unless checkMessage($automacro{$am}->{message}, $args)
- } else {next CHKAM}
- - } elsif (defined $automacro{$am}->{pubm}) {
- - if ($trigger eq 'packet_pubMsg') {
- - next CHKAM unless checkMsg(".lastpub", $automacro{$am}->{pubm}, $args)
- - } else {next CHKAM}
- - } elsif (defined $automacro{$am}->{system}) {
- - if ($trigger eq 'packet_sysMsg') {
- - next CHKAM unless checkMsg(".lastsys", $automacro{$am}->{system}, $args)
- - } else {next CHKAM}
- - } elsif (defined $automacro{$am}->{party}) {
- - if ($trigger eq 'packet_partyMsg') {
- - next CHKAM unless checkMsg(".lastparty", $automacro{$am}->{party}, $args)
- - } else {next CHKAM}
- - } elsif (defined $automacro{$am}->{guild}) {
- - if ($trigger eq 'packet_guildMsg') {
- - next CHKAM unless checkMsg(".lastguild", $automacro{$am}->{guild}, $args)
- - } else {next CHKAM}
- } elsif (defined $automacro{$am}->{mapchange}) {
- if ($trigger eq 'packet_mapChange') {
- next CHKAM unless checkMapChange($automacro{$am}->{mapchange})
- @@ -872,11 +783,9 @@
- next CHKAM if (defined $automacro{$am}->{map} && $automacro{$am}->{map} ne $field->baseName);
- next CHKAM if (defined $automacro{$am}->{class} && !checkClass($automacro{$am}->{class}));
- next CHKAM if (defined $automacro{$am}->{whenGround} && !checkGround($automacro{$am}->{whenGround}));
- - next CHKAM if (defined $automacro{$am}->{notMonster} && !checkMonster($automacro{$am}->{notMonster}, 1));
- foreach my $i (@{$automacro{$am}->{eval}}) {next CHKAM unless checkEval($i)}
- foreach my $i (@{$automacro{$am}->{action}}) {next CHKAM unless checkAction($i)}
- - foreach my $i (@{$automacro{$am}->{monster}}) {next CHKAM unless checkMonster($i)}
- foreach my $i (@{$automacro{$am}->{aggressives}}){next CHKAM unless checkAggressives($i)}
- foreach my $i (@{$automacro{$am}->{location}}) {next CHKAM unless checkLoc($i)}
- foreach my $i (@{$automacro{$am}->{localtime}}) {next CHKAM unless checkLocalTime($i, "")}
- @@ -894,9 +803,9 @@
- foreach my $i (@{$automacro{$am}->{soldout}}) {next CHKAM unless checkCond(getSoldOut(), $i)}
- foreach my $i (@{$automacro{$am}->{zeny}}) {next CHKAM unless checkCond($char->{zeny}, $i)}
- foreach my $i (@{$automacro{$am}->{cash}}) {next CHKAM unless checkCond($cashShop{points}->{cash}?$cashShop{points}->{cash}:0, $i)}
- - foreach my $i (@{$automacro{$am}->{player}}) {next CHKAM unless checkPerson($i)}
- foreach my $i (@{$automacro{$am}->{equipped}}) {next CHKAM unless checkEquip($i)}
- foreach my $i (@{$automacro{$am}->{status}}) {next CHKAM unless checkStatus($i)}
- + foreach my $i (@{$automacro{$am}->{actor}}) {next CHKAM unless checkActor($i)}
- foreach my $i (@{$automacro{$am}->{inventory}}) {next CHKAM unless checkItem("inv", $i)}
- foreach my $i (@{$automacro{$am}->{storage}}) {next CHKAM unless checkItem("stor", $i)}
- foreach my $i (@{$automacro{$am}->{shop}}) {next CHKAM unless checkItem("shop", $i)}
- Index: Macro/Data.pm
- ===================================================================
- --- Macro/Data.pm (revision 168)
- +++ Macro/Data.pm (working copy)
- @@ -26,12 +26,7 @@
- 'disabled' => 1, # option: automacro disabled
- 'call' => 1, # setting: macro to be called
- 'spell' => 1, # check: cast sensor
- - 'notMonster' => 1, # check: disallow monsters other than ~
- - 'pm' => 1, # check: private message
- - 'pubm' => 1, # check: public chat
- - 'system' => 1, # check: system chat
- - 'guild' => 1, # check: guild chat
- - 'party' => 1, # check: party chat
- + 'message' => 1, # check: all messages
- 'console' => 1, # check: console message
- 'overrideAI' => 1, # option: override AI
- 'orphan' => 1, # option: orphan handling
- @@ -50,7 +45,6 @@
- 'eval' => 1, # check : eval
- 'set' => 1, # set: variable
- 'save' => 1, # setting: save hook arguments
- - 'monster' => 1, # check: monster on screen
- 'aggressives' => 1, # check: aggressives
- 'location' => 1, # check: player's location
- 'var' => 1, # check: variable / value
- @@ -65,7 +59,6 @@
- 'soldout' => 1, # check: sold out shop slots
- 'zeny' => 1, # check: player's zeny
- 'cash' => 1, # check: player's cash
- - 'player' => 1, # check: player name near
- 'equipped' => 1, # check: equipment
- 'status' => 1, # check: player's status
- 'inventory' => 1, # check: item amount in inventory
- @@ -75,6 +68,7 @@
- 'localtime' => 1, # check: localtime
- 'config' => 1, # check: config key
- 'quest' => 1, # check: player quests
- + 'actor' => 1, # check: actor near
- 'action' => 1 # check: action
- );
- Index: Macro/Parser.pm
- ===================================================================
- --- Macro/Parser.pm (revision 168)
- +++ Macro/Parser.pm (working copy)
- @@ -122,10 +122,44 @@
- warning "$file: ignoring '$_' in line $. (munch, munch, not a pair)\n";
- next
- }
- + if ($key =~ /(player|monster|notMonster)/) {
- + $key = 'actor';
- + if ($1 eq "player") {
- + $value = "player $value";
- + } else {
- + my $not;
- + if ($value =~ /^not\s+/) {
- + $value =~ s/^not\s+//;
- + $not = "not ";
- + } elsif ($1 eq "notMonster") {
- + $not = "not ";
- + }
- + my ($monsterList, $cond, $mondist);
- + if ($value =~ /^\s*(.*),?\s+([<>=!~]+)\s+(\d+|\d+\s*.{2}\s*\d+)\s*$/) {
- + ($monsterList, $cond, $mondist) = ($1, $2, $3);
- + } else {
- + $monsterList = $value;
- + }
- + my @monsterList2 = split(/\s*,\s*/,$monsterList);
- + my $newMonsterList = join ("|",@monsterList2);
- + if ($cond && $mondist) {
- + $value = "monster ".$not."/^($newMonsterList)".'$'."/ $cond $mondist";
- + } elsif ($mondist) {
- + $value = "monster ".$not."/^($newMonsterList)".'$'."/ $mondist";
- + } else {
- + $value = "monster ".$not."/^($newMonsterList)".'$'."/";
- + }
- + }
- + } elsif ($key =~ /(pm|pub|party|guild|system)/) {
- + my $messageType;
- + if ($1 eq 'system') { $messageType = 'sys'; } else { $messageType = $1; }
- + $key = 'message';
- + $value = "$messageType $value";
- + }
- if ($amSingle{$key}) {
- - $automacro{$block{name}}->{$key} = $value
- + $automacro{$block{name}}->{$key} = $value;
- } elsif ($amMulti{$key}) {
- - push(@{$automacro{$block{name}}->{$key}}, $value)
- + push(@{$automacro{$block{name}}->{$key}}, $value);
- } else {
- warning "$file: ignoring '$_' in line $. (munch, munch, unknown automacro keyword)\n"
- }
Advertisement
Add Comment
Please, Sign In to add comment