Hello,
I find it difficult to do the MoveByPacket function (in SendPackets) in C # :
BaseAddress = 12817100
CharStruct = 52
(Short) InfoCharacter.CharacterMoveCounter = ((BaseAddress + CharStruct) + 2564)
(Float) InfoCharacter.CharacterSpeedFly = ((BaseAddress + CharStruct) + 1292)
(Float) InfoCharacter.CharacterSpeedRun = ((BaseAddress + CharStruct) + 1284)
(Float) InfoCharacter.CharacterSpeedWalk = ((BaseAddress + CharStruct) + 1280)
(Float) InfoCharacter.CharacterSpeedSwim = ((BaseAddress + CharStruct) + 1288)
(Coordinates) InfoCharacter.CharacterCoordinates And Destination are used like this:
The problem is that the MoveByPackets does nothing. I thought i had the wrong offset on SendPacket_Adress and SendPacket_Adress, but not since i use functions SelectTarget, RegularAttack, PickUpItem they work.
If you have an idea of the problem or if you have any questions do not hesitate to post.
For Perfect World International
I find it difficult to do the MoveByPacket function (in SendPackets) in C # :
Code:
public enum PacketMoveType { Flying = 0x61, Jumping = 0x28, Running = 0x21, Walking = 0x20, Swimming = 0xA1 };
public void moveByPackets(Coordinates Destination, PacketMoveType MoveType)
{
float Speed;
short MoveCounter;
Coordinates currentCoords = new Coordinates(InfoCharacter.CharacterCoordinates);
switch (MoveType)
{
case PacketMoveType.Flying:
Speed = InfoCharacter.CharacterSpeedFly;
break;
case PacketMoveType.Jumping:
Speed = InfoCharacter.CharacterSpeedRun;
break;
case PacketMoveType.Running:
Speed = InfoCharacter.CharacterSpeedRun;
break;
case PacketMoveType.Walking:
Speed = InfoCharacter.CharacterSpeedWalk;
break;
case PacketMoveType.Swimming:
Speed = InfoCharacter.CharacterSpeedSwim;
break;
default:
Speed = InfoCharacter.CharacterSpeedRun;
break;
}
short TimeInterval = 1000;
float TimeNeeded = Destination.Range3D(currentCoords) / Speed;
float dX = ((Destination.X - currentCoords.X) / TimeNeeded) * TimeInterval / 1000;
float dY = ((Destination.Y - currentCoords.Y) / TimeNeeded) * TimeInterval / 1000;
float dZ = ((Destination.Z - currentCoords.Z) / TimeNeeded) * TimeInterval / 1000;
if (Speed > 0)
{
while (TimeNeeded > (float)TimeInterval / 1000)
{
currentCoords.X += dX;
currentCoords.Y += dY;
currentCoords.Z += dZ;
MoveCounter = InfoCharacter.CharacterMoveCounter;
MoveTo(currentCoords.X, currentCoords.Y, currentCoords.Z, TimeInterval, Speed, 0, MoveCounter);
MoveCounter++;
InfoCharacter.CharacterMoveCounter = MoveCounter;
TimeNeeded -= (float)TimeInterval / 1000;
Thread.Sleep(TimeInterval);
}
if (TimeNeeded > 0)
{
MoveCounter = InfoCharacter.CharacterMoveCounter;
currentCoords.X += dX * TimeNeeded;
currentCoords.Y += dY * TimeNeeded;
currentCoords.Z += dZ * TimeNeeded;
MoveStop(currentCoords.X, currentCoords.Y, currentCoords.Z, (short)(TimeNeeded * 1000), Speed, (byte)MoveType, MoveCounter, 0);
MoveCounter++;
InfoCharacter.CharacterMoveCounter = MoveCounter;
}
}
}
private int moveAddress;
private byte[] moveAddressRev;
private byte[] movePkt = new byte[]
{
0x00, 0x00, //Header
0x00, 0x00, 0x00, 0x00, //x coord
0x00, 0x00, 0x00, 0x00, //y coord
0x00, 0x00, 0x00, 0x00, //z coord
0x00, 0x00, 0x00, 0x00, //x coord
0x00, 0x00, 0x00, 0x00, //y coord
0x00, 0x00, 0x00, 0x00, //z coord
0x00, 0x00, //interval
0x00, 0x00, //speed
0x00, //moveType
0x00, 0x00 //counter
};
public void MoveTo(float xCoord, float yCoord, float zCoord, short interval, float speed, byte moveType, short moveCounter)
{
int packetSize = movePkt.Length;
if (moveAddress == 0)
LoadPacket(movePkt, ref moveAddress, ref moveAddressRev);
byte[] xCoordRev = BitConverter.GetBytes(xCoord);
xCoordRev.Reverse();
Library.Memory.WriteBytes(moveAddress + 2, xCoordRev);
Library.Memory.WriteBytes(moveAddress + 14, xCoordRev);
byte[] yCoordRev = BitConverter.GetBytes(yCoord);
yCoordRev.Reverse();
Library.Memory.WriteBytes(moveAddress + 6, yCoordRev);
Library.Memory.WriteBytes(moveAddress + 18, yCoordRev);
byte[] zCoordRev = BitConverter.GetBytes(zCoord);
zCoordRev.Reverse();
Library.Memory.WriteBytes(moveAddress + 10, zCoordRev);
Library.Memory.WriteBytes(moveAddress + 22, zCoordRev);
byte[] intervalRev = BitConverter.GetBytes(interval);
intervalRev.Reverse();
Library.Memory.WriteBytes(moveAddress + 26, intervalRev);
short shortSpeed = (short)(speed * 256 + 0.5);
byte[] shortSpeedRev = BitConverter.GetBytes(shortSpeed);
shortSpeedRev.Reverse();
Library.Memory.WriteBytes(moveAddress + 28, shortSpeedRev);
Library.Memory.WriteByte(moveAddress + 30, moveType);
byte[] moveCounterRev = BitConverter.GetBytes(moveCounter);
moveCounterRev.Reverse();
Library.Memory.WriteBytes(moveAddress + 31, moveCounterRev);
SendPacket(moveAddressRev, packetSize);
}
//Move Stop
private int moveStopAddress;
private byte[] moveStopAddressRev;
private byte[] moveStopPkt = new byte[]
{
0x07, 0x00, //Header
0x00, 0x00, 0x00, 0x00, //x coord
0x00, 0x00, 0x00, 0x00, //y coord
0x00, 0x00, 0x00, 0x00, //z coord
0x00, 0x00, //speed
0x00, //direction
0x00, //moveType
0x00, 0x00, //counter
0x00, 0x00 //interval
};
public void MoveStop(float xCoord, float yCoord, float zCoord, short interval, float speed, byte moveType, short moveCounter, byte direction)
{
int packetSize = moveStopPkt.Length;
if (moveStopAddress == 0)
LoadPacket(moveStopPkt, ref moveStopAddress, ref moveStopAddressRev);
byte[] xCoordRev = BitConverter.GetBytes(xCoord);
xCoordRev.Reverse();
Library.Memory.WriteBytes(moveStopAddress + 2, xCoordRev);
byte[] yCoordRev = BitConverter.GetBytes(yCoord);
yCoordRev.Reverse();
Library.Memory.WriteBytes(moveStopAddress + 6, yCoordRev);
byte[] zCoordRev = BitConverter.GetBytes(zCoord);
zCoordRev.Reverse();
Library.Memory.WriteBytes(moveStopAddress + 10, zCoordRev);
byte[] intervalRev = BitConverter.GetBytes(interval);
intervalRev.Reverse();
Library.Memory.WriteBytes(moveStopAddress + 20, intervalRev);
short shortSpeed = (short)(speed * 256 + 0.5);
byte[] shortSpeedRev = BitConverter.GetBytes(shortSpeed);
shortSpeedRev.Reverse();
Library.Memory.WriteBytes(moveStopAddress + 14, shortSpeedRev);
Library.Memory.WriteByte(moveStopAddress + 16, direction);
Library.Memory.WriteByte(moveStopAddress + 17, moveType);
byte[] moveCounterRev = BitConverter.GetBytes(moveCounter);
moveCounterRev.Reverse();
Library.Memory.WriteBytes(moveStopAddress + 18, moveCounterRev);
SendPacket(moveStopAddressRev, packetSize);
}
CharStruct = 52
(Short) InfoCharacter.CharacterMoveCounter = ((BaseAddress + CharStruct) + 2564)
(Float) InfoCharacter.CharacterSpeedFly = ((BaseAddress + CharStruct) + 1292)
(Float) InfoCharacter.CharacterSpeedRun = ((BaseAddress + CharStruct) + 1284)
(Float) InfoCharacter.CharacterSpeedWalk = ((BaseAddress + CharStruct) + 1280)
(Float) InfoCharacter.CharacterSpeedSwim = ((BaseAddress + CharStruct) + 1288)
(Coordinates) InfoCharacter.CharacterCoordinates And Destination are used like this:
Code:
public class Coordinates
{
public float X;
public float Y;
public float Z;
public float DisplayX { get { return (float)Math.Round((X + 4000) / 10, 1); } }
public float DisplayY { get { return (float)Math.Round((Y + 5500) / 10, 1); } }
public float DisplayZ { get { return (float)Math.Round(Z / 10, 1); } }
public Coordinates()
{
X = 0;
Y = 0;
Z = 0;
}
public Coordinates(float x, float y, float z)
{
this.X = x;
this.Y = y;
this.Z = z;
}
public Coordinates(Coordinates Coords)
{
this.X = Coords.X;
this.Y = Coords.Y;
this.Z = Coords.Z;
}
public float Range3D(Coordinates Dest)
{
float dX = X - Dest.X;
float dY = Y - Dest.Y;
float dZ = Z - Dest.Z;
return (float)Math.Round(Math.Sqrt(dX * dX + dY * dY + dZ * dZ), 1);
}
public float Range2D(Coordinates Dest)
{
float dX = X - Dest.X;
float dZ = Z - Dest.Z;
return (float)Math.Sqrt(dX * dX + dZ * dZ);
}
}
If you have an idea of the problem or if you have any questions do not hesitate to post.
For Perfect World International