FlaminSarge / tf2attributes

TF2Attributes SourceMod plugin
49 stars 43 forks source link

Add CustomPlayerAttribute natives #38

Closed nosoop closed 2 years ago

nosoop commented 4 years ago

The other thing from my upstream that isn't massive refactoring work.

Allows SourceMod plugins to add attributes by definition name to the player, with an optional duration. Doesn't do error checking on invalid attribute names.

// Adds 50.0 max health for 30 seconds (what the Dalokoh's does internally)
TF2Attrib_AddCustomPlayerAttribute(client, "hidden maxhealth non buffed", 50.0, 30.0);
FlaminSarge commented 4 years ago

As with string attributes, the only reason I didn't put this in back then was because anything you could do with this you can just do normally with SM stuff. Is that still the case? (Going to merge this anyways just wondering).

nosoop commented 4 years ago

I don't believe there's anything new in that regard; the main thing is letting the engine handle attribute expiry instead of setting it up SP-side (on the consuming plugin) with all sorts of boilerplate code.

That said I didn't crack open the disassembly for it until now to discover that it's a plain old runtime attribute like everything else, custom expiry handling aside.

re: string attributes, no change for the most part, though the ability to read names and descriptions off of CEIVs would be somewhat nice for completeness' sake. They're still not networked to the client.

aside: on the attribute setting side of things, being able to parse key/value string pairs into attributes (by initializing the attribute_data_union_t) would make adding every attribute possible without additional kludges (including the few string attributes that work and I think the ones that get parsed into integers), but getting the gamedata for that's been a load of trouble.

nosoop commented 2 years ago

Resolved with 69dba726f455f6a15015505256e2690080ad924f.