Raised This Month: $32 Target: $400
 8% 

[TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.18.3, 2023-01-30)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
nosoop
Veteran Member
Join Date: Aug 2014
Plugin ID:
6476
Plugin Version:
0.18.3
Plugin Category:
Technical/Development
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    742 
    Plugin Description:
    Exposes natives to read properties from TF2's item definitions in-memory
    Old 03-17-2019 , 07:17   [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.18.3, 2023-01-30)
    Reply With Quote #1

    Description:
    Read TF2 item schema properties from game memory. Alternative to TF2ItemsInfo (only took 7 years for that mem-hacking version!) and TF2 Item DB.

    Looking for the CS:GO version? It's way over here.

    ConVars:
    • tfecondata_version: Version string. No touchy.
    Dependencies:
    • stocksoup is used to compile the shared plugin, using a few of its handle and memory-related stock functions. You don't need it unless you're interested in working on the library itself, or want to build from source. It's set up as a git submodule, so do a recursive clone to get the version the project is written against.
    Installation:
    Go to the releases page and get the following from the topmost release:
    • Copy tf_econ_data.smx to plugins/
    • Copy tf2.econ_data.txt to gamedata/
    • Copy tf_econ_data.inc to scripting/include/
    For plugin developers:
    Some example code is provided in the project README. The include file should be easy enough to read if you're familiar with how TF2 handles items; if there's anything that is unclear file an issue or post in the thread.

    I've also written up a list of equivalent natives between TF2II / TF2IDB and this library, for any developers that want to migrate.

    As this plugin is now able to match the feature set of the previous plugins, there is now a pre-alpha project that provides drop-in replacements for both TF2IDB and TF2ItemsInfo. If you're a developer that has plugins that depend on either, I'm sure others would appreciate any contributions to fill out the currently unimplemented natives.

    Important breaking changes / fixes for server operators running older versions:
    (This does not show feature additions; check the download link below or the include file link above for that.)
    • 0.18.1 Fixes the wrong value being read in TF2Econ_GetPaintKitDefinitionList, which led to out-of-bounds array accesses and crashes on Windows.
    • 0.17.1 Gamedata update; signatures were broken a recent game update used by TF2Econ_Get*DefinitionString, resulting in crashes on Windows.
    • 0.17.1 Fixes TF2Econ_TranslateAttributeNameToDefinitionInd ex returning a full 32-bit value instead of just the relevant 16 bits.
    • 0.16.6 Fixes item definition-related functions reading off a special "default" item definition.
    • 0.6.0 Deprecates TF2Econ_IsValidDefinitionIndex in favor of TF2Econ_IsValidItemDefinition. Both function names will continue to work, but this makes things consistent for when I eventually add TF2Econ_IsValidAttributeDefinition or something.
    • 0.5.1 Rectifies an issue in 0.5.0 where the SDKCall causes crashes due to nonexisting keys.

    Team Fortress 2: Source / Download

    CS:GO: Post
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

    Last edited by nosoop; 01-30-2023 at 17:43.
    nosoop is offline
    Benoist3012
    Veteran Member
    Join Date: Mar 2014
    Location: CWave::ForceFinish()
    Old 03-17-2019 , 08:10   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo)
    Reply With Quote #2

    Amazing!

    I started something similar as a SM extension but with your plugin out, I've no need to work on that

    Only thing to worry about is the gamedata, but I don't think the tf team is touching those functions anytime soon. Anyway great replacement for tf2ii & tf2idb thanks again.
    __________________
    Benoist3012 is offline
    nosoop
    Veteran Member
    Join Date: Aug 2014
    Old 03-18-2019 , 01:37   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo)
    Reply With Quote #3

    Quote:
    Originally Posted by Benoist3012 View Post
    Only thing to worry about is the gamedata, but I don't think the tf team is touching those functions anytime soon.
    Yeah; thinking about adding a few Linux-specific assertions to make sure the member offsets are correct (I'd assume that the member layout is the same on both platforms). Should probably add a few safeguards on unavailable SDKCalls as well.

    Otherwise, I'm not too worried about updates since I documented how to find the signatures / offsets to some extent; the bus factor should be greater than 1.

    Edit: I've written a basic porting guide for those that want to migrate plugins to this library from TF2ItemsInfo and TF2IDB. I'll get around to adding attribute support eventually, but for items you should be all set to migrate.

    Edit (2): 0.6.0 has been released. The only important change here is that a function was renamed. Plugins compiled against the older version will still work (the native is also mapped to the old function name), but I wanted to make this change while this plugin's still new.
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

    Last edited by nosoop; 03-18-2019 at 12:22.
    nosoop is offline
    404UserNotFound
    BANNED
    Join Date: Dec 2011
    Old 03-18-2019 , 18:08   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo)
    Reply With Quote #4

    Quote:
    Originally Posted by nosoop View Post
    Yeah; thinking about adding a few Linux-specific assertions to make sure the member offsets are correct (I'd assume that the member layout is the same on both platforms). Should probably add a few safeguards on unavailable SDKCalls as well.

    Otherwise, I'm not too worried about updates since I documented how to find the signatures / offsets to some extent; the bus factor should be greater than 1.

    Edit: I've written a basic porting guide for those that want to migrate plugins to this library from TF2ItemsInfo and TF2IDB. I'll get around to adding attribute support eventually, but for items you should be all set to migrate.

    Edit (2): 0.6.0 has been released. The only important change here is that a function was renamed. Plugins compiled against the older version will still work (the native is also mapped to the old function name), but I wanted to make this change while this plugin's still new.

    This thing's only been out for a day, I think it'd be safe to just scrap the old name entirely.
    404UserNotFound is offline
    nosoop
    Veteran Member
    Join Date: Aug 2014
    Old 03-21-2019 , 05:36   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo)
    Reply With Quote #5

    Quote:
    Originally Posted by 404UNF View Post
    This thing's only been out for a day, I think it'd be safe to just scrap the old name entirely.
    I like my backwards compatibility reeeee

    Anyways, 0.7.1 has been released with support to convert item slot names to indices and vice-versa.

    Considering what I just said about backwards compatibility, ironically enough, I do have to note that the slot values are not compatible with those in TF2IDB and TF2II. Those two plugins return values mapping approximately to the virtual CBaseCombatWeapon::GetSlot() function (which is what GetPlayerWeaponSlot() looks up), while TF2 itself has a slightly different mapping.

    I'll refer to the former as "weapon slots", and the latter as "loadout slots".

    Here is TF2IDB's list, and this is the current game-specific mapping for comparison (the indices go from 0 to 18 inclusive):

    Code:
    0: primary
    1: secondary
    2: melee
    3: utility
    4: building
    5: pda
    6: pda2
    7: head
    8: misc
    9: action
    11: taunt
    So, if you're porting from one of the two to this plugin, don't use the TF2ItemSlot enum values when checking the result of TF2Econ_GetItemSlot() -- convert between slot indices and names with TF2Econ_TranslateLoadoutSlotIndexToName() and TF2Econ_TranslateLoadoutSlotNameToIndex().

    If you want to access the entity in a specific loadout slot, it'd be preferable to use an SDKCall to CTFPlayer::GetEntityForLoadoutSlot() or use my maintained fork of Powerlord's TF2 Wearables API, which has a native to do just that.

    Otherwise, you may want to grab a variation of GetSlotByName and translate from loadout slot → name → weapon slot.
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

    Last edited by nosoop; 03-22-2019 at 00:34.
    nosoop is offline
    Drixevel
    AlliedModders Donor
    Join Date: Sep 2009
    Location: Somewhere headbangin'
    Old 03-21-2019 , 16:27   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.7.1, 2019-03-21)
    Reply With Quote #6

    I really appreciate this plugin a lot and the API it offers, thank you very much.
    Drixevel is offline
    Darthmule
    AlliedModders Donor
    Join Date: May 2012
    Location: Netherlands
    Old 03-25-2019 , 08:26   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.7.1, 2019-03-21)
    Reply With Quote #7

    thank you very much for this!
    Darthmule is offline
    FlaminSarge
    Veteran Member
    Join Date: Jul 2010
    Old 04-01-2019 , 04:47   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.7.1, 2019-03-21)
    Reply With Quote #8

    Nice work.
    (Compatibility layer when?)
    __________________
    Bread EOTL GunMettle Invasion Jungle Inferno will break everything. Don't even ask.

    All plugins: Randomizer/GiveWeapon, ModelManager, etc.
    Post in plugin threads with questions.
    Steam is for playing games.
    You will be fed to javalia otherwise.
    Psyduck likes replays.

    Last edited by FlaminSarge; 04-01-2019 at 04:47.
    FlaminSarge is offline
    nosoop
    Veteran Member
    Join Date: Aug 2014
    Old 04-04-2019 , 09:55   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.7.1, 2019-03-21)
    Reply With Quote #9

    Thanks, everyone!

    Quote:
    Originally Posted by Drixevel View Post
    the API it offers
    Personally, I really like how TF2Econ_GetItemList turned out; really nice to have a functional approach for that. I shouldn't be too surprised at how performant it is considering I use a similar amount of forward calls in another project, but I still am.

    The raw KeyValues and direct address getters are also handy to work around API limitations.

    Quote:
    Originally Posted by FlaminSarge View Post
    (Compatibility layer when?)
    Not against a separate plugin as a compatibility layer; main blocker at the moment is fleshing out the API. Library design is hard when I'm trying to keep the API clean (difficult to anticipate needs when it's stuff I'll rarely use myself, if ever).

    I'll probably hold off on native adapters for TF2ItemsInfo / TF2 Item DB until I've attained feature parity, though the port guide is up to date if someone wants to tackle that themselves.

    ----

    That said: 0.9.0 has been released with some basic attribute support. A bit more barebones than the item support. I have no clue what the use case is for reading attribute definitions (if any plugins even use that at all), so at the moment there are only the basic accessors in addition to reading static attribute definition / value pairs from item definitions.

    Let me know if there's any relevant features any of you would like to see added to attribute support (or other future additions).
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

    Last edited by nosoop; 04-04-2019 at 11:02.
    nosoop is offline
    Drixevel
    AlliedModders Donor
    Join Date: Sep 2009
    Location: Somewhere headbangin'
    Old 04-04-2019 , 15:42   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.7.1, 2019-03-21)
    Reply With Quote #10

    Quote:
    Originally Posted by nosoop View Post
    Thanks, everyone!



    Personally, I really like how TF2Econ_GetItemList turned out; really nice to have a functional approach for that. I shouldn't be too surprised at how performant it is considering I use a similar amount of forward calls in another project, but I still am.

    The raw KeyValues and direct address getters are also handy to work around API limitations.



    Not against a separate plugin as a compatibility layer; main blocker at the moment is fleshing out the API. Library design is hard when I'm trying to keep the API clean (difficult to anticipate needs when it's stuff I'll rarely use myself, if ever).

    I'll probably hold off on native adapters for TF2ItemsInfo / TF2 Item DB until I've attained feature parity, though the port guide is up to date if someone wants to tackle that themselves.

    ----

    That said: 0.9.0 has been released with some basic attribute support. A bit more barebones than the item support. I have no clue what the use case is for reading attribute definitions (if any plugins even use that at all), so at the moment there are only the basic accessors in addition to reading static attribute definition / value pairs from item definitions.

    Let me know if there's any relevant features any of you would like to see added to attribute support (or other future additions).
    I haven't messed with everything yet but do you know if there's a way to get a display name that can be used in menus and stuff from item definition indexes? I realized you could get decent display names if you use GetEntityClassname and print it into chat but I'm not sure how to access that, thanks homie.
    Drixevel is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 17:34.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode