# Openkore.com

OpenKore Forums
 It is currently 29 Mar 2020, 20:33

 All times are UTC - 5 hours [ DST ]

 Page 2 of 7 [ 61 posts ] Go to page Previous  1, 2, 3, 4, 5 ... 7  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Warp Portal macroPosted: 05 Apr 2009, 02:08
 Developers

Joined: 04 Apr 2008, 09:50
Posts: 109
Code:
#############################################
automacro onStart {
hook in_game
run-once 1
exclusive 1
set inGame 1
call coors
}
macro coors {
do eval @_degree0 = ([-1,1],[-2,2],[-1,2],[0,1],[0,2],[1,1],[2,2],[1,2]);@_degree315 = ([-1,0],[-2,0],[-2,1],[-2,2],[-1,1],[-1,2],[0,1],[0,2]);@_degree270 = ([-1,-1],[-2,-2],[-2,-1],[-1,0],[-2,0],[-1,1],[-2,1],[-2,2]);@_degree225 = ([-1,0],[-2,0],[-1,-1],[-2,-1],[-2,-2],[-1,-2],[0,-1],[0,-2]);@_degree180 = ([-1,-1],[-2,-2],[-1,-2],[0,-1],[0,-2],[1,-1],[1,-2],[2,-2]);@_degree135 = ([0,-1],[0,-2],[1,-1],[1,-2],[2,-2],[2,-1],[1,0],[2,0]);@_degree90 = ([1,-1],[2,-2],[2,-1],[1,0],[2,0],[1,1],[2,1],[2,2]);@_degree45 = ([1,0],[2,0],[1,1],[2,1],[2,2],[1,2],[0,1],[0,2]);
}

############################################
macro warp {
if (\$inGame = 1) goto pass
goto end

:pass
\$emptyList = 0
\$isWalkable = 1
\$cellIsFull = 0

call listPortals

:start
call isWalkable
call cellIsFull

if (\$emptyList = 1) goto end
if (\$isWalkable = 0 || \$cellIsFull = 1) goto start

call setWarp

log Pos= \$.pos, Warp= \$warp, Look= \$look
log do the warp at \$warp here
stop

:end
log Spot Is Not Available!!
}

macro setWarp {
do eval (\$::Macro::Data::varStack{warp}, \$::Macro::Data::varStack{look})  = (\$_warp{x} ." ". \$_warp{y}, \$_l)
}
macro listPortals {
do eval \$_l = \$::char->{look}{body} - 1;if (\$_l == -1) {@_degree = @_degree315} elsif (\$_l == 0) {@_degree = @_degree0} elsif (\$_l == 1) {@_degree = @_degree45} elsif (\$_l == 2) {@_degree = @_degree90} elsif (\$_l == 3) {@_degree = @_degree135} elsif (\$_l == 4) {@_degree = @_degree180} elsif (\$_l == 5) {@_degree = @_degree225} else {@_degree = @_degree270};
do eval my @lines;foreach (@_degree) {my \$_x = \$::char->{pos}{x} + \$_->[0];my \$_y = \$::char->{pos}{y} + \$_->[1];push @lines, \$_x ." ". \$_y} \$_lines = join ", ",@lines;
}

macro isWalkable {
do eval if (\$_lines eq "" || !defined \$_lines) {\$::Macro::Data::varStack{emptyList} = 1;return} (\$_warp{x},\$_warp{y}) = undef; my @_coors = split(/, /, \$_lines); foreach (@_coors) {my @_coor = split(/ /, \$_);next if (!\$::field->isWalkable(\$_coor[0], \$_coor[1])); (\$_warp{x},\$_warp{y}) = (\$_coor[0],\$_coor[1]);last} if (!defined \$_warp{x} || !defined \$_warp{y}) {\$::Macro::Data::varStack{isWalkable} = 0}
if (\$isWalkable = 0) call deleteSpot
}

macro cellIsFull  {
do eval if (\$_lines eq "" || !defined \$_lines) {\$::Macro::Data::varStack{emptyList} = 1;return} foreach (@{\$::playersList->getItems()}) {next if (\$_->{pos_to}{x} != \$_warp{x} || \$_->{pos_to}{y} != \$_warp{y});\$::Macro::Data::varStack{cellIsFull} = 1;last}
if (\$cellIsFull = 1) call deleteSpot
}

