Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Help me with simple code problem [Archive] - Forums

PDA

View Full Version : Help me with simple code problem



saviofcb
04-04-2016, 04:25 PM
I'm trying to print at my bot the target X position, however i'm not getting it. What is being printed is 0 always. My knowledge about programming is only one year of studying C++ at college, so don't judge me. I'm using this code:


public int getTargetID()
{
return ReadInt32(Tibia.Handle, targetidAdr);
}


public UInt32 getTargetAdr()
{
int tId = getTargetID();
UInt32 battleListIdAdr = 0x05C68B0;
UInt32 targetAdr = 0;
for (int i = 0; i <= 250; i++)
{
if (ReadInt32(Tibia.Handle, battleListIdAdr + i * 156) == tId)
{
targetAdr = Convert.ToUInt32(battleListIdAdr + i * 156);
}
}
return targetAdr;
}


public int getTargetXPos()
{
UInt32 targetAdr = getTargetAdr();
int xpos;
xpos = ReadInt32(Tibia.Handle, targetAdr + 32);
return xpos;
}


txpos = getTargetXPos();
label22.Text = Convert.ToString(txpos);

It's a bot for tibia 7.72, the creature step is 156. Can you guys help me?

Lolrapa
04-04-2016, 04:49 PM
I was about to say that creature structure size isnt 156 but then I read you comment.

I dont know whats the step of creatures in 7.72 but lets assume thats right.

Are you sure X position step is 32?
Current structure is



struct BattleCreature
{
int Id;
char Name[8 * sizeof(int)];
int Z;
int Y;
int X;
.
.
.


it means x offset is 44 = (8 + 1 + 1 + 1) * 4

saviofcb
04-04-2016, 05:09 PM
after you told me to review the offset to find the target position X , I realized that the distance from the address that stores the IDs in the battle list until the position X is 36 and not 32.
The distance from battle list starts until the position X is 32. So that is why I was doing it wrong. Thanks bro.

Lolrapa
04-04-2016, 05:22 PM
after you told me to review the offset to find the target position X , I realized that the distance from the address that stores the IDs in the battle list until the position X is 36 and not 32.
The distance from battle list starts until the position X is 32. So that is why I was doing it wrong. Thanks bro.

Glad I could help you! Whenever you want :)