[TF2] TF2Attributes (v1.7.2, 2022/09/18)
39 Attachment(s)
⚠️For latest fixes/gamedata/etc., see GitHub.⚠️
Update - 2022/09/18: Pulled in all changes from @nosoop's fork. The description line up there should be pretty self-explanatory. This basically offers a bunch of natives for setting, getting, and modifying attributes on any entity that has m_AttributeList (GetEntSendPropOffs(entity, "m_AttributeList") > 0). Available natives are all listed in the .inc file, so definitely go read that! It's redundant to copy all of them here, but just know that you're probably looking for: Code:
TF2Attrib_SetByName TF2Attrib_IsIntegerValue(iDefIndex) takes in an attribute definition index (as returned by TF2Attrib_GetDefIndex(Address:pAttrib)), and returns true if the attribute interpreted as an integer rather than as a float (items_game's definitions of this aren't accurate, so I hardcoded the native for the attributes that I found were stored as ints, such as "kill eater"). Let me know if the internal list needs updating. Any attribute index that returns true for TF2Attrib_IsIntegerValue should be used with a Float: tag or view_as<float>() rather than float() for TF2Attrib_SetByName, TF2Attrib_SetValue, and TF2Attrib_SetInitialValue, as in the following code block, if you want the number to match up to what appears/happens in game. Code:
int value = 20; Installation (SM1.10+): 1) Place tf2attributes.smx ("Get Plugin" for tf2attributes.sp) in the server's sourcemod plugins folder (normally "addons/sourcemod/plugins/"). 2) Place tf2.attributes.txt in the server's sourcemod gamedata folder (normally "addons/sourcemod/gamedata/"). 3) Write or install a plugin that uses these natives. If writing the plugin, you will need to #include <tf2attributes>, which means you will need to place tf2attributes.inc in the "include" folder of wherever you develop/compile SourceMod plugins. tf2attributes_example.sp is an example plugin that offers several root-level admin commands to test out the various natives. You can ignore it if you want to. Cvars: tf2attributes_version - do not touch. This registers a plugin library (via RegPluginLibrary) named "tf2attributes". Changelog (outdated, see GitHub below): Code:
07/02/2015 - v1.2.1 Known Weirdness: I would not recommend using TF2Attrib_SetDefIndex() at all. It doesn't behave as you'd expect it to, and while it does set the definition index of a given attribute, the game still treats it as the original attribute, though when it goes to look up the attribute by name it uses the 'new name' (as if it were actually the new attribute index). This messes up calls to GetByName and SetByName, so just... don't do it. HOWEVER... if you call TF2Attrib_ClearCache() after SetDefIndex, the game will properly update that attribute to be the new attribute... I think... ... Did I forget anything? asherkin gets all my cookies Previous plugin views - 60760 - up to 2022/09/18 Download: GitHub Source: GitHub |
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Reserved for things.
|
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Also, heads up, I'm already writing a replacement for the tf2items_manager/tf2items config using this. If anybody else decides to undertake that task as well, let me know.
|
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Whoo-hoo! I've been waiting for this for a while. Time to develop!
|
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Sweet.
But too late~ |
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Just to be clear, which entities will this work on?
I'm thinking players, weapons, hats, miscs, and most action items (except Dueling Minigames, Secret Saxtons, and Piles o' Gifts). |
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Quote:
This modifies the actual entities, not the item server info, so items that pull from the item server (which I presume are gifts, duels, etc) wouldn't be affected, presumably. Brb writing Randomizer MvM and UpgradeAnytime. I'll also get to work on changing all the code in VSH to use this instead of TF2Items. |
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
I updated the .inc file on March 10th, 2013 to not cause tag mismatches whenever you tried to use the return of SetByName properly. Woops. Also updated the tagging on Remove/RemoveAll.
|
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
Quote:
EDIT: Actually, after some testing, it does it rarely. |
Re: [TF2] TF2Attributes (v1.0.0, 03/08/2013)
The thing was, "attrib" returned by Get and Set are Address: tagged, and I bet you're forgetting that tag. Initially, I had forgotten the tag on Set, and the bool: tags on Remove/RemoveAll. Make sure you're tagging the variables you store your returns in properly.
|
All times are GMT -4. The time now is 18:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.