Releases: nosoop/tf2attributes
1.7.1.1
1.7.1
69 commits… nice…
Changed
- Further improvements to overall system stability, system security and other minor adjustments have been made to enhance the user's experience.
Fixed
- Resolves an issue where
TF2Attrib_GetSOCAttribs
was unnecessarily dereferencing to access the contents of a zero-lengthCUtlVector
.It looks like this was causing crashes under certain circumstances.probably not but 🤷
String attributes preview
This prerelease adds support for string attributes! This one was a doozy.
Nobody mentioned any crashes on it, so consider this a stable release.
Added
- Native
TF2Attrib_SetFromStringValue
lets you provide an attribute name and value as a string, then the game just Does The Right Thing™ and parses it into a runtime attribute with the proper type. This uses the same functionality that the game uses when reading attribute key / value pairs from the schema, so it should work with most attributes you throw at it.- Of course, you still can't network custom strings to the client (and they are likely to crash if you use an attribute they attempt to read), so this is only useful for attributes accessed on the server (but! you can inject custom attribute classes into the server's in-memory schema now, so you can use strings for those, too).
- Native
TF2Attrib_HookValueString
, which behaves similar to the otherTF2Attrib_HookValue*
natives — it takes advantage of the game's caching system and takes an attribute class instead of a specific attribute name. You can get the value of an attribute string this way. - Native
TF2Attrib_UnsafeGetStringValue
, which takes a raw attribute value for a string attribute (specifically, an address to aCAttribute_String
instance) and reads out the containing string. - An internal heap-tracking system that manages heap-allocated runtime attributes. The game doesn't manage such things itself (it only does this for GC and static attributes).
- A caching layer for the name / attribute mapping. The precedent was set with the heap-tracking functionality. I was going to commit this separately, but I already pushed more code on top and it's a pain to rebase.
Better accessors, pt. 1
Couple of new convenience functions to use. Huzzah.
Added
- Natives
TF2Attrib_HookValueFloat
andTF2Attrib_HookValueInt
, which transforms an input value based on attributes matching the specified attribute class on a given entity (player or weapon).- If you're familiar with the third-party TF2 projects, this implements the
CALL_ATTRIB_HOOK_FLOAT
andCALL_ATTRIB_HOOK_INT
macros, orCAttributeManager::AttribHookValue<>
functions. - If you're not familiar with it, this means you don't have to collect all the attributes from runtime or item server that share the same functionality (e.g., "damage penalty", "damage bonus", "CARD: damage bonus", etc.) and determine how they stack — the game handles all of that for you.
- If you're familiar with the third-party TF2 projects, this implements the
Changed
- Error messages have been reworded to match SourceMod's style.
- Native functions now use
const char[]
instead of unconstedchar[]
. This allows the use of passed-inconst char[]
arguments from functions up the call chain.
Experiment, B-Side
I haven't heard of any major bugs, so this is just a "completeness" update.
Added
- New native
TF2Attrib_RemoveCustomPlayerAttribute
, which removes an attribute previously added viaTF2Attrib_AddCustomPlayerAttribute
.
Fixed
- Fixed incorrect key
amc
, which is supposed to bemac
. Whoops.
Experiment Part A
Experimental branch for new functionality. Requires bundled gamedata.
Added
- New native
TF2Attrib_IsValidAttributeName
, which returns a boolean value indicating if the game has an attribute with that name. - New native
TF2Attrib_AddCustomPlayerAttribute
, which adds an attribute to a player for a possibly limited duration. Internally, it's used on the Dalokohs bite effect, thetrigger_add_or_remove_tf_player_attributes
brush entity, and as an animation event (though I'm not sure when the game uses the latter — for anyone that understands what that means, see if you can find a reference toapparently this is only used for the all-class Yeti taunt to force invisibility or something. go figure).AE_TAUNT_ADD_ATTRIBUTE
Changed
- Relative to the upstream branch, the
IsValidAddress
check has been changed to a runtimeAssertValidAddress
that will throw an exception if given a specific form of invalid value. The plugin's previous behavior was to silently handle the error in some way. The goal is to discover cases that previously silently failed so they can be appropriately handled. - Native
TF2Attrib_IsIntegerValue
now pulls the information from the game's attribute definition (thestored_as_integer
key initems_game.txt
). Not quite sure if there was some specific reason why a lookup table was used; I'll probably get DM'd bysenpaiSarge with a reason if henotices mesees this release note.
Massive code refactor
Rewrote the plugin to be slightly more understandable and DRY. (And formatted to my liking.)
Needs regression testing.