Author Topic: Distance in AC
Chazcon 
Title: FOR THE VITAE!
Posts: 5,298
Registered: Dec 11, '01
Extended Info (if available)
Real Post Cnt: 5,149
User ID: 541,776
Subject: Distance in AC
Old question, but how to calculate distance in AC across landblock boundaries?

These formules give heading & distance WITHIN a landblock:

EW1 = (Target EW) - (my EW loc)
NS1 = (Target NS) - (my NS loc)
distance = sqrt(sqr(NS1) + sqr(EW1))
Heading = ARCTAN(EW1/ NS1) * ( 180 / PI )

(ElgarL)

But if the start and end locations are in two different landblocks, how does one navigate? Do you first do a calc to the target landblock, and then switch to X,Y coordinates to navigate to the desired location?

Or is there a trig formula that will give a heading and distance?

The map in AC is made up as follows:

- landblocks are 8*8 squares
- squares are 24*24 units
- world is 255*255 landblocks (2040*2040 squares)
- center (in squares) is at 1020,1020
- the divide by 10 was a nice scaling factor which seems to give the right results (matches ac's map coords after rounding to one decimal place)
- For outdoors, the lower 7 bits of the landblock value represent which of the 64 squares within the landblock you are standing on. The value is 1 in the south west corner of the landblock, 8 in the north west corner, 57 in the south east corner and 64 in the north east corner (ie. count each column south to north). Not sure why they didn't have the south west corner as zero, could have saved a bit.

(antishreth)

 

-----signature-----
Chazcon - Aluvian swordsman
You say, "FOR THE VITAE!"
Ru tells you, "CHAZ!"
Simply Red tells you, "I am SO not recovering your body!"
-- Good times.
Link to this post
MT_Gouru 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: Distance in AC
WorldFilter has a method that will take two different objects and calculate the distance between them. IIRC correctly, it has a method you can give coords to as well. That is easiest/best way.

 

-----signature-----
Link to this post
Chazcon 
Title: FOR THE VITAE!
Posts: 5,298
Registered: Dec 11, '01
Extended Info (if available)
Real Post Cnt: 5,149
User ID: 541,776
Subject: Distance in AC
thanks Gouru

 

-----signature-----
Chazcon - Aluvian swordsman
You say, "FOR THE VITAE!"
Ru tells you, "CHAZ!"
Simply Red tells you, "I am SO not recovering your body!"
-- Good times.
Link to this post

Valid XHTML 1.0 Transitional Powered by PHP