[Half-Life AMXX] / include / fakemeta.inc Repository:
ViewVC logotype

Annotation of /include/fakemeta.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (view) (download)

1 : ian 1 /* FakeMeta functions
2 :     *
3 :     * by the AMX Mod X Development Team
4 :     *
5 :     * This file is provided as is (no warranties).
6 :     */
7 :    
8 :     #if defined _fakemeta_included
9 :     #endinput
10 :     #endif
11 :     #define _fakemeta_included
12 :    
13 :     #include <fakemeta_const>
14 :    
15 :     #if AMXX_VERSION_NUM >= 175
16 :     #pragma reqlib fakemeta
17 :     #if !defined AMXMODX_NOAUTOLOAD
18 :     #pragma loadlib fakemeta
19 :     #endif
20 :     #else
21 :     #pragma library fakemeta
22 :     #endif
23 :    
24 : ian 17 /**
25 :     * Returns entvar data from an entity. Use the pev_* enum (in fakemeta_const.inc) to specify which data you want retrieved.
26 : ian 1 *
27 : ian 17 * @note This function uses "read_data" style data syntax. It returns integer values,
28 :     * by-references float data, and sets a buffer for string data.
29 :     *
30 :     * @note If retrieving strings, you may optionally get a pointer into the global string table. Depending on
31 :     * your situation, there are two ways to do this.
32 :     * 1: This simply gets the pointer.
33 :     * new ptr = pev(entid, pev_classname)
34 :     * 2: The pointer will be stored in ptr AND the actual string is retrieved.
35 :     * new ptr, classname[32]
36 :     * pev(entid, pev_classname, ptr, classname, 31)
37 :     *
38 :     * @param _index The entity index to lookup.
39 :     * @param _value The pev field to lookup (look in fakemeta_const.inc)
40 : ian 1 */
41 : ian 17 native pev(_index,_value,any:...);
42 : ian 1
43 : ian 17 /**
44 :     * Sets entvar data for an entity. Use the pev_* enum from fakemeta_const.inc for reference.
45 :     *
46 :     * @note Setting string data will automatically allocate a new string (via AllocString)
47 :     * If you have a string already allocated with your own call to AllocString, use
48 :     * set_pev_string_ptr instead.
49 :     *
50 :     * @param _index The entity index to set the value on.
51 :     * @param _value The pev field to set, (look in fakemeta_const.inc)
52 :     */
53 :     native set_pev(_index,_value,any:...);
54 : ian 1
55 : ian 17 /**
56 :     * Use this native to set a pev field to a string that is already allocated (via a function such
57 :     * as EngFunc_AllocString).
58 :     *
59 :     * @note If you specify _value as anything other than string fields, an error will be thrown.
60 :     * @note Pass 0 as the _string field to set it to an empty string.
61 :     *
62 :     * @param _index The entity index to set the value on.
63 :     * @param _value The pev field to set - MUST be a string field.
64 :     * @param _string The string handle, retrieved from places like AllocString.
65 : ian 1 */
66 : ian 17 native set_pev_string(_index, _value, _string);
67 :    
68 :    
69 :     /**
70 :     * Checks the validity of an entity.
71 :     *
72 :     * @param entindex The entity id to check.
73 :     *
74 :     * @return 0 on invalid entity
75 :     * 1 on entity is valid
76 :     * 2 on entity is valid and it has private data (safe to use pdata natives on).
77 :     */
78 : ian 1 native pev_valid(entindex);
79 :    
80 : ian 17 /**
81 :     * Returns the serial number for each entity. The serial number is a unique identity
82 :     * generated when an entity is created.
83 :     *
84 :     * @param entindex The entity id.
85 :     *
86 :     * @return The serial number for the entity.
87 :     */
88 :     native pev_serial(entindex);
89 :    
90 : ian 1 /* Returns any global variable inside globalvars_t structure. Use the glb_* enum.
91 :     *
92 :     * When returning data from glb_pStringBase (the global string table), you may give a pointer into that table
93 :     * in order to get different strings.
94 :     * Example:
95 :     * new model[128]
96 :     * new ptr = pev(id, pev_viewmodel)
97 :     * global_get(glb_pStringBase, ptr, model, 127)
98 :     */
99 : ian 17 native global_get(_value, any:...);
100 : ian 1
101 :     /* Returns an integer from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
102 :     native get_pdata_int(_index,_Offset,_linuxdiff=5);
103 :    
104 :     /* Sets an integer from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
105 :     native set_pdata_int(_index,_Offset,_Value,_linuxdiff=5);
106 :    
107 :     /* Returns a float from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
108 :     native Float:get_pdata_float(_index,_Offset,_linuxdiff=5);
109 :    
110 :     /* Sets a float from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
111 :     native set_pdata_float(_index,_Offset,Float:_Value,_linuxdiff=5);
112 :    
113 : ian 17 /**
114 :     * Tries to retrieve an edict (entity encapsulation) pointer from an entity's private data.
115 :     *
116 :     * This function is byte-addressable. Unlike get_pdata_int() which searches in byte increments of 4,
117 :     * get_pdata_end searches in increments of 1.
118 :     *
119 :     * @param _index Entity index.
120 :     * @param _offset Offset to search.
121 :     * @param _linuxdiff Linux difference.
122 :     * @return -2 if an invalid entity was found.
123 :     * -1 if an empty entity was found.
124 :     * Otherwise, an entity index is returned.
125 :     */
126 :     native get_pdata_ent(_index, _offset, _linuxdiff=20);
127 : ian 1
128 :     /* Registers a forward.
129 :     * Returns an id you can pass to unregister_forward
130 :     */
131 :     native register_forward(_forwardType,const _function[],_post=0);
132 :    
133 :     /* Unregisters a forward.
134 :     * The registerId must be from register_forward, and
135 :     * post/forwardtype must match what you registered the forward as.
136 :     */
137 :     native unregister_forward(_forwardType, registerId, post=0);
138 :    
139 :     /* Returns data for metamod */
140 : ian 17 native forward_return(type,any:...);
141 : ian 1
142 :     /* Returns the original return value of an engine function.
143 :     * This is only valid in forwards that were registered as post.
144 :     *
145 :     * get_orig_retval() - no params, retrieves integer return value
146 :     * get_orig_retval(&Float:value) - retrieves float return value by reference
147 :     * get_orig_retval(value[], len) - retrives string return value
148 :     */
149 :     native get_orig_retval({Float,_}:...);
150 :    
151 : ian 17 native engfunc(type,any:...);
152 :     native dllfunc(type,any:...);
153 : ian 1
154 :     //only use this with functions that pass a Trace
155 :     // get: zero extra params - return int, one extra param = byref float or vector
156 :     // set: use anything
157 :     native get_tr(TraceResult:tr_member, {Float,_}:...);
158 :     native set_tr(TraceResult:tr_member, {Float,_}:...);
159 :    
160 :     //Upgraded version takes in a TraceResult handle, optionally passed in as the last parameter to the
161 :     //TraceResult forward. Use 0 to specify the global traceresult handle set from calling
162 :     // some of the Engfucs.
163 :     native get_tr2(tr_handle, TraceResult:tr_member, {Float,_}:...);
164 :     native set_tr2(tr_handle, TraceResult:tr_member, {Float,_}:...);
165 :    
166 : ian 17 /**
167 :     * Creates a traceresult handle. This value should never be altered.
168 :     * The handle can be used in get/set_tr2 and various traceresult engine functions.
169 :     *
170 :     * NOTE: You must call free_tr2() on every handle made with create_tr2().
171 :     *
172 :     * @return A new TraceResult handle.
173 :     */
174 :     native create_tr2();
175 :    
176 :     /**
177 :     * Frees a traceresult handle created with free_tr2(). Do not call
178 :     * this more than once per handle, or on handles not created through
179 :     * create_tr2().
180 :     *
181 :     * @param tr_handle TraceResult handle created via create_tr2().
182 :     * @noreturn
183 :     */
184 :     native free_tr2(tr_handle);
185 :    
186 : ian 1 //Same as above, use either a kvd_handle or 0 for global reserved kvd data
187 :     //kvd_handle is passed by the kvd hook, last param
188 :     native get_kvd(kvd_handle, KeyValueData:member, {Float,_}:...);
189 :    
190 :     //Using set_kvd with the handle from the hook for anything under KV_fHandled
191 :     // is considered an undefined operation (it could crash). You should fire a new
192 :     // keyvalues structure rather than changing the internal engine strings.
193 :     native set_kvd(kvd_handle, KeyValueData:member, {Float,_}:...);
194 :    
195 :     // These functions are used with the clientdata data structure (FM_UpdateClientData)
196 :     // Get: 0 extra params - Return integer; 1 extra param - by ref float or vector; 2 extra params - string and length
197 :     // Set: Use anything
198 :     // Use 0 for cd_handle to specify the global clientdata handle
199 :     native get_cd(cd_handle, ClientData:member, {Float,_}:...);
200 :     native set_cd(cd_handle, ClientData:member, {Float,_}:...);
201 :    
202 :     // These functions are used with the entity_state data structure (FM_AddToFullPack)
203 :     // Get: 0 extra params - Return integer; 1 extra param - by ref float or vector or array
204 :     // Set: Use anything
205 :     // Use 0 for es_handle to specify the global entity_state handle
206 :     native get_es(es_handle, EntityState:member, {Float,_}:...);
207 :     native set_es(es_handle, EntityState:member, {Float,_}:...);
208 :    
209 :     // These functions are used with the usercmd data structure (FM_CmdStart)
210 :     // Get: 0 extra params - Return integer; 1 extra param - by ref float or vector
211 :     // Set: Use anything
212 :     // Use 0 for uc_handle to specify the global usercmd handle
213 :     native get_uc(uc_handle, UserCmd:member, {Float,_}:...);
214 :     native set_uc(uc_handle, UserCmd:member, {Float,_}:...);
215 :    
216 :     //NOTE that for the string offsets below, on AMD64, a byref (char **) offset is NOT the same as an int offset
217 :     //In fact it's QWORD aligned rather than DWORD aligned, so the offset will be exactly half.
218 :     //Gets a string from a private offset. If byref is false, the string is treated as static rather than dynamic.
219 : ian 17 //linux value is what to add to the offset for linux servers.
220 :     //this cannot use a default value due to older version using an awkward default value.
221 :     native get_pdata_string(entity, offset, dest[], maxlength, byref=1, linux);
222 : ian 1
223 :     //Sets a string in a private offset.
224 :     //realloc = -1 - nonbyref copy (static
225 :     //realloc = 0 - copy byref, no realloc *(char **)
226 :     //realloc = 1 - reallocate new string with free+malloc
227 :     //realloc = 2 - reallocate new string with delete[]+new[]
228 : ian 17 //linux value is what to add to the offset for linux servers.
229 :     //this cannot use a default value due to older version using an awkward default value.
230 :     native set_pdata_string(entity, offset, const source[], realloc=2, linux);
231 : ian 1
232 :     // Copies the given infoBuffer pointer into out[]
233 :     // An infoBuffer pointer is returned by EngFunc_GetInfoKeyBuffer
234 :     native copy_infokey_buffer(infoBuffer, out[], maxlen);
235 : ian 17
236 :    
237 :     /**
238 :     * Looks up the sequence for the entity.
239 :     *
240 :     * @param entity The entity id to lookup.
241 :     * @param name The sequence name to lookup, case insensitive. ("JUMP" would match "jump")
242 :     * @param framerate The framerate of the sequence, if found.
243 :     * @param loops Whether or not the sequence loops.
244 :     * @param groundspeed The groundspeed setting of the sequence.
245 :     * @return -1 on failed lookup, the sequence number on successful lookup.
246 :     */
247 :     native lookup_sequence(entity, const name[], &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0);
248 :    
249 :     /**
250 :     * Sets a bone controller with the specified value.
251 :     *
252 :     * @param entity The entity id to set the value on.
253 :     * @param controller Which controller to set (0 through 3).
254 :     * @param value The value to set it to.
255 :     * @return The percentage that the controller is extended (0.0 through 1.0)
256 :     */
257 :     native Float:set_controller(entity, controller, Float:value);

Contact
ViewVC Help
Powered by ViewVC 1.0.4