macro deleteSpot {
do eval my @lines; my @_delete = split(/, /,\$_lines);foreach (@_delete) {next if (\$_ eq \$_warp{x}." ".\$_warp{y}); push @lines,\$_; } \$_lines = join ", ", @lines
}

I think the code above suits you very well. The angle that you are looking is 90 degree. Let say \$look = 0, the angle should be around 315 to 45 degree. Thats is our range of sight i mean human sight. But there will be only 8 spot per \$look. If you want more spot, try edit the macro coors so that it will include more far coordinate.

Note: in_game hook currently is in \$conState == 4, so it wont trigger unless --> http://forums.openkore.com/viewtopic.php?f=32&t=5472&p=21942#p21942

Happy warping ^^

_________________
An Overall Macro Plugins Diffs Proposal

Top

 Post subject: Re: Warp Portal macroPosted: 05 Apr 2009, 04:21
 Been there done that!

Joined: 25 Oct 2008, 08:14
Posts: 144
Thank you very much... But I'd really love to know how would be the correct syntax of the other code too... So well, I guess I'll try again. I'd like to know what is the problem with it, anyways.

_________________

Top

 Post subject: Re: Warp Portal macroPosted: 05 Apr 2009, 08:38
 Developers

Joined: 04 Apr 2008, 09:50
Posts: 109
Actually the eval above is what you are looking from the closestWalkableSpot function in Misc.PM

This is how it looks when we unwrap it..
Code:
#From macro coors
@_degree0 = ([-1,1],[-2,2],[-1,2],[0,1],[0,2],[1,1],[2,2],[1,2]);
@_degree315 = ([-1,0],[-2,0],[-2,1],[-2,2],[-1,1],[-1,2],[0,1],[0,2]);
@_degree270 = ([-1,-1],[-2,-2],[-2,-1],[-1,0],[-2,0],[-1,1],[-2,1],[-2,2]);
@_degree225 = ([-1,0],[-2,0],[-1,-1],[-2,-1],[-2,-2],[-1,-2],[0,-1],[0,-2]);
@_degree180 = ([-1,-1],[-2,-2],[-1,-2],[0,-1],[0,-2],[1,-1],[1,-2],[2,-2]);
@_degree135 = ([0,-1],[0,-2],[1,-1],[1,-2],[2,-2],[2,-1],[1,0],[2,0]);
@_degree90 = ([1,-1],[2,-2],[2,-1],[1,0],[2,0],[1,1],[2,1],[2,2]);
@_degree45 = ([1,0],[2,0],[1,1],[2,1],[2,2],[1,2],[0,1],[0,2])

#From macro listPortals
\$_l = \$::char->{look}{body} - 1;
if (\$_l == -1) {@_degree = @_degree315}
elsif (\$_l == 0) {@_degree = @_degree0}
elsif (\$_l == 1) {@_degree = @_degree45}
elsif (\$_l == 2) {@_degree = @_degree90}
elsif (\$_l == 3) {@_degree = @_degree135}
elsif (\$_l == 4) {@_degree = @_degree180}
elsif (\$_l == 5) {@_degree = @_degree225}
else {@_degree = @_degree270}

my @lines;
foreach (@_degree) {
my \$_x = \$::char->{pos}{x} + \$_->[0];
my \$_y = \$::char->{pos}{y} + \$_->[1];
push @lines, \$_x ." ". \$_y
}
\$_lines = join ", ",@lines;

#From isWalkable macro
if (\$_lines eq "" || !defined \$_lines) {
\$::Macro::Data::varStack{emptyList} = 1;
return
}
(\$_warp{x},\$_warp{y}) = undef;     #same as %_warp = undef or undef %_warp
my @_coors = split(/, /, \$_lines);
foreach (@_coors) {
my @_coor = split(/ /, \$_);
next if (!\$::field->isWalkable(\$_coor[0], \$_coor[1]));
(\$_warp{x},\$_warp{y}) = (\$_coor[0],\$_coor[1]);
last
}
if (!defined \$_warp{x} || !defined \$_warp{y}) {
\$::Macro::Data::varStack{isWalkable} = 0
}

#From cellIsFull macro
if (\$_lines eq "" || !defined \$_lines) {
\$::Macro::Data::varStack{emptyList} = 1;
return
}
foreach (@{\$::playersList->getItems()}) {
next if (\$_->{pos_to}{x} != \$_warp{x} || \$_->{pos_to}{y} != \$_warp{y});
\$::Macro::Data::varStack{cellIsFull} = 1;
last
}

