PenUltima Online

It is currently Mon Oct 06, 2008 3:45 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: GetCoordsincircle
PostPosted: Sat Sep 01, 2007 11:16 am 
Offline

Joined: Mon Jun 11, 2007 1:35 pm
Posts: 38
I dont have any idea how make GetCoordinCircle maybe someone have?

this is square example from 097


Code:
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 7:11 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 770
Location: Chicago, IL USA
are you talking of an actual circular pattern? or more of a diamond type pattern?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 02, 2007 3:38 am 
Offline

Joined: Mon Jun 11, 2007 1:35 pm
Posts: 38
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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 02, 2007 7:47 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 419
Location: San Diego, California
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.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 1:42 pm 
Offline
User avatar

Joined: Mon Apr 23, 2007 8:18 am
Posts: 26
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)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 8:03 am 
Offline

Joined: Mon Jun 11, 2007 1:35 pm
Posts: 38
thx, i think i will handle it


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl