Raised This Month: $51 Target: $400
 12% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-01-2020 , 19:56   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #21

I keep finding excuses to push non-1.0 versions.

Just like 0.17.1. Maintenance release and one new feature today.
  • TF2Econ_GetItemDefaultLoadoutSlot is now a thing, letting you get the default loadout slot for items that aren't normally compatible with a given class. Randomizer fans rejoice.
  • TF2Econ_TranslateAttributeNameToDefinitionInd ex gets a minor bugfix.
  • TF2Econ_GetItemSlot is renamed to TF2Econ_GetItemLoadoutSlot; the previous name now throws a compile-time deprecation warning. Friendly reminder that loadout slots cannot be used directly with GetPlayerWeaponSlot (prime example: the Spy's revolver).
    • If you want to get the weapon slot of an item, you can use my TF2 Utils project and call TF2Util_GetWeaponSlot on an existing weapon.
__________________
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; 11-01-2020 at 22:26.
nosoop is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-04-2020 , 20:33   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #22

One of the recent TF2 updates made the signature for KeyValues::GetString() match a different function on Windows. If one of the plugins you are running is using the TF2Econ_Get*DefinitionString set of natives, the gamedata in the latest release above was updated and should fix any crashes.
__________________
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; 11-04-2020 at 20:49.
nosoop is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-19-2020 , 15:08   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #23

The TF2ItemsInfo porting guide shows that "TF2II_ItemHasProperty() can be done with calls to TF2Econ_GetItemDefinitionString()"

What would that look like for these bool functions?
PHP Code:
TF2II_ItemCanBeStrange(itemindex)

TF2II_IsItemPaintable(itemindex
PC Gamer is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 12-19-2020 , 18:36   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #24

This could work:
Code:
char szPaintable[2];
if ( TF2Econ_GetItemDefinitionString( ITEM_INDEX_HERE, "capabilities/paintable", szPaintable, sizeof szPaintable, "0" ) && szPaintable[0] == '1' )
	// item is paintable
Not sure about TF2II_ItemCanBeStrange, it uses data/tf2itemsinfo.txt to read item qualities.

EDIT: There is also TFEconDataCompat.
__________________

Last edited by MAGNAT2645; 12-19-2020 at 18:42.
MAGNAT2645 is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-20-2020 , 03:07   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #25

Quote:
Originally Posted by MAGNAT2645 View Post
This could work:
Code:
char szPaintable[2];
if ( TF2Econ_GetItemDefinitionString( ITEM_INDEX_HERE, "capabilities/paintable", szPaintable, sizeof szPaintable, "0" ) && szPaintable[0] == '1' )
	// item is paintable
Thanks for the response! Unfortunately the example above caused a crash on plugin load without errorlog entry. I've reviewed the compatibility shim but there is no direct mapping for things like TF2II_ItemCanBeStrange or TF2II_ItemCanBeVintage or TF2II_IsItemPaintable.

If it helps... Accelerator crash dump: Crash ID: UBQ6-IFFU-JQ5R
PC Gamer is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 12-20-2020 , 05:55   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #26

Quote:
Originally Posted by PC Gamer View Post
Thanks for the response! Unfortunately the example above caused a crash on plugin load without errorlog entry. I've reviewed the compatibility shim but there is no direct mapping for things like TF2II_ItemCanBeStrange or TF2II_ItemCanBeVintage or TF2II_IsItemPaintable.
You'll need to update your gamedata - it was reported last month that the Windows signature for one of the functions used started also matching a different function.

Regarding strange / vintages, the schema doesn't report that particular information, so Econ Data has no way of knowing which items are available in which qualities.

You'll want to grab the data/tf2itemsinfo.txt file that MAGNAT2645 posted about and read the info from there (PRs welcome if someone would like to add support for reading that file in the compatibility shim it's been implemented in the shim, so you can build the latest version and things should work as expected).

TF2II_IsItemPaintable is supported in the compatibility shim; the logic is handled in tf_econ_data_compat/tf2itemsinfo.sp::GetItemProperties().
__________________
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; 12-20-2020 at 07:03.
nosoop is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-20-2020 , 18:44   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #27

Thanks nosoop! That's very helpful information.
PC Gamer is offline
Mr_panica
Senior Member
Join Date: Jan 2017
Location: Russia, Saint-Petersburg
Old 04-28-2021 , 15:37   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.17.1, 2020-11-01)
Reply With Quote #28

Can anyone write a function to issue any weapon using this plugin?
__________________
Sorry for my English.
Mr_panica is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-19-2021 , 21:09   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.18.1, 2021-11-18)
Reply With Quote #29

Can you illustrate a way to determine if a new unequipped cosmetic item will conflict with a specific currently equipped cosmetic item, and if so, remove the currently equipped item in conflict?

I thought maybe TF2Econ_GetItemEquipRegionGroupBits could help with that but I was unable to make it work.
PC Gamer is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 12-20-2021 , 04:04   Re: [TF2/CS:GO] Econ Data (supercedes TF2IDB, TF2ItemsInfo) (0.18.1, 2021-11-18)
Reply With Quote #30

Quote:
Originally Posted by PC Gamer View Post
Can you illustrate a way to determine if a new unequipped cosmetic item will conflict with a specific currently equipped cosmetic item, and if so, remove the currently equipped item in conflict?

I thought maybe TF2Econ_GetItemEquipRegionGroupBits could help with that but I was unable to make it work.
Close - you want TF2Econ_GetItemEquipRegionMask; group bits only indicates which equip regions the item is declared with.

For example:
  • The Essential Accessories will have the "sleeves" and "feet" group bits set, and those bits also will be set in their equip region mask. No additional bits are set since no other equip regions conflict with those.
  • The Mildly Disturbing Halloween Mask will have the "whole_head" group bit set, but will have the "whole_head", "hat", "face", and "glasses" bits set in their equip region mask, indicating that items with any of those bits set will conflict with the MDHM.

Here's what you need to do:

Code:
int equippedCosmetic = INVALID_ENT_REFERENCE; // TODO: get equipped cosmetic entity
int equippedItemDef = GetEntProp(equippedCosmetic, Prop_Send, "m_iItemDefinitionIndex");

int newItemDef = TF_ITEMDEF_DEFAULT; // TODO: get new cosmetic's item definition index
if (TF2Econ_GetItemEquipRegionMask(equippedItemDef) & TF2Econ_GetItemEquipRegionMask(newItemDef)) {
    // the result being non-zero means that the equip regions for these two item definitions overlap, so `equippedCosmetic` needs to be detached
}
__________________
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; 12-20-2021 at 04:25.
nosoop is offline
Reply



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 02:19.


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