GetCoordsincircle

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Unfaithful
Neophyte Poster
Posts: 38
Joined: Mon Jun 11, 2007 1:35 pm

GetCoordsincircle

Post by Unfaithful »

I dont have any idea how make GetCoordinCircle maybe someone have?

this is square example from 097

Code: Select all

function GetCoordsInSquare(mid_x, mid_y, radius)
	var x_row := CInt(mid_x)-CInt(radius);
	var y_col := CInt(mid_y)-CInt(radius);
	var stop_x := CInt(mid_x)+CInt(radius);
	var stop_y := CInt(mid_y)+CInt(radius);

	var point_list := array{};
	var coord := struct{"x", "y"};
	
	for ( x_row:=(mid_x-radius); x_row<=stop_x; x_row:=x_row+1 )
		for ( y_col:=(mid_y-radius); y_col<=stop_y; y_col:=y_col+1 )
			coord.x := x_row;
			coord.y := y_col;
			point_list.Append(coord);
			SleepMS(2);
		endfor
		SleepMS(2);
	endfor
	
	return point_list;
endfunction
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Post by CWO »

are you talking of an actual circular pattern? or more of a diamond type pattern?
Unfaithful
Neophyte Poster
Posts: 38
Joined: Mon Jun 11, 2007 1:35 pm

Post by Unfaithful »

doesnt matter it can be circle or diamond i need i to make for exapmle champion, when champion dies above his corpse in "circle" scripts creates a lot of gold stacks - see it in runuo its not exactly circle but almost
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

It involves a lot of trig and we never could find a math expert to figure out how to make it. We also noted that the smaller the radius, the less accurate it becomes.
RazorTongue
New User
Posts: 28
Joined: Mon Apr 23, 2007 8:18 am

Post by RazorTongue »

You can do it in a brute force way. Knowing the radius(r) and the magic formula (x-x1)^2 + (y-y1)^2 <= r^2 and the center point(x1, y1), run two loops like that:

R2 = r^2
for(X = x1-r to x1+r)
for(Y = y1-r to y1+r)
if (pow(X-x1, 2) + pow(Y-y1, 2) <= R2)
; // in circle

Running time: O(r^2)

Alternative way - generate config files with patterns from 1 to XX(your max) and load on demand.

Running time: O(1)
Unfaithful
Neophyte Poster
Posts: 38
Joined: Mon Jun 11, 2007 1:35 pm

Post by Unfaithful »

thx, i think i will handle it
Post Reply