.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening

Reply
 
Thread Tools Display Modes
  #1  
Old May 12th, 2009, 01:20 AM

Illuminated One Illuminated One is offline
First Lieutenant
 
Join Date: Oct 2008
Location: In Ulm und um Ulm herum
Posts: 787
Thanks: 133
Thanked 78 Times in 46 Posts
Illuminated One is on a distinguished road
Default 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)?
Reply With Quote
  #2  
Old May 12th, 2009, 09:48 AM

chrispedersen chrispedersen is offline
BANNED USER
 
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
chrispedersen is on a distinguished road
Default 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).
Reply With Quote
  #3  
Old May 18th, 2009, 03:47 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default 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
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
The Following 2 Users Say Thank You to lch For This Useful Post:
  #4  
Old May 18th, 2009, 07:25 PM

chrispedersen chrispedersen is offline
BANNED USER
 
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
chrispedersen is on a distinguished road
Default Re: Diagonal Distance/Range

Quote:
Originally Posted by lch View Post
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?
Reply With Quote
  #5  
Old May 18th, 2009, 07:59 PM
Jazzepi's Avatar

Jazzepi Jazzepi is offline
Major General
 
Join Date: Jan 2004
Location: Columbus, OH
Posts: 2,204
Thanks: 67
Thanked 49 Times in 31 Posts
Jazzepi is on a distinguished road
Default 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
Reply With Quote
  #6  
Old May 18th, 2009, 08:40 PM

Micah Micah is offline
Major
 
Join Date: Dec 2006
Posts: 1,226
Thanks: 12
Thanked 86 Times in 48 Posts
Micah is on a distinguished road
Default 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.
Reply With Quote
  #7  
Old May 18th, 2009, 09:05 PM

MaxWilson MaxWilson is offline
Major General
 
Join Date: Mar 2007
Location: Seattle
Posts: 2,497
Thanks: 165
Thanked 105 Times in 73 Posts
MaxWilson is on a distinguished road
Default 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.]
Reply With Quote
  #8  
Old May 18th, 2009, 09:46 PM

chrispedersen chrispedersen is offline
BANNED USER
 
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
chrispedersen is on a distinguished road
Default 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.
Reply With Quote
  #9  
Old May 18th, 2009, 10:09 PM

Micah Micah is offline
Major
 
Join Date: Dec 2006
Posts: 1,226
Thanks: 12
Thanked 86 Times in 48 Posts
Micah is on a distinguished road
Default 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)
Reply With Quote
  #10  
Old May 19th, 2009, 02:31 AM
Lingchih's Avatar

Lingchih Lingchih is offline
General
 
Join Date: Sep 2004
Location: Irving, TX
Posts: 3,207
Thanks: 54
Thanked 60 Times in 35 Posts
Lingchih is on a distinguished road
Default 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.
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:49 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.