Something changed in the Map structure?
Sometimes when I"m checking a tile look's like that it's getting another tile from another floor, really weird.
Something changed in the Map structure?
Sometimes when I"m checking a tile look's like that it's getting another tile from another floor, really weird.
The code that klusbert added/changed in TibiaAPI was written by me, and sadly there is a minor bug in it. I told him about it a while ago, but he must have forgotten to patch it.Originally Posted by maozao
This is TibiaAPI's current code:
[code=c#]
private Tile GetTile(Location worldLocation, Tile playerTile)
{
// All credits goes to blaster_89 who solved this.
if (playerTile == null) { playerTile = GetTileWithPlayer(); }
Location memLoc = worldLocation.ToMemoryLocation(playerTile,client);
uint num = memLoc.ToTileNumber();
int minFloor = 0, maxFloor = 0;
for (int i = 0; i < 8; i++)
{
if (playerTile.TileNumber >= Addresses.Map.MaxTiles * i &&
playerTile.TileNumber <= Addresses.Map.MaxTiles * (i + 1))
{
minFloor = Convert.ToInt32(Addresses.Map.MaxTiles * i);
maxFloor = Convert.ToInt32(Addresses.Map.MaxTiles * (i + 1) - 1);
break;
}
}
if (num > maxFloor) { num = Convert.ToUInt32(num - maxFloor + minFloor - 1); }
else if (num < minFloor) { num = Convert.ToUInt32(maxFloor - minFloor + num + 1); }
return GetTile(num, playerTile);
}
[/code]
and this is my current code:
[code=c#]
internal Tile GetTile(int X, int Y, Tile playerTile)
{
if (playerTile == null) playerTile = GetPlayerTile();
Location memLoc = WorldLocationToMemoryLocation(new Location(X, Y, playerTile.WorldLocation.Z), playerTile);
int num = MemoryLocationToTileNumber(memLoc);
int minFloor = 0, maxFloor = 0;
for (int i = 0; i < 8; i++)
{
if (playerTile.TileNumber >= Client.Addresses.Map.MaxTilesPerFloor * i &&
playerTile.TileNumber < Client.Addresses.Map.MaxTilesPerFloor * (i + 1))
{
minFloor = Client.Addresses.Map.MaxTilesPerFloor * i;
maxFloor = Client.Addresses.Map.MaxTilesPerFloor * (i + 1) - 1;
break;
}
}
if (num > maxFloor) { num = num - maxFloor + minFloor - 1; }
else if (num < minFloor) { num = maxFloor - minFloor + num + 1; }
return GetTile(num, playerTile);
}
internal Tile GetTile(Location loc, Tile playerTile)
{
if (playerTile == null) playerTile = GetPlayerTile();
return GetTile(loc.X, loc.Y, playerTile);
}
[/code]
Note that this will only return tiles on the same floor.
Thank you Blaster, I made some modifications and look's like that it's working better now.
I will try to test it more to find if it is working 100% for now.
Thank you again.
Can't seem to make it work for some reason >.<
Code:internal static int XoR = 0x3ABF8C;// ( internal static int HP = 0x541000;// int HP = Memory.ReadByte(Addresses.Player.HP) + Addresses.baseAddress(Client.Tibia); int XOR = Memory.ReadByte(Addresses.Player.XoR) + Addresses.baseAddress(Client.Tibia); int total = (HP ^ XOR); MessageBox.Show(Memory.ReadByte(total).ToString()); MessageBox.Show(total.ToString());
try read int32 or uint32 instead of read byte
why u are reading byte instead of read a int?
Shouldn't you read byte then convert it to int? That's what I've been doing but my readint32 command does both automatically! Careful with your instructions and advice guys, dunno if his code will do what it needs to.
int HP = Memory.ReadInt(Addresses.Player.HP) + Addresses.baseAddress(Client.Tibia);
int XOR = Memory.ReadInt(Addresses.Player.XoR) + Addresses.baseAddress(Client.Tibia);
int total = HP ^ XOR;
returns 33707513
@UpOriginally Posted by Geez
Nothing strange in returned value, you're reading it wrong way
[code=pseudocode]int baseAddress = (here do all operations counting base address);
int HP = Memory.ReadInt(hpAdr with XP base - 0x400000 + baseAddress);
int XOR = Memory.ReadInt(XOR adr with XP base - 0x400000 + baseAddress);
int total = HP ^ XOR;[/code]
rightt! thanks i knew i was doing something wrong lol