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
JAPI - Useful Tools for Tibia - Page 2
Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 47

Thread: JAPI - Useful Tools for Tibia

  1. #11
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    keep it up. I'm following your API development. Btw, looks like you are a bit confused with container structure and item structure.

    Suggestion: Wouldn't make more sense if you create a class "Self" and put there character-related functions like "Hp(), ..., Exp()" that are currently on ReaderClass?

  2. #12
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    The container and item structure are two things I've not read before, and after taking the offsets from the new TibiaAPI, I found it quite confusing that two of them are named Data and DataEx, so I named them Unknown1 and Unknown2, turns out Unknown1 is the stack count or 0, so I can use that, but Unknown2 appears to just return 0 under any conditions. I'm yet to find any use for it, after reading its value for items that are and aren't usable, stackable, changing ID, etc, but I will keep an eye on it to see if it changes at all. It does look to be returning correctly now, I'm getting a list of containers and each one has a list of items of the correct length for the container, as I'm passing the Container variable in to my getItems() function, to get the Container.Volume so I only need to read the relevant items (e.g no point trying to read 36 items for a corpse of 8 slots, when I can retrieve the volume and only read the 8.

    I'm not sure on the Self class, I know TibiaAPI has it, and there must be good reason behind it, but currently it fits nicely into the ReaderClass... If that class can support all memory reading functions I don't see why it shouldn't, I just can't find reason to split it up. On top of that, I'm not sure how the functions would call across classes. If you have a more in depth knowledge of it please let me know though, I don't mind the class being <2000 lines of code, since that's the limit I'm used to at work, it makes things slightly difficult but it's useful to be able to cram all functions in one place lol

    The primary concerns at the minute are going to be adding map reading, and making the entire library safer (adding exception handling to everything)... Map reading is going to take its toll on my brain though, given the complexity of it. After that's done, I'll be looking at implementing A* search algorithm and making a function like WalkTo(x, y, z) which will use arrow keys to walk to the SQM, then I need to look at mouse controls, and finding my way around the GUI.

  3. #13
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191
    The reasons for a player class are readability and the inheritance of the creature class.
    As things begin to grow, you'll realize it's not feasible to slap everything related to reading memory into one class.

  4. #14
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by Blaster_89 View Post
    The reasons for a player class are readability and the inheritance of the creature class.
    As things begin to grow, you'll realize it's not feasible to slap everything related to reading memory into one class.
    I sometimes think I'm far too ambitious... Then I realise, what the fuck, I'm amazing. I will add the player class this evening, need to take a break at the minute, just added the facilities to read the map and it doesn't work (probably due to a very simple mistake calculating the offsets or something of that nature).

    Thanks again guys <3

  5. #15
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191
    If you want an easy start reading the map, head over to this thread. Make sure you read and understand the article I mention in the beginning, it's very crucial.

  6. #16
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by ManInTheCave View Post
    The container and item structure are two things I've not read before, and after taking the offsets from the new TibiaAPI, I found it quite confusing that two of them are named Data and DataEx, so I named them Unknown1 and Unknown2, turns out Unknown1 is the stack count or 0, so I can use that, but Unknown2 appears to just return 0 under any conditions. I'm yet to find any use for it, after reading its value for items that are and aren't usable, stackable, changing ID, etc, but I will keep an eye on it to see if it changes at all. It does look to be returning correctly now, I'm getting a list of containers and each one has a list of items of the correct length for the container, as I'm passing the Container variable in to my getItems() function, to get the Container.Volume so I only need to read the relevant items (e.g no point trying to read 36 items for a corpse of 8 slots, when I can retrieve the volume and only read the 8.
    yes, Item structure is quite confusing and not so trivial to reverse. It's composed by 3 numbers (32-bit each) where the second is its count (apparently for splashes is its sprite index, for creatures is its id) and the third is its id (for creatures is 99).

    The first is a special case and in my opinion, a big fail of cipsoft in the sense that they waste a lot of memory due this.

    You only notice after watching tiles and messing around with items .dat property that this first number is a simple enum "HanglableState" where
    • 18 - means this item has the flag "IsHangable" and currently is hanging horizontally. Do not confuse with item having "IsHangableHorizontal" property.
    • 19 - means this item has the flag "IsHangable" and currently is hanging vertically. Do not confuse with item having "IsHangableVertical" property.
    • 0 - means simply not 18 and not 19


    Ex: Hang some of those skeletons on wall and look to this item in its respective tile. Also, some torches on wall has it.

    Code:
    enum HangableState
    {
        None = 0,
        Horizontal = 18,
        Vertical = 19
    }
    
    class Item
    {
        public HangableState HangableState;
        public int Count;
        public int Id;
    }
    Quote Originally Posted by ManInTheCave View Post
    I'm not sure on the Self class, I know TibiaAPI has it, and there must be good reason behind it, but currently it fits nicely into the ReaderClass... If that class can support all memory reading functions I don't see why it shouldn't, I just can't find reason to split it up. On top of that, I'm not sure how the functions would call across classes. If you have a more in depth knowledge of it please let me know though, I don't mind the class being <2000 lines of code, since that's the limit I'm used to at work, it makes things slightly difficult but it's useful to be able to cram all functions in one place lol
    Blaster explained well and moreover you're designing an API, it will be used for peoples and not only you, so everything need to be easy to reach/understand.

    Quote Originally Posted by ManInTheCave View Post
    The primary concerns at the minute are going to be adding map reading, and making the entire library safer (adding exception handling to everything)... Map reading is going to take its toll on my brain though, given the complexity of it.
    You should let tiles reading far later due its complexity. Why not Character List, Vip List?

    Quote Originally Posted by ManInTheCave View Post
    After that's done, I'll be looking at implementing A* search algorithm and making a function like WalkTo(x, y, z) which will use arrow keys to walk to the SQM, then I need to look at mouse controls, and finding my way around the GUI.
    A* is really amazing, but in my opinion you should do later, because cavebot-related are lasts steps to code. Why not attack, simple use items, or simple healing, ...?

  7. #17
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by Blaster_89 View Post
    If you want an easy start reading the map, head over to this thread. Make sure you read and understand the article I mention in the beginning, it's very crucial.
    I've got that thread bookmarked already >: ) lol I will go through it soon and of course credits will be posted if/as/when this reaches a releasable stage of development, same applies to TibiaAPI, I've got a list of all the tutorials and guides I've used, including a really good example of A* Search Algorithm, and several threads here :P Thanks!

    Quote Originally Posted by Blequi View Post
    yes, Item structure is quite confusing and not so trivial to reverse. It's composed by 3 numbers (32-bit each) where the second is its count (apparently for splashes is its sprite index, for creatures is its id) and the third is its id (for creatures is 99).

    The first is a special case and in my opinion, a big fail of cipsoft in the sense that they waste a lot of memory due this.

    You only notice after watching tiles and messing around with items .dat property that this first number is a simple enum "HanglableState" where
    • 18 - means this item has the flag "IsHangable" and currently is hanging horizontally. Do not confuse with item having "IsHangableHorizontal" property.
    • 19 - means this item has the flag "IsHangable" and currently is hanging vertically. Do not confuse with item having "IsHangableVertical" property.
    • 0 - means simply not 18 and not 19


    Ex: Hang some of those skeletons on wall and look to this item in its respective tile. Also, some torches on wall has it.

    Code:
    enum HangableState
    {
        None = 0,
        Horizontal = 18,
        Vertical = 19
    }
    
    class Item
    {
        public HangableState HangableState;
        public int Count;
        public int Id;
    }
    Blaster explained well and moreover you're designing an API, it will be used for peoples and not only you, so everything need to be easy to reach/understand.

    You should let tiles reading far later due its complexity. Why not Character List, Vip List?

    A* is really amazing, but in my opinion you should do later, because cavebot-related are lasts steps to code. Why not attack, simple use items, or simple healing, ...?
    That explains why I didn't get any value in the IsHangable/IsHanging property, I'll modify the code to show this soon. I've already implemented a healer, the next steps I hope to take are to complete the memory reading class, which does include Character list, VIP list, maps, and what not. I've already done BattleList, which I found quite simple compared to the containers and maps (primarily because the container & map structures are basically arrays which contain arrays.) I think my very next step will be to read hotkeys, and implement an automatic detection of spells into the hotkeys, so you can pass something like:

    sendHealRule(string spell = "", int itemid, int minhp, int maxhp, int mana)

    Then what it will do is find a hotkey which contains either the spell or itemid (depending on how you choose to submit the data), and return an instance of the HealRule object which can then be used to cycle through heal rules. The heal rule will still work, however, by passing sendButton("F1"). The actual way it will work is I'll add a function called getHotkey(int itemid, string spellwords) and it will return a hotkey keycode from the enumeration in the ControlWindow class, which can then be passed like so: sendButton(getHotkey(236)) or sendButton(getHotkey(0, "Exura Ico"). Something along those lines will hopefully make sense.

    I'm very eager to get started on A*, since heuristics are one of the reasons I enjoy programming at work, we use a lot of them for calculating print data (working in inkjet printing requires a shitload of in depth calculations). I intended to try get A* done this weekend, or at least the basics of it, but it looks like I've got too much to do before hand... We'll see how I get on anyway.

    Thanks again! More to come this evening

  8. #18
    Junior Member
    Join Date
    Jul 2009
    Posts
    25
    Ran in Visual Studio 2010 with .NET Framework 4.0.

    added to JAPI.dll the references and when I run the following error appears:

    Error 3 'JAPI.ReaderClass' does not contain a definition for 'getContainers' and no extension method 'getContainers' accepting a first argument of type 'JAPI.ReaderClass' could be found (are you missing a using directive or an assembly reference?)
    Error 7 'JAPI.ReaderClass' does not contain a definition for 'getMap' and no extension method 'getMap' accepting a first argument of type 'JAPI.ReaderClass' could be found (are you missing a using directive or an assembly reference?)
    Error 1 Cannot convert anonymous method to type 'System.Delegate' because it is not a delegate type
    Error 5 No overload for method 'BlGet' takes 2 arguments
    Error 2 The type name 'Container' does not exist in the type 'JAPI.Objects'
    Error 4 The type name 'Container' does not exist in the type 'JAPI.Objects'
    Error 6 The type name 'MapTile' does not exist in the type 'JAPI.Objects'
    Error 8 The type name 'MapTile' does not exist in the type 'JAPI.Objects'
    Last edited by campo486; 02-05-2013 at 06:57 PM.

  9. #19
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by campo486 View Post
    Ran in Visual Studio 2010 with .NET Framework 4.0.

    added to JAPI.dll the references and when I run the following error appears:

    Error 3 'JAPI.ReaderClass' does not contain a definition for 'getContainers' and no extension method 'getContainers' accepting a first argument of type 'JAPI.ReaderClass' could be found (are you missing a using directive or an assembly reference?)
    Error 7 'JAPI.ReaderClass' does not contain a definition for 'getMap' and no extension method 'getMap' accepting a first argument of type 'JAPI.ReaderClass' could be found (are you missing a using directive or an assembly reference?)
    Error 1 Cannot convert anonymous method to type 'System.Delegate' because it is not a delegate type
    Error 5 No overload for method 'BlGet' takes 2 arguments
    Error 2 The type name 'Container' does not exist in the type 'JAPI.Objects'
    Error 4 The type name 'Container' does not exist in the type 'JAPI.Objects'
    Error 6 The type name 'MapTile' does not exist in the type 'JAPI.Objects'
    Error 8 The type name 'MapTile' does not exist in the type 'JAPI.Objects'
    Try running in Visual Studio 2012 Express, for .NET 4.5, that's what it was written in.

    Also, are you declaring an instance of ReaderClass or trying to access it directly? It won't work if you try to access directly.
    Last edited by XtrmJash; 02-09-2013 at 09:21 PM.

  10. #20
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Just made an upload to the google code page, and it now has the latest version of the library available for download. The sources are now on rev 47, too, which includes all the map reading stuff ready to use. I'm currently working on A* Search Algorithm, so it may take me a few weeks before anything more is added (unless I get very bored and decide to use either a pre compiled path finder or use something in C++ instead of C#, or something like that...)

    I'll update the list of functions in the morning, but here are a few of the latest:

    MapReading.getMapSpeedFile(string fileName) fileName should actually be a path, and can include environment variables. Returns a Bitmap object which displays the speed of each tile on the minimap file.
    MapReading.getMapFile(string fileName) fileName should actually be a path, and can include environment variables. Returns a Bitmap object displaying the minimap as it is displayed in Tibia.
    MapReading.getMapTiles(string fileName) again fileName should be a path, and can use environment variables. This returns an array of MiniMapTile items, which includes coordinates, useful for pathfinding etc.
    ReaderClass.getMap() Returns an array of map tiles, which are the ones visible to the client. Useful for finding items like crates etc which might be blocking you, or just for item browsing.
    ReaderClass.getItems(int Volume, UInt32 AdrStart) Give it an amount of items to read, and the address at which they start, and you've got a list of items. Used for container reading.
    ReaderClass.getContainers() This will return a list of containers and the items within, in the form of an array of Objects.Container objects. Veri naijs.


    If you're looking to see something cool, check out the test applications "Map Graphical" tab, it will find your location in Tibia, and find the map file you're within the boundaries of, then display both the minimap image (as Tibia displays it) and a graphical representation of the speed at which you can travel over each tile.

    Enjoy & hopefully will have more soon!

Posting Permissions

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