View Full Version : Reading battlelist...
Huhu..
so i'm trying to make a program that will attack creatures in my screen..
I know how to send the packets to attack a creature, but for that i need the creatures' ID. and i dont know exactly how to find it.
from what ive read i need to read the battlelist, then check if its on my screen and then i can attack it.. or something like that?
this is what ive got, is it close? anyone got some clues maybe?
when i run this.. it only adds myself to the listbox ;)
public string FindCreatures()
{
//find creatures in battlelist
string CharName = "Not Found"; //will store name of creature
int CreatureId; // store id of the creature
int AdressToRead = Addresses.BattleList_Begin; //we start with reading the first object in battlelist
for (int i = 0; i <= Addresses.BattleList_Max; i++) //loop through battlelist
{
int temp = 0;
//read first battlelist item found + jump to first creature + jump to the creature id
CreatureId = Memory.ReadInt(AdressToRead + Addresses.BattleList_StepCreatures + Addresses.DistanceId);
if (CreatureId == 0) //if it has no creature id, its not interesting for us..
{
//no creature found
}
else //creature found
{
//we read the temporary address + jump to creature + jump to invis
int visible = 0;
//read isvisible
visible = Memory.ReadInt(AdressToRead + Addresses.BattleList_StepCreatures + Addresses.DistanceIsVisible);
if (visible == 1) //it has a creature id, and is visible.. to lets read the name.
{
CharName = Memory.ReadString(AdressToRead + Addresses.BattleList_StepCreatures + Addresses.DistanceName);
}
}
AdressToRead += Addresses.BattleList_StepCreatures; //next creature
}
if (CharName != "")
{
if (!listBoxBattle.Items.Contains(CharName)) //if its not already on the list
listBoxBattle.Items.Add(CharName); //then we add it
}
return CharName;
}
I managed to get the program to find players/NPCs and their ids. but that does not help me very much ;( need creatures only.
Huhu..
so i'm trying to make a program that will attack creatures in my screen..
I know how to send the packets to attack a creature, but for that i need the creatures' ID. and i dont know exactly how to find it.
from what ive read i need to read the battlelist, then check if its on my screen and then i can attack it.. or something like that?
this is what ive got, is it close? anyone got some clues maybe?
when i run this.. it only adds myself to the listbox ;)
public string FindCreatures()
{
//find creatures in battlelist
string CharName = "Not Found"; //will store name of creature
int CreatureId; // store id of the creature
int AdressToRead = Addresses.BattleList_Begin; //we start with reading the first object in battlelist
for (int i = 0; i <= Addresses.BattleList_Max; i++) //loop through battlelist
{
int temp = 0;
//read first battlelist item found + jump to first creature + jump to the creature id
CreatureId = Memory.ReadInt(AdressToRead + Addresses.BattleList_StepCreatures + Addresses.DistanceId);
if (CreatureId == 0) //if it has no creature id, its not interesting for us..
{
//no creature found
}
else //creature found
{
//we read the temporary address + jump to creature + jump to invis
int visible = 0;
//read isvisible
visible = Memory.ReadInt(AdressToRead + Addresses.BattleList_StepCreatures + Addresses.DistanceIsVisible);
if (visible == 1) //it has a creature id, and is visible.. to lets read the name.
{
CharName = Memory.ReadString(AdressToRead + Addresses.BattleList_StepCreatures + Addresses.DistanceName);
}
}
AdressToRead += Addresses.BattleList_StepCreatures; //next creature
}
if (CharName != "")
{
if (!listBoxBattle.Items.Contains(CharName)) //if its not already on the list
listBoxBattle.Items.Add(CharName); //then we add it
}
return CharName;
}
I managed to get the program to find players/NPCs and their ids. but that does not help me very much ;( need creatures only.
Had the same problem, the battlelist adresses must be wrong because you only find some of the stuffs who is in the battlelist i had the sameproblem i had to make 2 separate adresses for both start and end to find my char and monsters..
Had the same problem, the battlelist adresses must be wrong because you only find some of the stuffs who is in the battlelist i had the sameproblem i had to make 2 separate adresses for both start and end to find my char and monsters..
what do you mean with 2 seperate addresses?
atm i got
BattleList_Begin = 0x0049A07C;
BattleList_End = BattleList_Begin + BattleList_StepCreatures * BattleList_Max;
anyway, do you know how to find each of those? so i can look them all up to make sure they have the correct values.
now im using:
BattleList_StepCreatures = 0xA8; //168
BattleList_Dist = 156;
BattleList_Max = 250;
PlzNoKil
06-18-2010, 05:13
dont help him, he will only cheat on classictibia ;(
Does anyone have BattleList End?
No not this battlelist * steps etc.. wont work in my application i get overflow so i need a adress example from last
BattleListBegin = &H635F70
BattleListEnd = &H63FF9C
You could just calculate it yourself if you have Battlelist start adress.
0x63D350 + (0xA8 * 250)
0xA8 * 250 is 0xA410 (42000)
So, just add that to battlelist start:
0x63D350 + 0xA410 = 0x647760
There you go.
[posted from tpforums] myself asking and got answer from korv
klusbert
06-18-2010, 14:47
Vb.net
For i As Integer = Addresses.BattleList.Start To Addresses.BattleList.End Step Addresses.BattleList.StepCreatures
If client.Memory.ReadByte(i + Addresses.Creature.DistanceIsVisible) = 1 Then
MsgBox(client.Memory.ReadString(i + 4))
End If
Next
C#
for (int i = Addresses.BattleList.Start; i <= Addresses.BattleList.End; i += Addresses.BattleList.StepCreatures) {
if (client.Memory.ReadByte(i + Addresses.Creature.DistanceIsVisible) == 1) {
Messagebox.Show(client.Memory.ReadString(i + 4));
}
}
Stepcreatures = &HA8
maxcreatuers = 250
BlistEnds = bliststart +(stepcreatuers * maxcreatures)
IF you are doing this for classic remember the steps is not the same and max creatures is not the same either. This is only for latest tibia version 8.57
@up
thanks a lot,
anyways, last question:
could you point me in the right direction how i could find maxCreatures and stepCreatures?
look at battlelist loops in the client with ollyDBG and u should find them
look at battlelist loops in the client with ollyDBG and u should find them
i managed to find out that StepCreature = 156,
i did some manual searching with TSearch ;>
since im not that skilled with Ollydbg
anyways, how to find out maxcreatures on battlelist?
latest tibia version:
Public Enum Distance
IDDistance = 0
NameDistance = 4
XDistance = 36
YDistance = 40
ZDistance = 44
WalkingDistance = 76
DirectionDistance = 80
OutfitIDDistance = 96
HeadColorDistance = 100
BodyColorDistance = 104
LegsColorDistance = 108
FeetColorDistance = 112
AddonsDistance = 116
LightDistance = 120
LightColorDistance = 124
LightPatternDistance = 127
BlackSquareDistance = 132
HPDistance = 136
WalkSpeedDistance = 140
VisibleDistance = 144
SkullTypeDistance = 148
PartyTypeDistance = 152
SizeDistance = 168
Max = 250
End Enum
Vb.net
For i As Integer = Addresses.BattleList.Start To Addresses.BattleList.End Step Addresses.BattleList.StepCreatures
If client.Memory.ReadByte(i + Addresses.Creature.DistanceIsVisible) = 1 Then
MsgBox(client.Memory.ReadString(i + 4))
End If
Next
C#
for (int i = Addresses.BattleList.Start; i <= Addresses.BattleList.End; i += Addresses.BattleList.StepCreatures) {
if (client.Memory.ReadByte(i + Addresses.Creature.DistanceIsVisible) == 1) {
Messagebox.Show(client.Memory.ReadString(i + 4));
}
}
Stepcreatures = &HA8
maxcreatuers = 250
BlistEnds = bliststart +(stepcreatuers * maxcreatures)
IF you are doing this for classic remember the steps is not the same and max creatures is not the same either. This is only for latest tibia version 8.57
im now sure that all addresses are right,
it might be my ReadByte function that isnt working as it should, could you post yours?
i made it myself thats why its probably bugged heheh xD
Public Function Memory_ReadByte(windowHwnd As Long, Address As Long) As Byte
' Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle
Dim valbuffer As Byte ' Byte
' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Function
' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID
' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_VM_READ, False, PID)
If (phandle = 0) Then Exit Function
' Read Long
ReadProcessMemory phandle, Address, valbuffer, 1, 0&
' Return
Memory_ReadByte = valbuffer
' Close the Process Handle
CloseHandle phandle
End Function
thats the one i use, its from tpforums
latest tibia version:
Public Enum Distance
IDDistance = 0
NameDistance = 4
XDistance = 36
YDistance = 40
ZDistance = 44
WalkingDistance = 76
DirectionDistance = 80
OutfitIDDistance = 96
HeadColorDistance = 100
BodyColorDistance = 104
LegsColorDistance = 108
FeetColorDistance = 112
AddonsDistance = 116
LightDistance = 120
LightColorDistance = 124
LightPatternDistance = 127
BlackSquareDistance = 132
HPDistance = 136
WalkSpeedDistance = 140
VisibleDistance = 144
SkullTypeDistance = 148
PartyTypeDistance = 152
SizeDistance = 168
Max = 250
End Enum
thx but this is for an older version,
i already solved it anyway!
cavebot _/
currently the features sux tho,
it can only follow waypoints on one floor, and attack creatures. But as it seems now he is just hitting random creatures, like 1 hit each rotworm lol.
trying to solve that then im gonna have to fix looting ;>
thanks everyone for the help ;)
dunno what happend, looks like most post just dissapeared
anyway, its working now, thanks everyone for the help :P
i've got another question tho, instead of just opening new threads ill ask here.
atm im using a while loop to keep attacking the creature until it dies, but this freezez the whole program.
anyone got a nice way to avoid that?
edit: didnt saw there was a second page on the thread -.- hrhr
dunno what happend, looks like most post just dissapeared
anyway, its working now, thanks everyone for the help :P
i've got another question tho, instead of just opening new threads ill ask here.
atm im using a while loop to keep attacking the creature until it dies, but this freezez the whole program.
anyone got a nice way to avoid that?
edit: didnt saw there was a second page on the thread -.- hrhr
my bot checks the target for its HP% and isVisible properties (depending on if it's cavebot or trainer). if you want it to loot a monster, then make a loop that reads the isVisible and start looting when it returns 0
also, you should look into multi-threading, it will solve your issues with freezing :p
dunno what happend, looks like most post just dissapeared
anyway, its working now, thanks everyone for the help :P
i've got another question tho, instead of just opening new threads ill ask here.
atm im using a while loop to keep attacking the creature until it dies, but this freezez the whole program.
anyone got a nice way to avoid that?
edit: didnt saw there was a second page on the thread -.- hrhr
You should use timers instead of loops while attacking, multithreading is however the best way of doing it
the project is already closed but thanks for the help everyone.
i did read a lot about multithreading, if i get to work on this again thats probably how it will be done
Powered by vBulletin® Version 4.2.5 Copyright © 2021 vBulletin Solutions Inc. All rights reserved.