RichieBurundi commited on
Commit
c2b71e2
1 Parent(s): 6afc6e3

Upload 8 files

Browse files
Cvars.txt ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CVARs
2
+
3
+ This quick guide will show you what they are and how they behave.
4
+
5
+ Here's a great list of cvars: http://scripting.elxdraco.net/cvarlist/
6
+
7
+ What are they?
8
+
9
+ You can think of them as global (sort of) variables. You can retrieve their values, set new values, and also create new cvars. They differ from actual global variables, because you can change cvar values from the console.
10
+
11
+ Usage
12
+
13
+ You can store all sorts of stuff in your cvars. Typically, they are used to control plugins, turn them on/off, or to hold data temporarily. You can use the flags listed below to modify the behavior of the cvars.
14
+
15
+ If you will read the cvar value later on in your script, use pointers.
16
+
17
+ Use get_pcvar_flags, get_pcvar_float, get_pcvar_num, or get_pcvar_string.
18
+ Do not use get_cvar_flags, get_cvar_float, get_cvar_num, or get_cvar_string.
19
+
20
+ Code:
21
+ register_cvar ( const name[], const string[], flags = 0, Float:fvalue = 0.0 )
22
+
23
+ I haven't found any examples where fvalue is used, so please post if you know what it's for.
24
+
25
+ Example Usage:
26
+
27
+ Code:
28
+ new cvar_MyCvar // this is a pointer
29
+ new cvar_OtherCvar // this is also a pointer
30
+
31
+ public plugin_init()
32
+ {
33
+ // this cvar has no flags assigned
34
+ cvar_MyCvar = register_cvar("amx_mycvar", "0")
35
+
36
+ // this cvar has two flags assigned
37
+ cvar_OtherCvar = register_cvar("amx_other", "1", FCVAR_SPONLY|FCVAR_UNLOGGED)
38
+ }
39
+
40
+ public MyFunction()
41
+ {
42
+ if(get_pcvar_num(cvar_MyCvar))
43
+ return 1
44
+ return 0
45
+ }
46
+
47
+ How do they behave?
48
+
49
+ Code:
50
+ Order of Events:
51
+ 1.Server is off hlds.exe is not running
52
+ 2.Server starts
53
+ 3.plugin_init() cvars are created
54
+ 4.plugin_cfg()
55
+ 5.amxx.cfg cvars assigned values from amxx.cfg
56
+ 6.server.cfg cvars assigned values from server.cfg
57
+ 7.Server restarts mapchange or 'restart' command
58
+ 8.plugin_init() cvars are NOT re-created or overwritten; if they exist, only pointers are gathered
59
+ 9.plugin_cfg()
60
+ 10.amxx.cfg cvars assigned values from amxx.cfg (server.cfg is not called next)
61
+ The functions plugin_init() and plugin_cfg() are called on every map-change, restart, and "fresh" start. ("Fresh" start means the server turned on after being off.) The amxx.cfg file is read on every map-change, restart and "fresh" start. The server.cfg file is only read on "fresh" starts.
62
+
63
+ When you do register_cvar("cvar_name", "cvar_value"), you are attempting to create a new cvar with a new default value. If this cvar already exists, this function will not overwrite the original value. Instead, it will return a pointer to the existing cvar that you can later access with get_pcvar_flags, get_pcvar_float, get_pcvar_num, or get_pcvar_string.
64
+
65
+ To get a pointer for a cvar, use get_cvar_pointer("cvarname").
66
+
67
+ CVAR flags
68
+
69
+ This is taken directly from amxconst.inc:
70
+ FCVAR_ARCHIVE set to cause it to be saved to vars.rc
71
+ FCVAR_USERINFO changes the client's info string
72
+ FCVAR_SERVER notifies players when changed
73
+ FCVAR_EXTDLL defined by external DLL
74
+ FCVAR_CLIENTDLL defined by the client dll
75
+ FCVAR_PROTECTED It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
76
+ FCVAR_SPONLY This cvar cannot be changed by clients connected to a multiplayer server.
77
+ FCVAR_PRINTABLEONLY This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
78
+ FCVAR_UNLOGGED If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
79
+
80
+ Unfortunately, I can't find any examples for the following flags: FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_EXTDLL, FCVAR_CLIENTDLL.
81
+
82
+ So, I'd like to ask anyone who knows about these flags to post.
83
+
84
+ Example
85
+
86
+ Here's a simple script that counts how many times a server stops running. If you can understand how this script works, then you probably have a good grip on cvars.
87
+
88
+ This script should only be used as a demonstration to understand cvars. If you really want to count crashes accurately, I would recommend a different method. Let me know if you're interested.
89
+
90
+ Code:
91
+ #include <amxmodx>
92
+
93
+ #define PLUGIN "Crash Counter"
94
+ #define VERSION "1.0"
95
+ #define AUTHOR "stupok"
96
+
97
+ #define DIR_CRASHLOG "addons\amxmodx\logs\CrashLog"
98
+ #define FILE_CRASHMAP "addons\amxmodx\logs\CrashLog\crash_map.txt"
99
+ #define FILE_LOG "CrashLog.log" // will be found in addons\amxmodx\logs
100
+
101
+ new cvar_Crashed
102
+
103
+ public plugin_init()
104
+ {
105
+ register_plugin(PLUGIN, VERSION, AUTHOR)
106
+
107
+ cvar_Crashed = register_cvar("server_crashed", "1", FCVAR_SPONLY) // do not let players edit this cvar
108
+
109
+ if(!dir_exists(DIR_CRASHLOG)) mkdir(DIR_CRASHLOG) // make addons\amxmodx\logs\CrashLog
110
+
111
+ if(!file_exists(FILE_CRASHMAP)) write_file(FILE_CRASHMAP, "-- Do not edit --", -1) // make crash_map.txt
112
+
113
+ new szMapName[32]
114
+ new iLineLen
115
+ read_file(FILE_CRASHMAP, 2, szMapName, charsmax(szMapName), iLineLen) // read previous map from file
116
+
117
+ if(get_pcvar_num(cvar_Crashed)) // check if server just started, 1 = start, 0 = restart/mapchange
118
+ {
119
+ if(szMapName[0]) // do we have a map from crash_map.txt?
120
+ {
121
+ log_to_file(FILE_LOG, "The server exited or crashed on '%s' before this recorded time.", szMapName)
122
+ }
123
+ set_pcvar_num(cvar_Crashed, 0) // this will be set to 1 again when the server has a "fresh" start (not restart)
124
+ }
125
+
126
+ get_mapname(szMapName, charsmax(szMapName)) // get the name of the current map
127
+ write_file(FILE_CRASHMAP, szMapName, 2) // write it to crash_map.txt
128
+ }
Dynamic, Fake Natives.txt ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Dynamic / Fake Natives (I will refer to them as dynamic from here onward, I don't like the word fake when they actually do something) allow you to have the functionality of a module (through natives) by having a plugin that acts like a module running. In theory, it is possible to port entire modules to fakemeta + plugins using this principle (fun has already been done, engine can be done with more difficulty). From my experiences, dynamic natives go hand and hand with API design as shown in my "Plugin API" tutorial.
2
+
3
+ Here are the natives that are used along for dynamic natives:
4
+ register_native
5
+ register_library
6
+ get_param
7
+ get_param_byref
8
+ get_param_f
9
+ get_string
10
+ get_array
11
+ get_array_f
12
+ set_array
13
+ set_array_f
14
+ set_string
15
+ param_convert
16
+
17
+ Please keep in mind that dynamic natives are pretty useless when not dealing with more than one plugin. As such, the following examples will always be at least 2 scripts, plus one include file.
18
+
19
+ Here is a simple example to show the basics of dynamic natives:
20
+
21
+ Code:
22
+ #include <amxmodx>
23
+ #include <fun>
24
+
25
+ public plugin_init()
26
+ register_plugin("Dynamic Native Test - Handler","1.0","Hawk552")
27
+
28
+ public plugin_natives()
29
+ {
30
+ register_library("dyn_test")
31
+
32
+ register_native("half_user_hp","_half_user_hp")
33
+ }
34
+
35
+ public _half_user_hp(iPlugin,iParams)
36
+ {
37
+ if(iParams != 1)
38
+ return PLUGIN_CONTINUE
39
+
40
+ new id = get_param(1)
41
+ if(!id)
42
+ return PLUGIN_CONTINUE
43
+
44
+ set_user_health(id,get_user_health(id) / 2)
45
+
46
+ return PLUGIN_HANDLED
47
+ }
48
+
49
+ Code:
50
+ #include <amxmodx>
51
+ #include <dyn_test>
52
+
53
+ public plugin_init()
54
+ register_plugin("Dynamic Native Test - Caller","1.0","Hawk552")
55
+
56
+ public client_putinserver(id)
57
+ if(is_user_alive(id))
58
+ half_user_hp(id)
59
+
60
+ Code:
61
+ // NOTE: This file MUST be called dyn_test.inc (or you have to rename the #include <dyn_test> in script 2)
62
+
63
+ #pragma reqlib "dyn_test"
64
+
65
+ native half_user_hp(id)
66
+
67
+ Now, what is this doing? Basically, on client_putinserver, if the user is alive (which is only true in mods like sven coop where you spawn right away) then it will slice their HP in half. Let's pick apart each thing.
68
+
69
+ Script 1
70
+
71
+ At first we look at the plugin_init, and we notice nothing special. We then look down and see "plugin_natives", a forward most people here have probably never seen before. This is where natives and libraries must be registered. DO NOT try to put them in other forwards, like plugin_init or plugin_precache.
72
+
73
+ Now, let's look at the first part of plugin_natives, which is register_library.
74
+
75
+ What does this do? It basically tells AMXX that this plugin provides native functionality to other plugins, and aids with "native not found" errors to check if the plugin is loaded before trying to call the dynamic native. In this case, we're calling our library "dyn_test" for "Dynamic Native Test". There are 2 types of libraries in AMXX core, as of 1.75: libraries and classes. A module is a library, while a plugin is a class. This information is useful for LibraryExists, which will be covered later.
76
+
77
+ Next, we see register_native.
78
+
79
+ const native[] - this is the name of the native to register. Pretty obvious.
80
+ const handler[] - this is the name of the function that will be called when this native is used. Remember, it must be public (as with almost all functions that are put in quotes or called by outside sources)
81
+ [ style = 0 ] - this is will be covered later
82
+
83
+ Now, as we look at the register_native call, we see the handler is _half_user_hp. So, we look down, and we see this function.
84
+
85
+ Code:
86
+ public _half_user_hp(iPlugin,iParams)
87
+
88
+ In all dynamic natives, unless registered with style=1, we see something to the effect of (id,params), which I decided to rename in the header. The first param is the plugin id - this is useful in case you want to send it back a callfunc or a CreateOneForward/ExecuteForward, or have an array that stores data for each plugin loaded. The next param is iParams. In the case of the above example, iParams must be 1, because the only param is 1. If it's anything different, someone decided to be stupid and modify the include file.
89
+
90
+ Next, inside the function we check if iParams == 1, and if it doesn't we stop there. Next, we get_param(1), which allows you to get the first parameter assuming it's a cell (which it is). We then check if id is a counting number, because we can't use 0 with get_user_health. The rest is pretty self explanatory.
91
+
92
+ In this example, I returned PLUGIN_CONTINUE because that evaluates to false, and PLUGIN_HANDLED because it evaluates to true. This allows you to do simple error checking, ie "if(!half_user_health(id)) log_amx("failed")".
93
+
94
+ Now that the handler is out of the way, we get down to the plugin that will use this dynamic native.
95
+
96
+ First, I'd like you to look at the include file (the 3rd example). The first thing we see is #pragma reqlib "dyn_test". This effectively tells AMXX "If dyn_test isn't loaded, error me right here." The register_library function in the first example is what lets you bypass this, because it tells AMXX that dyn_test does exist. Next, in this same file, we see native half_user_hp(id). This basically tells the compiler that half_user_hp will be handled in the VM layer (which is where all the C++ coding is), but the VM layer will pass it down to the function that handles the dynamic native. After it's handled, the VM layer will pass the result back to the calling function.
97
+
98
+ Onto the script itself, we see that we included this file through #include <dyn_test>. The rest is quite self explanatory.
99
+
100
+ As for the get_param section, the natives above (get_param_f, get_param_byref, etc.) can be used to replace this, depending upon what arguments are passed into the function.
101
+
102
+ Now, onto style = 1. This style basically forgets about the iPlugin,iParams part of the header, and then assumes the plugin will pass the parameters correctly. This means _half_user_hp would look like:
103
+
104
+ Code:
105
+ public _half_user_hp(id)
EngFunc Tutorial.txt ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include <amxmodx>
2
+ #include <amxmisc>
3
+ #include <fakemeta>
4
+ #include <fakemeta_util>
5
+ #include <xs>
6
+
7
+ #pragma semicolon 1
8
+
9
+ #define PLUGIN_NAME "Tutorial Plugin"
10
+ #define PLUGIN_VERSION "1.0"
11
+ #define PLUGIN_AUTHOR "JoRoPiTo"
12
+
13
+ #define STR 32
14
+ #define LOG 128
15
+
16
+ #define TUT_PREFIX "[AMXX TUT]"
17
+ #define DIVISOR "======================================================="
18
+
19
+ static g_beamSprite;
20
+ static g_maxEntities;
21
+ static g_maxClients;
22
+ static g_msgSayText;
23
+
24
+
25
+ public plugin_init()
26
+ {
27
+ register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
28
+
29
+ // Console commands
30
+ register_concmd("con_showents", "con_showents");
31
+
32
+ // Client commands
33
+ register_clcmd("tutorial1", "tut_FindEntityByString");
34
+ register_clcmd("tutorial2", "tut_FindEntityInSphere");
35
+ register_clcmd("tutorial3", "tut_FindClientInPVS");
36
+ register_clcmd("tutorial4", "tut_TraceLine");
37
+ register_clcmd("tutorial5", "tut_TraceModel");
38
+
39
+ g_maxEntities = global_get(glb_maxEntities);
40
+ g_maxClients = global_get(glb_maxClients);
41
+ g_msgSayText = get_user_msgid("SayText");
42
+ }
43
+
44
+ public plugin_precache()
45
+ {
46
+ g_beamSprite = precache_model("sprites/zbeam1.spr");
47
+ }
48
+
49
+
50
+ //------------------------------------------------------------------------
51
+ //Internal functions
52
+ //------------------------------------------------------------------------
53
+ stock fn_log_con(name[], msg[])
54
+ {
55
+ server_print("%s %s: %s", TUT_PREFIX, name, msg);
56
+ }
57
+
58
+ stock fn_log_cli(id, name[], msg[])
59
+ {
60
+ static text[LOG];
61
+ formatex(text, charsmax(text), "^x04%s %s:^x01 %s", TUT_PREFIX, name, msg);
62
+ if(id != 0)
63
+ {
64
+ message_begin(MSG_ONE, g_msgSayText, {0,0,0}, id);
65
+ write_byte(id);
66
+ write_string(text);
67
+ message_end();
68
+ }
69
+ else
70
+ {
71
+ client_print(0, print_chat, text);
72
+ }
73
+ }
74
+
75
+ stock fn_create_beam(Float:origin[3], Float:end[3], t, r, g, b)
76
+ {
77
+ message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
78
+ write_byte(TE_BEAMPOINTS);
79
+ engfunc(EngFunc_WriteCoord, origin[0]);
80
+ engfunc(EngFunc_WriteCoord, origin[1]);
81
+ engfunc(EngFunc_WriteCoord, origin[2]);
82
+ engfunc(EngFunc_WriteCoord, end[0]);
83
+ engfunc(EngFunc_WriteCoord, end[1]);
84
+ engfunc(EngFunc_WriteCoord, end[2]);
85
+ write_short(g_beamSprite);
86
+ write_byte(1);
87
+ write_byte(5);
88
+ write_byte(t);
89
+ write_byte(20);
90
+ write_byte(0);
91
+ write_byte(r);
92
+ write_byte(g);
93
+ write_byte(b);
94
+ write_byte(200);
95
+ write_byte(200);
96
+ message_end();
97
+ }
98
+
99
+ //------------------------------------------------------------------------
100
+ //Console functions
101
+ //------------------------------------------------------------------------
102
+
103
+ public con_showents()
104
+ {
105
+ new class[STR], str[LOG];
106
+ new origin[3];
107
+ new ent, owner;
108
+ for(ent=1; ent < g_maxEntities; ++ent)
109
+ {
110
+ if(!pev_valid(ent))
111
+ continue;
112
+
113
+ pev(ent, pev_origin, origin);
114
+ pev(ent, pev_classname, class, charsmax(class));
115
+ owner = pev(ent, pev_owner);
116
+ formatex(str, charsmax(str), "%i %s (owner:%i) (%f,%f,%f)", ent, class, owner, origin[0], origin[1], origin[2]);
117
+ fn_log_con("Entity", str);
118
+ }
119
+ return PLUGIN_HANDLED;
120
+ }
121
+
122
+ //------------------------------------------------------------------------
123
+ //Client functions
124
+ //------------------------------------------------------------------------
125
+
126
+ // FindEntityByString
127
+ // This tutorial makes lines from the player to every player in the map
128
+ public tut_FindEntityByString(id)
129
+ {
130
+ static Float:origin[3];
131
+ static Float:point[3];
132
+ static text[LOG];
133
+ static ent;
134
+ static const class[] = "player"; // We are going to find "player" entitities
135
+
136
+ pev(id, pev_origin, origin);
137
+ pev(id, pev_view_ofs, point);
138
+ xs_vec_add(origin, point, origin);
139
+
140
+ fn_log_cli(id, "FindEntityInSphere", DIVISOR);
141
+ ent = -1;
142
+ while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", class)))
143
+ {
144
+ // We don't want our own entity
145
+ if(ent == id)
146
+ continue;
147
+
148
+ if(!pev_valid(ent))
149
+ continue;
150
+
151
+ pev(ent, pev_origin, point);
152
+ fn_create_beam(origin, point, 60, 255, 0, 0); // Create red line from ID to ENT for 60 seconds
153
+ formatex(text, charsmax(text), "Found entity 'player' (ent:%i)", ent);
154
+ fn_log_cli(id, "FindEntityInSphere", text);
155
+ }
156
+
157
+ return PLUGIN_HANDLED;
158
+ }
159
+
160
+ // FindEntityInSphere
161
+ // This tutorial makes lines from a player to every entity found in sphere radius
162
+ public tut_FindEntityInSphere(id)
163
+ {
164
+ static Float:origin[3];
165
+ static Float:point[3];
166
+ static text[LOG];
167
+ static class[STR];
168
+ static ent;
169
+ static const radius = 2000; // We are going to find entities using this sphere radius
170
+
171
+ pev(id, pev_origin, origin);
172
+ pev(id, pev_view_ofs, point);
173
+ xs_vec_add(origin, point, origin);
174
+
175
+ fn_log_cli(id, "FindEntityInSphere", DIVISOR);
176
+ ent = -1;
177
+ while((ent = engfunc(EngFunc_FindEntityInSphere, ent, origin, radius)))
178
+ {
179
+ // We don't want worldspawn entity
180
+ if(ent == 0)
181
+ continue;
182
+
183
+ // We don't want our own entity
184
+ if(ent == id)
185
+ continue;
186
+
187
+ if(!pev_valid(ent))
188
+ continue;
189
+
190
+ pev(ent, pev_origin, point);
191
+ pev(ent, pev_classname, class, charsmax(class));
192
+ if(equal(class, "func_buyzone") || equal(class, "player") || equal(class, "func_bomb_target")
193
+ || equal(class, "func_breakable") || equal(class, "func_door"))
194
+ {
195
+ fn_create_beam(origin, point, 60, 0, 255, 0); // Create green line from ID to ENT for 60 seconds
196
+ formatex(text, charsmax(text), "Found entity in sphere (ent:%i class:%s)", ent, class);
197
+ fn_log_cli(id, "FindEntityInSphere", text);
198
+ }
199
+ }
200
+ return PLUGIN_HANDLED;
201
+ }
202
+
203
+ // FindClientInPVS
204
+ // This tutorial makes lines from a player to every entity found in PVS
205
+ public tut_FindClientInPVS(id)
206
+ {
207
+ static Float:origin[3];
208
+ static Float:point[3];
209
+ static class[STR];
210
+ static text[LOG];
211
+ static ent, chain;
212
+
213
+ pev(id, pev_origin, origin);
214
+ pev(id, pev_view_ofs, point);
215
+ xs_vec_add(origin, point, origin);
216
+
217
+ fn_log_cli(id, "FindClientInPVS", DIVISOR);
218
+
219
+ ent = engfunc(EngFunc_EntitiesInPVS, id);
220
+ while(ent)
221
+ {
222
+ chain = pev(ent, pev_chain);
223
+ pev(ent, pev_origin, point);
224
+ pev(ent, pev_classname, class, charsmax(class));
225
+ if(!equal(class, ""))
226
+ {
227
+ fn_create_beam(origin, point, 60, 0, 0, 255); // Create blue line from ID to ENT for 60 seconds
228
+ formatex(text, charsmax(text), "Found entity in PVS (ent:%i class:%s)", ent, class);
229
+ fn_log_con("FindClientInPVS", text);
230
+ }
231
+
232
+ if(!chain)
233
+ break;
234
+
235
+ ent = chain;
236
+ }
237
+ return PLUGIN_HANDLED;
238
+ }
239
+
240
+ // TraceLine
241
+ // This tutorial makes 2 lines, one of them stoping on entities.
242
+ public tut_TraceLine(id)
243
+ {
244
+ static Float:origin[3];
245
+ static Float:aim[3];
246
+ static Float:point[3];
247
+ static text[LOG];
248
+ static const tr = 0;
249
+
250
+ pev(id, pev_origin, origin);
251
+ pev(id, pev_view_ofs, aim);
252
+ xs_vec_add(origin, aim, origin);
253
+
254
+ fm_get_aim_origin(id, aim);
255
+ // Multiply vector to make it larger
256
+ xs_vec_sub(aim, origin, aim);
257
+ xs_vec_mul_scalar(aim, 10.0, aim);
258
+ xs_vec_add(origin, aim, aim);
259
+
260
+ engfunc(EngFunc_TraceLine, origin, aim, 0, id, tr);
261
+
262
+ fn_log_cli(id, "TraceLine", DIVISOR);
263
+ fn_create_beam(origin, aim, 60, 255, 0, 0); // Create red line from ID to aim point for 60 seconds
264
+ formatex(text, charsmax(text), "Created red line to aim point");
265
+ fn_log_cli(id, "TraceLine", text);
266
+
267
+ get_tr2(tr, TR_vecEndPos, point);
268
+ fn_create_beam(origin, point, 60, 0, 255, 0); // Create green line from ID to hit point for 60 seconds
269
+ formatex(text, charsmax(text), "Created green line to hit point");
270
+ fn_log_cli(id, "TraceLine", text);
271
+
272
+ return PLUGIN_HANDLED;
273
+ }
274
+
275
+ // TraceModel
276
+ // This tutorial makes one line to where you are aiming. The color of the line depends on the model you hit.
277
+ public tut_TraceModel(id)
278
+ {
279
+ static Float:origin[3];
280
+ static Float:aim[3];
281
+ static Float:point[3];
282
+ static class[STR];
283
+ static text[LOG];
284
+ static ent;
285
+ static const tr = 0;
286
+
287
+ pev(id, pev_origin, origin);
288
+ pev(id, pev_view_ofs, aim);
289
+ xs_vec_add(origin, aim, origin);
290
+
291
+ fm_get_aim_origin(id, aim);
292
+ // Multiply vector to make it larger
293
+ xs_vec_sub(aim, origin, aim);
294
+ xs_vec_mul_scalar(aim, 2.0, aim);
295
+
296
+ for(ent=g_maxClients+1; ent<g_maxEntities; ent++)
297
+ {
298
+ if(!pev_valid(ent))
299
+ continue;
300
+
301
+ pev(ent, pev_classname, class, charsmax(class));
302
+ if(equal(class, "weaponbox") || equal(class, "armoury_entity") || equal(class, "player")
303
+ || equal(class, "func_breakable") || equal(class, "func_door"))
304
+ {
305
+ engfunc(EngFunc_TraceModel, origin, aim, HULL_POINT, ent, tr);
306
+ if((ent > 0) && (get_tr2(tr, TR_pHit) == ent))
307
+ {
308
+ fn_log_cli(id, "TraceModel", DIVISOR);
309
+ formatex(text, charsmax(text), "Found model by aim (ent:%i class:%s)", ent, class);
310
+ fn_log_cli(id, "TraceModel", text);
311
+ get_tr2(tr, TR_vecEndPos, point);
312
+ fn_create_beam(origin, point, 60, 0, 255, 0); // Create green line from ID to hit point for 60 seconds
313
+ }
314
+ }
315
+ }
316
+
317
+ return PLUGIN_HANDLED;
318
+ }
Fakemeta General.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ About
2
+
3
+ FakeMeta is an extremely powerful module for AMX Mod X that effectively allows you to write Metamod plugins in Pawn.
4
+ Unlike Engine, FakeMeta uses no CPU if it is not told to do anything (other than to exist). For this reason, it is recommended to use FakeMeta over Engine. There is nothing in Engine that is not in FakeMeta -- while some functionality might be less abstracted, it is still achievable, and usually with more flexibility.
5
+
6
+
7
+ Engine vs. FakeMeta
8
+
9
+ Comparison between Engine and FakeMeta:
10
+ FakeMeta:
11
+ Code:
12
+ #include <amxmodx>
13
+ #include <fakemeta>
14
+
15
+ public plugin_init()
16
+ {
17
+ register_plugin("FakeMeta Test","1.0","Hawk552");
18
+
19
+ register_forward(FM_PlayerPreThink,"PreThink");
20
+ }
21
+
22
+ public PreThink(id)
23
+ {
24
+ // here you would insert some code
25
+
26
+ return FMRES_IGNORED;
27
+ }
28
+ Engine:
29
+ Code:
30
+ #include <amxmodx>
31
+ #include <engine>
32
+
33
+ public plugin_init()
34
+ {
35
+ register_plugin("FakeMeta Test","1.0","Hawk552");
36
+ }
37
+
38
+ public client_PreThink(id)
39
+ {
40
+ // here you would insert some code
41
+
42
+ return;
43
+ }
44
+ The "return FMRES_IGNORED" section will be covered later on this page.
45
+
46
+
47
+ General Functionality
48
+
49
+ FakeMeta also allows you to do other things, such as retrieve private data (using pev, set_pev / get_pdata_int, get_pdata_float, get_pdata_string, set_pdata_int, set_pdata_float, set_pdata_string), forcing DLL functions to be executed, as well as call Engine (not the module) functions.
50
+
51
+
52
+ Entvars
53
+
54
+ It is easy to read entvars in FakeMeta, however it can sometimes cause problems if not done correctly (which is why Engine is more commonly used). Entvars are variables in a player's edict structure (an edict is the basis for an entity).
55
+ Here is an example of how to retrieve the armor entvar from an entity in FakeMeta:
56
+ Code:
57
+ #include <amxmodx>
58
+ #include <fakemeta>
59
+
60
+ public plugin_init()
61
+ {
62
+ register_plugin("FakeMeta Test","1.0","Hawk552");
63
+
64
+ register_forward(FM_PlayerPreThink, "PreThink");
65
+ }
66
+
67
+ public PreThink(id)
68
+ {
69
+ new value = pev(id,pev_armorvalue); // gets armor from client/entity
70
+
71
+ client_print(id,print_chat,"%i",value); // prints armor value to client
72
+
73
+ return FMRES_IGNORED;
74
+ }
75
+ DLL / Engine Function Usage
76
+
77
+ In DLLs and the Engine, there are functions that are called when certain events happen. These can be forced to be called through FakeMeta. Here is a general example:
78
+ Code:
79
+ #include <amxmodx>
80
+ #include <fakemeta>
81
+
82
+ public plugin_init()
83
+ {
84
+ register_plugin("FakeMeta Test","1.0","Hawk552");
85
+
86
+ register_forward(FM_PlayerPreThink,"PreThink");
87
+ }
88
+
89
+ public PreThink(id)
90
+ {
91
+ dllfunc(DLLFunc_RegisterEncoders);
92
+
93
+ return FMRES_IGNORED;
94
+ }
95
+ Refer to the end of the line while viewing the DLLFunc and EngFunc sections, as there is usually some description of paramaters, such as edict_t *p_Entity or void. void generally refers to no parameters, while edict_t *p_Entity means the entity id, so the first parameter in the function would be the entity to call the function onto.
96
+
97
+
98
+ Return Values
99
+
100
+ There are 4 return values in FakeMeta:
101
+ FMRES_HANDLED --> Something was done in this function, but call the one in the DLL / Engine anyways.
102
+ FMRES_SUPERCEDE --> Prevent function in DLL / Engine from being called.
103
+ FMRES_IGNORED --> Call original function.
104
+ FMRES_OVERRIDE --
Issues, Examples.txt ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is a compilation of examples, explanations, and answers for commonly asked questions / issues.
2
+
3
+ The Countdown
4
+ Code:
5
+ #include <amxmodx>
6
+
7
+ #define TASKID 1996
8
+ #define SECONDS 10
9
+
10
+ new iSeconds
11
+
12
+ public plugin_init()
13
+ {
14
+ register_plugin( "Countdown Example", "1.0", "Wrecked" )
15
+
16
+ register_logevent( "LogEventRoundStart", 2, "1=Round_Start" )
17
+ }
18
+
19
+ public LogEventRoundStart()
20
+ {
21
+ if( task_exists( TASKID ) )
22
+ remove_task( TASKID )
23
+
24
+ iSeconds = SECONDS
25
+ set_task( 1.0, "TaskShowCountdown", TASKID, _, _, "a", SECONDS )
26
+ }
27
+
28
+ public TaskShowCountdown()
29
+ {
30
+ set_hudmessage( 120, 120, 120, 0.50, 0.50, 0, 0.1, 0.8, 0.1, 0.1, -1 )
31
+ show_hudmessage( 0, "Seconds Remaining: %i", iSeconds-- )
32
+ }
33
+ Detecting Kill/Headshot Streaks
34
+
35
+ Code:
36
+ #include <amxmodx>
37
+
38
+ new Headshots[33]
39
+ new Kills[33]
40
+
41
+ public plugin_init()
42
+ {
43
+ register_plugin( "How To Keep Kill Counts", "1.0", "Wrecked" )
44
+
45
+ register_event( "DeathMsg", "EventDeathMsg", "a" )
46
+
47
+ register_logevent( "LogEventRoundStart", 2, "1=Round_Start" )
48
+ }
49
+
50
+ public EventDeathMsg()
51
+ {
52
+ new killer = read_data( 1 )
53
+ new victim = read_data( 2 )
54
+
55
+ Headshots[victim] = 0
56
+ Kills[victim] = 0
57
+ Kills[killer]++
58
+
59
+ if( read_data( 3 ) ) // headshot
60
+ Headshots[killer]++
61
+
62
+ // Kills holds kills of each player
63
+ // Headshots holds headshots
64
+ }
65
+
66
+ public LogEventRoundStart()
67
+ {
68
+ arrayset( Headshots, 0, 33 )
69
+ arrayset( Kills, 0, 33 )
70
+ }
71
+ Once Every x Rounds
72
+
73
+ Code:
74
+ #include <amxmodx>
75
+
76
+ #define ROUND_INTERVAL 4
77
+
78
+ new iRound
79
+
80
+ public plugin_init()
81
+ {
82
+ register_plugin( "Do Something Every X Rounds", "1.0", "Wrecked" )
83
+
84
+ register_logevent( "LogEventRoundStart", 2, "1=Round_Start" )
85
+ }
86
+
87
+ public LogEventRoundStart()
88
+ {
89
+ if( ( ++iRound % ROUND_INTERVAL ) == 1 )
90
+ // do whatever you need to do here
91
+ }
92
+
93
+ Blocking Weapon Pickup
94
+ Code:
95
+ #include <amxmodx>
96
+ #include <hamsandwich>
97
+
98
+ public plugin_init()
99
+ {
100
+ register_plugin( "Block Weapon Pickup", "1.0", "Wrecked" )
101
+
102
+ new classname[20] // weapon_smokegrenade (19) + 1
103
+
104
+ for( new i = CSW_P228; i <= CSW_P90; i++ )
105
+ {
106
+ if ( get_weaponname( i, classname, charsmax( classname ) ) )
107
+ {
108
+ RegisterHam( Ham_Item_Deploy, classname, "HamItemDeployPre", 0 )
109
+ /* Other forwards that you could've used:
110
+ * Ham_AddPlayerItem
111
+ * Ham_Item_CanDeploy
112
+ */
113
+ }
114
+ }
115
+ }
116
+
117
+ public HamItemDeployPre( weapon )
118
+ {
119
+ return HAM_SUPERCEDE; // blocks function call
120
+ }
121
+
122
+ Properly Removing Buyzones (by Exolent[jNr])
123
+ Code:
124
+ #include < amxmodx >
125
+ #include < engine >
126
+ #include < fakemeta >
127
+
128
+ new const info_map_parameters[ ] = "info_map_parameters";
129
+
130
+ new g_hSpawn;
131
+
132
+ public plugin_precache( ) {
133
+ new iEntity = create_entity( info_map_parameters );
134
+ DispatchKeyValue( iEntity, "buying", "3" );
135
+ DispatchSpawn( iEntity );
136
+
137
+ g_hSpawn = register_forward( FM_Spawn, "FwdSpawn" );
138
+ }
139
+
140
+ public FwdSpawn( iEntity ) {
141
+ static szClassname[ 32 ];
142
+ entity_get_string( iEntity, EV_SZ_classname, szClassname, 31 );
143
+
144
+ if( equal( szClassname, info_map_parameters ) ) {
145
+ remove_entity( iEntity );
146
+
147
+ return FMRES_SUPERCEDE;
148
+ }
149
+
150
+ return FMRES_IGNORED;
151
+ }
152
+
153
+ public plugin_init( ) {
154
+ if( g_hSpawn > 0 ) {
155
+ unregister_forward( FM_Spawn, g_hSpawn );
156
+ }
157
+ }
158
+
159
+ Properly Removing an Entity at Plugin Start (by Alucard^)
160
+ Code:
161
+ #include <amxmodx>
162
+ #include <fakemeta>
163
+
164
+ new const g_RemoveEntity[] = "classname_here";
165
+
166
+ public plugin_precache()
167
+ {
168
+ register_plugin("Fine", "and", "you?");
169
+
170
+ // Remember to do this in plugin_precache, if you
171
+ // do this in plugin_init( ) this will not work!
172
+
173
+ register_forward(FM_Spawn, "HookFmSpawn");
174
+ }
175
+
176
+ public HookFmSpawn(iEntity)
177
+ {
178
+ if(!pev_valid(iEntity) )
179
+ return FMRES_IGNORED;
180
+
181
+ static szClassName[32];
182
+ pev(iEntity, pev_classname, szClassName, 31);
183
+
184
+ if(equali(szClassName, g_RemoveEntity) )
185
+ {
186
+ engfunc(EngFunc_RemoveEntity, iEntity);
187
+
188
+ return FMRES_SUPERCEDE;
189
+ }
190
+
191
+ return FMRES_IGNORED;
192
+ }
193
+
194
+ What is the proper way to respawn someone?
195
+ Well, there are two methods that are correct and efficient.
196
+ Code:
197
+ // GOOD, hamsandwich
198
+ ExecuteHamB( Ham_CS_RoundRespawn, playerindex )
199
+
200
+ // GOOD, fakemeta
201
+ set_pev( playerindex, pev_deadflag, DEAD_RESPAWNABLE )
202
+
203
+ // BAD, fun
204
+ // This is usable, but requires a fix that really isn't worth it.
205
+ spawn( playerindex )
206
+
207
+ // BAD, cstrike
208
+ cs_user_spawn( playerindex )
209
+
210
+ What module should I use for my large plugin? Fakemeta or engine?
211
+ You should use whatever module gets the job done. The actual efficiency impact between including either is very trivial. Don't be hesitant to include both if you need both to get what you need done properly.
212
+
213
+ I've compiled my plugin and the loose indentation warning has come up. What is this and how can I fix it?
214
+ This warning shows up whenever you indent your lines with spaces AND tabs. Conform to using one style; I personally use tabs because they're much easier.
215
+
216
+ How do I dynamically add values into my menu title / items?
217
+ Code:
218
+ menufunc()
219
+ {
220
+ new info[128]
221
+ formatex( info, 127, "Welcome to the Point Shop^nYour Points: %i", iVariableForPoints[id] )
222
+ new menu = menu_create( info, "HandlerFunction" )
223
+
224
+ // rest of menu code
225
+ }
226
+
227
+ How to remove properly the BuyZones in the map:
228
+
229
+ Code:
230
+ #include <amxmodx>
231
+ #include <fakemeta>
232
+
233
+ public plugin_precache()
234
+ {
235
+ register_plugin("How", "are", "you?");
236
+
237
+ // If i am not wrong, this must be made in plugin_precache( )
238
+
239
+ new iEnt;
240
+
241
+ iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_map_parameters") );
242
+ SetKeyValue(iEnt, "buying", "3", "info_map_parameters");
243
+ dllfunc(DLLFunc_KeyValue, iEnt, 0);
244
+ }
245
+
246
+ SetKeyValue(iEnt, const szKey[], const szValue[], const szClassName[])
247
+ {
248
+ set_kvd(0, KV_ClassName, szClassName);
249
+ set_kvd(0, KV_KeyName, szKey);
250
+ set_kvd(0, KV_Value, szValue);
251
+ set_kvd(0, KV_fHandled, 0);
252
+
253
+ dllfunc(DLLFunc_KeyValue, iEnt, 0);
254
+ }
255
+
256
+ How to remove properly an entity in the map:
257
+
258
+ Code:
259
+ #include <amxmodx>
260
+ #include <fakemeta>
261
+
262
+ new const g_RemoveEntity[] = "func_push";
263
+
264
+ public plugin_precache()
265
+ {
266
+ register_plugin("Fine", "and", "you?");
267
+
268
+ // Remember to do this in plugin_precache, if you
269
+ // do this in plugin_init( ) this will not work!
270
+
271
+ register_forward(FM_Spawn, "HookFmSpawn", 1);
272
+ }
273
+
274
+ public HookFmSpawn(iEntity)
275
+ {
276
+ if(!pev_valid(iEntity) )
277
+ return FMRES_IGNORED;
278
+
279
+ new szClassName[32];
280
+ pev(iEntity, pev_classname, szClassName, 31);
281
+
282
+ if(equali(szClassName, g_RemoveEntity) )
283
+ {
284
+ engfunc(EngFunc_RemoveEntity, iEntity);
285
+ return FMRES_SUPERCEDE;
286
+ }
287
+
288
+ return FMRES_IGNORED;
289
+ }
290
+
291
+ This is really simple but, for some people that want to do something at the first spawn only, or at the first event (round start, or whatever):
292
+
293
+ Code:
294
+ #include <amxmodx>
295
+ #include <hamsandwich>
296
+
297
+ #define PLUGIN "First Spawn"
298
+ #define AUTHOR "Alucard"
299
+ #define VERSION "0.0.1"
300
+
301
+ new bool:FirstSpawn[33];
302
+
303
+ public plugin_init()
304
+ {
305
+ register_plugin(PLUGIN, VERSION, AUTHOR);
306
+ RegisterHam(Ham_Spawn, "player", "HookPlrSpawn", 1);
307
+ }
308
+
309
+ public client_connect(id)
310
+ FirstSpawn[id] = true;
311
+
312
+ public HookPlrSpawn(id)
313
+ {
314
+ if(FirstSpawn[id])
315
+ {
316
+ // do stuff here, that you only want
317
+ // to do at the first spawn
318
+
319
+ FirstSpawn[id] = false;
320
+ }
321
+ }
fakemeta_util.inc.txt ADDED
@@ -0,0 +1,831 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Fakemeta Utilities
2
+ *
3
+ * by VEN
4
+ *
5
+ * This file is provided as is (no warranties).
6
+ */
7
+
8
+ #if !defined _fakemeta_included
9
+ #include <fakemeta>
10
+ #endif
11
+
12
+ #if defined _fakemeta_util_included
13
+ #endinput
14
+ #endif
15
+ #define _fakemeta_util_included
16
+
17
+ #include <xs>
18
+ #include <hlsdk_const> //! this line should be removed for 1.75
19
+
20
+
21
+ /* Engine functions */
22
+
23
+ #define fm_precache_generic(%1) engfunc(EngFunc_PrecacheGeneric, %1)
24
+ /* stock fm_precache_generic(const file[])
25
+ return engfunc(EngFunc_PrecacheGeneric, file) */
26
+
27
+ #define fm_precache_event(%1,%2) engfunc(EngFunc_PrecacheEvent, %1, %2)
28
+ /* stock fm_precache_event(type, const name[])
29
+ return engfunc(EngFunc_PrecacheEvent, type, name) */
30
+
31
+ // ported by v3x
32
+ #define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor, %1)
33
+ /* stock fm_drop_to_floor(entity)
34
+ return engfunc(EngFunc_DropToFloor, entity) */
35
+
36
+ #define fm_force_use(%1,%2) dllfunc(DLLFunc_Use, %2, %1)
37
+ /* stock fm_force_use(user, used)
38
+ return dllfunc(DLLFunc_Use, used, user) */
39
+
40
+ #define fm_entity_set_size(%1,%2,%3) engfunc(EngFunc_SetSize, %1, %2, %3)
41
+ /* stock fm_entity_set_size(index, const Float:mins[3], const Float:maxs[3])
42
+ return engfunc(EngFunc_SetSize, index, mins, maxs) */
43
+
44
+ #define fm_get_decal_index(%1) engfunc(EngFunc_DecalIndex, %1)
45
+ /* stock fm_get_decal_index(const decalname[])
46
+ return engfunc(EngFunc_DecalIndex, decalname) */
47
+
48
+ stock Float:fm_entity_range(ent1, ent2) {
49
+ new Float:origin1[3], Float:origin2[3]
50
+ pev(ent1, pev_origin, origin1)
51
+ pev(ent2, pev_origin, origin2)
52
+
53
+ return get_distance_f(origin1, origin2)
54
+ }
55
+
56
+ // based on KoST's port, upgraded version fits into the macros
57
+ #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
58
+ /* stock fm_create_entity(const classname[])
59
+ return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname)) */
60
+
61
+ #define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
62
+ /* stock fm_find_ent_by_class(index, const classname[])
63
+ return engfunc(EngFunc_FindEntityByString, index, "classname", classname) */
64
+
65
+ stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
66
+ new strtype[11] = "classname", ent = index
67
+ switch (jghgtype) {
68
+ case 1: copy(strtype, 6, "target")
69
+ case 2: copy(strtype, 10, "targetname")
70
+ }
71
+
72
+ while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
73
+
74
+ return ent
75
+ }
76
+
77
+ #define fm_find_ent_by_target(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "target", %2)
78
+ /* stock fm_find_ent_by_target(index, const target[])
79
+ return engfunc(EngFunc_FindEntityByString, index, "target", target) */
80
+
81
+ #define fm_find_ent_by_tname(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "targetname", %2)
82
+ /* stock fm_find_ent_by_tname(index, const targetname[])
83
+ return engfunc(EngFunc_FindEntityByString, index, "targetname", targetname) */
84
+
85
+ stock fm_find_ent_by_model(index, const classname[], const model[]) {
86
+ new ent = index, mdl[72]
87
+ while ((ent = fm_find_ent_by_class(ent, classname))) {
88
+ pev(ent, pev_model, mdl, 71)
89
+ if (equal(mdl, model))
90
+ return ent
91
+ }
92
+
93
+ return 0
94
+ }
95
+
96
+ #define fm_find_ent_in_sphere(%1,%2,%3) engfunc(EngFunc_FindEntityInSphere, %1, %2, %3)
97
+ /* stock fm_find_ent_in_sphere(index, const Float:origin[3], Float:radius)
98
+ return engfunc(EngFunc_FindEntityInSphere, index, origin, radius) */
99
+
100
+ #define fm_call_think(%1) dllfunc(DLLFunc_Think, %1)
101
+ /* stock fm_call_think(entity)
102
+ return dllfunc(DLLFunc_Think, entity) */
103
+
104
+ #define fm_is_valid_ent(%1) pev_valid(%1)
105
+ /* stock fm_is_valid_ent(index)
106
+ return pev_valid(index) */
107
+
108
+ stock fm_entity_set_origin(index, const Float:origin[3]) {
109
+ new Float:mins[3], Float:maxs[3]
110
+ pev(index, pev_mins, mins)
111
+ pev(index, pev_maxs, maxs)
112
+ engfunc(EngFunc_SetSize, index, mins, maxs)
113
+
114
+ return engfunc(EngFunc_SetOrigin, index, origin)
115
+ }
116
+
117
+ #define fm_entity_set_model(%1,%2) engfunc(EngFunc_SetModel, %1, %2)
118
+ /* stock fm_entity_set_model(index, const model[])
119
+ return engfunc(EngFunc_SetModel, index, model) */
120
+
121
+ // ported by v3x
122
+ #define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
123
+ /* stock fm_remove_entity(index)
124
+ return engfunc(EngFunc_RemoveEntity, index) */
125
+
126
+ #define fm_entity_count() engfunc(EngFunc_NumberOfEntities)
127
+ /* stock fm_entity_count()
128
+ return engfunc(EngFunc_NumberOfEntities) */
129
+
130
+ #define fm_fake_touch(%1,%2) dllfunc(DLLFunc_Touch, %1, %2)
131
+ /* stock fm_fake_touch(toucher, touched)
132
+ return dllfunc(DLLFunc_Touch, toucher, touched) */
133
+
134
+ #define fm_DispatchSpawn(%1) dllfunc(DLLFunc_Spawn, %1)
135
+ /* stock fm_DispatchSpawn(entity)
136
+ return dllfunc(DLLFunc_Spawn, entity) */
137
+
138
+ stock fm_velocity_by_aim(index, multiplier, Float:velocity[3]) {
139
+ new Float:vec[3]
140
+ pev(index, pev_v_angle, vec)
141
+ engfunc(EngFunc_MakeVectors, vec)
142
+ global_get(glb_v_forward, vec)
143
+
144
+ velocity[0] = vec[0] * multiplier
145
+ velocity[1] = vec[1] * multiplier
146
+ velocity[2] = vec[2] * multiplier
147
+
148
+ return 1
149
+ }
150
+
151
+ // ported by v3x
152
+ #define fm_point_contents(%1) engfunc(EngFunc_PointContents, %1)
153
+ /* stock fm_point_contents(const Float:point[3])
154
+ return engfunc(EngFunc_PointContents, point) */
155
+
156
+ stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
157
+ engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent)
158
+
159
+ new ent = global_get(glb_trace_ent)
160
+ global_get(glb_trace_endpos, ret)
161
+
162
+ return pev_valid(ent) ? ent : 0
163
+ }
164
+
165
+ stock fm_trace_hull(const Float:origin[3], hull, ignoredent = 0, ignoremonsters = 0) {
166
+ new tr = 0, result = 0
167
+ engfunc(EngFunc_TraceHull, origin, origin, ignoremonsters, hull, ignoredent > 0 ? ignoredent : 0, tr)
168
+
169
+ if (get_tr2(tr, TR_StartSolid))
170
+ result += 1
171
+ if (get_tr2(tr, TR_AllSolid))
172
+ result += 2
173
+ if (!get_tr2(tr, TR_InOpen))
174
+ result += 4
175
+
176
+ return result
177
+ }
178
+
179
+ stock fm_trace_normal(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
180
+ new tr = 0
181
+ engfunc(EngFunc_TraceLine, start, end, 0, ignoreent, tr)
182
+ get_tr2(tr, TR_vecPlaneNormal, ret)
183
+
184
+ new Float:fraction
185
+ get_tr2(tr, TR_flFraction, fraction)
186
+ if (fraction >= 1.0)
187
+ return 0
188
+
189
+ return 1
190
+ }
191
+
192
+ #define fm_vector_to_angle(%1,%2) engfunc(EngFunc_VecToAngles, %1, %2)
193
+ /* stock fm_vector_to_angle(const Float:vector[3], Float:anglevec[3])
194
+ return engfunc(EngFunc_VecToAngles, vector, anglevec) */
195
+
196
+ stock fm_angle_vector(const Float:vector[3], FRU, Float:ret[3]) {
197
+ new Float:fwd[3], Float:right[3], Float:up[3]
198
+ engfunc(EngFunc_AngleVectors, vector, fwd, right, up)
199
+
200
+ switch (FRU) {
201
+ case 1: xs_vec_copy(fwd, ret)
202
+ case 2: xs_vec_copy(right, ret)
203
+ case 3: xs_vec_copy(up, ret)
204
+ }
205
+
206
+ return 1
207
+ }
208
+
209
+ stock Float:fm_vector_length(const Float:vector[3]) {
210
+ return floatsqroot(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2])
211
+ }
212
+
213
+ #define fm_vector_distance(%1,%2) get_distance_f(%1, %2)
214
+ /* stock Float:fm_vector_distance(const Float:vector1[3], const Float:vector2[3])
215
+ return get_distance_f(vector1, vector2) */
216
+
217
+ // note that for CS planted C4 has a "grenade" classname as well
218
+ stock fm_get_grenade_id(id, model[], len, grenadeid = 0) {
219
+ new ent = fm_find_ent_by_owner(grenadeid, "grenade", id)
220
+ if (ent && len > 0)
221
+ pev(ent, pev_model, model, len)
222
+
223
+ return ent
224
+ }
225
+
226
+ #define fm_halflife_time() get_gametime()
227
+ /* stock Float:fm_halflife_time()
228
+ return get_gametime() */
229
+
230
+ #define fm_attach_view(%1,%2) engfunc(EngFunc_SetView, %1, %2)
231
+ /* stock fm_attach_view(index, entity)
232
+ return engfunc(EngFunc_SetView, index, entity) */
233
+
234
+ stock fm_playback_event(flags, invoker, eventindex, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2) {
235
+ return engfunc(EngFunc_PlaybackEvent, flags, invoker, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2)
236
+ }
237
+
238
+ #define fm_eng_get_string(%1,%2,%3) engfunc(EngFunc_SzFromIndex, %1, %2, %3)
239
+ /* stock fm_eng_get_string(istring, string[], len)
240
+ return engfunc(EngFunc_SzFromIndex, istring, string, len) */
241
+
242
+
243
+ /* HLSDK functions */
244
+
245
+ #define M_PI 3.14159265358979323846 //! should be removed for 1.75
246
+
247
+ // the dot product is performed in 2d, making the view cone infinitely tall
248
+ stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
249
+ new Float:angles[3]
250
+ pev(index, pev_angles, angles)
251
+ engfunc(EngFunc_MakeVectors, angles)
252
+ global_get(glb_v_forward, angles)
253
+ angles[2] = 0.0
254
+
255
+ new Float:origin[3], Float:diff[3], Float:norm[3]
256
+ pev(index, pev_origin, origin)
257
+ xs_vec_sub(point, origin, diff)
258
+ diff[2] = 0.0
259
+ xs_vec_normalize(diff, norm)
260
+
261
+ new Float:dot, Float:fov
262
+ dot = xs_vec_dot(norm, angles)
263
+ pev(index, pev_fov, fov)
264
+ if (dot >= floatcos(fov * M_PI / 360))
265
+ return true
266
+
267
+ return false
268
+ }
269
+
270
+ stock bool:fm_is_visible(index, const Float:point[3]) {
271
+ new Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
272
+ pev(index, pev_origin, origin)
273
+ pev(index, pev_view_ofs, view_ofs)
274
+ xs_vec_add(origin, view_ofs, eyespos)
275
+
276
+ engfunc(EngFunc_TraceLine, eyespos, point, 0, index)
277
+
278
+ new Float:fraction
279
+ global_get(glb_trace_fraction, fraction)
280
+ if (fraction == 1.0)
281
+ return true
282
+
283
+ return false
284
+ }
285
+
286
+
287
+ /* Engine_stocks functions */
288
+
289
+ stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
290
+ new class[] = "trigger_hurt"
291
+ new entity = fm_create_entity(class)
292
+ if (!entity)
293
+ return 0
294
+
295
+ new value[16]
296
+ format(value, 15, "%f", takedmgdamage * 2)
297
+ fm_set_kvd(entity, "dmg", value, class)
298
+
299
+ format(value, 15, "%i", damagetype)
300
+ fm_set_kvd(entity, "damagetype", value, class)
301
+
302
+ fm_set_kvd(entity, "origin", "8192 8192 8192", class)
303
+ fm_DispatchSpawn(entity)
304
+
305
+ set_pev(entity, pev_classname, classname)
306
+ fm_fake_touch(entity, victim)
307
+ fm_remove_entity(entity)
308
+
309
+ return 1
310
+ }
311
+
312
+ #define fm_find_ent(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
313
+ /* stock fm_find_ent(index, const classname[])
314
+ return engfunc(EngFunc_FindEntityByString, index, "classname", classname) */
315
+
316
+ stock fm_IVecFVec(const IVec[3], Float:FVec[3]) {
317
+ FVec[0] = float(IVec[0])
318
+ FVec[1] = float(IVec[1])
319
+ FVec[2] = float(IVec[2])
320
+
321
+ return 1
322
+ }
323
+
324
+ stock fm_FVecIVec(const Float:FVec[3], IVec[3]) {
325
+ IVec[0] = floatround(FVec[0])
326
+ IVec[1] = floatround(FVec[1])
327
+ IVec[2] = floatround(FVec[2])
328
+
329
+ return 1
330
+ }
331
+
332
+ #define fm_get_user_button(%1) pev(%1, pev_button)
333
+ /* stock fm_get_user_button(index)
334
+ return pev(index, pev_button) */
335
+
336
+ #define fm_get_user_oldbutton(%1) pev(%1, pev_oldbuttons)
337
+ /* stock fm_get_user_oldbutton(index)
338
+ return pev(index, pev_oldbuttons) */
339
+
340
+ #define fm_get_entity_flags(%1) pev(%1, pev_flags)
341
+ /* stock fm_get_entity_flags(index)
342
+ return pev(index, pev_flags) */
343
+
344
+ #define fm_get_entity_distance(%1,%2) floatround(fm_entity_range(%1, %2))
345
+ /* stock fm_get_entity_distance(ent1, ent2)
346
+ return floatround(fm_entity_range(ent1, ent2)) */
347
+
348
+ #define fm_get_grenade(%1) fm_get_grenade_id(%1, "", 0)
349
+ /* stock fm_get_grenade(id)
350
+ return fm_get_grenade_id(id, "", 0) */
351
+
352
+ // optimization idea by Orangutanz
353
+ stock fm_get_brush_entity_origin(index, Float:origin[3]) {
354
+ new Float:mins[3], Float:maxs[3]
355
+ pev(index, pev_mins, mins)
356
+ pev(index, pev_maxs, maxs)
357
+
358
+ origin[0] = (mins[0] + maxs[0]) * 0.5
359
+ origin[1] = (mins[1] + maxs[1]) * 0.5
360
+ origin[2] = (mins[2] + maxs[2]) * 0.5
361
+
362
+ return 1
363
+ }
364
+
365
+ // based on v3x's port, upgraded version returns number of removed entities
366
+ stock fm_remove_entity_name(const classname[]) {
367
+ new ent = -1, num = 0
368
+ while ((ent = fm_find_ent_by_class(ent, classname)))
369
+ num += fm_remove_entity(ent)
370
+
371
+ return num
372
+ }
373
+
374
+ stock fm_ViewContents(id) {
375
+ new origin[3], Float:Orig[3]
376
+ get_user_origin(id, origin, 3)
377
+ fm_IVecFVec(origin, Orig)
378
+
379
+ return fm_point_contents(Orig)
380
+ }
381
+
382
+ stock fm_get_speed(entity) {
383
+ new Float:Vel[3]
384
+ pev(entity, pev_velocity, Vel)
385
+
386
+ return floatround(fm_vector_length(Vel))
387
+ }
388
+
389
+ stock fm_make_deathmsg(killer, victim, headshot, /* const */ weapon[]) {
390
+ message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0, 0, 0}, 0)
391
+ write_byte(killer)
392
+ write_byte(victim)
393
+
394
+ new mod_name[32]
395
+ get_modname(mod_name, 31)
396
+ if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"))
397
+ write_byte(headshot)
398
+
399
+ write_string(weapon)
400
+ message_end()
401
+
402
+ return 1
403
+ }
404
+
405
+ stock fm_dod_make_deathmsg(killer, victim, weaponNUM) {
406
+ message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0, 0, 0}, 0)
407
+ write_byte(killer)
408
+ write_byte(victim)
409
+ write_byte(weaponNUM)
410
+ message_end()
411
+
412
+ return 1
413
+ }
414
+
415
+ //! should be uncommented for 1.75
416
+ /*
417
+ stock fm_user_silentkill(index) {
418
+ set_msg_block(get_user_msgid("DeathMsg"), BLOCK_ONCE)
419
+ user_kill(index, 1)
420
+
421
+ return 1
422
+ }
423
+ */
424
+
425
+ stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
426
+ new Float:RenderColor[3]
427
+ RenderColor[0] = float(r)
428
+ RenderColor[1] = float(g)
429
+ RenderColor[2] = float(b)
430
+
431
+ set_pev(entity, pev_renderfx, fx)
432
+ set_pev(entity, pev_rendercolor, RenderColor)
433
+ set_pev(entity, pev_rendermode, render)
434
+ set_pev(entity, pev_renderamt, float(amount))
435
+
436
+ return 1
437
+ }
438
+
439
+ stock fm_set_entity_flags(index, flag, onoff) {
440
+ new flags = pev(index, pev_flags)
441
+ if ((flags & flag) > 0)
442
+ return onoff == 1 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags - flag)
443
+ else
444
+ return onoff == 0 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags + flag)
445
+
446
+ return 0
447
+ }
448
+
449
+ stock fm_set_entity_visibility(index, visible = 1) {
450
+ set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)
451
+
452
+ return 1
453
+ }
454
+
455
+ #define fm_get_entity_visibility(%1) (!(pev(%1, pev_effects) & EF_NODRAW))
456
+ /* stock fm_get_entity_visibility(index)
457
+ return !(pev(index, pev_effects) & EF_NODRAW) */
458
+
459
+ stock fm_set_user_velocity(entity, const Float:vector[3]) {
460
+ set_pev(entity, pev_velocity, vector)
461
+
462
+ return 1
463
+ }
464
+
465
+ #define fm_get_user_velocity(%1,%2) pev(%1, pev_velocity, %2)
466
+ /* stock fm_get_user_velocity(entity, Float:vector[3])
467
+ return pev(entity, pev_velocity, vector) */
468
+
469
+
470
+ /* Fun functions */
471
+
472
+ #define fm_get_client_listen(%1,%2) engfunc(EngFunc_GetClientListening, %1, %2)
473
+ /* stock fm_get_client_listen(receiver, sender)
474
+ return engfunc(EngFunc_GetClientListening, receiver, sender) */
475
+
476
+ #define fm_set_client_listen(%1,%2,%3) engfunc(EngFunc_SetClientListening, %1, %2, %3)
477
+ /* stock fm_set_client_listen(receiver, sender, listen)
478
+ return engfunc(EngFunc_SetClientListening, receiver, sender, listen) */
479
+
480
+ stock fm_get_user_godmode(index) {
481
+ new Float:val
482
+ pev(index, pev_takedamage, val)
483
+
484
+ return (val == 0.0)
485
+ }
486
+
487
+ stock fm_set_user_godmode(index, godmode = 0) {
488
+ set_pev(index, pev_takedamage, godmode == 1 ? 0.0 : 2.0)
489
+
490
+ return 1
491
+ }
492
+
493
+ stock fm_set_user_armor(index, armor) {
494
+ set_pev(index, pev_armorvalue, float(armor))
495
+
496
+ return 1
497
+ }
498
+
499
+ stock fm_set_user_health(index, health) {
500
+ health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
501
+
502
+ return 1
503
+ }
504
+
505
+ stock fm_set_user_origin(index, const origin[3]) {
506
+ new Float:orig[3]
507
+ fm_IVecFVec(origin, orig)
508
+
509
+ return fm_entity_set_origin(index, orig)
510
+ }
511
+
512
+ stock fm_set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
513
+ return fm_set_rendering(index, fx, r, g, b, render, amount)
514
+ }
515
+
516
+ stock fm_give_item(index, const item[]) {
517
+ if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
518
+ return 0
519
+
520
+ new ent = fm_create_entity(item)
521
+ if (!pev_valid(ent))
522
+ return 0
523
+
524
+ new Float:origin[3]
525
+ pev(index, pev_origin, origin)
526
+ set_pev(ent, pev_origin, origin)
527
+ set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
528
+ dllfunc(DLLFunc_Spawn, ent)
529
+
530
+ new save = pev(ent, pev_solid)
531
+ dllfunc(DLLFunc_Touch, ent, index)
532
+ if (pev(ent, pev_solid) != save)
533
+ return ent
534
+
535
+ engfunc(EngFunc_RemoveEntity, ent)
536
+
537
+ return -1
538
+ }
539
+
540
+ stock fm_set_user_maxspeed(index, Float:speed = -1.0) {
541
+ engfunc(EngFunc_SetClientMaxspeed, index, speed)
542
+ set_pev(index, pev_maxspeed, speed)
543
+
544
+ return 1
545
+ }
546
+
547
+ stock Float:fm_get_user_maxspeed(index) {
548
+ new Float:speed
549
+ pev(index, pev_maxspeed, speed)
550
+
551
+ return speed
552
+ }
553
+
554
+ stock fm_set_user_gravity(index, Float:gravity = 1.0) {
555
+ set_pev(index, pev_gravity, gravity)
556
+
557
+ return 1
558
+ }
559
+
560
+ stock Float:fm_get_user_gravity(index) {
561
+ new Float:gravity
562
+ pev(index, pev_gravity, gravity)
563
+
564
+ return gravity
565
+ }
566
+
567
+ /* interferes with FM_Spawn enum, just use fm_DispatchSpawn
568
+ stock fm_spawn(entity) {
569
+ return dllfunc(DLLFunc_Spawn, entity)
570
+ }
571
+ */
572
+
573
+ stock fm_set_user_noclip(index, noclip = 0) {
574
+ set_pev(index, pev_movetype, noclip == 1 ? MOVETYPE_NOCLIP : MOVETYPE_WALK)
575
+
576
+ return 1
577
+ }
578
+
579
+ #define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)
580
+ /* stock fm_get_user_noclip(index)
581
+ return (pev(index, pev_movetype) == MOVETYPE_NOCLIP) */
582
+
583
+ // note: get_user_weapon will still return former weapon index
584
+ stock fm_strip_user_weapons(index) {
585
+ new ent = fm_create_entity("player_weaponstrip")
586
+ if (!pev_valid(ent))
587
+ return 0
588
+
589
+ dllfunc(DLLFunc_Spawn, ent)
590
+ dllfunc(DLLFunc_Use, ent, index)
591
+ engfunc(EngFunc_RemoveEntity, ent)
592
+
593
+ return 1
594
+ }
595
+
596
+ stock fm_set_user_frags(index, frags) {
597
+ set_pev(index, pev_frags, float(frags))
598
+
599
+ return 1
600
+ }
601
+
602
+
603
+ /* Cstrike functions */
604
+
605
+ stock fm_cs_user_spawn(index) {
606
+ set_pev(index, pev_deadflag, DEAD_RESPAWNABLE)
607
+ dllfunc(DLLFunc_Spawn, index)
608
+ set_pev(index, pev_iuser1, 0)
609
+
610
+ return 1
611
+ }
612
+
613
+
614
+ /* Other functions */
615
+
616
+ // based on Basic-Master's set_keyvalue, upgraded version optionally accepts a classname
617
+ stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
618
+ if (classname[0])
619
+ set_kvd(0, KV_ClassName, classname)
620
+ else {
621
+ new class[32]
622
+ pev(entity, pev_classname, class, 31)
623
+ set_kvd(0, KV_ClassName, class)
624
+ }
625
+
626
+ set_kvd(0, KV_KeyName, key)
627
+ set_kvd(0, KV_Value, value)
628
+ set_kvd(0, KV_fHandled, 0)
629
+
630
+ return dllfunc(DLLFunc_KeyValue, entity, 0)
631
+ }
632
+
633
+ stock fm_find_ent_by_integer(index, pev_field, value) {
634
+ new maxents = global_get(glb_maxEntities)
635
+ for (new i = index + 1; i < maxents; ++i) {
636
+ if (pev_valid(i) && pev(i, pev_field) == value)
637
+ return i
638
+ }
639
+
640
+ return 0
641
+ }
642
+
643
+ stock fm_find_ent_by_flags(index, pev_field, flags) {
644
+ new maxents = global_get(glb_maxEntities)
645
+ for (new i = index + 1; i < maxents; ++i) {
646
+ if (pev_valid(i) && (pev(i, pev_field) & flags) == flags)
647
+ return i
648
+ }
649
+
650
+ return 0
651
+ }
652
+
653
+ stock Float:fm_distance_to_box(const Float:point[3], const Float:mins[3], const Float:maxs[3]) {
654
+ new Float:dist[3]
655
+ for (new i = 0; i < 3; ++i) {
656
+ if (point[i] > maxs[i])
657
+ dist[i] = point[i] - maxs[i]
658
+ else if (mins[i] > point[i])
659
+ dist[i] = mins[i] - point[i]
660
+ }
661
+
662
+ return fm_vector_length(dist)
663
+ }
664
+
665
+ stock Float:fm_boxes_distance(const Float:mins1[3], const Float:maxs1[3], const Float:mins2[3], const Float:maxs2[3]) {
666
+ new Float:dist[3]
667
+ for (new i = 0; i < 3; ++i) {
668
+ if (mins1[i] > maxs2[i])
669
+ dist[i] = mins1[i] - maxs2[i]
670
+ else if (mins2[i] > maxs1[i])
671
+ dist[i] = mins2[i] - maxs1[i]
672
+ }
673
+
674
+ return fm_vector_length(dist)
675
+ }
676
+
677
+ stock Float:fm_distance_to_boxent(entity, boxent) {
678
+ new Float:point[3]
679
+ pev(entity, pev_origin, point)
680
+
681
+ new Float:mins[3], Float:maxs[3]
682
+ pev(boxent, pev_absmin, mins)
683
+ pev(boxent, pev_absmax, maxs)
684
+
685
+ return fm_distance_to_box(point, mins, maxs)
686
+ }
687
+
688
+ stock Float:fm_boxents_distance(boxent1, boxent2) {
689
+ new Float:mins1[3], Float:maxs1[3]
690
+ pev(boxent1, pev_absmin, mins1)
691
+ pev(boxent1, pev_absmax, maxs1)
692
+
693
+ new Float:mins2[3], Float:maxs2[3]
694
+ pev(boxent2, pev_absmin, mins2)
695
+ pev(boxent2, pev_absmax, maxs2)
696
+
697
+ return fm_boxes_distance(mins1, maxs1, mins2, maxs2)
698
+ }
699
+
700
+ // projects the center of the player's feet base (originally by P34nut, improved)
701
+ stock Float:fm_distance_to_floor(index, ignoremonsters = 1) {
702
+ new Float:start[3], Float:dest[3], Float:end[3]
703
+ pev(index, pev_origin, start)
704
+ dest[0] = start[0]
705
+ dest[1] = start[1]
706
+ dest[2] = -8191.0
707
+
708
+ engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index)
709
+ global_get(glb_trace_endpos, end)
710
+
711
+ pev(index, pev_absmin, start)
712
+ new Float:ret = start[2] - end[2]
713
+
714
+ return ret > 0 ? ret : 0.0
715
+ }
716
+
717
+ stock fm_get_user_weapon_entity(id, wid = 0) {
718
+ new weap = wid, clip, ammo
719
+ if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
720
+ return 0
721
+
722
+ new class[32]
723
+ get_weaponname(weap, class, 31)
724
+
725
+ return fm_find_ent_by_owner(-1, class, id)
726
+ }
727
+
728
+ stock fm_kill_entity(index) {
729
+ set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME)
730
+
731
+ return 1
732
+ }
733
+
734
+ stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") {
735
+ new ent_class[32]
736
+ if (!wid && wname[0])
737
+ copy(ent_class, 31, wname)
738
+ else {
739
+ new weapon = wid, clip, ammo
740
+ if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
741
+ return false
742
+
743
+ get_weaponname(weapon, ent_class, 31)
744
+ }
745
+
746
+ new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)
747
+ if (!ent_weap)
748
+ return false
749
+
750
+ engclient_cmd(index, "drop", ent_class)
751
+
752
+ new ent_box = pev(ent_weap, pev_owner)
753
+ if (!ent_box || ent_box == index)
754
+ return false
755
+
756
+ dllfunc(DLLFunc_Think, ent_box)
757
+
758
+ return true
759
+ }
760
+
761
+ stock bool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "") {
762
+ new ent_class[32]
763
+ if (!wid && wname[0])
764
+ copy(ent_class, 31, wname)
765
+ else {
766
+ new weapon = wid, clip, ammo
767
+ if (!weapon && !(weapon = get_user_weapon(index1, clip, ammo)))
768
+ return false
769
+
770
+ get_weaponname(weapon, ent_class, 31)
771
+ }
772
+
773
+ new ent_weap = fm_find_ent_by_owner(-1, ent_class, index1)
774
+ if (!ent_weap)
775
+ return false
776
+
777
+ engclient_cmd(index1, "drop", ent_class)
778
+
779
+ new ent_box = pev(ent_weap, pev_owner)
780
+ if (!ent_box || ent_box == index1)
781
+ return false
782
+
783
+ set_pev(ent_box, pev_flags, pev(ent_box, pev_flags) | FL_ONGROUND)
784
+ dllfunc(DLLFunc_Touch, ent_box, index2)
785
+ if (pev(ent_weap, pev_owner) != index2)
786
+ return false
787
+
788
+ return true
789
+ }
790
+
791
+ stock bool:fm_is_ent_visible(index, entity) {
792
+ new Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
793
+ pev(index, pev_origin, origin)
794
+ pev(index, pev_view_ofs, view_ofs)
795
+ xs_vec_add(origin, view_ofs, eyespos)
796
+
797
+ new Float:entpos[3]
798
+ pev(entity, pev_origin, entpos)
799
+ engfunc(EngFunc_TraceLine, eyespos, entpos, 0, index)
800
+
801
+ switch (pev(entity, pev_solid)) {
802
+ case SOLID_BBOX..SOLID_BSP: return global_get(glb_trace_ent) == entity
803
+ }
804
+
805
+ new Float:fraction
806
+ global_get(glb_trace_fraction, fraction)
807
+ if (fraction == 1.0)
808
+ return true
809
+
810
+ return false
811
+ }
812
+
813
+ // ported from the core's get_user_origin (idea by Greenberet)
814
+ stock fm_get_aim_origin(index, Float:origin[3]) {
815
+ new Float:start[3], Float:view_ofs[3]
816
+ pev(index, pev_origin, start)
817
+ pev(index, pev_view_ofs, view_ofs)
818
+ xs_vec_add(start, view_ofs, start)
819
+
820
+ new Float:dest[3]
821
+ pev(index, pev_v_angle, dest)
822
+ engfunc(EngFunc_MakeVectors, dest)
823
+ global_get(glb_v_forward, dest)
824
+ xs_vec_mul_scalar(dest, 9999.0, dest)
825
+ xs_vec_add(start, dest, dest)
826
+
827
+ engfunc(EngFunc_TraceLine, start, dest, 0, index)
828
+ global_get(glb_trace_endpos, origin)
829
+
830
+ return 1
831
+ }
fakemeta_util2.inc.txt ADDED
@@ -0,0 +1,872 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Fakemeta Utilities
2
+ *
3
+ * by VEN
4
+ *
5
+ * This file is provided as is (no warranties).
6
+ */
7
+
8
+ #if !defined _fakemeta_included
9
+ #include <fakemeta>
10
+ #endif
11
+
12
+ #if defined _fakemeta_util_included
13
+ #endinput
14
+ #endif
15
+ #define _fakemeta_util_included
16
+
17
+ #include <xs>
18
+
19
+
20
+ /* Engine functions */
21
+
22
+ #define fm_precache_generic(%1) engfunc(EngFunc_PrecacheGeneric, %1)
23
+ /* stock fm_precache_generic(const file[])
24
+ return engfunc(EngFunc_PrecacheGeneric, file) */
25
+
26
+ #define fm_precache_event(%1,%2) engfunc(EngFunc_PrecacheEvent, %1, %2)
27
+ /* stock fm_precache_event(type, const name[])
28
+ return engfunc(EngFunc_PrecacheEvent, type, name) */
29
+
30
+ // ported by v3x
31
+ #define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor, %1)
32
+ /* stock fm_drop_to_floor(entity)
33
+ return engfunc(EngFunc_DropToFloor, entity) */
34
+
35
+ #define fm_force_use(%1,%2) dllfunc(DLLFunc_Use, %2, %1)
36
+ /* stock fm_force_use(user, used)
37
+ return dllfunc(DLLFunc_Use, used, user) */
38
+
39
+ #define fm_entity_set_size(%1,%2,%3) engfunc(EngFunc_SetSize, %1, %2, %3)
40
+ /* stock fm_entity_set_size(index, const Float:mins[3], const Float:maxs[3])
41
+ return engfunc(EngFunc_SetSize, index, mins, maxs) */
42
+
43
+ #define fm_get_decal_index(%1) engfunc(EngFunc_DecalIndex, %1)
44
+ /* stock fm_get_decal_index(const decalname[])
45
+ return engfunc(EngFunc_DecalIndex, decalname) */
46
+
47
+ stock Float:fm_entity_range(ent1, ent2) {
48
+ new Float:origin1[3], Float:origin2[3]
49
+ pev(ent1, pev_origin, origin1)
50
+ pev(ent2, pev_origin, origin2)
51
+
52
+ return get_distance_f(origin1, origin2)
53
+ }
54
+
55
+ // based on KoST's port, upgraded version fits into the macros
56
+ #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
57
+ /* stock fm_create_entity(const classname[])
58
+ return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname)) */
59
+
60
+ #define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
61
+ /* stock fm_find_ent_by_class(index, const classname[])
62
+ return engfunc(EngFunc_FindEntityByString, index, "classname", classname) */
63
+
64
+ stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
65
+ new strtype[11] = "classname", ent = index
66
+ switch (jghgtype) {
67
+ case 1: strtype = "target"
68
+ case 2: strtype = "targetname"
69
+ }
70
+
71
+ while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
72
+
73
+ return ent
74
+ }
75
+
76
+ #define fm_find_ent_by_target(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "target", %2)
77
+ /* stock fm_find_ent_by_target(index, const target[])
78
+ return engfunc(EngFunc_FindEntityByString, index, "target", target) */
79
+
80
+ #define fm_find_ent_by_tname(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "targetname", %2)
81
+ /* stock fm_find_ent_by_tname(index, const targetname[])
82
+ return engfunc(EngFunc_FindEntityByString, index, "targetname", targetname) */
83
+
84
+ stock fm_find_ent_by_model(index, const classname[], const model[]) {
85
+ new ent = index, mdl[72]
86
+ while ((ent = fm_find_ent_by_class(ent, classname))) {
87
+ pev(ent, pev_model, mdl, sizeof mdl - 1)
88
+ if (equal(mdl, model))
89
+ return ent
90
+ }
91
+
92
+ return 0
93
+ }
94
+
95
+ #define fm_find_ent_in_sphere(%1,%2,%3) engfunc(EngFunc_FindEntityInSphere, %1, %2, %3)
96
+ /* stock fm_find_ent_in_sphere(index, const Float:origin[3], Float:radius)
97
+ return engfunc(EngFunc_FindEntityInSphere, index, origin, radius) */
98
+
99
+ #define fm_call_think(%1) dllfunc(DLLFunc_Think, %1)
100
+ /* stock fm_call_think(entity)
101
+ return dllfunc(DLLFunc_Think, entity) */
102
+
103
+ #define fm_is_valid_ent(%1) pev_valid(%1)
104
+ /* stock fm_is_valid_ent(index)
105
+ return pev_valid(index) */
106
+
107
+ stock fm_entity_set_origin(index, const Float:origin[3]) {
108
+ new Float:mins[3], Float:maxs[3]
109
+ pev(index, pev_mins, mins)
110
+ pev(index, pev_maxs, maxs)
111
+ engfunc(EngFunc_SetSize, index, mins, maxs)
112
+
113
+ return engfunc(EngFunc_SetOrigin, index, origin)
114
+ }
115
+
116
+ #define fm_entity_set_model(%1,%2) engfunc(EngFunc_SetModel, %1, %2)
117
+ /* stock fm_entity_set_model(index, const model[])
118
+ return engfunc(EngFunc_SetModel, index, model) */
119
+
120
+ // ported by v3x
121
+ #define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
122
+ /* stock fm_remove_entity(index)
123
+ return engfunc(EngFunc_RemoveEntity, index) */
124
+
125
+ #define fm_entity_count() engfunc(EngFunc_NumberOfEntities)
126
+ /* stock fm_entity_count()
127
+ return engfunc(EngFunc_NumberOfEntities) */
128
+
129
+ #define fm_fake_touch(%1,%2) dllfunc(DLLFunc_Touch, %1, %2)
130
+ /* stock fm_fake_touch(toucher, touched)
131
+ return dllfunc(DLLFunc_Touch, toucher, touched) */
132
+
133
+ #define fm_DispatchSpawn(%1) dllfunc(DLLFunc_Spawn, %1)
134
+ /* stock fm_DispatchSpawn(entity)
135
+ return dllfunc(DLLFunc_Spawn, entity) */
136
+
137
+ // ported by v3x
138
+ #define fm_point_contents(%1) engfunc(EngFunc_PointContents, %1)
139
+ /* stock fm_point_contents(const Float:point[3])
140
+ return engfunc(EngFunc_PointContents, point) */
141
+
142
+ stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
143
+ engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0)
144
+
145
+ new ent = get_tr2(0, TR_pHit)
146
+ get_tr2(0, TR_vecEndPos, ret)
147
+
148
+ return pev_valid(ent) ? ent : 0
149
+ }
150
+
151
+ stock fm_trace_hull(const Float:origin[3], hull, ignoredent = 0, ignoremonsters = 0) {
152
+ new result = 0
153
+ engfunc(EngFunc_TraceHull, origin, origin, ignoremonsters, hull, ignoredent > 0 ? ignoredent : 0, 0)
154
+
155
+ if (get_tr2(0, TR_StartSolid))
156
+ result += 1
157
+ if (get_tr2(0, TR_AllSolid))
158
+ result += 2
159
+ if (!get_tr2(0, TR_InOpen))
160
+ result += 4
161
+
162
+ return result
163
+ }
164
+
165
+ stock fm_trace_normal(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
166
+ engfunc(EngFunc_TraceLine, start, end, 0, ignoreent, 0)
167
+ get_tr2(0, TR_vecPlaneNormal, ret)
168
+
169
+ new Float:fraction
170
+ get_tr2(0, TR_flFraction, fraction)
171
+ if (fraction >= 1.0)
172
+ return 0
173
+
174
+ return 1
175
+ }
176
+
177
+ // note that for CS planted C4 has a "grenade" classname as well
178
+ stock fm_get_grenade_id(id, model[], len, grenadeid = 0) {
179
+ new ent = fm_find_ent_by_owner(grenadeid, "grenade", id)
180
+ if (ent && len > 0)
181
+ pev(ent, pev_model, model, len)
182
+
183
+ return ent
184
+ }
185
+
186
+ #define fm_halflife_time() get_gametime()
187
+ /* stock Float:fm_halflife_time()
188
+ return get_gametime() */
189
+
190
+ #define fm_attach_view(%1,%2) engfunc(EngFunc_SetView, %1, %2)
191
+ /* stock fm_attach_view(index, entity)
192
+ return engfunc(EngFunc_SetView, index, entity) */
193
+
194
+ stock fm_playback_event(flags, invoker, eventindex, Float:delay, const Float:origin[3], const Float:angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2) {
195
+ return engfunc(EngFunc_PlaybackEvent, flags, invoker, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2)
196
+ }
197
+
198
+ #define fm_eng_get_string(%1,%2,%3) engfunc(EngFunc_SzFromIndex, %1, %2, %3)
199
+ /* stock fm_eng_get_string(istring, string[], len)
200
+ return engfunc(EngFunc_SzFromIndex, istring, string, len) */
201
+
202
+
203
+ /* HLSDK functions */
204
+
205
+ // the dot product is performed in 2d, making the view cone infinitely tall
206
+ stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
207
+ new Float:angles[3]
208
+ pev(index, pev_angles, angles)
209
+ engfunc(EngFunc_MakeVectors, angles)
210
+ global_get(glb_v_forward, angles)
211
+ angles[2] = 0.0
212
+
213
+ new Float:origin[3], Float:diff[3], Float:norm[3]
214
+ pev(index, pev_origin, origin)
215
+ xs_vec_sub(point, origin, diff)
216
+ diff[2] = 0.0
217
+ xs_vec_normalize(diff, norm)
218
+
219
+ new Float:dot, Float:fov
220
+ dot = xs_vec_dot(norm, angles)
221
+ pev(index, pev_fov, fov)
222
+ if (dot >= floatcos(fov * M_PI / 360))
223
+ return true
224
+
225
+ return false
226
+ }
227
+
228
+ stock bool:fm_is_visible(index, const Float:point[3], ignoremonsters = 0) {
229
+ new Float:start[3], Float:view_ofs[3]
230
+ pev(index, pev_origin, start)
231
+ pev(index, pev_view_ofs, view_ofs)
232
+ xs_vec_add(start, view_ofs, start)
233
+
234
+ engfunc(EngFunc_TraceLine, start, point, ignoremonsters, index, 0)
235
+
236
+ new Float:fraction
237
+ get_tr2(0, TR_flFraction, fraction)
238
+ if (fraction == 1.0)
239
+ return true
240
+
241
+ return false
242
+ }
243
+
244
+
245
+ /* Engine_stocks functions */
246
+
247
+ stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
248
+ new class[] = "trigger_hurt"
249
+ new entity = fm_create_entity(class)
250
+ if (!entity)
251
+ return 0
252
+
253
+ new value[16]
254
+ float_to_str(takedmgdamage * 2, value, sizeof value - 1)
255
+ fm_set_kvd(entity, "dmg", value, class)
256
+
257
+ num_to_str(damagetype, value, sizeof value - 1)
258
+ fm_set_kvd(entity, "damagetype", value, class)
259
+
260
+ fm_set_kvd(entity, "origin", "8192 8192 8192", class)
261
+ fm_DispatchSpawn(entity)
262
+
263
+ set_pev(entity, pev_classname, classname)
264
+ fm_fake_touch(entity, victim)
265
+ fm_remove_entity(entity)
266
+
267
+ return 1
268
+ }
269
+
270
+ #define fm_find_ent(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
271
+ /* stock fm_find_ent(index, const classname[])
272
+ return engfunc(EngFunc_FindEntityByString, index, "classname", classname) */
273
+
274
+ #define fm_get_user_button(%1) pev(%1, pev_button)
275
+ /* stock fm_get_user_button(index)
276
+ return pev(index, pev_button) */
277
+
278
+ #define fm_get_user_oldbutton(%1) pev(%1, pev_oldbuttons)
279
+ /* stock fm_get_user_oldbutton(index)
280
+ return pev(index, pev_oldbuttons) */
281
+
282
+ #define fm_get_entity_flags(%1) pev(%1, pev_flags)
283
+ /* stock fm_get_entity_flags(index)
284
+ return pev(index, pev_flags) */
285
+
286
+ #define fm_get_entity_distance(%1,%2) floatround(fm_entity_range(%1, %2))
287
+ /* stock fm_get_entity_distance(ent1, ent2)
288
+ return floatround(fm_entity_range(ent1, ent2)) */
289
+
290
+ #define fm_get_grenade(%1) fm_get_grenade_id(%1, "", 0)
291
+ /* stock fm_get_grenade(id)
292
+ return fm_get_grenade_id(id, "", 0) */
293
+
294
+ // optimization idea by Orangutanz
295
+ stock fm_get_brush_entity_origin(index, Float:origin[3]) {
296
+ new Float:mins[3], Float:maxs[3]
297
+ pev(index, pev_mins, mins)
298
+ pev(index, pev_maxs, maxs)
299
+
300
+ origin[0] = (mins[0] + maxs[0]) * 0.5
301
+ origin[1] = (mins[1] + maxs[1]) * 0.5
302
+ origin[2] = (mins[2] + maxs[2]) * 0.5
303
+
304
+ return 1
305
+ }
306
+
307
+ // based on v3x's port, upgraded version returns number of removed entities
308
+ stock fm_remove_entity_name(const classname[]) {
309
+ new ent = -1, num = 0
310
+ while ((ent = fm_find_ent_by_class(ent, classname)))
311
+ num += fm_remove_entity(ent)
312
+
313
+ return num
314
+ }
315
+
316
+ stock fm_ViewContents(id) {
317
+ new origin[3], Float:Orig[3]
318
+ get_user_origin(id, origin, 3)
319
+ IVecFVec(origin, Orig)
320
+
321
+ return fm_point_contents(Orig)
322
+ }
323
+
324
+ stock fm_get_speed(entity) {
325
+ new Float:Vel[3]
326
+ pev(entity, pev_velocity, Vel)
327
+
328
+ return floatround(vector_length(Vel))
329
+ }
330
+
331
+ stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
332
+ new Float:RenderColor[3]
333
+ RenderColor[0] = float(r)
334
+ RenderColor[1] = float(g)
335
+ RenderColor[2] = float(b)
336
+
337
+ set_pev(entity, pev_renderfx, fx)
338
+ set_pev(entity, pev_rendercolor, RenderColor)
339
+ set_pev(entity, pev_rendermode, render)
340
+ set_pev(entity, pev_renderamt, float(amount))
341
+
342
+ return 1
343
+ }
344
+
345
+ stock fm_set_entity_flags(index, flag, onoff) {
346
+ new flags = pev(index, pev_flags)
347
+ if ((flags & flag) > 0)
348
+ return onoff == 1 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags - flag)
349
+ else
350
+ return onoff == 0 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags + flag)
351
+
352
+ return 0
353
+ }
354
+
355
+ stock fm_set_entity_visibility(index, visible = 1) {
356
+ set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)
357
+
358
+ return 1
359
+ }
360
+
361
+ #define fm_get_entity_visibility(%1) (!(pev(%1, pev_effects) & EF_NODRAW))
362
+ /* stock fm_get_entity_visibility(index)
363
+ return !(pev(index, pev_effects) & EF_NODRAW) */
364
+
365
+ stock fm_set_user_velocity(entity, const Float:vector[3]) {
366
+ set_pev(entity, pev_velocity, vector)
367
+
368
+ return 1
369
+ }
370
+
371
+ #define fm_get_user_velocity(%1,%2) pev(%1, pev_velocity, %2)
372
+ /* stock fm_get_user_velocity(entity, Float:vector[3])
373
+ return pev(entity, pev_velocity, vector) */
374
+
375
+
376
+ /* Fun functions */
377
+
378
+ #define fm_get_client_listen(%1,%2) engfunc(EngFunc_GetClientListening, %1, %2)
379
+ /* stock fm_get_client_listen(receiver, sender)
380
+ return engfunc(EngFunc_GetClientListening, receiver, sender) */
381
+
382
+ #define fm_set_client_listen(%1,%2,%3) engfunc(EngFunc_SetClientListening, %1, %2, %3)
383
+ /* stock fm_set_client_listen(receiver, sender, listen)
384
+ return engfunc(EngFunc_SetClientListening, receiver, sender, listen) */
385
+
386
+ stock fm_get_user_godmode(index) {
387
+ new Float:val
388
+ pev(index, pev_takedamage, val)
389
+
390
+ return (val == DAMAGE_NO)
391
+ }
392
+
393
+ stock fm_set_user_godmode(index, godmode = 0) {
394
+ set_pev(index, pev_takedamage, godmode == 1 ? DAMAGE_NO : DAMAGE_AIM)
395
+
396
+ return 1
397
+ }
398
+
399
+ stock fm_set_user_armor(index, armor) {
400
+ set_pev(index, pev_armorvalue, float(armor))
401
+
402
+ return 1
403
+ }
404
+
405
+ stock fm_set_user_health(index, health) {
406
+ health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
407
+
408
+ return 1
409
+ }
410
+
411
+ stock fm_set_user_origin(index, /* const */ origin[3]) {
412
+ new Float:orig[3]
413
+ IVecFVec(origin, orig)
414
+
415
+ return fm_entity_set_origin(index, orig)
416
+ }
417
+
418
+ stock fm_set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
419
+ return fm_set_rendering(index, fx, r, g, b, render, amount)
420
+ }
421
+
422
+ stock fm_give_item(index, const item[]) {
423
+ if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
424
+ return 0
425
+
426
+ new ent = fm_create_entity(item)
427
+ if (!pev_valid(ent))
428
+ return 0
429
+
430
+ new Float:origin[3]
431
+ pev(index, pev_origin, origin)
432
+ set_pev(ent, pev_origin, origin)
433
+ set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
434
+ dllfunc(DLLFunc_Spawn, ent)
435
+
436
+ new save = pev(ent, pev_solid)
437
+ dllfunc(DLLFunc_Touch, ent, index)
438
+ if (pev(ent, pev_solid) != save)
439
+ return ent
440
+
441
+ engfunc(EngFunc_RemoveEntity, ent)
442
+
443
+ return -1
444
+ }
445
+
446
+ stock fm_set_user_maxspeed(index, Float:speed = -1.0) {
447
+ engfunc(EngFunc_SetClientMaxspeed, index, speed)
448
+ set_pev(index, pev_maxspeed, speed)
449
+
450
+ return 1
451
+ }
452
+
453
+ stock Float:fm_get_user_maxspeed(index) {
454
+ new Float:speed
455
+ pev(index, pev_maxspeed, speed)
456
+
457
+ return speed
458
+ }
459
+
460
+ stock fm_set_user_gravity(index, Float:gravity = 1.0) {
461
+ set_pev(index, pev_gravity, gravity)
462
+
463
+ return 1
464
+ }
465
+
466
+ stock Float:fm_get_user_gravity(index) {
467
+ new Float:gravity
468
+ pev(index, pev_gravity, gravity)
469
+
470
+ return gravity
471
+ }
472
+
473
+ /* interferes with FM_Spawn enum, just use fm_DispatchSpawn
474
+ stock fm_spawn(entity) {
475
+ return dllfunc(DLLFunc_Spawn, entity)
476
+ }
477
+ */
478
+
479
+ stock fm_set_user_noclip(index, noclip = 0) {
480
+ set_pev(index, pev_movetype, noclip == 1 ? MOVETYPE_NOCLIP : MOVETYPE_WALK)
481
+
482
+ return 1
483
+ }
484
+
485
+ #define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)
486
+ /* stock fm_get_user_noclip(index)
487
+ return (pev(index, pev_movetype) == MOVETYPE_NOCLIP) */
488
+
489
+ // note: get_user_weapon will still return former weapon index
490
+ stock fm_strip_user_weapons(index) {
491
+ new ent = fm_create_entity("player_weaponstrip")
492
+ if (!pev_valid(ent))
493
+ return 0
494
+
495
+ dllfunc(DLLFunc_Spawn, ent)
496
+ dllfunc(DLLFunc_Use, ent, index)
497
+ engfunc(EngFunc_RemoveEntity, ent)
498
+
499
+ return 1
500
+ }
501
+
502
+ stock fm_set_user_frags(index, frags) {
503
+ set_pev(index, pev_frags, float(frags))
504
+
505
+ return 1
506
+ }
507
+
508
+
509
+ /* Cstrike functions */
510
+
511
+ stock fm_cs_user_spawn(index) {
512
+ set_pev(index, pev_deadflag, DEAD_RESPAWNABLE)
513
+ dllfunc(DLLFunc_Spawn, index)
514
+ set_pev(index, pev_iuser1, 0)
515
+
516
+ return 1
517
+ }
518
+
519
+
520
+ /* Custom functions */
521
+
522
+ // based on Basic-Master's set_keyvalue, upgraded version accepts an optional classname (a bit more efficient if it is passed)
523
+ stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
524
+ if (classname[0])
525
+ set_kvd(0, KV_ClassName, classname)
526
+ else {
527
+ new class[32]
528
+ pev(entity, pev_classname, class, sizeof class - 1)
529
+ set_kvd(0, KV_ClassName, class)
530
+ }
531
+
532
+ set_kvd(0, KV_KeyName, key)
533
+ set_kvd(0, KV_Value, value)
534
+ set_kvd(0, KV_fHandled, 0)
535
+
536
+ return dllfunc(DLLFunc_KeyValue, entity, 0)
537
+ }
538
+
539
+ stock fm_find_ent_by_integer(index, pev_field, value) {
540
+ static maxents
541
+ if (!maxents)
542
+ maxents = global_get(glb_maxEntities)
543
+
544
+ for (new i = index + 1; i < maxents; ++i) {
545
+ if (pev_valid(i) && pev(i, pev_field) == value)
546
+ return i
547
+ }
548
+
549
+ return 0
550
+ }
551
+
552
+ stock fm_find_ent_by_flags(index, pev_field, flags) {
553
+ static maxents
554
+ if (!maxents)
555
+ maxents = global_get(glb_maxEntities)
556
+
557
+ for (new i = index + 1; i < maxents; ++i) {
558
+ if (pev_valid(i) && (pev(i, pev_field) & flags) == flags)
559
+ return i
560
+ }
561
+
562
+ return 0
563
+ }
564
+
565
+ stock Float:fm_distance_to_box(const Float:point[3], const Float:mins[3], const Float:maxs[3]) {
566
+ new Float:dist[3]
567
+ for (new i = 0; i < 3; ++i) {
568
+ if (point[i] > maxs[i])
569
+ dist[i] = point[i] - maxs[i]
570
+ else if (mins[i] > point[i])
571
+ dist[i] = mins[i] - point[i]
572
+ }
573
+
574
+ return vector_length(dist)
575
+ }
576
+
577
+ stock Float:fm_boxes_distance(const Float:mins1[3], const Float:maxs1[3], const Float:mins2[3], const Float:maxs2[3]) {
578
+ new Float:dist[3]
579
+ for (new i = 0; i < 3; ++i) {
580
+ if (mins1[i] > maxs2[i])
581
+ dist[i] = mins1[i] - maxs2[i]
582
+ else if (mins2[i] > maxs1[i])
583
+ dist[i] = mins2[i] - maxs1[i]
584
+ }
585
+
586
+ return vector_length(dist)
587
+ }
588
+
589
+ stock Float:fm_distance_to_boxent(entity, boxent) {
590
+ new Float:point[3]
591
+ pev(entity, pev_origin, point)
592
+
593
+ new Float:mins[3], Float:maxs[3]
594
+ pev(boxent, pev_absmin, mins)
595
+ pev(boxent, pev_absmax, maxs)
596
+
597
+ return fm_distance_to_box(point, mins, maxs)
598
+ }
599
+
600
+ stock Float:fm_boxents_distance(boxent1, boxent2) {
601
+ new Float:mins1[3], Float:maxs1[3]
602
+ pev(boxent1, pev_absmin, mins1)
603
+ pev(boxent1, pev_absmax, maxs1)
604
+
605
+ new Float:mins2[3], Float:maxs2[3]
606
+ pev(boxent2, pev_absmin, mins2)
607
+ pev(boxent2, pev_absmax, maxs2)
608
+
609
+ return fm_boxes_distance(mins1, maxs1, mins2, maxs2)
610
+ }
611
+
612
+ // projects a center of a player's feet base (originally by P34nut, improved)
613
+ stock Float:fm_distance_to_floor(index, ignoremonsters = 1) {
614
+ new Float:start[3], Float:dest[3], Float:end[3]
615
+ pev(index, pev_origin, start)
616
+ dest[0] = start[0]
617
+ dest[1] = start[1]
618
+ dest[2] = -8191.0
619
+
620
+ engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0)
621
+ get_tr2(0, TR_vecEndPos, end)
622
+
623
+ pev(index, pev_absmin, start)
624
+ new Float:ret = start[2] - end[2]
625
+
626
+ return ret > 0 ? ret : 0.0
627
+ }
628
+
629
+ // potential to crash (?) if used on weaponbox+weapon_* entity pair (use fm_remove_weaponbox instead)
630
+ stock fm_kill_entity(index) {
631
+ set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME)
632
+
633
+ return 1
634
+ }
635
+
636
+ // if weapon index isn't passed then assuming that it's the current weapon
637
+ stock fm_get_user_weapon_entity(id, wid = 0) {
638
+ new weap = wid, clip, ammo
639
+ if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
640
+ return 0
641
+
642
+ new class[32]
643
+ get_weaponname(weap, class, sizeof class - 1)
644
+
645
+ return fm_find_ent_by_owner(-1, class, id)
646
+ }
647
+
648
+ // only weapon index or its name can be passed, if neither is passed then the current gun will be stripped
649
+ stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") {
650
+ new ent_class[32]
651
+ if (!wid && wname[0])
652
+ copy(ent_class, sizeof ent_class - 1, wname)
653
+ else {
654
+ new weapon = wid, clip, ammo
655
+ if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
656
+ return false
657
+
658
+ get_weaponname(weapon, ent_class, sizeof ent_class - 1)
659
+ }
660
+
661
+ new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)
662
+ if (!ent_weap)
663
+ return false
664
+
665
+ engclient_cmd(index, "drop", ent_class)
666
+
667
+ new ent_box = pev(ent_weap, pev_owner)
668
+ if (!ent_box || ent_box == index)
669
+ return false
670
+
671
+ dllfunc(DLLFunc_Think, ent_box)
672
+
673
+ return true
674
+ }
675
+
676
+ // only weapon index or its name can be passed, if neither is passed then the current gun will be transferred
677
+ stock bool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "") {
678
+ new ent_class[32]
679
+ if (!wid && wname[0])
680
+ copy(ent_class, sizeof ent_class - 1, wname)
681
+ else {
682
+ new weapon = wid, clip, ammo
683
+ if (!weapon && !(weapon = get_user_weapon(index1, clip, ammo)))
684
+ return false
685
+
686
+ get_weaponname(weapon, ent_class, sizeof ent_class - 1)
687
+ }
688
+
689
+ new ent_weap = fm_find_ent_by_owner(-1, ent_class, index1)
690
+ if (!ent_weap)
691
+ return false
692
+
693
+ engclient_cmd(index1, "drop", ent_class)
694
+
695
+ new ent_box = pev(ent_weap, pev_owner)
696
+ if (!ent_box || ent_box == index1)
697
+ return false
698
+
699
+ set_pev(ent_box, pev_flags, pev(ent_box, pev_flags) | FL_ONGROUND)
700
+ dllfunc(DLLFunc_Touch, ent_box, index2)
701
+ if (pev(ent_weap, pev_owner) != index2)
702
+ return false
703
+
704
+ return true
705
+ }
706
+
707
+ stock bool:fm_is_ent_visible(index, entity, ignoremonsters = 0) {
708
+ new Float:start[3], Float:dest[3]
709
+ pev(index, pev_origin, start)
710
+ pev(index, pev_view_ofs, dest)
711
+ xs_vec_add(start, dest, start)
712
+
713
+ pev(entity, pev_origin, dest)
714
+ engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0)
715
+
716
+ new Float:fraction
717
+ get_tr2(0, TR_flFraction, fraction)
718
+ if (fraction == 1.0 || get_tr2(0, TR_pHit) == entity)
719
+ return true
720
+
721
+ return false
722
+ }
723
+
724
+ // ported from AMXX's core get_user_origin(..., 3) (suggested by Greenberet)
725
+ stock fm_get_aim_origin(index, Float:origin[3]) {
726
+ new Float:start[3], Float:view_ofs[3]
727
+ pev(index, pev_origin, start)
728
+ pev(index, pev_view_ofs, view_ofs)
729
+ xs_vec_add(start, view_ofs, start)
730
+
731
+ new Float:dest[3]
732
+ pev(index, pev_v_angle, dest)
733
+ engfunc(EngFunc_MakeVectors, dest)
734
+ global_get(glb_v_forward, dest)
735
+ xs_vec_mul_scalar(dest, 9999.0, dest)
736
+ xs_vec_add(start, dest, dest)
737
+
738
+ engfunc(EngFunc_TraceLine, start, dest, 0, index, 0)
739
+ get_tr2(0, TR_vecEndPos, origin)
740
+
741
+ return 1
742
+ }
743
+
744
+ stock bool:fm_get_user_longjump(index) {
745
+ new value[2]
746
+ engfunc(EngFunc_GetPhysicsKeyValue, index, "slj", value, 1)
747
+ switch (value[0]) {
748
+ case '1': return true
749
+ }
750
+
751
+ return false
752
+ }
753
+
754
+ stock fm_set_user_longjump(index, bool:longjump = true, bool:tempicon = true) {
755
+ if (longjump == fm_get_user_longjump(index))
756
+ return
757
+
758
+ if (longjump) {
759
+ engfunc(EngFunc_SetPhysicsKeyValue, index, "slj", "1")
760
+ if (tempicon) {
761
+ static msgid_itempickup
762
+ if (!msgid_itempickup)
763
+ msgid_itempickup = get_user_msgid("ItemPickup")
764
+
765
+ message_begin(MSG_ONE, msgid_itempickup, _, index)
766
+ write_string("item_longjump")
767
+ message_end()
768
+ }
769
+ }
770
+ else
771
+ engfunc(EngFunc_SetPhysicsKeyValue, index, "slj", "0")
772
+ }
773
+
774
+ #define WEAPON_SUIT 31
775
+
776
+ stock bool:fm_get_user_suit(index) {
777
+ return bool:(!(!(pev(index, pev_weapons) & (1<<WEAPON_SUIT)))) // i'm not insane, this is a trick!
778
+ }
779
+
780
+ stock fm_set_user_suit(index, bool:suit = true, bool:sound = true) {
781
+ new weapons = pev(index, pev_weapons)
782
+ if (!suit)
783
+ set_pev(index, pev_weapons, weapons & ~(1<<WEAPON_SUIT))
784
+ else if (!(weapons & (1<<WEAPON_SUIT))) {
785
+ set_pev(index, pev_weapons, weapons | (1<<WEAPON_SUIT))
786
+ if (sound)
787
+ emit_sound(index, CHAN_VOICE, "items/tr_kevlar.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
788
+ }
789
+ }
790
+
791
+ #define FEV_RELIABLE (1<<1)
792
+ #define FEV_GLOBAL (1<<2)
793
+
794
+ // removes all created decals and players' corpses from the world
795
+ // set a specific index to remove decals only for the given client
796
+ stock fm_cs_remove_decals(index = 0) {
797
+ static eventindex_decal_reset
798
+ if (!eventindex_decal_reset)
799
+ eventindex_decal_reset = engfunc(EngFunc_PrecacheEvent, 1, "events/decal_reset.sc")
800
+
801
+ new flags = FEV_RELIABLE
802
+ if (!index)
803
+ flags |= FEV_GLOBAL
804
+
805
+ engfunc(EngFunc_PlaybackEvent, flags, index, eventindex_decal_reset, 0.0, Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0}, 0.0, 0.0, 0, 0, 0, 0)
806
+ }
807
+
808
+ // checks whether the entity's classname is equal to the passed classname
809
+ stock bool:fm_is_ent_classname(index, const classname[]) {
810
+ if (!pev_valid(index))
811
+ return false
812
+
813
+ new class[32]
814
+ pev(index, pev_classname, class, sizeof class - 1)
815
+ if (equal(class, classname))
816
+ return true
817
+
818
+ return false
819
+ }
820
+
821
+ // the same as AMXX's core user_kill but fixes the issue when the scoreboard doesn't update immediately if flag is set to 1
822
+ stock fm_user_kill(index, flag = 0) {
823
+ if (flag) {
824
+ new Float:frags
825
+ pev(index, pev_frags, frags)
826
+ set_pev(index, pev_frags, ++frags)
827
+ }
828
+
829
+ dllfunc(DLLFunc_ClientKill, index)
830
+
831
+ return 1
832
+ }
833
+
834
+ // returns a degree angle between player-to-point and player's view vectors
835
+ stock Float:fm_get_view_angle_diff(index, const Float:point[3]) {
836
+ new Float:vec[3], Float:ofs[3], Float:aim[3]
837
+ pev(index, pev_origin, vec)
838
+ pev(index, pev_view_ofs, ofs)
839
+ xs_vec_add(vec, ofs, vec)
840
+ xs_vec_sub(point, vec, vec)
841
+ xs_vec_normalize(vec, vec)
842
+
843
+ pev(index, pev_v_angle, aim)
844
+ engfunc(EngFunc_MakeVectors, aim)
845
+ global_get(glb_v_forward, aim)
846
+
847
+ return xs_vec_angle(vec, aim)
848
+ }
849
+
850
+ // gets a weapon type of the linked to weaponbox weapon_* entity
851
+ stock fm_get_weaponbox_type(entity) {
852
+ static max_clients, max_entities
853
+ if (!max_clients)
854
+ max_clients = global_get(glb_maxClients)
855
+ if (!max_entities)
856
+ max_entities = global_get(glb_maxEntities)
857
+
858
+ for (new i = max_clients + 1; i < max_entities; ++i) {
859
+ if (pev_valid(i) && entity == pev(i, pev_owner)) {
860
+ new wname[32]
861
+ pev(i, pev_classname, wname, sizeof wname - 1)
862
+ return get_weaponid(wname)
863
+ }
864
+ }
865
+
866
+ return 0
867
+ }
868
+
869
+ // safe removal of weaponbox+weapon_* entity pair (delay =~= 0.03 second)
870
+ #define fm_remove_weaponbox(%1) dllfunc(DLLFunc_Think, %1)
871
+ /* stock fm_remove_weaponbox(entity)
872
+ return dllfunc(DLLFunc_Think, entity) */
hldsk_const.inc.txt ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Half-Life Software Development Kit constants
2
+ *
3
+ * by the AMX Mod X Development Team
4
+ *
5
+ * This file is provided as is (no warranties).
6
+ *
7
+ */
8
+
9
+ #if defined _hlsdk_const_included
10
+ #endinput
11
+ #endif
12
+ #define _hlsdk_const_included
13
+
14
+ // pev(entity, pev_button) or pev(entity, pev_oldbuttons) values
15
+ #define IN_ATTACK (1<<0)
16
+ #define IN_JUMP (1<<1)
17
+ #define IN_DUCK (1<<2)
18
+ #define IN_FORWARD (1<<3)
19
+ #define IN_BACK (1<<4)
20
+ #define IN_USE (1<<5)
21
+ #define IN_CANCEL (1<<6)
22
+ #define IN_LEFT (1<<7)
23
+ #define IN_RIGHT (1<<8)
24
+ #define IN_MOVELEFT (1<<9)
25
+ #define IN_MOVERIGHT (1<<10)
26
+ #define IN_ATTACK2 (1<<11)
27
+ #define IN_RUN (1<<12)
28
+ #define IN_RELOAD (1<<13)
29
+ #define IN_ALT1 (1<<14)
30
+ #define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down
31
+
32
+ // pev(entity, pev_flags) values
33
+ #define FL_FLY (1<<0) // Changes the SV_Movestep() behavior to not need to be on ground
34
+ #define FL_SWIM (1<<1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water)
35
+ #define FL_CONVEYOR (1<<2)
36
+ #define FL_CLIENT (1<<3)
37
+ #define FL_INWATER (1<<4)
38
+ #define FL_MONSTER (1<<5)
39
+ #define FL_GODMODE (1<<6)
40
+ #define FL_NOTARGET (1<<7)
41
+ #define FL_SKIPLOCALHOST (1<<8) // Don't send entity to local host, it's predicting this entity itself
42
+ #define FL_ONGROUND (1<<9) // At rest / on the ground
43
+ #define FL_PARTIALGROUND (1<<10) // Not all corners are valid
44
+ #define FL_WATERJUMP (1<<11) // Player jumping out of water
45
+ #define FL_FROZEN (1<<12) // Player is frozen for 3rd person camera
46
+ #define FL_FAKECLIENT (1<<13) // JAC: fake client, simulated server side; don't send network messages to them
47
+ #define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched
48
+ #define FL_FLOAT (1<<15) // Apply floating force to this entity when in water
49
+ #define FL_GRAPHED (1<<16) // Worldgraph has this ent listed as something that blocks a connection
50
+ #define FL_IMMUNE_WATER (1<<17)
51
+ #define FL_IMMUNE_SLIME (1<<18)
52
+ #define FL_IMMUNE_LAVA (1<<19)
53
+ #define FL_PROXY (1<<20) // This is a spectator proxy
54
+ #define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path)
55
+ #define FL_BASEVELOCITY (1<<22) // Base velocity has been applied this frame (used to convert base velocity into momentum)
56
+ #define FL_MONSTERCLIP (1<<23) // Only collide in with monsters who have FL_MONSTERCLIP set
57
+ #define FL_ONTRAIN (1<<24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
58
+ #define FL_WORLDBRUSH (1<<25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something)
59
+ #define FL_SPECTATOR (1<<26) // This client is a spectator, don't run touch functions, etc.
60
+ #define FL_CUSTOMENTITY (1<<29) // This is a custom entity
61
+ #define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
62
+ #define FL_DORMANT (1<<31) // Entity is dormant, no updates to client
63
+
64
+ // engfunc(EngFunc_WalkMove, entity, Float:yaw, Float:dist, iMode) iMode values
65
+ #define WALKMOVE_NORMAL 0 // Normal walkmove
66
+ #define WALKMOVE_WORLDONLY 1 // Doesn't hit ANY entities, no matter what the solid type
67
+ #define WALKMOVE_CHECKONLY 2 // Move, but don't touch triggers
68
+
69
+ // pev(entity, pev_movetype) values
70
+ #define MOVETYPE_NONE 0 // Never moves
71
+ #define MOVETYPE_WALK 3 // Player only - moving on the ground
72
+ #define MOVETYPE_STEP 4 // Gravity, special edge handling -- monsters use this
73
+ #define MOVETYPE_FLY 5 // No gravity, but still collides with stuff
74
+ #define MOVETYPE_TOSS 6 // Gravity/Collisions
75
+ #define MOVETYPE_PUSH 7 // No clip to world, push and crush
76
+ #define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity
77
+ #define MOVETYPE_FLYMISSILE 9 // Extra size to monsters
78
+ #define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces
79
+ #define MOVETYPE_BOUNCEMISSILE 11 // Bounce w/o gravity
80
+ #define MOVETYPE_FOLLOW 12 // Track movement of aiment
81
+ #define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision)
82
+
83
+ // pev(entity, pev_solid) values
84
+ // NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves
85
+ // SOLID only effects OTHER entities colliding with this one when they move - UGH!
86
+ #define SOLID_NOT 0 // No interaction with other objects
87
+ #define SOLID_TRIGGER 1 // Touch on edge, but not blocking
88
+ #define SOLID_BBOX 2 // Touch on edge, block
89
+ #define SOLID_SLIDEBOX 3 // Touch on edge, but not an onground
90
+ #define SOLID_BSP 4 // BSP clip, touch on edge, block
91
+
92
+ // pev(entity, pev_deadflag) values
93
+ #define DEAD_NO 0 // Alive
94
+ #define DEAD_DYING 1 // Playing death animation or still falling off of a ledge waiting to hit ground
95
+ #define DEAD_DEAD 2 // Dead, lying still
96
+ #define DEAD_RESPAWNABLE 3
97
+ #define DEAD_DISCARDBODY 4
98
+
99
+ // new Float:takedamage, pev(entity, pev_takedamage, takedamage) values
100
+ #define DAMAGE_NO 0.0
101
+ #define DAMAGE_YES 1.0
102
+ #define DAMAGE_AIM 2.0
103
+
104
+ // pev(entity, pev_effects) values
105
+ #define EF_BRIGHTFIELD 1 // Swirling cloud of particles
106
+ #define EF_MUZZLEFLASH 2 // Single frame ELIGHT on entity attachment 0
107
+ #define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin
108
+ #define EF_DIMLIGHT 8 // Player flashlight
109
+ #define EF_INVLIGHT 16 // Get lighting from ceiling
110
+ #define EF_NOINTERP 32 // Don't interpolate the next frame
111
+ #define EF_LIGHT 64 // Rocket flare glow sprite
112
+ #define EF_NODRAW 128 // Don't draw entity
113
+
114
+ // engfunc(EngFunc_PointContents, Float:origin) return values
115
+ #define CONTENTS_EMPTY -1
116
+ #define CONTENTS_SOLID -2
117
+ #define CONTENTS_WATER -3
118
+ #define CONTENTS_SLIME -4
119
+ #define CONTENTS_LAVA -5
120
+ #define CONTENTS_SKY -6
121
+ #define CONTENTS_ORIGIN -7 // Removed at csg time
122
+ #define CONTENTS_CLIP -8 // Changed to contents_solid
123
+ #define CONTENTS_CURRENT_0 -9
124
+ #define CONTENTS_CURRENT_90 -10
125
+ #define CONTENTS_CURRENT_180 -11
126
+ #define CONTENTS_CURRENT_270 -12
127
+ #define CONTENTS_CURRENT_UP -13
128
+ #define CONTENTS_CURRENT_DOWN -14
129
+ #define CONTENTS_TRANSLUCENT -15
130
+ #define CONTENTS_LADDER -16
131
+ #define CONTENT_FLYFIELD -17
132
+ #define CONTENT_GRAVITY_FLYFIELD -18
133
+ #define CONTENT_FOG -19
134
+
135
+ // Instant damage values for use with gmsgDamage 3rd value write_long(BIT)
136
+ #define DMG_GENERIC 0 // Generic damage was done
137
+ #define DMG_CRUSH (1<<0) // Crushed by falling or moving object
138
+ #define DMG_BULLET (1<<1) // Shot
139
+ #define DMG_SLASH (1<<2) // Cut, clawed, stabbed
140
+ #define DMG_BURN (1<<3) // Heat burned
141
+ #define DMG_FREEZE (1<<4) // Frozen
142
+ #define DMG_FALL (1<<5) // Fell too far
143
+ #define DMG_BLAST (1<<6) // Explosive blast damage
144
+ #define DMG_CLUB (1<<7) // Crowbar, punch, headbutt
145
+ #define DMG_SHOCK (1<<8) // Electric shock
146
+ #define DMG_SONIC (1<<9) // Sound pulse shockwave
147
+ #define DMG_ENERGYBEAM (1<<10) // Laser or other high energy beam
148
+ #define DMG_NEVERGIB (1<<12) // With this bit OR'd in, no damage type will be able to gib victims upon death
149
+ #define DMG_ALWAYSGIB (1<<13) // With this bit OR'd in, any damage type can be made to gib victims upon death.
150
+ #define DMG_DROWN (1<<14) // Drowning
151
+ #define DMG_PARALYZE (1<<15) // Slows affected creature down
152
+ #define DMG_NERVEGAS (1<<16) // Nerve toxins, very bad
153
+ #define DMG_POISON (1<<17) // Blood poisioning
154
+ #define DMG_RADIATION (1<<18) // Radiation exposure
155
+ #define DMG_DROWNRECOVER (1<<19) // Drowning recovery
156
+ #define DMG_ACID (1<<20) // Toxic chemicals or acid burns
157
+ #define DMG_SLOWBURN (1<<21) // In an oven
158
+ #define DMG_SLOWFREEZE (1<<22) // In a subzero freezer
159
+ #define DMG_MORTAR (1<<23) // Hit by air raid (done to distinguish grenade from mortar)
160
+ #define DMG_TIMEBASED (~(0x3fff)) // Mask for time-based damage
161
+
162
+ // The hullnumber paramater of EngFunc_TraceHull, EngFunc_TraceModel and DLLFunc_GetHullBounds
163
+ #define HULL_POINT 0
164
+ #define HULL_HUMAN 1
165
+ #define HULL_LARGE 2
166
+ #define HULL_HEAD 3
167
+
168
+ // global_get(glb_trace_flags)
169
+ #define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box
170
+
171
+ // Used with get/set_es(es_handle, ES_eFlags, ...) (entity_state data structure)
172
+ #define EFLAG_SLERP 1 // Do studio interpolation of this entity
173
+
174
+ // pev(entity, pev_spawnflags) values
175
+ // Many of these flags apply to specific entities
176
+ // func_train
177
+ #define SF_TRAIN_WAIT_RETRIGGER 1
178
+ #define SF_TRAIN_START_ON 4 // Train is initially moving
179
+ #define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains
180
+
181
+ // func_wall_toggle
182
+ #define SF_WALL_START_OFF 0x0001
183
+
184
+ // func_converyor
185
+ #define SF_CONVEYOR_VISUAL 0x0001
186
+ #define SF_CONVEYOR_NOTSOLID 0x0002
187
+
188
+ // func_button
189
+ #define SF_BUTTON_DONTMOVE 1
190
+ #define SF_BUTTON_TOGGLE 32 // Button stays pushed until reactivated
191
+ #define SF_BUTTON_SPARK_IF_OFF 64 // Button sparks in OFF state
192
+ #define SF_BUTTON_TOUCH_ONLY 256 // Button only fires as a result of USE key.
193
+
194
+ // func_rot_button
195
+ #define SF_ROTBUTTON_NOTSOLID 1
196
+
197
+ // env_global
198
+ #define SF_GLOBAL_SET 1 // Set global state to initial state on spawn
199
+
200
+ // multisource
201
+ #define SF_MULTI_INIT 1
202
+
203
+ // momentary_rot_button
204
+ #define SF_MOMENTARY_DOOR 0x0001
205
+
206
+ // button_target
207
+ #define SF_BTARGET_USE 0x0001
208
+ #define SF_BTARGET_ON 0x0002
209
+
210
+ // func_door, func_water, func_door_rotating, momementary_door
211
+ #define SF_DOOR_ROTATE_Y 0
212
+ #define SF_DOOR_START_OPEN 1
213
+ #define SF_DOOR_ROTATE_BACKWARDS 2
214
+ #define SF_DOOR_PASSABLE 8
215
+ #define SF_DOOR_ONEWAY 16
216
+ #define SF_DOOR_NO_AUTO_RETURN 32
217
+ #define SF_DOOR_ROTATE_Z 64
218
+ #define SF_DOOR_ROTATE_X 128
219
+ #define SF_DOOR_USE_ONLY 256 // Door must be opened by player's use button
220
+ #define SF_DOOR_NOMONSTERS 512 // Monster can't open
221
+ #define SF_DOOR_SILENT 0x80000000
222
+
223
+ // gibshooter
224
+ #define SF_GIBSHOOTER_REPEATABLE 1 // Allows a gibshooter to be refired
225
+
226
+ // env_funnel
227
+ #define SF_FUNNEL_REVERSE 1 // Funnel effect repels particles instead of attracting them
228
+
229
+ // env_bubbles
230
+ #define SF_BUBBLES_STARTOFF 0x0001
231
+
232
+ // env_blood
233
+ #define SF_BLOOD_RANDOM 0x0001
234
+ #define SF_BLOOD_STREAM 0x0002
235
+ #define SF_BLOOD_PLAYER 0x0004
236
+ #define SF_BLOOD_DECAL 0x0008
237
+
238
+ // env_shake
239
+ #define SF_SHAKE_EVERYONE 0x0001 // Don't check radius
240
+ #define SF_SHAKE_DISRUPT 0x0002 // Disrupt controls
241
+ #define SF_SHAKE_INAIR 0x0004 // Shake players in air
242
+
243
+ // env_fade
244
+ #define SF_FADE_IN 0x0001 // Fade in, not out
245
+ #define SF_FADE_MODULATE 0x0002 // Modulate, don't blend
246
+ #define SF_FADE_ONLYONE 0x0004
247
+
248
+ // env_beam, env_lightning
249
+ #define SF_BEAM_STARTON 0x0001
250
+ #define SF_BEAM_TOGGLE 0x0002
251
+ #define SF_BEAM_RANDOM 0x0004
252
+ #define SF_BEAM_RING 0x0008
253
+ #define SF_BEAM_SPARKSTART 0x0010
254
+ #define SF_BEAM_SPARKEND 0x0020
255
+ #define SF_BEAM_DECALS 0x0040
256
+ #define SF_BEAM_SHADEIN 0x0080
257
+ #define SF_BEAM_SHADEOUT 0x0100
258
+ #define SF_BEAM_TEMPORARY 0x8000
259
+
260
+ // env_sprite
261
+ #define SF_SPRITE_STARTON 0x0001
262
+ #define SF_SPRITE_ONCE 0x0002
263
+ #define SF_SPRITE_TEMPORARY 0x8000
264
+
265
+ // env_message
266
+ #define SF_MESSAGE_ONCE 0x0001 // Fade in, not out
267
+ #define SF_MESSAGE_ALL 0x0002 // Send to all clients
268
+
269
+ // env_explosion
270
+ #define SF_ENVEXPLOSION_NODAMAGE (1<<0) // When set, ENV_EXPLOSION will not actually inflict damage
271
+ #define SF_ENVEXPLOSION_REPEATABLE (1<<1) // Can this entity be refired?
272
+ #define SF_ENVEXPLOSION_NOFIREBALL (1<<2) // Don't draw the fireball
273
+ #define SF_ENVEXPLOSION_NOSMOKE (1<<3) // Don't draw the smoke
274
+ #define SF_ENVEXPLOSION_NODECAL (1<<4) // Don't make a scorch mark
275
+ #define SF_ENVEXPLOSION_NOSPARKS (1<<5) // Don't make a scorch mark
276
+
277
+ // func_tank
278
+ #define SF_TANK_ACTIVE 0x0001
279
+ #define SF_TANK_PLAYER 0x0002
280
+ #define SF_TANK_HUMANS 0x0004
281
+ #define SF_TANK_ALIENS 0x0008
282
+ #define SF_TANK_LINEOFSIGHT 0x0010
283
+ #define SF_TANK_CANCONTROL 0x0020
284
+ #define SF_TANK_SOUNDON 0x8000
285
+
286
+ // grenade
287
+ #define SF_DETONATE 0x0001
288
+
289
+ // item_suit
290
+ #define SF_SUIT_SHORTLOGON 0x0001
291
+
292
+ // game_score
293
+ #define SF_SCORE_NEGATIVE 0x0001
294
+ #define SF_SCORE_TEAM 0x0002
295
+
296
+ // game_text
297
+ #define SF_ENVTEXT_ALLPLAYERS 0x0001
298
+
299
+ // game_team_master
300
+ #define SF_TEAMMASTER_FIREONCE 0x0001
301
+ #define SF_TEAMMASTER_ANYTEAM 0x0002
302
+
303
+ // game_team_set
304
+ #define SF_TEAMSET_FIREONCE 0x0001
305
+ #define SF_TEAMSET_CLEARTEAM 0x0002
306
+
307
+ // game_player_hurt
308
+ #define SF_PKILL_FIREONCE 0x0001
309
+
310
+ // game_counter
311
+ #define SF_GAMECOUNT_FIREONCE 0x0001
312
+ #define SF_GAMECOUNT_RESET 0x0002
313
+
314
+ // game_player_equip
315
+ #define SF_PLAYEREQUIP_USEONLY 0x0001
316
+
317
+ // game_player_team
318
+ #define SF_PTEAM_FIREONCE 0x0001
319
+ #define SF_PTEAM_KILL 0x0002
320
+ #define SF_PTEAM_GIB 0x0004
321
+
322
+ // func_trackchange
323
+ #define SF_PLAT_TOGGLE 0x0001
324
+ #define SF_TRACK_ACTIVATETRAIN 0x00000001
325
+ #define SF_TRACK_RELINK 0x00000002
326
+ #define SF_TRACK_ROTMOVE 0x00000004
327
+ #define SF_TRACK_STARTBOTTOM 0x00000008
328
+ #define SF_TRACK_DONT_MOVE 0x00000010
329
+
330
+ // func_tracktrain
331
+ #define SF_TRACKTRAIN_NOPITCH 0x0001
332
+ #define SF_TRACKTRAIN_NOCONTROL 0x0002
333
+ #define SF_TRACKTRAIN_FORWARDONLY 0x0004
334
+ #define SF_TRACKTRAIN_PASSABLE 0x0008
335
+ #define SF_PATH_DISABLED 0x00000001
336
+ #define SF_PATH_FIREONCE 0x00000002
337
+ #define SF_PATH_ALTREVERSE 0x00000004
338
+ #define SF_PATH_DISABLE_TRAIN 0x00000008
339
+ #define SF_PATH_ALTERNATE 0x00008000
340
+ #define SF_CORNER_WAITFORTRIG 0x001
341
+ #define SF_CORNER_TELEPORT 0x002
342
+ #define SF_CORNER_FIREONCE 0x004
343
+
344
+ // trigger_push
345
+ #define SF_TRIGGER_PUSH_START_OFF 2 // Spawnflag that makes trigger_push spawn turned OFF
346
+
347
+ // trigger_hurt
348
+ #define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once
349
+ #define SF_TRIGGER_HURT_START_OFF 2 // Spawnflag that makes trigger_push spawn turned OFF
350
+ #define SF_TRIGGER_HURT_NO_CLIENTS 8 // Spawnflag that makes trigger_push spawn turned OFF
351
+ #define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 // Trigger hurt will only fire its target if it is hurting a client
352
+ #define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // Only clients may touch this trigger
353
+
354
+ // trigger_auto
355
+ #define SF_AUTO_FIREONCE 0x0001
356
+
357
+ // trigger_relay
358
+ #define SF_RELAY_FIREONCE 0x0001
359
+
360
+ // multi_manager
361
+ #define SF_MULTIMAN_CLONE 0x80000000
362
+ #define SF_MULTIMAN_THREAD 0x00000001
363
+
364
+ // env_render - Flags to indicate masking off various render parameters that are normally copied to the targets
365
+ #define SF_RENDER_MASKFX (1<<0)
366
+ #define SF_RENDER_MASKAMT (1<<1)
367
+ #define SF_RENDER_MASKMODE (1<<2)
368
+ #define SF_RENDER_MASKCOLOR (1<<3)
369
+
370
+ // trigger_changelevel
371
+ #define SF_CHANGELEVEL_USEONLY 0x0002
372
+
373
+ // trigger_endsection
374
+ #define SF_ENDSECTION_USEONLY 0x0001
375
+
376
+ // trigger_camera
377
+ #define SF_CAMERA_PLAYER_POSITION 1
378
+ #define SF_CAMERA_PLAYER_TARGET 2
379
+ #define SF_CAMERA_PLAYER_TAKECONTROL 4
380
+
381
+ // func_rotating
382
+ #define SF_BRUSH_ROTATE_Y_AXIS 0
383
+ #define SF_BRUSH_ROTATE_INSTANT 1
384
+ #define SF_BRUSH_ROTATE_BACKWARDS 2
385
+ #define SF_BRUSH_ROTATE_Z_AXIS 4
386
+ #define SF_BRUSH_ROTATE_X_AXIS 8
387
+ #define SF_PENDULUM_AUTO_RETURN 16
388
+ #define SF_PENDULUM_PASSABLE 32
389
+ #define SF_BRUSH_ROTATE_SMALLRADIUS 128
390
+ #define SF_BRUSH_ROTATE_MEDIUMRADIUS 256
391
+ #define SF_BRUSH_ROTATE_LARGERADIUS 512
392
+
393
+ // triggers
394
+ #define SF_TRIGGER_ALLOWMONSTERS 1 // Monsters allowed to fire this trigger
395
+ #define SF_TRIGGER_NOCLIENTS 2 // Players not allowed to fire this trigger
396
+ #define SF_TRIGGER_PUSHABLES 4 // Only pushables can fire this trigger
397
+
398
+ #define SF_TRIG_PUSH_ONCE 1
399
+ // func_breakable
400
+ #define SF_BREAK_TRIGGER_ONLY 1 // May only be broken by trigger
401
+ #define SF_BREAK_TOUCH 2 // Can be 'crashed through' by running player (plate glass)
402
+ #define SF_BREAK_PRESSURE 4 // Can be broken by a player standing on it
403
+ #define SF_BREAK_CROWBAR 256 // Instant break if hit with crowbar
404
+
405
+ // func_pushable (it's also func_breakable, so don't collide with those flags)
406
+ #define SF_PUSH_BREAKABLE 128
407
+
408
+ // light_spawn
409
+ #define SF_LIGHT_START_OFF 1
410
+ #define SPAWNFLAG_NOMESSAGE 1
411
+ #define SPAWNFLAG_NOTOUCH 1
412
+ #define SPAWNFLAG_DROIDONLY 4
413
+ #define SPAWNFLAG_USEONLY 1 // Can't be touched, must be used (buttons)
414
+
415
+ // Monster Spawnflags
416
+ #define SF_MONSTER_WAIT_TILL_SEEN 1 // Spawnflag that makes monsters wait until player can see them before attacking
417
+ #define SF_MONSTER_GAG 2 // No idle noises from this monster
418
+ #define SF_MONSTER_HITMONSTERCLIP 4
419
+ #define SF_MONSTER_PRISONER 16 // Monster won't attack anyone, no one will attacke him
420
+ #define SF_MONSTER_WAIT_FOR_SCRIPT 128 // Spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked
421
+ #define SF_MONSTER_PREDISASTER 256 // This is a predisaster scientist or barney; influences how they speak
422
+ #define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death
423
+ #define SF_MONSTER_FALL_TO_GROUND 0x80000000
424
+ #define SF_MONSTER_TURRET_AUTOACTIVATE 32
425
+ #define SF_MONSTER_TURRET_STARTINACTIVE 64
426
+ #define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // Don't attack the player unless provoked
427
+
428
+ // info_decal
429
+ #define SF_DECAL_NOTINDEATHMATCH 2048
430
+
431
+ // worldspawn
432
+ #define SF_WORLD_DARK 0x0001 // Fade from black at startup
433
+ #define SF_WORLD_TITLE 0x0002 // Display game title at startup
434
+ #define SF_WORLD_FORCETEAM 0x0004 // Force teams
435
+
436
+ // Set this bit on guns and stuff that should never respawn
437
+ #define SF_NORESPAWN (1<<30)