#From deleteSpot macro
my @lines;
my @_delete = split(/, /,\$_lines);
foreach (@_delete) {
next if (\$_ eq \$_warp{x}." ".\$_warp{y});
push @lines,\$_;
}
\$_lines = join ", ", @lines

To let you understand the eval better, I've saperated the eval into its own macro functions. Well, as you can see it really use the closestWalkableSpot idea but more narrow based on the \$look. At 1st, I've tried whatever I can to not to use the closestWalkableSpot becoz I wanna make it more flexible... but in the last, the closestWalkableSpot is still the best method to use.
The codes also shows how to play with hashes and array... and also shows how to get the data from them. If you take a close look... some arrays/hashes/variables were declared using "my" function while others not. It sure have a different uses... you have to find the answers youself ... its your home work

_________________
An Overall Macro Plugins Diffs Proposal

Top

 Post subject: Re: Warp Portal macroPosted: 05 Apr 2009, 14:10
 Been there done that!

Joined: 25 Oct 2008, 08:14
Posts: 144
Okaaaaaaaay now I see it better. ^^U Sorry to be a bother but it seems I understand it better in this way, when you splitted it I went completely "wtf? o.O". It still needs some changes to get the spots, because I still want it to check squares in different radius around the caster, but that can be done by me (just tweaking the @_degree" part).

The only thing I don't see clearly is the changes between the subroutine and this code you wrote. It still seems even more simple, and I'd prefer to put it in an only eval to minimize the job, also you use a different type of variable for the spot selection ("@_" instead of just the "\$z"), and even that part there to delete the "useless" spots is not neccesary in the sub, it seems it checks all in a row and then just returns the info. Is that done because the differences between the variables? Because if that's the case maybe it's be easier to do that way.

I mean, from this code:
Code:
foreach my \$z ( [0,0], [0,1],[1,0],[0,-1],[-1,0], [-1,1],[1,1],[1,-1],[-1,-1],[0,2],[2,0],[0,-2],[-2,0] ) {

# <--------------- it would just need to add the diferences between each look

next if !\$field->isWalkable(\$pos->{x} + \$z->[0], \$pos->{y} + \$z->[1]);

# <-------- here it'd need to check for people too

\$pos->{x} += \$z->[0];
\$pos->{y} += \$z->[1];
return 1;

# <-------- here it'd set the location variables

}
return 0;

# <------- and here it'd set a variable to just say there's no spot.
}
Now I see clearly the similitudes between the sub and the one you did, but seeing the kore code, I still think it could be done simpler, just like that. My problem really I think it's just syntax, because I have some idea of how it should be.

But well, I guess I'll try the tutorial tto solve those primary doubts (though it never worked well because there's too much info). ^^U Thank you very much, Ezza. Now I don't have too much time but I'll try to check all in some hours, if not I'll just do tomorrow early (Spain time: 20:17 xD).

_________________

Top

 Post subject: Re: Warp Portal macroPosted: 05 Apr 2009, 15:53
 Been there done that!

Joined: 25 Oct 2008, 08:14
Posts: 144
Okay, sorry for the double post but I've been doing my experiments ant thought it'd be better to write it in a new post.

Looking at your code and the subroutine, I guessed if it was possible to do in a simpler way, so, using a perl tutorial and struggling my brain I've come out with this:
Code:
do eval
\$_l = \$::char->{look}{body} - 1;

if (\$_l == -1) {\$z = ([-1,0],[-2,0],[-2,1],[-2,2],[-1,1],[-1,2],[0,1],[0,2])}
elsif (\$_l == 0) {\$z = ([-1,1],[-2,2],[-1,2],[0,1],[0,2],[1,1],[2,2],[1,2])}
elsif (\$_l == 1) {\$z = ([1,0],[2,0],[1,1],[2,1],[2,2],[1,2],[0,1],[0,2])}
elsif (\$_l == 2) {\$z = ([1,-1],[2,-2],[2,-1],[1,0],[2,0],[1,1],[2,1],[2,2])}
elsif (\$_l == 3) {\$z = ([0,-1],[0,-2],[1,-1],[1,-2],[2,-2],[2,-1],[1,0],[2,0])}
elsif (\$_l == 4) {\$z = ([-1,-1],[-2,-2],[-1,-2],[0,-1],[0,-2],[1,-1],[1,-2],[2,-2])}
elsif (\$_l == 5) {\$z = ([-1,0],[-2,0],[-1,-1],[-2,-1],[-2,-2],[-1,-2],[0,-1],[0,-2])}
else {\$z = ([-1,-1],[-2,-2],[-2,-1],[-1,0],[-2,0],[-1,1],[-2,1],[-2,2])}

