PDA

View Full Version : Raw distance calc



Naroe
April 12th, 2020, 03:48
Im trying to work out distance values for raw distances between attacker and defender. Note with size 5' for each its fine, but change the size and ????

I cant work out how you are measuring because as far as I can tell if an attacker is at 0, 90, 180 or 270 degree from defender the calc is correct for any size, but everything other offset it being underestimated.

Your calc seems to take the edge of the token as 2.5' (half the grid unit in feet) in from the edge, which for a 5 foot token is the centre of it.
So by my reckoning the distance in the image between tokens is 20.4' in image shown

Where can I find calc for raw distance if my assumptions are wrong.

Images below show aligned tokens showing that the calc is 5' in from edges of token.
Other shows approx 30 degree offset which shows 19 and should be 20.4.

33504 33505

Moon Wizard
April 17th, 2020, 00:33
The way that it's supposed to work is that the center of the nearest grid square in for each token's location/size (i.e. 1x1 for Medium/Small, 2x2 for Large, etc.) is used to determine the number of squares distance and then multiplied by the grid scale.

Regards,
JPG

Naroe
April 17th, 2020, 01:22
including raw distance?
I thought based on the raw distance it would have been simpler and more accurate to just do the trig. Image shows calc to half square in for each, just as easy to do to edge.

33834

Moon Wizard
April 17th, 2020, 01:37
Nope, because that's not how game systems measure distance.

In your example, you are discounting the "grid size" of the tokens. So the cut off on your line would be where the red region starts. Token asset graphics can be scaled to any size, independent of token "grid size". Also, game systems don't measure like that, because people don't like to do trig at the table.
So, the "game system" calculation for D&D in your example is 3.5 grid squares (or roughly 17.5 feet at a 5 feet per square measure). (i.e. number of grid squares closest to filled square of each creature where diagonals are counted as 1; e.g. 5E D&D rules)

There is a prototype option in the underlying APIs to turn on "raw" distance measures that we added with FGU; but we haven't built the interface to test and modify the "measurements" within a map or campaign. For now, all calculations are based on grid squares and settings specified by the ruleset (diagonal multiplier, and per grid square distance)

Regards,
JPG

Naroe
April 17th, 2020, 04:53
yep, exactly what ive said in the previously attached diagram. And this IS for the Raw option.

not discounting the grid at all.
half the squares size is used in the trig calc for the actual distance to remove from the centre distance. You need to use the grid size and units per grid to do the trig calc.
The code below takes distance half square in as that is what distance appears for 1 square size creatures.

Distance between centers minus the distance of creature based on each of their sizes is the EXACT distance between them.
And its the computer is doing the trig not the players so i dont see why that would come into it.



if distmult == 0 then

print("Raw")

-- 1 decimal place

distance = math.ceil(10*(((xDiff)^2+(yDiff)^2)^0.5)/(nGrid/nDU))/10;

print("Ctr Distance" .. distance)

-- allowance for attacker and defender space
-- angle between


local distDefenderspace = ((nDefenderSpace-1) / 2)*nDU;
local distAttackerspace = ((nAttackerSpace-1) / 2)*nDU;

if xDiff > yDiff then

local tAnglerad = (math.atan(yDiff/xDiff));
local tAngledeg = math.deg(tAnglerad);


print("x>y " .. math.deg(math.cos(tAnglerad)))

distance = distance - math.ceil(10*math.abs((distDefenderspace+distAttac kerspace)/math.cos(tAnglerad)))/10;

else

local tAnglerad = (math.atan(xDiff/yDiff));
local tAngledeg = math.deg(tAnglerad);


print("y>x " .. math.deg(math.cos(tAnglerad)))

-- 1 decimal place

distance = distance - math.ceil(10*math.abs((distDefenderspace+distAttac kerspace)/math.cos(tAnglerad)))/10;

end



else

LordEntrails
April 17th, 2020, 05:29
Distance between centers minus the distance of creature based on each of their sizes is the EXACT distance between them.
And its the computer is doing the trig not the players so i dont see why that would come into it.
Because that is not how the rules of D&D (3, 3.5, 4, or 5E) or most other game systems calculate distance.

But, as Moon said, they have an underlying engine that measures geometric distances, but they haven't taken the time to build out the code on the ruleset side. Patience Grasshopper :)

Naroe
April 17th, 2020, 05:45
ok. i had thought raw was independent of that. I'll wait patiently then.
.
.
.
is it ready yet. lol :)

I can still use my calcs in ext for ranged weapon attacks, and ignore pointer distance till then.