forked from FlaminSarge/tf2attributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tf2attributes.inc
303 lines (276 loc) · 11.2 KB
/
tf2attributes.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#if defined _tf2attributes_included
#endinput
#endif
#define _tf2attributes_included
/**
* Sets an attribute's value on an entity, adding it if it isn't on the entity.
*
* @param iEntity Entity index to set the attribute on. Must have m_AttributeList.
* @param strAttrib Name of the attribute, as from the "name" key in items_game.
* @param flValue Value to set the attribute to
*
* @return True if the attribute was added successfully, false if entity does not have m_AttributeList.
* @error Invalid entity index or attribute name passed.
*/
native bool TF2Attrib_SetByName(int iEntity, char[] strAttrib, float flValue);
/**
* Sets an attribute's value on an entity, adding it if it isn't on the entity.
*
* @param iEntity Entity index to set the attribute on. Must have m_AttributeList.
* @param iDefIndex Definition index of the attribute, as from the number on the attribute entry in items_game.
* @param flValue Value to set the attribute to
*
* @return True if the attribute was added successfully, false if entity does not have m_AttributeList.
* @error Invalid entity index or attribute name passed.
*/
native bool TF2Attrib_SetByDefIndex(int iEntity, int iDefIndex, float flValue);
/**
* Returns the address of an attribute on an entity.
*
* @param iEntity Entity index to get attribute from. Must have m_AttributeList.
* @param strAttrib Name of the attribute, as from the "name" key in items_game.
*
* @return Address of the attribute on the entity, or Address_Null if the attribute does not exist on the entity.
* @error Invalid entity index or attribute name passed.
*/
native Address TF2Attrib_GetByName(int iEntity, char[] strAttrib);
/**
* Returns the address of an attribute (by attribute index) on an entity.
*
* @param iEntity Entity index to get attribute from. Must have m_AttributeList.
* @param iDefIndex Definition index of the attribute, as from the number on the attribute entry in items_game.
*
* @return Address of the attribute on the entity, or Address_Null if the attribute does not exist on the entity.
* @error Invalid entity index or attribute index passed.
*/
native Address TF2Attrib_GetByDefIndex(int iEntity, int iDefIndex);
/**
* Removes an attribute from an entity.
*
* @param iEntity Entity index to remove attribute from. Must have m_AttributeList.
* @param strAttrib Name of the attribute, as from the "name" key in items_game.
*
* @return True if the SDKCall was made, false if entity had invalid address or m_AttributeList missing.
* @error Invalid entity index or attribute name passed.
*/
native bool TF2Attrib_RemoveByName(int iEntity, char[] strAttrib);
/**
* Removes an attribute from an entity.
*
* @param iEntity Entity index to remove attribute from. Must have m_AttributeList.
* @param iDefIndex Definition index of the attribute, as from the number on the attribute entry in items_game.
*
* @return True if the SDKCall was made, false if entity had invalid address or m_AttributeList missing.
* @error Invalid entity index or attribute index passed.
*/
native bool TF2Attrib_RemoveByDefIndex(int iEntity, int iDefIndex);
/**
* Removes all attributes from an entity.
*
* @param iEntity Entity index to remove attribute from. Must have m_AttributeList.
*
* @return True if the SDKCall was made, false if entity had invalid address or m_AttributeList missing.
* @error Invalid entity index passed.
*/
native bool TF2Attrib_RemoveAll(int iEntity);
/**
* Clears and presumably rebuilds the attribute cache for an entity, 'refreshing' attributes.
* Call this after making changes to an attribute with any of the TF2Attrib_Set*(Address pAttrib, arg) natives below.
* You may also need to call this on the entity's m_hOwnerEntity if it is a weapon or wearable.
* You do NOT need to call this after calls to TF2Attrib_SetByName, TF2Attrib_Remove, and TF2Attrib_RemoveAll.
*
* @param iEntity Entity index to remove attribute from. Must have m_AttributeList.
*
* @return True if the SDKCall was made, false if entity had invalid address or m_AttributeList missing.
* @error Invalid entity index passed.
*/
native bool TF2Attrib_ClearCache(int iEntity);
/**
* Sets the value of m_iAttributeDefinitionIndex (the attribute ID) on an attribute.
* Warning, this changes what GetByName/ID and SetByName 'see' as the name of the attribute,
* but will only change attribute's effects if TF2Attrib_ClearCache is called on the entity with the attribute after.
*
* @param pAttrib Address of the attribute.
* @param iDefIndex Value to set m_iAttributeDefinitionIndex to.
*
* @noreturn
*/
native void TF2Attrib_SetDefIndex(Address pAttrib, int iDefIndex);
/**
* Returns the value of m_iAttributeDefinitionIndex (the attribute ID) on an attribute.
*
* @param pAttrib Address of the attribute.
*
* @return The integer value of m_iAttributeDefinitionIndex on the attribute.
*/
native int TF2Attrib_GetDefIndex(Address pAttrib);
/**
* Sets the value of m_flValue on an attribute.
*
* @param pAttrib Address of the attribute.
* @param flValue Value to set m_flValue to.
*
* @noreturn
*/
native void TF2Attrib_SetValue(Address pAttrib, float flValue);
/**
* Returns the value of m_flValue on an attribute.
*
* @param pAttrib Address of the attribute.
*
* @return The floating point value of m_flValue on the attribute.
*/
native float TF2Attrib_GetValue(Address pAttrib);
/**
* Sets the value of m_nRefundableCurrency on an attribute.
*
* @param pAttrib Address of the attribute.
* @param nCurrency Value to set m_nRefundableCurrency to.
*
* @noreturn
*/
native void TF2Attrib_SetRefundableCurrency(Address pAttrib, int nCurrency);
/**
* Returns the value of m_nRefundableCurrency on an attribute.
*
* @param pAttrib Address of the attribute.
*
* @return The (unsigned) integer value of m_nRefundableCurrency on the attribute.
*/
native int TF2Attrib_GetRefundableCurrency(Address pAttrib);
/**
* Returns an array containing the attributes (as indices) present on an entity.
*
* @param iEntity Entity index to get attribute list from. Must have m_AttributeList.
* @param iDefIndices Array (max size 16) of attribute definition indices found on the entity.
*
* @return The number of attributes found on the entity's attribute list, or -1 if some error happened.
* @error Invalid entity index passed.
*/
native int TF2Attrib_ListDefIndices(int iEntity, int[] iDefIndices);
/**
* Returns arrays containing the static attributes and their values present on an item definition.
*
* @param iItemDefIndex Item definition index (e.g. 7 for Shovel) to get static attribute list from.
* @param iAttribIndices Array (max size 16) of attribute definition indices found on the item definition.
* @param flAttribValues Array (max size 16) of attribute values found on the item definition, corresponding to the indices.
*
* @return The number of attributes found on the item definition's static attribute list, or -1 if no schema or item definition found.
* @error Gamedata for this function failed to load.
*/
native int TF2Attrib_GetStaticAttribs(int iItemDefIndex, int[] iAttribIndices, float[] flAttribValues);
/**
* Returns arrays containing the item server (SOC) attributes and their values present on an item definition.
*
* @param iEntity Entity index to get the item server attribute list from.
* @param iAttribIndices Array (max size 16) of attribute definition indices found.
* @param flAttribValues Array (max size 16) of attribute values found, corresponding to the indices.
*
* @return The number of attributes found on the item's SOC attribute list, or -1 if some error happened.
* @error Invalid entity index passed or gamedata for this function failed to load.
*/
native int TF2Attrib_GetSOCAttribs(int iEntity, int[] iAttribIndices, float[] flAttribValues);
/**
* Gets whether an attribute is stored as an integer or as a float.
* Use TF2Attrib_SetValue(attribute, view_as<float>(intValue)) on attributes that store values as ints
* to avoid compiler tag mismatch warnings.
*
* @param iDefIndex Index of the attribute (as returned by TF2Attrib_GetDefIndex()).
*
* @return True if attribute value is supposed to be an int, false if float.
*/
native bool TF2Attrib_IsIntegerValue(int iDefIndex);
/**
* Gets whether the plugin loaded without ANY errors.
* For the purpose of allowing dependencies to ignore the plugin if this returns false.
* Check in OnAllPluginsLoaded() or something. I dunno.
*
* @return True if no errors while loading, false otherwise.
*/
native bool TF2Attrib_IsReady();
public SharedPlugin __pl_tf2attributes =
{
name = "tf2attributes",
file = "tf2attributes.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_tf2attributes_SetNTVOptional()
{
MarkNativeAsOptional("TF2Attrib_SetByName");
MarkNativeAsOptional("TF2Attrib_SetByDefIndex");
MarkNativeAsOptional("TF2Attrib_GetByName");
MarkNativeAsOptional("TF2Attrib_GetByDefIndex");
MarkNativeAsOptional("TF2Attrib_RemoveByName");
MarkNativeAsOptional("TF2Attrib_RemoveByDefIndex");
MarkNativeAsOptional("TF2Attrib_RemoveAll");
MarkNativeAsOptional("TF2Attrib_ClearCache");
MarkNativeAsOptional("TF2Attrib_SetDefIndex");
MarkNativeAsOptional("TF2Attrib_GetDefIndex");
MarkNativeAsOptional("TF2Attrib_SetValue");
MarkNativeAsOptional("TF2Attrib_GetValue");
MarkNativeAsOptional("TF2Attrib_SetRefundableCurrency");
MarkNativeAsOptional("TF2Attrib_GetRefundableCurrency");
MarkNativeAsOptional("TF2Attrib_ListDefIndices");
MarkNativeAsOptional("TF2Attrib_GetStaticAttribs");
MarkNativeAsOptional("TF2Attrib_GetSOCAttribs");
MarkNativeAsOptional("TF2Attrib_ListDefIndices");
MarkNativeAsOptional("TF2Attrib_IsIntegerValue");
MarkNativeAsOptional("TF2Attrib_IsReady");
MarkNativeAsOptional("TF2Attrib_SetInitialValue");
MarkNativeAsOptional("TF2Attrib_GetInitialValue");
MarkNativeAsOptional("TF2Attrib_SetIsSetBonus");
MarkNativeAsOptional("TF2Attrib_GetIsSetBonus");
}
#endif
//OLD things lie here
//flInitialValue and bSetBonus don't exist anymore
/**
* Sets the value of m_flInitialValue on an attribute.
*
* @param pAttrib Address of the attribute.
* @param flValue Value to set m_flInitialValue to.
*
* @noreturn
*/
//native TF2Attrib_SetInitialValue(Address pAttrib, float flValue);
/**
* Returns the value of m_flInitialValue on an attribute.
*
* @param pAttrib Address of the attribute.
*
* @return The floating point value of m_flInitialValue on the attribute.
*/
//native float TF2Attrib_GetInitialValue(Address pAttrib);
/**
* Sets the boolean value of m_bSetBonus on an attribute.
*
* @param pAttrib Address of the attribute.
* @param bSetBonus Value to set m_bSetBonus to.
*
* @noreturn
*/
//native TF2Attrib_SetIsSetBonus(Address pAttrib, bool bSetBonus);
/**
* Returns the boolean value of m_bSetBonus on an attribute.
*
* @param pAttrib Address of the attribute.
*
* @return The boolean value of m_bSetBonus on the attribute.
*/
//native bool TF2Attrib_GetIsSetBonus(Address pAttrib);
//stock TF2Attrib_IsIntegerValue(iDefIndex)
//{
// switch (iDefIndex)
// {
// case 133, 143, 147, 152, 184, 185, 186, 192, 193, 194, 198, 211, 214, 227, 228, 229, 262, 294, 302, 372, 373, 374, 379, 381, 383, 403, 420:
// {
// return true;
// }
// }
// return false;
//}