foreach (\$z) {
next if (!\$::field->isWalkable(\$::char->{pos}{x} + \$z->[0], \$::char->{pos}{x} + \$z->[1]));

foreach (@{\$::npcsList->getItems()}) {
next if (\$_->{pos_to}{x} != \$::char->{pos}{x} + \$z->[0] || \$_->{pos_to}{y} != \$::char->{pos}{x} + \$z->[1]);

foreach (@{\$::playersList->getItems()}) {
next if (\$_->{pos_to}{x} != \$::char->{pos}{x} + \$z->[0] || \$_->{pos_to}{y} != \$::char->{pos}{x} + \$z->[1]);

\$::Macro::Data::varStack{loc} = "\$::char->{pos}{x} += \$z->[0] \$::char->{pos}{y} += \$z->[1]";
}
}
next;
}
\$::Macro::Data::varStack{loc} = "none";
I also added a check for NPCs. And, as I see it's really simple at all. It has syntax errors yet (or so OK says) but that's my limit for today... Where are the errors?

P.s: When I finish this damn thing I'll even post pictures explaining the area. -_-

_________________

Top

 Post subject: Re: Warp Portal macroPosted: 06 Apr 2009, 04:45
 Developers

Joined: 04 Apr 2008, 09:50
Posts: 109
The very most important thing that you shoud know is... we cant create or declare such variable/s that is same as our macro variable. Which is in the regex of ... /\\$[a-zA-Z][a-zA-Z\d]*/

So, create a variable that starts with a string "\$" and followed by an underscore "_" and then followed by the regex /[a-zA-Z][a-zA-Z\d]*/ will escape us from the original creating of macro variable. This explain why I've used \$_ and followed by /[a-zA-Z]/.

The \$_ only in perl is actually a special variable that is temporarily being used in certain condition... example in loop condition. As I can see, you use a multiple foreach loop in a block using \$_ special variable. It use the \$_ becoz you never assign them in each loop. The \$_ special variable can only being used for 1 time per block... so it never mind if you never set the var in 1st loop... but you have to assign it for the 2nd loop and so on or the 1st \$_ value will be lost.

_________________
An Overall Macro Plugins Diffs Proposal

Top

 Post subject: Re: Warp Portal macroPosted: 06 Apr 2009, 10:36
 Been there done that!

Joined: 25 Oct 2008, 08:14
Posts: 144
EDIT: Going along and rewritting the code more further I've come with the following one. I've changed the direction number so it's more alike to the look command (so now north is 0, not -1), and I've taken in mind your advice. Note that I've updated it with the final coordinates for each look, as you can see it's more complex, but I guess that's not the issue now:
Code:
\$_l = \$::char->{look}{body} - 0;

if (\$_l == 0) {\$_z = ( [0,4], [0,3],[-1,3],[1,3],[-1,4],[1,4],[-1,5],[1,5],[0,5], [0,2],[-1,2],[1,2],[-2,2],[2,2],[-2,3],[2,3],[-2,4],[2,4],[-2,5],[2,5],[-2,6],[2,6],[-1,6],[1,6],[0,6] )}
elsif (\$_l == 1) {\$_z = ( [-3,3], [-3,2],[-2,3],[-4,3],[-3,4], [-2,2],[-3,1],[-1,3],[-4,2],[-2,4],[-5,3],[-3,5],[-4,4], [-2,1],[-1,2],[-3,0],[0,3],[-4,1],[-1,4],[-5,2],[-2,5],[-6,3],[-3,6],[-5,4],[-4,5] )}
elsif (\$_l == 2) {\$_z = ( [-4,0], [-3,0],[-3,-1],[-3,1],[-4,-1],[-4,1],[-5,-1],[-5,1],[-5,0], [-2,0],[-2,-1],[-2,1],[-2,-2],[-2,2],[-3,-2],[-3,2],[-4,-2],[-4,2],[-5,-2],[-5,2],[-6,-2],[-6,2],[-6,-1],[-6,1],[-6,0] )}
elsif (\$_l == 3) {\$_z = ( [-3,-3], [-2,-3],[-3,-2],[-3,-4],[-4,-3], [-2,-2],[-1,-3],[-3,-1],[-2,-4],[-4,-2],[-3,-5],[-5,-3],[-4,-4], [-1,-2],[-2,-1],[0,-3],[-3,0],[-1,-4],[-4,-1],[-2,-5],[-5,-2],[-3,-6],[-6,-3],[-4,-5],[-5,-4] )}
elsif (\$_l == 4) {\$_z = ( [0,-4], [0,-3],[1,-3],[1,-3],[1,-4],[-1,-4],[1,-5],[-1,-5],[0,-5], [0,-2],[1,-2],[-1,-2],[2,-2],[-2,-2],[2,-3],[-2,-3],[2,-4],[-2,-4],[2,-5],[-2,-5],[2,-6],[-2,-6],[1,-6],[-1,-6],[0,-6] )}
elsif (\$_l == 5) {\$_z = ( [3,-3], [3,-2],[2,-3],[4,-3],[3,-4], [2,-2],[3,-1],[1,-3],[4,-2],[2,-4],[5,-3],[3,-5],[4,-4], [2,-1],[1,-2],[3,0],[0,-3],[4,-1],[1,-4],[5,-2],[2,-5],[6,-3],[3,-6],[5,-4],[4,-5] )}
elsif (\$_l == 6) {\$_z = ( [4,0], [3,0],[3,1],[3,-1],[4,1],[4,-1],[5,1],[5,-1],[5,0], [2,0],[2,1],[2,-1],[2,2],[2,-2],[3,2],[3,-2],[4,2],[4,-2],[5,2],[5,-2],[6,2],[6,-2],[6,1],[6,-1],[6,0] )}
else {\$_z = ( [3,3], [2,3],[3,2],[3,4],[4,3], [2,2],[1,3],[3,1],[2,4],[4,2],[3,5],[5,3],[4,4], [1,2],[2,1],[0,3],[3,0],[1,4],[4,1],[2,5],[5,2],[3,6],[6,3],[4,5],[5,4] )}

foreach (\$_z) {
next if (!\$::field->isWalkable(\$::char->{pos}{x} + \$_z->[0], \$::char->{pos}{x} + \$_z->[1]));

foreach my \$_npc (@{\$::npcsList->getItems()}) {
next if (\$_npc->{pos_to}{x} != \$::char->{pos}{x} + \$_z->[0] || \$_npc->{pos_to}{y} != \$::char->{pos}{x} + \$_z->[1]);

foreach my \$_player (@{\$::playersList->getItems()}) {
next if (\$_player->{pos_to}{x} != \$::char->{pos}{x} + \$_z->[0] || \$_player->{pos_to}{y} != \$::char->{pos}{x} + \$_z->[1]);

\$::Macro::Data::varStack{loc} = "\$::char->{pos}{x} += \$_z->[0] \$::char->{pos}{y} += \$_z->[1]";
}
}
next;
}
\$::Macro::Data::varStack{loc} = "none";

But now the problem is that it always print "none". I'm starting to get tired of this...

_________________

Last edited by Darki on 06 Apr 2009, 10:47, edited 1 time in total.

Top

 Post subject: Re: Warp Portal macroPosted: 06 Apr 2009, 10:45
 Developers

Joined: 04 Apr 2008, 09:50
Posts: 109
Yes you are correct. I mean the var assignment for each loop. But you misunderstood the \$z in the Misc.PM ... the \$z is actually the var assign and the coordinates is actually an arrays. So, I think the code should work like this...

