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 misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Battlelist Position
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: Battlelist Position

  1. #1
    Senior Member
    Join Date
    Dec 2011
    Posts
    249

    Battlelist Position

    Is there any way to find the position of a creature in the battlelist? E.g. the creature at the top of the battlelist would have an index of 0 and the one below that one would have an index of 1?

    DarkstaR said that the battlelist array in the memory would be structured that way but I looked into it and it seemed like it wasn't like that way, please correct me if I'm wrong =)

  2. #2
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Battlelist Position

    Fairly sure it's oldest at the top, newest at the bottom.
    By oldest and newest I mean time since entering the player's screen.

  3. #3
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Battlelist Position

    I'm guessing you're comparing this to the client's battle window? Keep in mind that the client's battle window only displays creatures that are visible to you, while the battlelist in memory stores all creatures you encounter (until it gets full, then it removes older, unnecessary entries). And yes, they are listed in memory in the same order they're listed in the battle window, by checking the IsVisible offset while looping the memory structure will give you the creatures that you're looking for.

    Now my second question, are you wanting this information because you're working on sending mouseclicks to the battle window in order to attack creatures? If so, then you should stop. Why? Because this would require having the battle window open and stretched out enough to accommodate the target being shown in the list. This would reduce space needed for containers, and, in the end, just be completely frustrating. You would be better off interacting with creatures on-screen via the game window. Which is actually a lot easier to perform than you might think, and a lot easier than interacting with the battle window. The client holds all the information you need to make this work, and all you need is the game windows top/left positions and it's width and height. Let me show you with an example...

    Let's say the game windows values needed are like so:
    Left = 100
    Top = 100
    Height = 500
    Width = 700

    The game window can be seen as a grid of 15 horizontal tiles and 11 vertical tiles with yourself in the middle:
    HorizontalTiles = 15
    VerticalTiles = 11

    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOXOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO
    OOOOOOOOOOOOOOO

    Knowing this we can get our player position because we know it'll always be at 8x,6y on the tiles. And we can use this to find the screen position of our player like so:
    Code:
    private point GetPlayerPosition()
    {
        double TileSize = Width / HorizontalTiles; //this is the size of each tile, in this case 46.66-
        double xCoordinate = (TileSize * 8) - (TileSize / 2) + Left; //we have to subtract half of a tile to get the middle of our tile, then add the left of the game window to get the x position on the client
        double yCoordiante = (TileSize * 6) - (TileSize / 2) + Top; //read above, but we need to add the top here for y position.
        return new point(xCoordinate, yCoordinate);
    }
    Using the creatures position in battlelist compared to your own you can easily find where the creature is on screen. I won't show you how because I don't want to make it too easy on you. :P

  4. #4
    Senior Member
    Join Date
    Jan 2012
    Posts
    417

    RE: Battlelist Position

    In my view, work with battle window is a lot better (and easy, and accurate) than working with gamewindow.

    because:
    if you want to work with mouse/keyboard simulation, then I suppose you understand very well how to find any pointer at Tibia GUI.

    1) gamewindow you missclick easily when a creature is moving, battle window rarely has this problem if you cache it correctly and at 1-step before attack(etc) check white square id.
    2) gamewindow has annoying trouble related to projectiles if you are trying attack/follow/any context menu interact/shoot runes ..., battle window no.

    these are from top head.

    Of course, you can solve 2) by reaching creature in some cases...

  5. #5
    Senior Member
    Join Date
    Dec 2011
    Posts
    249

    RE: Battlelist Position

    Thanks for the reply, but I have already made a function that will right click on the creature on the gamewindow and I found it a bit inaccurate so I also wanted a battlelist feature

    I've also got the X,Y, Width, Height and Scroll position and IsOpen for the battlelist window, so I thought that if I could just get the sequence of creatures I could calculate where exactly to click to on the battlelist.

    Code:
    for (unit i = Battlelist.Start; i <= Battlelist.End; i+= Battlelist.Step)
    {
        if (ReadByte(i + OffsetIsVisible) == 1 && ReadInt32(i + OffsetIsWithinView) && ReadInt32(PlayerID) != ReadInt32(i)) // I know withinview isnt a real offset just cba writing all the arguments for it
            {
                 listBox1.Items.Add(ReadString(i+OffsetName));
            }
    }
    I guess something like this should print out the current battlelist sequence? The thing is it doesn't.

  6. #6
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Battlelist Position

    Quote Originally Posted by ottizy
    Code:
    for (unit i = Battlelist.Start; i <= Battlelist.End; i++)
    {
        if (ReadByte(i + OffsetIsVisible) == 1 && ReadInt32(i + OffsetIsWithinView)) // I know withinview isnt a real offset just cba writing all the arguments for it
            {
                 listBox1.Items.Add(ReadString(i+OffsetName));
            }
    }
    I guess something like this should print out the current battlelist sequence? The thing is it doesn't.
    i++? You need to increase i with the creature step value

    edit: that code will also include creatures on another floor than the player

  7. #7
    Senior Member
    Join Date
    Dec 2011
    Posts
    249

    RE: Battlelist Position

    Quote Originally Posted by Blaster_89
    Quote Originally Posted by ottizy
    Code:
    for (unit i = Battlelist.Start; i <= Battlelist.End; i++)
    {
        if (ReadByte(i + OffsetIsVisible) == 1 && ReadInt32(i + OffsetIsWithinView)) // I know withinview isnt a real offset just cba writing all the arguments for it
            {
                 listBox1.Items.Add(ReadString(i+OffsetName));
            }
    }
    I guess something like this should print out the current battlelist sequence? The thing is it doesn't.
    i++? You need to increase i with the creature step value

    edit: that code will also include creatures on another floor than the player
    Ops xd just wrote that in a hurry so you'd get an idea of what I meant. Anyhow that code doesn't return the battlelist sequence [hr]


  8. #8
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Battlelist Position

    Why the F*** would you right-click and use the context menu?! Alt+click = attack... I NEVER had a problem attacking/following creatures using game window. My code was always 100% accurate. Using the battle window is the dumbest choice.

  9. #9
    Senior Member
    Join Date
    Dec 2011
    Posts
    249

    RE: Battlelist Position

    Quote Originally Posted by Jo3Bingham
    Why the F*** would you right-click and use the context menu?! Alt+click = attack... I NEVER had a problem attacking/following creatures using game window. My code was always 100% accurate. Using the battle window is the dumbest choice.
    I suppose then you clicked in the absolute middle of the tile right? The problem I've had with clicking on the game window is when the creature is moving and you have to click somewhere around in the middle of the two squares which the creature is moving from else it will end up in some kind of mapclick.

    Just my experiences

  10. #10
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Battlelist Position

    Quote Originally Posted by ottizy
    Quote Originally Posted by Jo3Bingham
    Why the F*** would you right-click and use the context menu?! Alt+click = attack... I NEVER had a problem attacking/following creatures using game window. My code was always 100% accurate. Using the battle window is the dumbest choice.
    I suppose then you clicked in the absolute middle of the tile right? The problem I've had with clicking on the game window is when the creature is moving and you have to click somewhere around in the middle of the two squares which the creature is moving from else it will end up in some kind of mapclick.

    Just my experiences
    You know there are values that tells you how far a creature is from it's original tile when it's walking, right?

Posting Permissions

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