Results 1 to 4 of 4

Thread: Help me with simple code problem

  1. #1
    Junior Member
    Join Date
    Mar 2016
    Posts
    2

    Question Help me with simple code problem

    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:

    Code:
     public int getTargetID()
            {
                return ReadInt32(Tibia.Handle, targetidAdr);
            }
    Code:
     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;
            }
    Code:
     public int getTargetXPos()
            {
                UInt32 targetAdr = getTargetAdr();
                int xpos;
                xpos = ReadInt32(Tibia.Handle, targetAdr + 32);
                return xpos;
            }
    Code:
    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?

  2. #2
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    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

    Code:
    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

  3. #3
    Junior Member
    Join Date
    Mar 2016
    Posts
    2
    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.

  4. #4
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by saviofcb View Post
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •