|
You last visited: Today at 02:23
Advertisement
help with moving
Discussion on help with moving within the Kal Online forum part of the MMORPGs category.
07/16/2009, 13:26
|
#1
|
elite*gold: 0
Join Date: Oct 2007
Posts: 175
Received Thanks: 8
|
help with moving
ok hello
here is the thing- i am trying for alot of time to do the moving...but i cant
its bot mocing exacly to the place...but it moves
so i need your help making it currect...please?
here is the code for the moving:
PHP Code:
DWORD itemid,x,y;
memcpy((void*)&itemid,(void*)((DWORD)buf2+5),4);
memcpy((void*)&x,(void*)((DWORD)buf2+5+4),4);
memcpy((void*)&y,(void*)((DWORD)buf2+5+4+4),4);
int difx=x-Player[0].X;
int dify=y-Player[0].Y;
float range=(difx*difx+dify*dify)*1.0;
int timex=difx/20,timey=dify/20;
if(sqrt(range)<500000000.0&&sqrt(range)>-500000000.0)
{
if(difx<0)
{
for(int i=0;i>timex;i--)
{
SendPacket(0x15,"bbb",-20,0,0);
SendPacket(0x14,"bbb",-20,0,0);
}
}
if(difx>0)
{
for(int i=0;i<timex;i++)
{
SendPacket(0x15,"bbb",20,0,0);
SendPacket(0x14,"bbb",20,0,0);;
}
}
if(dify<0)
{
for(int i=0;i>timey;i--)
{
SendPacket(0x15,"bbb",0,-20,0);
SendPacket(0x14,"bbb",0,-20,0);
}
}
if(dify>0)
{
for(int i=0;i<timey;i++)
{
SendPacket(0x15,"bbb",0,20,0);
SendPacket(0x14,"bbb",0,20,0);
}
}
SendPacket(0x20,"ddd",itemid,x/32,y/32);
}
please help me...its driving me crazy...i spent hours to solve it and i cant
please...help me to fix the code ^^? thanks
|
|
|
07/16/2009, 13:51
|
#2
|
elite*gold: 0
Join Date: Dec 2006
Posts: 648
Received Thanks: 342
|
I tell you already what to do.
|
|
|
07/16/2009, 14:21
|
#3
|
elite*gold: 0
Join Date: Oct 2007
Posts: 175
Received Thanks: 8
|
PHP Code:
if(difx<0)
{
while(difx<0)
{
SendPacket(0x15,"bbb",-44,0,0);
difx+=44;
}
}
if(difx>0)
{
while(difx>0)
{
SendPacket(0x15,"bbb",44,0,0);
difx-=44;
}
}
if(dify<0)
{
while(dify<0)
{
SendPacket(0x15,"bbb",0,-44,0);
dify+=44;
}
}
if(dify>0)
{
while(dify>0)
{
SendPacket(0x15,"bbb",0,44,0);
dify-=44;
}
}
lol do you mean that code? its aint working!
|
|
|
07/16/2009, 16:37
|
#4
|
elite*gold: 0
Join Date: Oct 2007
Posts: 175
Received Thanks: 8
|
ok i have changed the code...but it still doesnt seem to work...please help me dudes?
here's the code:
PHP Code:
int difx=x-Player[0].X;
int dify=y-Player[0].Y;
int timex=difx/10,timey=dify/10;
if(timex<1000000&&timey<1000000)
{
if(timex<0)
for(int i=0;i>timex;i--)
SendPacket(0x15,"bbb",-10,0,0);
if(timex>0)
for(int i=0;i<timex;i++)
SendPacket(0x15,"bbb",10,0,0);
if(timey<0)
for(int i=0;i>timey;i--)
SendPacket(0x15,"bbb",0,-10,0);
if(timey>0)
for(int i=0;i<timey;i++)
SendPacket(0x15,"bbb",0,10,0);
}
|
|
|
07/17/2009, 17:38
|
#5
|
elite*gold: 0
Join Date: Dec 2008
Posts: 208
Received Thanks: 24
|
not perfekt, but everyone can understand
Code:
unsigned long double calcRange(Coord a,Coord b)
{
DWORD difx,dify;
unsigned long double range;
difx=a.X-b.X;
dify=a.Y-b.Y;
range=(difx*difx)+(dify*dify);
if(range<0) { printf("Error while Range-Calc\n");range=4294967294; }
//printf("\nBefore Sqrt: %lf",range);
range=sqrt(range);
//printf("\nAfter Sqrt: %lf\n",range);
//printf("A: %d %d \nB: %d %d --> %lf\n",a.X,a.Y,b.X,b.Y,range);
return range;
}
Code:
void makeStepTo(Coord target)
{
//double range=(double)calcRange(player.pos,target);
int difx=player.pos.X-target.X;
int dify=player.pos.Y-target.Y;
int difz=player.pos.Z-(target.Z-underground);
int tempx=-difx;
int tempy=-dify;
int tempz=-difz;
//unsigned char moveX, moveY;
if(tempx>20) { tempx=20; }
if(tempx<-20) { tempx=-20; }
if(tempy>20) { tempy=20; }
if(tempy<-20) { tempy=-20; }
if(tempz>20) { tempz=20; }
if(tempz<-20) { tempz=-20; }
if(tempx<0)
{
tempx=255+tempx;
}
if(tempy<0)
{
tempy=255+tempy;
}
if(tempz<0)
{
tempz=255+tempz;
}
if(target.Z==0) { tempz=0; }
SendPacket(0x15,"bbb",tempx,tempy,tempz);
}
Code:
bool walkToCoord(Coord target, int speed,unsigned long double range, int timeout)
{
//Normal Walk Speed =500
//Speed Walk ~ 300
printf("Walk to X:%d Y:%d, Z:%d\n",target.X,target.Y,target.Z);
for(int i=0;calcRange(player.pos,target)>range;++i)
{
if(timeout>0 && i>timeout) { printf("Error. Timeout.\n"); return false;}
makeStepTo(target);
Sleep(speed);
printf(".");
}
printf("\n");
return true;
}
|
|
|
09/09/2009, 22:05
|
#6
|
elite*gold: 0
Join Date: Jul 2009
Posts: 87
Received Thanks: 3
|
This is my code. It moves to given coordinates very well, but sometimes is crashing.
PHP Code:
int nDifX,nDifY,nDistance,nRange;
int x,y;
int Teleport(int tele_x, int tele_y)
{
while (true)
{
nDifX=playerx-tele_x;
nDifY=playery-tele_y;
nDistance=(nDifX*nDifX)+(nDifY*nDifY);
nRange = sqrt(nDistance*1.0);
if (nRange < 5.0)
{
printf("Place reached\n");
return 1;
}
else
{
x=-(nDifX)/sqrt(nRange*1.0);
y=-(nDifY)/sqrt(nRange*1.0);
while (abs(x)>44 || abs(y)>44)
{
x = x/2;
y = y/2;
}
SendPacket(0x15,"bbb",x,y,0);
playerx =playerx + x;
playery =playery + y;
i++;
}
printf("tele_x: %d tele_y:%d nDifX: %d nDifY: %d nDistance: %d nRange: %d x: %d y: %d\n", tele_x, tele_y, nDifX, nDifY, nDistance, nRange, x, y);
Sleep(50);
}
return 1;
}
Can you send more than 44 or -44 packet values for moving? For me dont work 128 for example.
Some people here told me that 1-127 is positive move and 128-255 is negative, but my character dont move when I use more than 44 and less than -44.
Some people also use unsigned chars instead chars or int.
How you do it? Maybe thats why my code crashes?
|
|
|
09/09/2009, 22:29
|
#7
|
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
|
Well, I guess there is a reason why 0x14 is moving, and 0x15 is endmove ;D
|
|
|
09/09/2009, 22:31
|
#8
|
elite*gold: 220
Join Date: Jun 2007
Posts: 3,768
Received Thanks: 1,126
|
what u talk XD? my bot have only 0x15 ;D
|
|
|
09/09/2009, 22:35
|
#9
|
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
|
Was just an idea =P
Well, I guess I know what actually crashes him, but nvm, he will find out by himself one day
|
|
|
09/10/2009, 14:27
|
#10
|
elite*gold: 0
Join Date: Jul 2009
Posts: 87
Received Thanks: 3
|
I just dont understand why I cant send more than 44 and less than -44 !
Quote:
|
Well, I guess I know what actually crashes him, but nvm, he will find out by himself one day
|
I guess not.
|
|
|
09/10/2009, 14:41
|
#11
|
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
|
Quote:
Originally Posted by Xorg
I just dont understand why I cant send more than 44 and less than -44 !
I guess not.
|
Coz it is so. Accept it ;>
|
|
|
09/10/2009, 21:03
|
#12
|
elite*gold: 0
Join Date: Jan 2008
Posts: 20
Received Thanks: 5
|
jesus fucking christ, just use the goddamn public code.
PHP Code:
int movestatus = 0;
int itemx,itemy;
while (movestatus == 0)
{
int difx=Player[0].X-itemx;
int dify=Player[0].Y-itemy;
float range=(difx * difx)+(dify * dify);
float sqrt_range=sqrt(range);
if (sqrt_range > 20.0)
{
unsigned char movex=-(difx/sqrt(range))*30;
unsigned char movey=-(dify/sqrt(range))*30;
// moving to item jackass
SendDetour(0x15,"bbb",movex,movey,0) ;
Sleep(50);
}
else
{
// arrived at item
movestatus = 1;
}
}
if you're worrying about cpu usage with sleep, go suck a cock. cause if you can't get this moving shit right and you're worrying about that, you're a fucking tool.
btw, even if you're moving straight to the item dropped, don't think you're gonna pick it 100% of the time. if I'm wrong, and show me, and you're my hero.
but really, why even fucking bother with this shit? just fucking bot and send a pick up command at drop you stupid ass cunts. afraid of getting banned? only twats like you guys get banned, retards.
PHP Code:
if (strcmp(input,"move") == 0)
{
char placename[255];
int movestatus = 0;
int destx,desty;
printf("Enter place name: \n");
cin >> placename;
if (strcmp(placename,"direct") == 0)
{
printf("\nx coord: ");
scanf_s("%d",&destx);
printf("\ny coord: ");
scanf_s("%d",&desty);
}
if (strcmp(placename,"temp") == 0)
{
destx = 269065;
desty = 242924;
}
if (strcmp(placename,"pub") == 0)
{
destx = 256279;
desty = 289106;
}
if (strcmp(placename,"naroo") == 0)
{
destx = 257521;
desty = 258184;
}
while (movestatus == 0)
{
int difx=Player[0].X-destx;
int dify=Player[0].Y-desty;
float range=(difx * difx)+(dify * dify);
float sqrt_range=sqrt(range);
if (sqrt_range > 20.0)
{
unsigned char movex=-(difx/sqrt(range))*30;
unsigned char movey=-(dify/sqrt(range))*30;
printf("Moving to %s\n",placename);
// SendDetour(0x15,"Ubbb",last_u,movex,movey,0) ;
SendDetour(0x15,"bbb",movex,movey,0) ;
Sleep(50);
}
else
{
printf("Arrived at %s\n",placename);
movestatus = 1;
}
}
}
and why do you call it teleport? teleport implies moving directly from one point to another, like x=1 y=1 to x=10 y=10, you non-english speaking douches. it is not teleporting. it is MOVING. x=1 y=1 to x=2 y=2 to x=3 y=3, eventually going to x=10 y=10.
PHP Code:
if (strcmp(input,"moveunderground") == 0)
{
DWORD underground_z = 10000;
if (Player[0].Z <= underground_z)
{
// arrived at spot
printf("Underground: %d\n",Player[0].Z);
}
else
{
while (Player[0].Z >= underground_z)
{
printf("going underground: %d\n",Player[0].Z);
SendDetour(0x15,"bbb",0,0,128); // decrement z by 128
// for some reason all of a sudden wasn't moving correctly one day so added this and didn't feel like finding the real reason why
Player[0].Z-=128;
Sleep(100);
}
}
}
all public, nothing new. nothing to see here.
|
|
|
09/10/2009, 21:50
|
#13
|
elite*gold: 0
Join Date: Jul 2009
Posts: 87
Received Thanks: 3
|
Do not insult me and read carefully what I have to say.
Teleport is my name of function and its not your ****** bussines.
|
|
|
Similar Threads
|
moving char
03/20/2008 - Silkroad Online - 5 Replies
is it possible to move char from one server to another server
|
Moving on.
01/13/2007 - Conquer Online 2 - 9 Replies
I know many where upset with this latest patch. Yes it bites hit alot of hard. I relied on my archer to get plus ones and mets to hellp fund my equipment but well now tq has made it where I can't rely on that anymore. I am going to have to do oone of two things i can gripe about it or learn to adjust and adapt.
I'm not going to quit. I will adjust to the changes adapt and find a way to overcome them. I can't say what other folk will do but i will try to over come this latest obstacle as...
|
MOVING NPC's
11/14/2006 - Conquer Online 2 - 21 Replies
Can some one answer on this question. how is posible to move NPC's. One guy comed to my server and he was moving the NPC's telling us he hacked GM panel...
|
All times are GMT +1. The time now is 02:25.
|
|