|
You last visited: Today at 15:58
Advertisement
Calculate Distance and XY
Discussion on Calculate Distance and XY within the SRO Coding Corner forum part of the Silkroad Online category.
07/08/2012, 11:43
|
#1
|
elite*gold: 163
Join Date: Mar 2008
Posts: 110
Received Thanks: 37
|
Calculate Distance and XY
Hi. I need calculating distance between positionX & destinationX.
That are my codes but not perfectly works.
Code:
float Distance = Formula.Distance (posX, 0, directionX, 0);
float waitTime = (Formula.Distance (posX, posY, directionX, directionY)) * 10000f / (((Speed * (Speed * 1.05f)) / 100f) + ((20f / Speed) * 105f));
float Interval = (waitTime / Distance) * 0.1f;
Distance Formula
Code:
public static float Distance(float posX, float posY, float directionX, float directionY)
{
double gamedistance = Math.Sqrt((directionX - posX) * (directionX - posX)) + ((directionY - posY) * (directionY - posY));
return float.Parse(gamedistance.ToString());
}
Waiting your helps...
|
|
|
07/08/2012, 13:15
|
#2
|
elite*gold: 0
Join Date: May 2009
Posts: 67
Received Thanks: 37
|
(((Speed * (Speed * 1.05f)) / 100f) + ((20f / Speed) * 105f)
WTF?
Time = distance / speed
Although if i recall correctly you have to multiply by 10. I don't recall why though
|
|
|
07/08/2012, 14:15
|
#3
|
elite*gold: 0
Join Date: Jan 2009
Posts: 575
Received Thanks: 752
|
I use this to get time in ms:
Code:
int time = Convert.ToInt32(dist * 10000 / Speed);
|
|
|
07/08/2012, 15:37
|
#4
|
elite*gold: 0
Join Date: May 2009
Posts: 67
Received Thanks: 37
|
Quote:
Originally Posted by zeteris
I use this to get time in ms:
Code:
int time = Convert.ToInt32(dist * 10000 / Speed);
|
Which is the same thing i said, except it will be in milliseconds instead of seconds
|
|
|
07/09/2012, 09:58
|
#5
|
elite*gold: 163
Join Date: Mar 2008
Posts: 110
Received Thanks: 37
|
Thanks but why i can't calculate %100 correctly?
|
|
|
07/09/2012, 11:13
|
#6
|
elite*gold: 0
Join Date: Apr 2008
Posts: 934
Received Thanks: 746
|
Quote:
Originally Posted by fatihy93
Thanks but why i can't calculate %100 correctly?
|
because there is Z position
|
|
|
07/09/2012, 20:52
|
#7
|
Chat Killer In Duty
elite*gold: 5
Join Date: May 2008
Posts: 16,397
Received Thanks: 6,509
|
i have some interest on this(i dont know how to make coords for /warp command)
|
|
|
07/09/2012, 23:39
|
#8
|
elite*gold: 0
Join Date: Apr 2008
Posts: 934
Received Thanks: 746
|
Quote:
Originally Posted by PortalDark
i have some interest on this(i dont know how to make coords for /warp command)
|
|
|
|
07/09/2012, 23:42
|
#9
|
Chat Killer In Duty
elite*gold: 5
Join Date: May 2008
Posts: 16,397
Received Thanks: 6,509
|
Quote:
Originally Posted by paxemuman
|
have the method to myself, not that page
|
|
|
07/09/2012, 23:55
|
#10
|
elite*gold: 0
Join Date: Apr 2008
Posts: 934
Received Thanks: 746
|
Quote:
Originally Posted by PortalDark
have the method to myself, not that page
|
let me search in my backups , i should have somewhere an app which convert warp to normal coords (i have made it to convert spots from pk2 and put it to my emu). It was hard to figureout it  . If i will find it i will make second option (from normal coorfinates to Pk2"Warp") and i will public it here as an open source tool  . To be honest i don't rememeber formula it was too long time ago.
Edit :
I have found it, i will make an app today or tommorow and i will make it public here in coding section(source will be included).
|
|
|
07/10/2012, 01:39
|
#11
|
elite*gold: 163
Join Date: Mar 2008
Posts: 110
Received Thanks: 37
|
Quote:
Originally Posted by paxemuman
because there is Z position
|
What? You tell i need calculate distance with Z position ?
|
|
|
07/10/2012, 03:15
|
#12
|
elite*gold: 0
Join Date: Apr 2008
Posts: 934
Received Thanks: 746
|
Quote:
Originally Posted by fatihy93
What? You tell i need calculate distance with Z position ?
|
if you want 100% correct then yes i will draw for you why:
As you can see A terrain are flat so you will go faster trought when same X/Y distance in B will take you longer because Z position are different.
|
|
|
07/10/2012, 08:33
|
#13
|
elite*gold: 163
Join Date: Mar 2008
Posts: 110
Received Thanks: 37
|
Quote:
Originally Posted by paxemuman
if you want 100% correct then yes i will draw for you why:
As you can see A terrain are flat so you will go faster trought when same X/Y distance in B will take you longer because Z position are different.
|
I know this but i thought Z position not important on this time.
Ah, now i understand. When i walk on directly, i calculate correctly because Z was not effective or fixed.
Thank you bro, and sorry for my sentences without grammar ^^.
|
|
|
07/16/2012, 00:50
|
#14
|
elite*gold: 0
Join Date: May 2009
Posts: 18
Received Thanks: 6
|
here is code in c++ (sorry idk any other language)
Code:
float CalculateDist(D3DXVECTOR3 from, D3DXVECTOR3 to)
{
float _x, _y, _z;
_x = to.x - from.x;
_y = to.y - from.y;
_z = to.z - from.z;
return sqrt(_x*_x + _y*_y + _z*_z);
}
sorry for using D3DXVECTOR3 as i use this in my crossfire hack
any way if you dont have directx sdk use this structure:
Code:
#ifndef D3DXVECTOR3
struct D3DXVECTOR3
{
float x;
float y;
float z;
};
#endif
|
|
|
07/16/2012, 10:16
|
#15
|
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
|
Thanks now I know why the movement was always a bit wrong.
Little note the so called "z" axis is actually the "y" axis in a 3d space. Not that it matters in distance calulation but it might confuse the hell out of you if you are going to work with the navmesh and other 3d objects.
|
|
|
 |
|
Similar Threads
|
How to calculate a hybrid?
04/01/2019 - Silkroad Online - 19 Replies
hey, ive got a char which i made random hybrid.. but i really love it!
now i opened a 2nd char on esro and wanna have the same char.
how can i calculate the kind of hybrid?
the stats are:
STR : 172 HP : 14,337
INT : 346 MP : 26,117
|
Calculate the Weapon %
04/15/2011 - SRO Coding Corner - 15 Replies
Hi guys,
Anyone know how can i calculate the difference of an atribute of the weapon by the %?
for example:
Phy. attack power 504 ~ 616 (0%)
Phy. attack power X ~ Y (50%)
|
RELEASE SF-RANK CALCULATE..
02/09/2011 - Soldier Front Philippines - 9 Replies
This Will Calculate How Much EXP You will Need To Rank
SF-RankCalc.rar
|
Calculate DMG , SP , WEAPON!
06/25/2008 - Silkroad Online - 4 Replies
Calculate DMG, SP ALL THINGS! Take a look and font forget press thanx button if you like :D:D.
Just click here
|
DO ANYONE HOW TO CALCULATE MENTOR EXP
06/03/2008 - Conquer Online 2 - 1 Replies
LIKE WHEN WILL MENTOR GOT EXP FROM STUDENT WHEN THEY KILL MONSTER AND LEVEL OR WHEN STUDEMT KILL CERTAIN AMOUNT OF MONSTER
|
All times are GMT +1. The time now is 16:01.
|
|