Porting TF2IDB and TF2II plugins to TFEconData - nosoop/SM-TFEconData GitHub Wiki
This entry is up-to-date as of version 0.17.1 of the plugin. Newer versions may have added natives that I forgot to add here.
These are the closest available equivalents for both TF2II and TF2IDB. The following terminology is used:
- "maps directly" indicates the function name can be replaced and everything should work as expected provided there are no additional conditions that need to be met (listed in the same bullet point)
- "can be done" indicates that a similar native exists, so you should be able to get the same functionality with some rewriting
- "has no equivalent" indicates that TF2 Econ Data isn't capable of that functionality (yet!)
Additionally, there is now a compatibility shim whose purpose is to accurately respond to TF2II and TF2IDB native calls while using Econ Data as the data source.
TF2ItemsInfo to TFEconData
TF2II_IsItemSchemaPrecached()
maps directly totrue
TF2II_IsValidItemID()
maps directly toTF2Econ_IsValidItemDefinition()
TF2II_GetItemName()
maps directly toTF2Econ_GetItemName()
TF2II_ItemHasProperty()
can be done with calls toTF2Econ_GetItemDefinitionString()
TF2II_GetItemClass()
maps directly toTF2Econ_GetItemClassName()
TF2II_GetListedItemSlot()
maps partially toTF2Econ_GetItemLoadoutSlot()
, with the following restrictions:- The player class must be specified, and
-1
is the return value for invalid class / slot combinations. UseTF2Econ_GetItemDefaultLoadoutSlot()
if you only care about the default slot. - See notes about loadout slots.
TF2II_GetItemSlot()
maps thetf_weapon_revolver
item class to primary instead of secondary.
- The player class must be specified, and
TF2II_GetListedItemSlotName()
can be done withTF2Econ_GetItemDefinitionString(int defindex, "item_slot", ...)
, or callingTF2Econ_TranslateLoadoutSlotIndexToName()
on the result ofTF2Econ_GetItem*LoadoutSlot()
TF2II_GetItemSlotName()
mapstf_weapon_revolver
entities toprimary
instead ofsecondary
.
TF2II_IsItemUsedByClass()
can be done by checking ifTF2Econ_GetItemLoadoutSlot()
returns -1 for the given player class.TF2II_GetItemMinLevel()
andTF2II_GetItemMaxLevel()
can be done by passing in integer variables by-ref toTF2Econ_GetItemLevelRange()
TF2II_GetItemQuality()
maps directly toTF2Econ_GetItemQuality()
TF2II_GetItemQualityName()
can be done by callingTF2Econ_GetQualityName()
on the quality returned fromTF2Econ_GetItemQuality()
.TF2II_GetItemNumAttributes()
can be done by getting the length of theArrayList
returned fromTF2Econ_GetItemStaticAttributes()
.TF2II_GetItemAttributeName()
can be done by getting the attribute ID from theArrayList
returned fromTF2Econ_GetItemStaticAttributes()
, callingTF2Econ_GetAttributeName()
to get the name.TF2II_GetItemAttributeID()
can be done by getting the attribute ID from theArrayList
returned fromTF2Econ_GetItemStaticAttributes()
.TF2II_GetItemAttributeValue()
can be done by getting the attribute value fromTF2Econ_GetItemStaticAttributes()
. This returns a raw 32-bit value; if the attribute is a string / vector you'll probably be better off callingTF2Econ_GetItemDefinitionString(defindex, "static_attrs/${attr}", ...)
with the attribute name.TF2II_GetItemAttributes()
cab be done withTF2Econ_GetItemStaticAttributes()
. I have no idea how theirArrayList
is laid out, though.TF2II_GetToolType()
can be done withTF2Econ_GetItemDefinitionString(defindex, "tool/type", ...)
TF2II_ItemHolidayRestriction()
can be done withTF2Econ_GetItemDefinitionString(defindex, "holiday_restriction", ...)
and checking the string for your holidayTF2II_GetItemEquipRegions()
can be done by extracting the group names fromTF2Econ_GetItemEquipRegionGroupBits
throughTF2Econ_GetEquipRegionGroups
.TF2II_IsValidAttribID()
maps directly toTF2Econ_IsValidAttributeDefinition()
TF2II_GetAttribName()
maps directly toTF2Econ_GetAttributeName()
TF2II_GetAttribClass()
maps directly toTF2Econ_GetAttributeClassName()
TF2II_GetAttribDispName()
is deprecated — the game doesn't useattribute_name
at all.TF2II_GetAttribMinValue()
is deprecated — the game doesn't usemin_value
at all.TF2II_GetAttribMaxValue()
is deprecated — the game doesn't usemax_value
at all.TF2II_GetAttribGroup()
is deprecated. I have no idea what it originally was.TF2II_GetAttribDescrString()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "description_string", ...)
TF2II_GetAttribDescrFormat()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "description_format", ...)
TF2II_HiddenAttrib()
maps directly toTF2Econ_IsAttributeHidden()
TF2II_GetAttribEffectType()
can be done by callingTF2Econ_GetAttributeDefinitionString(defindex, "effect_type", ...)
and mapping the results to the appropriate numbers.TF2II_AttribStoredAsInteger()
maps directly toTF2Econ_IsAttributeStoredAsInteger()
TF2II_GetItemKeyValues()
has no equivalent, but if you know the key(s) you're looking for you can useTF2Econ_GetItemDefinitionString()
TF2II_GetItemKey()
can be done by runningStringToInt
on the output ofTF2Econ_GetItemDefinitionString()
TF2II_GetItemKeyFloat()
can be done by runningStringToFloat
on the output ofTF2Econ_GetItemDefinitionString()
TF2II_GetItemKeyString()
maps directly toTF2Econ_GetItemDefinitionString()
(with an optional default value as an additional argument)TF2II_GetAttribKeyValues()
has no equivalent, but if you know the key(s) you're looking for you can useTF2Econ_GetAttributeDefinitionString()
TF2II_GetAttribKey()
can be done by runningStringToInt
on the output ofTF2Econ_GetAttributeDefinitionString()
TF2II_GetAttribKeyFloat()
can be done by runningStringToFloat
on the output ofTF2Econ_GetAttributeDefinitionString()
TF2II_GetAttribKeyString()
maps directly toTF2Econ_GetAttributeDefinitionString()
(with an optional default value as an additional argument)TF2II_IsConflictRegions()
can be done byand
-ing together bits from the appropriate regions fromTF2Econ_GetEquipRegionMask
.TF2II_GetQualityByName()
maps directly toTF2Econ_TranslateQualityNameToValue()
TF2II_GetQualityName()
maps directly toTF2Econ_GetQualityName()
TF2II_GetAttributeIDByName()
maps directly toTF2Econ_TranslateAttributeNameToDefinitionIndex()
TF2II_GetAttributeNameByID()
maps directly toTF2Econ_GetAttributeName()
TF2II_FindItems()
can be done withTF2Econ_GetItemList()
and a user-defined function to filter the resultsTF2II_ListAttachableEffects()
andTF2II_ListEffects()
can be done withTF2Econ_GetParticleAttributeList()
. Note that this only seems to exclude non-Unusual cosmetic effects andother_particles
; no special handling for killstreak glows and weapon effects are available in Econ Data.TF2II_GetItemLevelByID()
can be done by callingGetRandomInt
after getting the level range withTF2Econ_GetItemLevelRange()
TF2II_GetQualityColor()
has no equivalent; it is a stock function with hardcoded color values.TF2II_GetSlotByName()
maps directly toTF2Econ_TranslateLoadoutSlotNameToIndex()
, though you will need to see notes about loadout slots.
TF2IDB to TFEconData
TF2IDB_IsValidItemID()
maps directly toTF2Econ_IsValidItemDefinition()
TF2IDB_GetItemName()
maps directly toTF2Econ_GetItemName()
TF2IDB_GetItemClass()
maps directly toTF2Econ_GetItemClassName()
TF2IDB_GetItemSlotName()
can be done withTF2Econ_GetItemDefinitionString(int defindex, "item_slot", ...)
, or callingTF2Econ_TranslateLoadoutSlotIndexToName()
on the result ofTF2Econ_GetItem*LoadoutSlot()
; this depends on if you want the class-specific or default class slotTF2IDB_GetItemSlot()
maps directly toTF2Econ_GetItem*LoadoutSlot()
, with the following restrictions.- The player class must be specified, and
-1
is the return value for invalid class / slot combinations. UseTF2Econ_GetItemDefaultLoadoutSlot()
if you only care about the default slot. - See notes about loadout slots.
- The player class must be specified, and
TF2IDB_GetItemQuality()
maps directly toTF2Econ_GetItemQuality()
TF2IDB_GetItemQualityName()
can be done by callingTF2Econ_GetQualityName()
on the quality returned fromTF2Econ_GetItemQuality()
.TF2IDB_GetItemLevels()
maps directly toTF2Econ_GetItemLevelRange()
TF2IDB_GetItemAttributes()
can be done by translating the output ofTF2Econ_GetItemStaticAttributes()
from a key / valur pair array into separate keys / values arrays.TF2IDB_GetItemEquipRegions()
can be done by extracting the group names fromTF2Econ_GetItemEquipRegionGroupBits()
throughTF2Econ_GetEquipRegionGroups()
.TF2IDB_DoRegionsConflict()
can be done byand
-ing together bits from the appropriate regions fromTF2Econ_GetEquipRegionMask()
.TF2IDB_ListParticles()
can be done withTF2Econ_GetParticleAttributeList()
and removing the values corresponding tostamp_spin
anddrg_pipe_smoke
.TF2IDB_FindItemCustom()
can be done withTF2Econ_GetItemList()
for items; instead of writing an SQL query you pass in a filter function and use the other available natives to restrict your selectionTF2IDB_ItemHasAttribute()
can be done by callingTF2Econ_GetItemStaticAttributes()
and checking for the attribute ID in the first blockTF2IDB_UsedByClasses()
can be done by iterating overTFClassType
and checking the result ofTF2Econ_GetItemLoadoutSlot()
TF2IDB_IsValidAttributeID()
maps directly toTF2Econ_IsValidAttributeDefinition()
TF2IDB_GetAttributeName()
maps directly toTF2Econ_GetAttributeName()
TF2IDB_GetAttributeClass()
maps directly toTF2Econ_GetAttributeClassName()
TF2IDB_GetAttributeType()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "attribute_type", ...)
TF2IDB_GetAttributeDescString()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "description_string", ...)
TF2IDB_GetAttributeDescFormat()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "description_format", ...)
TF2IDB_GetAttributeEffectType()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "effect_type", ...)
TF2IDB_GetAttributeArmoryDesc()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "armory_desc", ...)
TF2IDB_GetAttributeItemTag()
can be done withTF2Econ_GetAttributeDefinitionString(defindex, "apply_tag_to_item_definition", ...)
TF2IDB_GetAttributeProperties()
can be done by parsing out the appropriate data.TF2IDB_GetQualityName()
maps directly toTF2Econ_GetQualityName()
TF2IDB_GetQualityByName()
maps directly toTF2Econ_TranslateQualityNameToValue()
TF2IDB_CustomQuery()
has no equivalent; determine your use case and use alternative natives.- For getting a list of items, use
TF2Econ_GetItemList()
. - You may also want to use the compatibility shim, which attempts to generate a compatible SQLite database and subsequently supports arbitrary queries.
- For getting a list of items, use
Notes about loadout slots
The results of TF2IDB_GetItemSlot()
and TF2II_GetItemSlot()
are not equivalent to the result of TF2Econ_GetItemLoadoutSlot()
.
The former matches what the weapon shows up as in GetPlayerWeaponSlot()
(which I will refer to as "weapon slots"); this is used to switch weapons during gameplay. The latter uses the TF2-specific slot indices (which are called "loadout slots" internally); this is used in the player inventory system.
You'll have to do one of the following if you're porting a plugin that used TF2IDB_GetItemSlot()
/ TF2II_GetItemSlot()
along with GetPlayerWeaponSlot()
:
- Use
TF2Util_GetPlayerLoadoutEntity()
from TF2 Utils instead ofGetPlayerWeaponSlot()
. This will require you to consistently use loadout slots.- This does not work if the item is normally incompatible with the class (such as Randomizer).
- This was previously
TF2_GetPlayerLoadoutSlot()
from the TF2 Wearables API, but TF2 Utils is a more complete package of functions.
- Use
TF2Util_GetWeaponSlot()
from TF2 Utils to consistently use weapon slots.- This requires an actual spawned entity, and it only works for weapons; it cannot be used for wearables that can be equipped in weapon loadout slots such shields or boots.
- Use
TF2Econ_TranslateLoadoutSlotIndexToName()
andTF2Econ_TranslateLoadoutSlotNameToIndex()
and maintain your own internal mapping of the slots.