|
|
|
|
|
May 12th, 2009, 01:20 AM
|
First Lieutenant
|
|
Join Date: Oct 2008
Location: In Ulm und um Ulm herum
Posts: 787
Thanks: 133
Thanked 78 Times in 46 Posts
|
|
Diagonal Distance/Range
Well, does anyone know how the distance on the battlefield is determined?
If your unit and your target are on a line in the grid, that's just counting.
But if say your mage starts in the middle of the field (0 on x axis, 0 on y) and an enemy SC starts in the upper left corner (20 on x axis, 10 on y), what effective range would be necessary to guarantee a hit before buffing?
Would you just add the difference on x and y (20 + 10)?
Pythagoras (sqr(20²+10²))?
Or maybe jump diagonal until you are on the same height and then straight to him (20)?
|
May 12th, 2009, 09:48 AM
|
BANNED USER
|
|
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
|
|
Re: Diagonal Distance/Range
When moving, diagonal moves cost 3 ap, all others 2.
However, range caluculations for spells and missiles are not neccesarily done the same way. I don't know a way to confirm.
My suspician is that range is just calculated SR(a^2+b^2).
|
May 18th, 2009, 03:47 AM
|
|
General
|
|
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
|
|
Re: Diagonal Distance/Range
It's almost the Manhattan metric. The game calculates the distance between (x0,y0) and (x1,y1) by
dx = |x0-x1|
dy = |y0-y1|
r = dx+dy
if (dx > 0 and dy > 0) --r
if (dx > 3 and dy > 3) --r
if (dx > 6 and dy > 6) --r
if (dx > 9 and dy > 9) --r
|
The Following 2 Users Say Thank You to lch For This Useful Post:
|
|
May 18th, 2009, 07:25 PM
|
BANNED USER
|
|
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
|
|
Re: Diagonal Distance/Range
Quote:
Originally Posted by lch
It's almost the Manhattan metric. The game calculates the distance between (x0,y0) and (x1,y1) by
dx = |x0-x1|
dy = |y0-y1|
r = dx+dy
if (dx > 0 and dy > 0) --r
if (dx > 3 and dy > 3) --r
if (dx > 6 and dy > 6) --r
if (dx > 9 and dy > 9) --r
|
ok, I'll be the ignoramous.. I don't get the if (dx>0... etc
--r explain in english?
|
May 18th, 2009, 07:59 PM
|
|
Major General
|
|
Join Date: Jan 2004
Location: Columbus, OH
Posts: 2,204
Thanks: 67
Thanked 49 Times in 31 Posts
|
|
Re: Diagonal Distance/Range
http://en.wikipedia.org/wiki/Manhattan_distance
I believe the simple explanation is that to move from point A to point B, you must follow a line that only turns 90 degrees at a time.
Jazzepi
|
May 18th, 2009, 08:40 PM
|
Major
|
|
Join Date: Dec 2006
Posts: 1,226
Thanks: 12
Thanked 86 Times in 48 Posts
|
|
Re: Diagonal Distance/Range
I think the "if (dx>0...)" bits subtract 1 from the range for each of those pairs that are true, so for a diagonal line you'd get range-length 1, 3, 5, 6, 8, 10, 11, 13, 15, 16. For straighter lines you'd be using the shorter coordinate to pass through each of those if gates, so if you have a differential of x=20 y=5 you would add them to get 25 and then subtract one for the first and second if statements, for a total of 23. Hopefully that's clear, and correct.
|
May 18th, 2009, 09:05 PM
|
Major General
|
|
Join Date: Mar 2007
Location: Seattle
Posts: 2,497
Thanks: 165
Thanked 105 Times in 73 Posts
|
|
Re: Diagonal Distance/Range
So displacing vertically on the battlefield is a LOT more effective at upping the range than I had previously thought.
__________________
Bauchelain - "Qwik Ben iz uzin wallhax! HAX!"
Quick Ben - "lol pwned"
["Memories of Ice", by Steven Erikson. Retranslated into l33t.]
|
May 18th, 2009, 09:46 PM
|
BANNED USER
|
|
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
|
|
Re: Diagonal Distance/Range
oh, I get it. seems like
zx=min{dx,dy)
decrease = trunc(zx/3)
range=r-decrease or something like that is a little more elegant.. still .. interesting algorythmn.
|
May 18th, 2009, 10:09 PM
|
Major
|
|
Join Date: Dec 2006
Posts: 1,226
Thanks: 12
Thanked 86 Times in 48 Posts
|
|
Re: Diagonal Distance/Range
Looks mostly right chris, although you'd need to round "decrease" up to model the function, and it looks like you're truncating it. (Otherwise diagonals immediately next to a square would probably not count as melee range since they'd be range 2)
|
May 19th, 2009, 02:31 AM
|
|
General
|
|
Join Date: Sep 2004
Location: Irving, TX
Posts: 3,207
Thanks: 54
Thanked 60 Times in 35 Posts
|
|
Re: Diagonal Distance/Range
Geez, I am so math challenged. I just stick them on the edges, and tell the to fire at whatever seems to be in range. Seems to work most of the time.
__________________
Be forewarned, anything I post is probably either 1) Sophomoric humor, 2) Satire, 3) A gross exaggeration of the power I currently possess, 4) An outright lie, or 5) Drunken ramblings.
I occasionally post something useful.
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
|
|