Code:
my \$_l = \$::char->{look}{body} - 1;
my @degree;my \$_skip;
if (\$_l == -1) {@degree = ([-1,0],[-2,0],[-2,1],[-2,2],[-1,1],[-1,2],[0,1],[0,2])}
elsif (\$_l == 0) {@degree = ([-1,1],[-2,2],[-1,2],[0,1],[0,2],[1,1],[2,2],[1,2])}
elsif (\$_l == 1) {@degree = ([1,0],[2,0],[1,1],[2,1],[2,2],[1,2],[0,1],[0,2])}
elsif (\$_l == 2) {@degree = ([1,-1],[2,-2],[2,-1],[1,0],[2,0],[1,1],[2,1],[2,2])}
elsif (\$_l == 3) {@degree = ([0,-1],[0,-2],[1,-1],[1,-2],[2,-2],[2,-1],[1,0],[2,0])}
elsif (\$_l == 4) {@degree = ([-1,-1],[-2,-2],[-1,-2],[0,-1],[0,-2],[1,-1],[1,-2],[2,-2])}
elsif (\$_l == 5) {@degree = ([-1,0],[-2,0],[-1,-1],[-2,-1],[-2,-2],[-1,-2],[0,-1],[0,-2])}
else {@degree = ([-1,-1],[-2,-2],[-2,-1],[-1,0],[-2,0],[-1,1],[-2,1],[-2,2])}

foreach my \$_z (@degree) {
my (\$_x, \$_y) = (\$::char->{pos}{x} + \$_z->[0], \$::char->{pos}{y} + \$_z->[1]);
\$_skip = 1;
next if (!\$::field->isWalkable(\$_x, \$_y));
\$_skip = 0;
foreach my \$_npc (@{\$::npcsList->getItems()}) {
next if (\$_npc->{pos_to}{x} != \$_x || \$_npc->{pos_to}{y} != \$_y);
\$_skip = 1;last
}
next if (\$_skip);
foreach my \$_pl (@{\$::playersList->getItems()}) {
next if (\$_pl->{pos_to}{x} != \$_x || \$_pl->{pos_to}{y} != \$_y);
\$_skip = 1;last
}
next if (\$_skip);
\$::Macro::Data::varStack{loc} = \$_x ." ". \$_y
}
if (\$_skip) {\$::Macro::Data::varStack{loc} = "none";}

_________________
An Overall Macro Plugins Diffs Proposal

Top

 Post subject: Re: Warp Portal macroPosted: 06 Apr 2009, 11:07
 Been there done that!

Joined: 25 Oct 2008, 08:14
Posts: 144
ZOMG I've tested that code and it seems working (at least it returns a position! xD) Fuck I was starting to feel hopeless. ^^U I'll tweak it a little (after I sleep a siesta, need to use my little vacations ^^U) to add the correct spot selection and I'll test it with the macro, then I'll FINALLY post the damn final macro. xD

I'll also update the other two macros now that I've learnt a little more of perl... Fuck this was difficult, and I though my macro for the item list was awful! I hope it works, I don't want to be happy till I do it.

Anyways, thank you reeeeeeally much, Ezza, I luv u! xDD

_________________

Top

 Post subject: Re: Warp Portal macroPosted: 06 Apr 2009, 14:57
 Been there done that!

Joined: 25 Oct 2008, 08:14
Posts: 144
K, we ran too fast. xD I've tested it, and yes, it gets spots and changes position at all, but for some reason it is unable to determine then there's no place for the skill. :/

I used this code, basically is tweaked with the new spots and all the sheet:
Code:
\$_l = \$::char->{look}{body} - 0;
my \$_skip;
if (\$_l == 0) {@area = ([0,4],[0,3],[-1,3],[1,3],[-1,4],[1,4],[-1,5],[1,5],[0,5],[0,2],[-1,2],[1,2],[-2,2],[2,2],[-2,3],[2,3],[-2,4],[2,4],[-2,5],[2,5],[-2,6],[2,6],[-1,6],[1,6],[0,6])}
elsif (\$_l == 1) {@area = ([-3,3],[-3,2],[-2,3],[-4,3],[-3,4],[-2,2],[-3,1],[-1,3],[-4,2],[-2,4],[-5,3],[-3,5],[-4,4],[-2,1],[-1,2],[-3,0],[0,3],[-4,1],[-1,4],[-5,2],[-2,5],[-6,3],[-3,6],[-5,4],[-4,5])}
elsif (\$_l == 2) {@area = ([-4,0],[-3,0],[-3,-1],[-3,1],[-4,-1],[-4,1],[-5,-1],[-5,1],[-5,0],[-2,0],[-2,-1],[-2,1],[-2,-2],[-2,2],[-3,-2],[-3,2],[-4,-2],[-4,2],[-5,-2],[-5,2],[-6,-2],[-6,2],[-6,-1],[-6,1],[-6,0])}
elsif (\$_l == 3) {@area = ([-3,-3],[-2,-3],[-3,-2],[-3,-4],[-4,-3],[-2,-2],[-1,-3],[-3,-1],[-2,-4],[-4,-2],[-3,-5],[-5,-3],[-4,-4],[-1,-2],[-2,-1],[0,-3],[-3,0],[-1,-4],[-4,-1],[-2,-5],[-5,-2],[-3,-6],[-6,-3],[-4,-5],[-5,-4])}
elsif (\$_l == 4) {@area = ([0,-4],[0,-3],[1,-3],[1,-3],[1,-4],[-1,-4],[1,-5],[-1,-5],[0,-5],[0,-2],[1,-2],[-1,-2],[2,-2],[-2,-2],[2,-3],[-2,-3],[2,-4],[-2,-4],[2,-5],[-2,-5],[2,-6],[-2,-6],[1,-6],[-1,-6],[0,-6])}
elsif (\$_l == 5) {@area = ([3,-3],[3,-2],[2,-3],[4,-3],[3,-4],[2,-2],[3,-1],[1,-3],[4,-2],[2,-4],[5,-3],[3,-5],[4,-4],[2,-1],[1,-2],[3,0],[0,-3],[4,-1],[1,-4],[5,-2],[2,-5],[6,-3],[3,-6],[5,-4],[4,-5])}
elsif (\$_l == 6) {@area = ([4,0],[3,0],[3,1],[3,-1],[4,1],[4,-1],[5,1],[5,-1],[5,0],[2,0],[2,1],[2,-1],[2,2],[2,-2],[3,2],[3,-2],[4,2],[4,-2],[5,2],[5,-2],[6,2],[6,-2],[6,1],[6,-1],[6,0] )}
else {@area = ([3,3],[2,3],[3,2],[3,4],[4,3],[2,2],[1,3],[3,1],[2,4],[4,2],[3,5],[5,3],[4,4],[1,2],[2,1],[0,3],[3,0],[1,4],[4,1],[2,5],[5,2],[3,6],[6,3],[4,5],[5,4])}

foreach my \$_z (@area) {
next if (!\$::field->isWalkable(\$::char->{pos}{x} + \$_z->[0], \$::char->{pos}{x} + \$_z->[1]));
\$_skip = 0;
foreach my \$_npc (@{\$::npcsList->getItems()}) {
next if (\$_npc->{pos_to}{x} != \$::char->{pos}{x} + \$_z->[0] || \$_npc->{pos_to}{y} != \$::char->{pos}{x} + \$_z->[1]);
\$_skip = 1;
last;
}
next if (\$_skip);
foreach my \$_pl (@{\$::playersList->getItems()}) {
next if (\$_pl->{pos_to}{x} != \$::char->{pos}{x} + \$_z->[0] || \$_pl->{pos_to}{y} != \$::char->{pos}{x} + \$_z->[1]);
\$_skip = 1;
last;
}
next if (\$_skip);
my \$_x = \$::char->{pos}{x} + \$_z->[0];
my \$_y = \$::char->{pos}{y} + \$_z->[1];
\$::Macro::Data::varStack{loc} = \$_x ." ". \$_y
}
if (\$_skip == 1) {\$::Macro::Data::varStack{loc} = "none";}
But as I said, it never returns "none" even when I forced it looking into a big building. It always return a position even if that position is not walkable, but the funny thing is that it avoids non walkable spots, characters and npcs well, so maybe there's a problem with the \$_skip assignement at the end of the check?

P.s: I'm getting nightmares with this fucking macro.

_________________

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 7 [ 61 posts ] Go to page Previous  1, 2, 3, 4, 5 ... 7  Next

 All times are UTC - 5 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Announcements    Announcements Support    Frequently Asked Questions & Guides    Resolved Questions    Official Servers       bRO       fRO       iRO       idRO       kRO       jRO       tRO       twRO       pRO       Private Servers       Other OpenKore support Discussions    Discussion    Tips & Tricks    Feature suggestions Plugins    Howto write plugins    Macro Plugin       Share your macro's    Other Plugins Technical    Developers Corner    Development Help    Tester's corner    Bug reports       Fixed bugs       Unresolvable bugs    Commit Queue Off Topic    Misc    Trashcan Links    OpenKore Manual    Official GitHub    Download Openkore .zip    AJAX IRC Client (Chat)    Developer Manual
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group