Parent Directory | Revision Log
Revision 1 - (view) (download)
1 : | ian | 1 | /** |
2 : | * AMX Mod Compatibility engine | ||
3 : | * by the AMX Mod X Development Team | ||
4 : | */ | ||
5 : | |||
6 : | #include <VexdUM_const> | ||
7 : | #include <VexdUM_stock> | ||
8 : | |||
9 : | /* Forwards */ | ||
10 : | new g_FwdTouch | ||
11 : | new g_FwdThink | ||
12 : | new g_FwdSpawn | ||
13 : | new g_FwdClientPreThink | ||
14 : | new g_FwdClientPostThink | ||
15 : | new g_FwdEmitSound | ||
16 : | new g_FwdEmitAmbientSound | ||
17 : | new g_FwdSetModel | ||
18 : | new g_FwdTraceLine | ||
19 : | new g_FwdSetCliKeyValue | ||
20 : | new g_FwdKeyValue | ||
21 : | new g_PlayerModels[33][64] | ||
22 : | new g_PlayerModeled[33] | ||
23 : | |||
24 : | /* User Messages */ | ||
25 : | new g_msgDamage | ||
26 : | new g_msgDeathMsg | ||
27 : | new g_msgScoreInfo | ||
28 : | |||
29 : | new g_LastTrace = 0 | ||
30 : | |||
31 : | VexdUM_Register() | ||
32 : | { | ||
33 : | /* Fakemeta Hooks */ | ||
34 : | register_forward(FM_EmitSound, "Hook_FM_EmitSound") | ||
35 : | register_forward(FM_EmitAmbientSound, "Hook_FM_EmitAmbientSound") | ||
36 : | register_forward(FM_SetModel, "Hook_FM_SetModel") | ||
37 : | register_forward(FM_TraceLine, "Hook_FM_TraceLine") | ||
38 : | register_forward(FM_SetClientKeyValue, "Hook_FM_SetClientKeyValue") | ||
39 : | register_forward(FM_KeyValue, "Hook_FM_KeyValue") | ||
40 : | register_forward(FM_Touch, "Hook_FM_Touch") | ||
41 : | register_forward(FM_Think, "Hook_FM_Think") | ||
42 : | register_forward(FM_Spawn, "Hook_FM_Spawn") | ||
43 : | register_forward(FM_PlayerPreThink, "Hook_FM_PlayerPreThink") | ||
44 : | register_forward(FM_PlayerPostThink, "Hook_FM_PlayerPostThink") | ||
45 : | register_forward(FM_ClientUserInfoChanged, "Hook_ClientUserInfoChanged") | ||
46 : | |||
47 : | /* Global Forwards */ | ||
48 : | g_FwdTouch = CreateMultiForwardEx("entity_touch", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_CELL) | ||
49 : | g_FwdThink = CreateMultiForwardEx("entity_think", ET_STOP, FORWARD_ONLY_OLD, FP_CELL) | ||
50 : | g_FwdSpawn = CreateMultiForwardEx("entity_spawn", ET_STOP, FORWARD_ONLY_OLD, FP_CELL) | ||
51 : | g_FwdClientPreThink = CreateMultiForwardEx("client_prethink", ET_IGNORE, FORWARD_ONLY_OLD, FP_CELL) | ||
52 : | g_FwdClientPostThink = CreateMultiForwardEx("client_postthink", ET_IGNORE, FORWARD_ONLY_OLD, FP_CELL) | ||
53 : | g_FwdEmitSound = CreateMultiForwardEx("emitsound", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING) | ||
54 : | g_FwdEmitAmbientSound = CreateMultiForwardEx("emitambientsound", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING) | ||
55 : | g_FwdSetModel = CreateMultiForwardEx("set_model", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING) | ||
56 : | g_FwdTraceLine = CreateMultiForwardEx("traceline", ET_STOP, FORWARD_ONLY_OLD, FP_CELL) | ||
57 : | g_FwdSetCliKeyValue = CreateMultiForwardEx("setclientkeyvalue", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING, FP_STRING) | ||
58 : | g_FwdKeyValue = CreateMultiForwardEx("keyvalue", ET_STOP, FORWARD_ONLY_OLD, FP_CELL) | ||
59 : | |||
60 : | /* User Messages */ | ||
61 : | g_msgDamage = get_user_msgid("Damage") | ||
62 : | g_msgDeathMsg = get_user_msgid("DeathMsg") | ||
63 : | g_msgScoreInfo = get_user_msgid("ScoreInfo") | ||
64 : | } | ||
65 : | |||
66 : | VexdUM_Natives() | ||
67 : | { | ||
68 : | /* implicit compatibility */ | ||
69 : | register_native("is_entity", "__is_entity") | ||
70 : | register_native("find_entity", "__find_entity") | ||
71 : | register_native("find_entity_sphere", "__find_entity_sphere") | ||
72 : | register_native("in_view_cone", "__in_view_cone") | ||
73 : | register_native("get_offset_int", "__get_offset_int") | ||
74 : | register_native("set_offset_int", "__set_offset_int") | ||
75 : | register_native("trace_line", "__trace_line") | ||
76 : | register_native("traceline_get_int", "__traceline_get_int") | ||
77 : | register_native("traceline_set_int", "__traceline_set_int") | ||
78 : | register_native("traceline_get_edict", "__traceline_get_edict") | ||
79 : | register_native("traceline_set_edict", "__traceline_set_edict") | ||
80 : | register_native("traceline_set_float", "__traceline_set_float") | ||
81 : | register_native("can_see", "__can_see") | ||
82 : | register_native("user_spawn", "__user_spawn") | ||
83 : | register_native("get_maxentities", "__get_maxentities") | ||
84 : | register_native("PointContents", "__PointContents") | ||
85 : | register_native("DispatchKeyValue", "__DispatchKeyValue") | ||
86 : | register_native("entity_use","__entity_use") | ||
87 : | register_native("get_num_ents","__get_num_ents") | ||
88 : | register_native("take_damage","__take_damage") | ||
89 : | |||
90 : | if (g_ModType == MOD_CSTRIKE) | ||
91 : | { | ||
92 : | register_native("set_user_model", "__cs_set_user_model") | ||
93 : | } else { | ||
94 : | register_native("set_user_model", "__set_user_model") | ||
95 : | } | ||
96 : | } | ||
97 : | |||
98 : | VexdUM_ClientConnect(id) | ||
99 : | { | ||
100 : | g_PlayerModels[id][0] = 0 | ||
101 : | g_PlayerModeled[id] =0 | ||
102 : | } | ||
103 : | |||
104 : | SetClientKeyValue(id, const key[], const value[]) | ||
105 : | { | ||
106 : | new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id) | ||
107 : | |||
108 : | return engfunc(EngFunc_SetClientKeyValue, buffer, key, value) | ||
109 : | } | ||
110 : | |||
111 : | GetClientKeyValue(id, const key[], value[], maxlen) | ||
112 : | { | ||
113 : | new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id) | ||
114 : | |||
115 : | engfunc(EngFunc_InfoKeyValue, buffer, key, value, maxlen) | ||
116 : | } | ||
117 : | |||
118 : | Death(victim, killer, weapon[64], hs) | ||
119 : | { | ||
120 : | if(pev(victim,pev_takedamage) > DAMAGE_NO) | ||
121 : | { | ||
122 : | new inflictor = pev(killer,pev_owner) | ||
123 : | if(pev(killer,pev_flags) & (FL_CLIENT | FL_FAKECLIENT)) | ||
124 : | { | ||
125 : | if(equal(weapon,"")) | ||
126 : | { | ||
127 : | pev(killer,pev_viewmodel2,weapon,63) | ||
128 : | |||
129 : | replace(weapon,63,"models/v_","") | ||
130 : | weapon[strlen(weapon) - 4] = '^0' | ||
131 : | } | ||
132 : | } | ||
133 : | else if(inflictor > 0 && inflictor < get_maxplayers()) | ||
134 : | { | ||
135 : | if(equal(weapon,"")) | ||
136 : | { | ||
137 : | pev(killer,pev_viewmodel2,weapon,63) | ||
138 : | |||
139 : | replace(weapon,63,"weapon_","") | ||
140 : | replace(weapon,63,"monster_","") | ||
141 : | replace(weapon,63,"func_","") | ||
142 : | } | ||
143 : | |||
144 : | if(inflictor == victim) | ||
145 : | { | ||
146 : | killer = victim | ||
147 : | } else { | ||
148 : | killer = inflictor | ||
149 : | } | ||
150 : | } | ||
151 : | |||
152 : | message_begin(MSG_ALL,g_msgDeathMsg) | ||
153 : | write_byte(killer) | ||
154 : | write_byte(victim) | ||
155 : | write_byte(hs) | ||
156 : | write_string(weapon) | ||
157 : | message_end() | ||
158 : | |||
159 : | new vname[32],vauthid[32],vteam[32] | ||
160 : | get_user_name(victim,vname,31) | ||
161 : | get_user_authid(victim,vauthid,31) | ||
162 : | get_user_team(victim,vteam,31) | ||
163 : | |||
164 : | if(victim == killer) | ||
165 : | { | ||
166 : | log_message("^"%s<%i><%s><%s>^" killed self with ^"%s^"^n",vname,get_user_userid(victim), | ||
167 : | vauthid,vteam,weapon) | ||
168 : | } | ||
169 : | else if(pev(killer,pev_flags) & (FL_CLIENT | FL_FAKECLIENT)) | ||
170 : | { | ||
171 : | new kname[32],kauthid[32],kteam[32],team | ||
172 : | get_user_name(killer,kname,31) | ||
173 : | get_user_authid(killer,kauthid,31) | ||
174 : | team = get_user_team(killer,kteam,31) | ||
175 : | |||
176 : | log_message("^"%s<%i><%s><%s>^" killed ^"%s<%i><%s><%s>^" with ^"%s^"^n",kname,get_user_userid(killer), | ||
177 : | kauthid,kteam,vname,get_user_userid(victim),vauthid,vteam,weapon) | ||
178 : | |||
179 : | new Float:frags | ||
180 : | pev(killer,pev_frags,frags) | ||
181 : | set_pev(killer,pev_frags,frags+1.0) | ||
182 : | |||
183 : | message_begin(MSG_ALL,g_msgScoreInfo) | ||
184 : | write_byte(killer) | ||
185 : | write_short(floatround(frags)) | ||
186 : | write_short(get_user_deaths(killer)) | ||
187 : | write_short(0) | ||
188 : | write_short(team) | ||
189 : | message_end() | ||
190 : | |||
191 : | pev(victim,pev_frags,frags) | ||
192 : | set_pev(victim,pev_frags,frags+1.0) | ||
193 : | } else { | ||
194 : | log_message("^"%s<%i><%s><%s>^" killed by ^"%s^"^n",vname,get_user_userid(victim),vauthid,vteam,weapon) | ||
195 : | } | ||
196 : | |||
197 : | set_msg_block(g_msgDeathMsg,BLOCK_ONCE) | ||
198 : | dllfunc(DLLFunc_ClientKill,victim) | ||
199 : | } | ||
200 : | } | ||
201 : | |||
202 : | public __is_entity(plid, num) | ||
203 : | { | ||
204 : | new ent = get_param(1) | ||
205 : | return is_entity(ent) | ||
206 : | } | ||
207 : | |||
208 : | public __find_entity(plid, num) | ||
209 : | { | ||
210 : | static entstr[256] | ||
211 : | new startEnt, type | ||
212 : | |||
213 : | startEnt = get_param(1) | ||
214 : | get_string(2, entstr, 255) | ||
215 : | type = get_param(3) | ||
216 : | |||
217 : | return find_entity(startEnt, entstr, type) | ||
218 : | } | ||
219 : | |||
220 : | public __find_entity_sphere(plid, num) | ||
221 : | { | ||
222 : | new ent | ||
223 : | new Float:orig[3] | ||
224 : | new Float:radius | ||
225 : | |||
226 : | ent = get_param(1) | ||
227 : | get_array_f(2, orig, 3) | ||
228 : | radius = get_param_f(3) | ||
229 : | |||
230 : | return find_entity_sphere(ent, orig, radius) | ||
231 : | } | ||
232 : | |||
233 : | public __in_view_cone(plid, num) | ||
234 : | { | ||
235 : | new ent | ||
236 : | new Float:orig[3] | ||
237 : | |||
238 : | ent = get_param(1) | ||
239 : | get_array_f(2, orig, 3) | ||
240 : | |||
241 : | return in_view_cone(ent, orig) | ||
242 : | } | ||
243 : | |||
244 : | public __get_offset_int(plid, num) | ||
245 : | { | ||
246 : | new ent = get_param(1) | ||
247 : | new offs = get_param(2) | ||
248 : | new linux = get_param(3) | ||
249 : | |||
250 : | return get_pdata_int(ent, offs, linux) | ||
251 : | } | ||
252 : | |||
253 : | public __set_offset_int(plid, num) | ||
254 : | { | ||
255 : | return set_offset_int(get_param(1), get_param(2), get_param(3), get_param(4)) | ||
256 : | } | ||
257 : | |||
258 : | public __trace_line(plid, num) | ||
259 : | { | ||
260 : | new ent = get_param(1) | ||
261 : | |||
262 : | new Float:vStart[3], Float:vEnd[3], Float:vReturn[3] | ||
263 : | |||
264 : | get_array_f(2, vStart, 3) | ||
265 : | get_array_f(3, vEnd, 3) | ||
266 : | |||
267 : | if (ent == FM_NULLENT) | ||
268 : | engfunc(EngFunc_TraceLine, vStart, vEnd, IGNORE_MONSTERS, 0, 0) | ||
269 : | else | ||
270 : | engfunc(EngFunc_TraceLine, vStart, vEnd, DONT_IGNORE_MONSTERS, ent, 0) | ||
271 : | |||
272 : | get_tr2(0, TraceResult:TR_vecEndPos, vReturn) | ||
273 : | |||
274 : | set_array_f(4, vReturn, 3) | ||
275 : | |||
276 : | new traceHit = get_tr2(0, TraceResult:TR_pHit) | ||
277 : | |||
278 : | if (!pev_valid(traceHit)) | ||
279 : | return FM_NULLENT | ||
280 : | |||
281 : | return traceHit | ||
282 : | } | ||
283 : | |||
284 : | public __traceline_get_int(plid, num) | ||
285 : | { | ||
286 : | new iSet = get_param(1) | ||
287 : | new iValue = 0 | ||
288 : | |||
289 : | switch (iSet) | ||
290 : | { | ||
291 : | case TR_INT_fAllSolid: | ||
292 : | iValue = get_tr2(g_LastTrace, TraceResult:TR_AllSolid) | ||
293 : | case TR_INT_fStartSolid: | ||
294 : | iValue = get_tr2(g_LastTrace, TraceResult:TR_StartSolid) | ||
295 : | case TR_INT_fInOpen: | ||
296 : | iValue = get_tr2(g_LastTrace, TraceResult:TR_InOpen) | ||
297 : | case TR_INT_fInWater: | ||
298 : | iValue = get_tr2(g_LastTrace, TraceResult:TR_InWater) | ||
299 : | case TR_INT_iHitgroup: | ||
300 : | iValue = get_tr2(g_LastTrace, TraceResult:TR_iHitgroup) | ||
301 : | default: | ||
302 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
303 : | } | ||
304 : | |||
305 : | return iValue | ||
306 : | } | ||
307 : | |||
308 : | public __traceline_set_int(plid, num) | ||
309 : | { | ||
310 : | new iSet = get_param(1) | ||
311 : | new iValue = get_param(2) | ||
312 : | |||
313 : | switch (iSet) | ||
314 : | { | ||
315 : | case TR_INT_fAllSolid: | ||
316 : | set_tr2(g_LastTrace, TraceResult:TR_AllSolid, iValue) | ||
317 : | case TR_INT_fStartSolid: | ||
318 : | set_tr2(g_LastTrace, TraceResult:TR_StartSolid, iValue) | ||
319 : | case TR_INT_fInOpen: | ||
320 : | set_tr2(g_LastTrace, TraceResult:TR_InOpen, iValue) | ||
321 : | case TR_INT_fInWater: | ||
322 : | set_tr2(g_LastTrace, TraceResult:TR_InWater, iValue) | ||
323 : | case TR_INT_iHitgroup: | ||
324 : | set_tr2(g_LastTrace, TraceResult:TR_iHitgroup, iValue) | ||
325 : | default: | ||
326 : | { | ||
327 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
328 : | return 0 | ||
329 : | } | ||
330 : | } | ||
331 : | |||
332 : | return 1 | ||
333 : | } | ||
334 : | |||
335 : | public __traceline_get_edict(plid, num) | ||
336 : | { | ||
337 : | new iSet = get_param(1) | ||
338 : | new iValue = 0 | ||
339 : | |||
340 : | switch (iSet) | ||
341 : | { | ||
342 : | case TR_ENT_pHit: | ||
343 : | iValue = get_tr2(g_LastTrace, TraceResult:TR_pHit) | ||
344 : | default: | ||
345 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
346 : | } | ||
347 : | |||
348 : | return iValue | ||
349 : | } | ||
350 : | |||
351 : | public __traceline_set_edict(plid, num) | ||
352 : | { | ||
353 : | new iSet = get_param(1) | ||
354 : | new iValue = get_param(2) | ||
355 : | |||
356 : | switch (iSet) | ||
357 : | { | ||
358 : | case TR_ENT_pHit: | ||
359 : | set_tr2(g_LastTrace, TraceResult:TR_pHit, iValue) | ||
360 : | default: | ||
361 : | { | ||
362 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
363 : | return 0 | ||
364 : | } | ||
365 : | } | ||
366 : | |||
367 : | return 1 | ||
368 : | } | ||
369 : | |||
370 : | public Float:__traceline_get_float(plid, num) | ||
371 : | { | ||
372 : | new iSet = get_param(1) | ||
373 : | new Float:fValue = 0.0 | ||
374 : | |||
375 : | switch (iSet) | ||
376 : | { | ||
377 : | case TR_FL_flFraction: | ||
378 : | get_tr2(g_LastTrace, TraceResult:TR_flFraction, fValue) | ||
379 : | case TR_FL_flPlaneDist: | ||
380 : | get_tr2(g_LastTrace, TraceResult:TR_flPlaneDist, fValue) | ||
381 : | default: | ||
382 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
383 : | } | ||
384 : | |||
385 : | return fValue | ||
386 : | } | ||
387 : | |||
388 : | public __traceline_set_float(plid, num) | ||
389 : | { | ||
390 : | new iSet = get_param(1) | ||
391 : | new Float:fValue = get_param_f(2) | ||
392 : | |||
393 : | switch (iSet) | ||
394 : | { | ||
395 : | case TR_FL_flFraction: | ||
396 : | set_tr2(g_LastTrace, TraceResult:TR_flFraction, fValue) | ||
397 : | case TR_FL_flPlaneDist: | ||
398 : | get_tr2(g_LastTrace, TraceResult:TR_flPlaneDist, fValue) | ||
399 : | default: | ||
400 : | { | ||
401 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
402 : | return 0 | ||
403 : | } | ||
404 : | } | ||
405 : | |||
406 : | return 1 | ||
407 : | } | ||
408 : | |||
409 : | public __traceline_get_vector(plid, num) | ||
410 : | { | ||
411 : | new iSet = get_param(1) | ||
412 : | new Float:vValue[3] | ||
413 : | |||
414 : | switch (iSet) | ||
415 : | { | ||
416 : | case TR_VEC_vecEndPos: | ||
417 : | get_tr2(g_LastTrace, TraceResult:TR_vecEndPos, vValue) | ||
418 : | case TR_VEC_vecPlaneNormal: | ||
419 : | get_tr2(g_LastTrace, TraceResult:TR_vecPlaneNormal, vValue) | ||
420 : | default: | ||
421 : | { | ||
422 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
423 : | return 0 | ||
424 : | } | ||
425 : | } | ||
426 : | |||
427 : | set_array_f(2, vValue, 3) | ||
428 : | |||
429 : | return 1 | ||
430 : | } | ||
431 : | |||
432 : | public __traceline_set_vector(plid, num) | ||
433 : | { | ||
434 : | new iSet = get_param(1) | ||
435 : | new Float:vValue[3] | ||
436 : | |||
437 : | get_array_f(2, vValue, 3) | ||
438 : | |||
439 : | switch (iSet) | ||
440 : | { | ||
441 : | case TR_VEC_vecEndPos: | ||
442 : | set_tr2(g_LastTrace, TraceResult:TR_vecEndPos, vValue) | ||
443 : | case TR_VEC_vecPlaneNormal: | ||
444 : | set_tr2(g_LastTrace, TraceResult:TR_vecPlaneNormal, vValue) | ||
445 : | default: | ||
446 : | { | ||
447 : | log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter") | ||
448 : | return 0 | ||
449 : | } | ||
450 : | } | ||
451 : | |||
452 : | return 1 | ||
453 : | } | ||
454 : | |||
455 : | public __can_see(plid, num) | ||
456 : | { | ||
457 : | return can_see(get_param(1), get_param(2)) | ||
458 : | } | ||
459 : | |||
460 : | public __user_spawn(plid, num) | ||
461 : | { | ||
462 : | return dllfunc(DLLFunc_Spawn, get_param(1)) | ||
463 : | } | ||
464 : | |||
465 : | public __set_user_model(plid, num) | ||
466 : | { | ||
467 : | new id = get_param(1) | ||
468 : | if (id < 1 || id > g_MaxPlayers) | ||
469 : | { | ||
470 : | return 0 | ||
471 : | } | ||
472 : | |||
473 : | new model[64] | ||
474 : | get_string(2, model, 63) | ||
475 : | if (model[0] == 0) | ||
476 : | { | ||
477 : | if (!g_PlayerModeled[id]) | ||
478 : | { | ||
479 : | return 0 | ||
480 : | } | ||
481 : | g_PlayerModeled[id] = 0 | ||
482 : | g_PlayerModels[id][0] = 0 | ||
483 : | dllfunc(DLLFunc_ClientUserInfoChanged, id) | ||
484 : | } else { | ||
485 : | copy(g_PlayerModels[id], 63, model) | ||
486 : | g_PlayerModeled[id] = 1 | ||
487 : | SetClientKeyValue(id, "model", model) | ||
488 : | } | ||
489 : | |||
490 : | return 1 | ||
491 : | } | ||
492 : | |||
493 : | public __cs_set_user_model(plid, num) | ||
494 : | { | ||
495 : | new id = get_param(1) | ||
496 : | new model[64] | ||
497 : | |||
498 : | get_string(2, model, 63) | ||
499 : | |||
500 : | return cs_set_user_model(id, model) | ||
501 : | } | ||
502 : | |||
503 : | public __get_maxentities(plid, num) | ||
504 : | { | ||
505 : | return get_maxentities() | ||
506 : | } | ||
507 : | |||
508 : | public __PointContents(plid, num) | ||
509 : | { | ||
510 : | new Float:vCheckAt[3] | ||
511 : | |||
512 : | get_array_f(1, vCheckAt, 3) | ||
513 : | |||
514 : | return point_contents(vCheckAt) | ||
515 : | } | ||
516 : | |||
517 : | public __DispatchKeyValue(plid, num) | ||
518 : | { | ||
519 : | new ent = get_param(1) | ||
520 : | |||
521 : | new szClassname[32], szKey[32], szValue[32] | ||
522 : | |||
523 : | if (pev_valid(ent)) | ||
524 : | { | ||
525 : | get_string(2, szKey, 31) | ||
526 : | get_string(3, szValue, 31) | ||
527 : | pev(ent, pev_classname, szClassname, 31) | ||
528 : | |||
529 : | set_kvd(0, KV_ClassName, szClassname) | ||
530 : | set_kvd(0, KV_KeyName, szKey) | ||
531 : | set_kvd(0, KV_Value, szValue) | ||
532 : | set_kvd(0, KV_fHandled, 0) | ||
533 : | |||
534 : | dllfunc(DLLFunc_KeyValue, ent, 0) | ||
535 : | } | ||
536 : | |||
537 : | return 1 | ||
538 : | } | ||
539 : | |||
540 : | public __entity_use(plid, num) | ||
541 : | { | ||
542 : | new entUsed = get_param(1) | ||
543 : | new entOther = get_param(2) | ||
544 : | return dllfunc(DLLFunc_Use,entUsed,entOther) | ||
545 : | } | ||
546 : | |||
547 : | public __get_num_ents(plid, num) | ||
548 : | { | ||
549 : | return engfunc(EngFunc_NumberOfEntities) | ||
550 : | } | ||
551 : | |||
552 : | public __take_damage(plid, num) | ||
553 : | { | ||
554 : | new victim = get_param(1) | ||
555 : | new attacker = get_param(2) | ||
556 : | new Float:orig[3] | ||
557 : | get_array_f(3,orig,3) | ||
558 : | new Float:dmg = get_param_f(4) | ||
559 : | new bit = get_param(5) | ||
560 : | new wpnName[64] | ||
561 : | get_string(6,wpnName,63) | ||
562 : | new hs = get_param(7) | ||
563 : | |||
564 : | if(pev(victim,pev_takedamage) > DAMAGE_NO) | ||
565 : | { | ||
566 : | set_pev(victim,pev_dmg_inflictor,attacker) | ||
567 : | |||
568 : | new Float:olddmg | ||
569 : | pev(victim,pev_dmg_take,olddmg) | ||
570 : | set_pev(victim,pev_dmg_take,olddmg+dmg) | ||
571 : | |||
572 : | message_begin(MSG_ONE, g_msgDamage, {0,0,0} , victim) | ||
573 : | write_byte(0) | ||
574 : | write_byte(floatround(olddmg+dmg)) | ||
575 : | write_long(bit) | ||
576 : | write_coord(floatround(orig[0])) | ||
577 : | write_coord(floatround(orig[1])) | ||
578 : | write_coord(floatround(orig[2])) | ||
579 : | message_end() | ||
580 : | |||
581 : | new Float:health | ||
582 : | pev(victim,pev_health,health) | ||
583 : | if((dmg >= health) && (health > 0.0)) | ||
584 : | { | ||
585 : | Death(victim,attacker,wpnName,hs) | ||
586 : | } else { | ||
587 : | set_pev(victim,pev_health,health-dmg) | ||
588 : | } | ||
589 : | } | ||
590 : | } | ||
591 : | |||
592 : | /********************************* | ||
593 : | ***** HOOKS ********************* | ||
594 : | *********************************/ | ||
595 : | |||
596 : | public Hook_ClientUserInfoChanged(id, buffer) | ||
597 : | { | ||
598 : | if (g_PlayerModeled[id] && (pev(id, pev_deadflag) == DEAD_NO)) | ||
599 : | { | ||
600 : | return FMRES_SUPERCEDE | ||
601 : | } | ||
602 : | |||
603 : | return FMRES_IGNORED | ||
604 : | } | ||
605 : | |||
606 : | public Hook_FM_EmitSound(entid, channel, const sample[]) //we don't care about the rest | ||
607 : | { | ||
608 : | new ret | ||
609 : | |||
610 : | ExecuteForward(g_FwdEmitSound, ret, entid, sample) | ||
611 : | |||
612 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
613 : | } | ||
614 : | |||
615 : | public Hook_FM_EmitAmbientSound(entid, Float:pos[3], const sample[]) //we don't care about the rest | ||
616 : | { | ||
617 : | new ret | ||
618 : | |||
619 : | ExecuteForward(g_FwdEmitAmbientSound, ret, entid, sample) | ||
620 : | |||
621 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
622 : | } | ||
623 : | |||
624 : | public Hook_FM_SetModel(entid, const model[]) | ||
625 : | { | ||
626 : | new ret | ||
627 : | |||
628 : | ExecuteForward(g_FwdSetModel, ret, entid, model) | ||
629 : | |||
630 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
631 : | } | ||
632 : | |||
633 : | public Hook_FM_TraceLine(Float:v1[3], Float:v2[3], noMonsters, skip_ent, ptr) | ||
634 : | { | ||
635 : | g_LastTrace = ptr | ||
636 : | |||
637 : | engfunc(EngFunc_TraceLine, v1, v2, noMonsters, skip_ent, ptr) | ||
638 : | |||
639 : | new ret | ||
640 : | |||
641 : | ExecuteForward(g_FwdTraceLine, ret, skip_ent) | ||
642 : | |||
643 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
644 : | } | ||
645 : | |||
646 : | public Hook_FM_SetClientKeyValue(id, const infobuffer[], const key[], const value[]) | ||
647 : | { | ||
648 : | new ret | ||
649 : | |||
650 : | ExecuteForward(g_FwdSetCliKeyValue, ret, id, key, value) | ||
651 : | |||
652 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
653 : | } | ||
654 : | |||
655 : | public Hook_FM_KeyValue(ent, kvd) | ||
656 : | { | ||
657 : | new ret | ||
658 : | |||
659 : | ExecuteForward(g_FwdKeyValue, ret, ent) | ||
660 : | |||
661 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
662 : | } | ||
663 : | |||
664 : | public Hook_FM_Touch(ent1, ent2) | ||
665 : | { | ||
666 : | new ret | ||
667 : | |||
668 : | ExecuteForward(g_FwdTouch, ret, ent1, ent2) | ||
669 : | |||
670 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
671 : | } | ||
672 : | |||
673 : | public Hook_FM_Think(entid) | ||
674 : | { | ||
675 : | new ret | ||
676 : | |||
677 : | ExecuteForward(g_FwdThink, ret, entid) | ||
678 : | |||
679 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
680 : | } | ||
681 : | |||
682 : | public Hook_FM_Spawn(entid) | ||
683 : | { | ||
684 : | new ret | ||
685 : | |||
686 : | ExecuteForward(g_FwdSpawn, ret, entid) | ||
687 : | |||
688 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
689 : | } | ||
690 : | |||
691 : | public Hook_FM_PlayerPreThink(id) | ||
692 : | { | ||
693 : | new ret | ||
694 : | |||
695 : | ExecuteForward(g_FwdClientPreThink, ret, id) | ||
696 : | |||
697 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
698 : | } | ||
699 : | |||
700 : | public Hook_FM_PlayerPostThink(id) | ||
701 : | { | ||
702 : | new ret | ||
703 : | |||
704 : | if (g_PlayerModeled[id]) | ||
705 : | { | ||
706 : | new model[64] | ||
707 : | GetClientKeyValue(id, "model", model, 63) | ||
708 : | if (!equal(g_PlayerModels[id], model)) | ||
709 : | { | ||
710 : | SetClientKeyValue(id, "model", g_PlayerModels[id]) | ||
711 : | } | ||
712 : | } | ||
713 : | |||
714 : | ExecuteForward(g_FwdClientPostThink, ret, id) | ||
715 : | |||
716 : | return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED | ||
717 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |