Parent Directory | Revision Log
Revision 6 - (view) (download)
1 : | ian | 1 | /* |
2 : | Grab+ v1.1 | ||
3 : | Copyright (C) 2007 Ian (Juan) Cammarata | ||
4 : | |||
5 : | This program is free software; you can redistribute it and/or modify it under | ||
6 : | the terms of the GNU General Public License as published by the Free Software | ||
7 : | Foundation; either version 2 of the License, or (at your option) any later | ||
8 : | version. | ||
9 : | |||
10 : | This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
11 : | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
12 : | PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
13 : | |||
14 : | You should have received a copy of the GNU General Public License along with | ||
15 : | this program; go to http://www.opensource.org/licenses/gpl-license.php | ||
16 : | -------------------------------------------------------------------------------- | ||
17 : | |||
18 : | http://ian.cammarata.us/projects/grab_plus | ||
19 : | Oct 16 21:03 | ||
20 : | |||
21 : | |||
22 : | Description: | ||
23 : | This is a remake from scratch of SpaceDude's Jedi Force Grab plugin. It has many additional features and optimizations, is less spammy, multilingual and requires fewer binds. | ||
24 : | |||
25 : | |||
26 : | See it in Action: | ||
27 : | http://www.game-monitor.com/search.php?search=grab_plus_version&type=variable&game=all&location=all | ||
28 : | |||
29 : | |||
30 : | Features: | ||
31 : | Multilingual | ||
32 : | Screenfade to indicate grab activity instead of chat spam. | ||
33 : | Can grab players off a ladder. | ||
34 : | Automatically choke by holding down +pull while at min distance. | ||
35 : | Choke with use key. | ||
36 : | Throw with drop. | ||
37 : | Can't have mutliple admins grabbing the same player. | ||
38 : | Auto drop on death. | ||
39 : | Grab entities other than players, such as bombs, weapons, and hostages. | ||
40 : | |||
41 : | |||
42 : | Commands: | ||
43 : | |||
44 : | +grab : Grab something for as long as you hold down the key. | ||
45 : | grab_toggle : Same as +grab but toggles. | ||
46 : | amx_grab <name> : Grab client by name or id and teleport them to you. Use +grab or grab_toggle key to release. | ||
47 : | |||
48 : | +pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button. | ||
49 : | |||
50 : | +use : Chokes the grabbed (it damages the grabbed with 5 (cvar: gp_chokedmg) hp per 1.5 (cvar: gp_choketime) seconds) | ||
51 : | drop - Throws the grabbed with 1500 velocity. (cvar: gp_throwforce) | ||
52 : | |||
53 : | |||
54 : | Cvars (First value is default): | ||
55 : | gp_enabled <1|0> Enables all plugin functionality. | ||
56 : | gp_playersonly <0|1> Disables admins grabbing entities other than players. | ||
57 : | |||
58 : | gp_min_dist <90|...> Min distance between the grabber and grabbed. | ||
59 : | gp_grabforce <8|...> Sets the amount of force used when grabbing players. | ||
60 : | gp_throwforce <1500|...> Sets the power used when throwing players. | ||
61 : | gp_speed <5|...> How fast the grabbed moves when using push and pull. | ||
62 : | |||
63 : | gp_choketime <1.5|...> Time frequency for choking. | ||
64 : | gp_chokedmg <5|...> Amount of damage done with each choke. | ||
65 : | |||
66 : | gp_glow_r <50|0-255> Sets red amount for glow. | ||
67 : | gp_glow_g <0|0-255> Sets green amount for glow. | ||
68 : | gp_glow_b <0|0-255> Sets blue amount for glow. | ||
69 : | |||
70 : | |||
71 : | Notes: | ||
72 : | Make sure you place the grab_plus.txt file in addons\amxmodx\data\lang | ||
73 : | |||
74 : | |||
75 : | Credits: | ||
76 : | ian | 5 | Thanks to vittu for contributing code (changed all engine/fun module stuff to fakemeta). |
77 : | |||
78 : | ian | 1 | Thanks to all the coders who worked on the original Jedi Force Grab plugin for all their ideas: |
79 : | SpaceDude | ||
80 : | KCE | ||
81 : | KRoTaL | ||
82 : | BOB_SLAYER | ||
83 : | kosmo111 | ||
84 : | |||
85 : | |||
86 : | Supported Languages: | ||
87 : | 1337 (100%) - Thanks to l337newb | ||
88 : | Brazilian Portuguese (100%) - Thanks to Arion | ||
89 : | Danish (100%) - Thanks to nellerbabz | ||
90 : | Dutch (100%) - Thanks to BlackMilk | ||
91 : | English (100%) | ||
92 : | Finnish (100%) - Thanks to Pro Patria Finland | ||
93 : | French (100%) - Thanks to connorr | ||
94 : | German (100%) - Thanks to SchlumPF* | ||
95 : | Russian (100%) - Thanks to `666 | ||
96 : | Spanish (100%) - Hope these don't suck. | ||
97 : | Swedish (100%) - Thanks to Bend3r | ||
98 : | |||
99 : | |||
100 : | Change Log: | ||
101 : | Key (+ added | - removed | c changed | f fixed) | ||
102 : | |||
103 : | ian | 5 | v1.2 (Nov ??, 2007) |
104 : | +: Cvars gp_screenfade and gp_glow to enable/disable these features. | ||
105 : | +: Cvar gp_glow_a controls to control alpha of screenfade and glow. | ||
106 : | c: Removed dependency of engine and fun modules. Thanks to vittu for doing all the work. | ||
107 : | f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7x as well). | ||
108 : | |||
109 : | ian | 1 | v1.1 (Oct 16, 2007) |
110 : | +: Grab a few types of entities other than players. | ||
111 : | +: Cvar gp_playersonly. | ||
112 : | |||
113 : | v1.0 (Oct 13, 2007) | ||
114 : | !: Initial release | ||
115 : | |||
116 : | */ | ||
117 : | |||
118 : | #include <amxmodx> | ||
119 : | #include <amxmisc> | ||
120 : | #include <fakemeta> | ||
121 : | |||
122 : | ian | 6 | #define VERSION "1.2b2" |
123 : | ian | 1 | #define ADMIN ADMIN_LEVEL_A |
124 : | |||
125 : | #define TSK_CHKE 50 | ||
126 : | |||
127 : | ian | 5 | #define SVC_DAMAGE 19 |
128 : | ian | 1 | #define SF_FADEOUT 0 |
129 : | |||
130 : | new client_data[33][4] | ||
131 : | #define GRABBED 0 | ||
132 : | #define GRABBER 1 | ||
133 : | #define GRAB_LEN 2 | ||
134 : | #define FLAGS 3 | ||
135 : | |||
136 : | #define CDF_IN_PUSH (1<<0) | ||
137 : | #define CDF_IN_PULL (1<<1) | ||
138 : | #define CDF_NO_CHOKE (1<<2) | ||
139 : | |||
140 : | //Cvar Pointers | ||
141 : | new p_enabled, p_playersonly | ||
142 : | new p_throwforce, p_mindist, p_speed, p_grabforce | ||
143 : | new p_choketime, p_chokedmg | ||
144 : | ian | 5 | new p_glow_r, p_glow_b, p_glow_g, p_glow_a |
145 : | new p_fade, p_glow | ||
146 : | ian | 1 | |
147 : | //Pseudo Constants | ||
148 : | new MAXPLAYERS | ||
149 : | ian | 5 | new SVC_SCREENFADE, SVC_SCREENSHAKE |
150 : | ian | 1 | |
151 : | public plugin_init( ) | ||
152 : | { | ||
153 : | register_plugin( "Grab+", VERSION, "Ian Cammarata" ) | ||
154 : | register_cvar( "grab_plus_version", VERSION, FCVAR_SERVER ) | ||
155 : | set_cvar_string( "grab_plus_version", VERSION ) | ||
156 : | |||
157 : | p_enabled = register_cvar( "gp_enabled", "1" ) | ||
158 : | p_playersonly = register_cvar( "gp_playersonly", "0" ) | ||
159 : | |||
160 : | p_mindist = register_cvar ( "gp_min_dist", "90" ) | ||
161 : | p_throwforce = register_cvar( "gp_throwforce", "1500" ) | ||
162 : | p_grabforce = register_cvar( "gp_grabforce", "8" ) | ||
163 : | p_speed = register_cvar( "gp_speed", "5" ) | ||
164 : | |||
165 : | p_choketime = register_cvar( "gp_choketime", "1.5" ) | ||
166 : | p_chokedmg = register_cvar( "gp_chokedmg", "5" ) | ||
167 : | |||
168 : | p_glow_r = register_cvar( "gp_glow_r", "50" ) | ||
169 : | p_glow_g = register_cvar( "gp_glow_g", "0" ) | ||
170 : | p_glow_b = register_cvar( "gp_glow_b", "0" ) | ||
171 : | ian | 5 | p_glow_a = register_cvar( "gp_glow_a", "200" ) |
172 : | ian | 1 | |
173 : | ian | 5 | p_fade = register_cvar( "gp_screenfade", "1" ) |
174 : | p_glow = register_cvar( "gp_glow", "1" ) | ||
175 : | |||
176 : | ian | 1 | register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
177 : | register_clcmd( "grab_toggle", "grab_toggle", ADMIN, "press once to grab and again to release" ) | ||
178 : | register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" ) | ||
179 : | register_clcmd( "-grab", "unset_grabbed" ) | ||
180 : | |||
181 : | register_clcmd( "+push", "push", ADMIN, "bind a key to +push" ) | ||
182 : | register_clcmd( "-push", "push" ) | ||
183 : | register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" ) | ||
184 : | register_clcmd( "-pull", "pull" ) | ||
185 : | register_clcmd( "push", "push2" ) | ||
186 : | register_clcmd( "pull", "pull2" ) | ||
187 : | |||
188 : | register_clcmd( "drop" ,"throw" ) | ||
189 : | |||
190 : | register_event( "DeathMsg", "DeathMsg", "a" ) | ||
191 : | |||
192 : | register_dictionary( "grab_plus.txt" ) | ||
193 : | |||
194 : | MAXPLAYERS = get_maxplayers() | ||
195 : | |||
196 : | SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) | ||
197 : | SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) | ||
198 : | |||
199 : | return PLUGIN_CONTINUE | ||
200 : | } | ||
201 : | |||
202 : | public plugin_precache( ) | ||
203 : | { | ||
204 : | precache_sound( "player/PL_PAIN2.WAV" ) | ||
205 : | return PLUGIN_CONTINUE | ||
206 : | } | ||
207 : | |||
208 : | public client_PreThink( id ) | ||
209 : | { | ||
210 : | //Search for a target | ||
211 : | if ( client_data[id][GRABBED] == -1 ) | ||
212 : | { | ||
213 : | new Float:orig[3], Float:ret[3] | ||
214 : | ian | 5 | pev( id, pev_origin, orig ) |
215 : | pev( id, pev_view_ofs, ret ) | ||
216 : | ian | 1 | |
217 : | for( new i = 0; i < 3; i++ ) orig[i] += ret[i] | ||
218 : | ian | 5 | engfunc( EngFunc_GetAimVector, id, 1, ret ) |
219 : | ian | 1 | for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ( ret[i] * 9999 ) |
220 : | |||
221 : | ian | 5 | new tr = 0 |
222 : | engfunc( EngFunc_TraceLine, orig, ret, 0, id, tr ) | ||
223 : | new target = get_tr2( tr, TR_pHit ) | ||
224 : | get_tr2( tr, TR_vecEndPos, ret ) | ||
225 : | ian | 1 | |
226 : | if( 0 < target <= MAXPLAYERS ) | ||
227 : | { | ||
228 : | if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE | ||
229 : | set_grabbed( id, target ) | ||
230 : | } | ||
231 : | else if( !get_pcvar_num( p_playersonly ) ) | ||
232 : | { | ||
233 : | new movetype | ||
234 : | if( target ) | ||
235 : | { | ||
236 : | movetype = pev( target, pev_movetype ) | ||
237 : | if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) | ||
238 : | return PLUGIN_CONTINUE | ||
239 : | } | ||
240 : | else | ||
241 : | { | ||
242 : | ian | 5 | new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
243 : | ian | 1 | while( !target && ent > 0 ) |
244 : | { | ||
245 : | movetype = pev( ent, pev_movetype ) | ||
246 : | if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) | ||
247 : | && ent != id ) | ||
248 : | target = ent | ||
249 : | ian | 5 | ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 ) |
250 : | ian | 1 | } |
251 : | } | ||
252 : | if( target ) | ||
253 : | { | ||
254 : | if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE | ||
255 : | set_grabbed( id, target ) | ||
256 : | } | ||
257 : | } | ||
258 : | } | ||
259 : | //If they've grabbed something | ||
260 : | if( client_data[id][GRABBED] > 0 ) | ||
261 : | { | ||
262 : | new target = client_data[id][GRABBED] | ||
263 : | if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) ) | ||
264 : | { | ||
265 : | unset_grabbed( id ) | ||
266 : | return PLUGIN_CONTINUE | ||
267 : | } | ||
268 : | |||
269 : | //Use key choke | ||
270 : | if( pev( id, pev_button ) & IN_USE ) | ||
271 : | do_choke( id ) | ||
272 : | |||
273 : | //Push and pull | ||
274 : | if ( client_data[id][FLAGS] & CDF_IN_PULL ) | ||
275 : | do_pull( id ) | ||
276 : | else if ( client_data[id][FLAGS] & CDF_IN_PUSH ) | ||
277 : | do_push( id ) | ||
278 : | |||
279 : | grab_think( id ) | ||
280 : | } | ||
281 : | if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] ) | ||
282 : | |||
283 : | return PLUGIN_CONTINUE | ||
284 : | } | ||
285 : | |||
286 : | public grab_think ( id ) | ||
287 : | { | ||
288 : | new target = client_data[id][GRABBED] | ||
289 : | |||
290 : | //Keep grabbed clients from sticking to ladders | ||
291 : | if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" ) | ||
292 : | |||
293 : | //Move targeted client | ||
294 : | new Float:tmpvec[3], Float:tmpvec2[3], Float:dest[3], Float:torig[3], Float:tvel[3] | ||
295 : | new len = client_data[id][GRAB_LEN] | ||
296 : | |||
297 : | ian | 5 | pev( id, pev_origin, dest ) |
298 : | pev( id, pev_view_ofs, tmpvec ) | ||
299 : | ian | 6 | engfunc( EngFunc_GetAimVector, id, len, tmpvec2 ) |
300 : | ian | 1 | torig = get_target_origin_f( target ) |
301 : | |||
302 : | new force = get_pcvar_num( p_grabforce ) | ||
303 : | |||
304 : | for( new i = 0; i < 3; i++ ) | ||
305 : | { | ||
306 : | dest[i] += tmpvec[i] + tmpvec2[i] | ||
307 : | tvel[i] = ( dest[i] - torig[i] ) * force | ||
308 : | } | ||
309 : | |||
310 : | ian | 5 | set_pev( target, pev_velocity, tvel ) |
311 : | ian | 1 | } |
312 : | |||
313 : | stock Float:get_target_origin_f( id ) | ||
314 : | { | ||
315 : | new Float:orig[3] | ||
316 : | ian | 5 | pev( id, pev_origin, orig ) |
317 : | ian | 1 | |
318 : | //If grabbed is not a player, move origin to center | ||
319 : | if( id > MAXPLAYERS ) | ||
320 : | { | ||
321 : | new Float:mins[3], Float:maxs[3] | ||
322 : | ian | 5 | pev( id, pev_mins, mins ) |
323 : | pev( id, pev_maxs, maxs ) | ||
324 : | ian | 1 | |
325 : | if( !mins[2] ) orig[2] += maxs[2] / 2 | ||
326 : | } | ||
327 : | |||
328 : | return orig | ||
329 : | } | ||
330 : | |||
331 : | public grab_toggle( id, level, cid ) | ||
332 : | { | ||
333 : | if( !client_data[id][GRABBED] ) grab( id, level, cid ) | ||
334 : | else unset_grabbed( id ) | ||
335 : | |||
336 : | return PLUGIN_HANDLED | ||
337 : | } | ||
338 : | |||
339 : | public grab( id, level, cid ) | ||
340 : | { | ||
341 : | if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED | ||
342 : | |||
343 : | if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1 | ||
344 : | screenfade_in( id ) | ||
345 : | |||
346 : | return PLUGIN_HANDLED | ||
347 : | } | ||
348 : | |||
349 : | public screenfade_in( id ) | ||
350 : | { | ||
351 : | ian | 5 | if( get_pcvar_num( p_fade ) ) |
352 : | { | ||
353 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, id ) | ||
354 : | write_short( 10000 ) //duration | ||
355 : | write_short( 0 ) //hold | ||
356 : | write_short( SF_FADE_IN + SF_FADE_ONLYONE ) //flags | ||
357 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
358 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
359 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
360 : | write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a | ||
361 : | message_end( ) | ||
362 : | } | ||
363 : | ian | 1 | } |
364 : | |||
365 : | public throw( id ) | ||
366 : | { | ||
367 : | new target = client_data[id][GRABBED] | ||
368 : | if( target > 0 ) | ||
369 : | { | ||
370 : | new Float:pVelocity[3] | ||
371 : | ian | 5 | engfunc( EngFunc_GetAimVector, id, get_pcvar_num( p_throwforce ), pVelocity ) |
372 : | set_pev( target, pev_velocity, pVelocity ) | ||
373 : | ian | 1 | unset_grabbed( id ) |
374 : | return PLUGIN_HANDLED | ||
375 : | } | ||
376 : | return PLUGIN_CONTINUE | ||
377 : | } | ||
378 : | |||
379 : | public unset_grabbed( id ) | ||
380 : | { | ||
381 : | new target = client_data[id][GRABBED] | ||
382 : | if( target > 0 && pev_valid( target ) ) | ||
383 : | { | ||
384 : | ian | 5 | set_pev( target, pev_renderfx, kRenderFxNone ) |
385 : | set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} ) | ||
386 : | set_pev( target, pev_rendermode, kRenderNormal ) | ||
387 : | set_pev( target, pev_renderamt, 16.0 ) | ||
388 : | |||
389 : | ian | 1 | if( 0 < target <= MAXPLAYERS ) |
390 : | client_data[target][GRABBER] = 0 | ||
391 : | } | ||
392 : | client_data[id][GRABBED] = 0 | ||
393 : | |||
394 : | ian | 5 | if( get_pcvar_num( p_fade ) ) |
395 : | { | ||
396 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, id ) | ||
397 : | write_short( 10000 ) //duration | ||
398 : | write_short( 0 ) //hold | ||
399 : | write_short( SF_FADEOUT ) //flags | ||
400 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
401 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
402 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
403 : | write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a | ||
404 : | message_end( ) | ||
405 : | } | ||
406 : | ian | 1 | } |
407 : | |||
408 : | //Grabs onto someone | ||
409 : | public set_grabbed( id, target ) | ||
410 : | { | ||
411 : | ian | 5 | if( get_pcvar_num( p_glow ) ) |
412 : | { | ||
413 : | new Float:color[3] | ||
414 : | color[0] = get_pcvar_float( p_glow_r ) | ||
415 : | color[1] = get_pcvar_float( p_glow_g ) | ||
416 : | color[2] = get_pcvar_float( p_glow_b ) | ||
417 : | ian | 6 | set_pev( target, pev_renderfx, kRenderFxGlowShell ) |
418 : | set_pev( target, pev_rendercolor, color ) | ||
419 : | set_pev( target, pev_rendermode, kRenderTransColor ) | ||
420 : | set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) ) | ||
421 : | ian | 5 | } |
422 : | ian | 1 | |
423 : | if( 0 < target <= MAXPLAYERS ) | ||
424 : | client_data[target][GRABBER] = id | ||
425 : | client_data[id][FLAGS] = 0 | ||
426 : | client_data[id][GRABBED] = target | ||
427 : | ian | 5 | new Float:torig[3], Float:orig[3] |
428 : | pev( target, pev_origin, torig ) | ||
429 : | pev( id, pev_origin, orig ) | ||
430 : | client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) | ||
431 : | ian | 1 | if( client_data[id][GRAB_LEN] < get_pcvar_num( p_mindist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_mindist ) |
432 : | } | ||
433 : | |||
434 : | public push( id ) | ||
435 : | { | ||
436 : | client_data[id][FLAGS] ^= CDF_IN_PUSH | ||
437 : | return PLUGIN_HANDLED | ||
438 : | } | ||
439 : | |||
440 : | public pull( id ) | ||
441 : | { | ||
442 : | client_data[id][FLAGS] ^= CDF_IN_PULL | ||
443 : | return PLUGIN_HANDLED | ||
444 : | } | ||
445 : | |||
446 : | public push2( id ) | ||
447 : | { | ||
448 : | if( client_data[id][GRABBED] > 0 ) | ||
449 : | { | ||
450 : | do_push( id ) | ||
451 : | return PLUGIN_HANDLED | ||
452 : | } | ||
453 : | return PLUGIN_CONTINUE | ||
454 : | } | ||
455 : | |||
456 : | public pull2( id ) | ||
457 : | { | ||
458 : | if( client_data[id][GRABBED] > 0 ) | ||
459 : | { | ||
460 : | do_pull( id ) | ||
461 : | return PLUGIN_HANDLED | ||
462 : | } | ||
463 : | return PLUGIN_CONTINUE | ||
464 : | } | ||
465 : | |||
466 : | public do_push( id ) | ||
467 : | if( client_data[id][GRAB_LEN] < 9999 ) | ||
468 : | client_data[id][GRAB_LEN] += get_pcvar_num( p_speed ) | ||
469 : | |||
470 : | public do_pull( id ) | ||
471 : | { | ||
472 : | new mindist = get_pcvar_num( p_mindist ) | ||
473 : | new len = client_data[id][GRAB_LEN] | ||
474 : | |||
475 : | if( len > mindist ) | ||
476 : | { | ||
477 : | len -= get_pcvar_num( p_speed ) | ||
478 : | if( len < mindist ) len = mindist | ||
479 : | client_data[id][GRAB_LEN] = len | ||
480 : | } | ||
481 : | else do_choke( id ) | ||
482 : | } | ||
483 : | |||
484 : | public do_choke( id ) | ||
485 : | { | ||
486 : | new target = client_data[id][GRABBED] | ||
487 : | if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return | ||
488 : | |||
489 : | new dmg = get_pcvar_num( p_chokedmg ) | ||
490 : | new Float:vec[3] | ||
491 : | get_target_origin_f( target ) | ||
492 : | |||
493 : | message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target ) | ||
494 : | write_short( 999999 ) //amount | ||
495 : | write_short( 9999 ) //duration | ||
496 : | write_short( 999 ) //frequency | ||
497 : | message_end( ) | ||
498 : | |||
499 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, target ) | ||
500 : | write_short( 9999 ) //duration | ||
501 : | write_short( 100 ) //hold | ||
502 : | write_short( SF_FADE_MODULATE ) //flags | ||
503 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
504 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
505 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
506 : | write_byte( 200 ) //a | ||
507 : | message_end( ) | ||
508 : | |||
509 : | message_begin( MSG_ONE, SVC_DAMAGE, _, target ) | ||
510 : | write_byte( 0 ) //damage armor | ||
511 : | write_byte( dmg ) //damage health | ||
512 : | write_long( DMG_CRUSH ) //damage type | ||
513 : | write_coord( floatround( vec[0] ) ) //origin[x] | ||
514 : | write_coord( floatround( vec[1] ) ) //origin[y] | ||
515 : | write_coord( floatround( vec[2] ) ) //origin[z] | ||
516 : | message_end( ) | ||
517 : | |||
518 : | message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) | ||
519 : | write_byte( TE_BLOODSTREAM ) | ||
520 : | write_coord( floatround( vec[0] ) ) //pos.x | ||
521 : | write_coord( floatround( vec[1] ) ) //pos.y | ||
522 : | write_coord( floatround( vec[2] ) + 15 ) //pos.z | ||
523 : | write_coord( random_num( 0, 255 ) ) //vec.x | ||
524 : | write_coord( random_num( 0, 255 ) ) //vec.y | ||
525 : | write_coord( random_num( 0, 255 ) ) //vec.z | ||
526 : | write_byte( 70 ) //col index | ||
527 : | write_byte( random_num( 50, 250 ) ) //speed | ||
528 : | message_end( ) | ||
529 : | |||
530 : | new health = pev( target, pev_health ) - dmg | ||
531 : | set_pev( target, pev_health, float( health ) ) | ||
532 : | if( health < 1 ) dllfunc( DLLFunc_ClientKill, target ) | ||
533 : | |||
534 : | emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM ) | ||
535 : | |||
536 : | client_data[id][FLAGS] ^= CDF_NO_CHOKE | ||
537 : | set_task( get_pcvar_float( p_choketime ), "clear_no_choke", TSK_CHKE + id ) | ||
538 : | } | ||
539 : | |||
540 : | public clear_no_choke( tskid ) | ||
541 : | { | ||
542 : | new id = tskid - TSK_CHKE | ||
543 : | client_data[id][FLAGS] ^= CDF_NO_CHOKE | ||
544 : | } | ||
545 : | |||
546 : | //Grabs the client and teleports them to the admin | ||
547 : | public force_grab(id, level, cid) | ||
548 : | { | ||
549 : | if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED | ||
550 : | |||
551 : | new arg[33] | ||
552 : | read_argv( 1, arg, 32 ) | ||
553 : | |||
554 : | new targetid = cmd_target( id, arg, 1 ) | ||
555 : | |||
556 : | if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED | ||
557 : | if( !is_user_alive( targetid ) ) | ||
558 : | { | ||
559 : | client_print( id, print_console, "[AMXX] %L", id, "COULDNT" ) | ||
560 : | return PLUGIN_HANDLED | ||
561 : | } | ||
562 : | |||
563 : | //Safe to tp target to aim spot? | ||
564 : | new Float:tmpvec[3], Float:tmpvec2[3], Float:orig[3], Float:torig[3], Float:trace_ret[3] | ||
565 : | new bool:safe = false, i | ||
566 : | |||
567 : | ian | 5 | pev( id, pev_origin, orig ) |
568 : | pev( id, pev_view_ofs, tmpvec ) | ||
569 : | ian | 1 | for( i = 0; i < 3; i++ ) tmpvec[i] += orig[i] |
570 : | ian | 5 | engfunc( EngFunc_GetAimVector, id, get_pcvar_num( p_mindist ), tmpvec2 ) |
571 : | ian | 1 | |
572 : | for( new j = 1; j < 11 && !safe; j++ ) | ||
573 : | { | ||
574 : | for( i = 0; i < 3; i++ ) | ||
575 : | torig[i] = tmpvec[i] + tmpvec2[i] * j | ||
576 : | |||
577 : | ian | 5 | new tr = 0 |
578 : | engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr ) | ||
579 : | get_tr2( tr, TR_vecEndPos, trace_ret ) | ||
580 : | |||
581 : | ian | 1 | if( get_distance_f( trace_ret, torig ) ) break |
582 : | ian | 5 | if( !_trace_hull( torig, HULL_HUMAN ) ) safe = true |
583 : | ian | 1 | } |
584 : | |||
585 : | //Still not safe? Then find another safe spot somewhere around the grabber | ||
586 : | new try[3] | ||
587 : | orig[2] += 2 | ||
588 : | while( try[2] < 3 && !safe ) | ||
589 : | { | ||
590 : | for( i = 0; i < 3; i++ ) | ||
591 : | switch( try[i] ) | ||
592 : | { | ||
593 : | case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 ) | ||
594 : | case 1 : torig[i] = orig[i] | ||
595 : | case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) | ||
596 : | } | ||
597 : | |||
598 : | ian | 5 | new tr2 = 0 |
599 : | engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr2 ) | ||
600 : | get_tr2( tr2, TR_vecEndPos, trace_ret ) | ||
601 : | ian | 1 | |
602 : | ian | 5 | if( !_trace_hull( torig, HULL_HUMAN ) && !get_distance_f( trace_ret, torig ) ) safe = true |
603 : | |||
604 : | ian | 1 | try[0]++ |
605 : | if( try[0] == 3 ) | ||
606 : | { | ||
607 : | try[0] = 0 | ||
608 : | try[1]++ | ||
609 : | if( try[1] == 3 ) | ||
610 : | { | ||
611 : | try[1] = 0 | ||
612 : | try[2]++ | ||
613 : | } | ||
614 : | } | ||
615 : | } | ||
616 : | |||
617 : | if( safe ) | ||
618 : | { | ||
619 : | ian | 5 | set_pev( targetid, pev_origin, torig ) |
620 : | ian | 1 | set_grabbed( id, targetid ) |
621 : | screenfade_in( id ) | ||
622 : | } | ||
623 : | else client_print( id, print_chat, "[AMXX] %L", id, "COULDNT" ) | ||
624 : | |||
625 : | return PLUGIN_HANDLED | ||
626 : | } | ||
627 : | |||
628 : | public is_grabbed( target, grabber ) | ||
629 : | { | ||
630 : | for( new i = 1; i <= MAXPLAYERS; i++ ) | ||
631 : | if( client_data[i][GRABBED] == target ) | ||
632 : | { | ||
633 : | client_print( grabber, print_chat, "[AMXX] %L", grabber, "ALREADY" ) | ||
634 : | unset_grabbed( grabber ) | ||
635 : | return true | ||
636 : | } | ||
637 : | return false | ||
638 : | } | ||
639 : | |||
640 : | public DeathMsg( ) | ||
641 : | kill_grab( read_data( 2 ) ) | ||
642 : | |||
643 : | public client_disconnect( id ) | ||
644 : | { | ||
645 : | kill_grab( id ) | ||
646 : | return PLUGIN_CONTINUE | ||
647 : | } | ||
648 : | |||
649 : | public kill_grab( id ) | ||
650 : | { | ||
651 : | //If given client has grabbed, or has a grabber, unset it | ||
652 : | if( client_data[id][GRABBED] ) | ||
653 : | unset_grabbed( id ) | ||
654 : | else if( client_data[id][GRABBER] ) | ||
655 : | unset_grabbed( client_data[id][GRABBER] ) | ||
656 : | } | ||
657 : | ian | 5 | |
658 : | //Complements of vittu | ||
659 : | //Complements of fakemeta_util, cause i was too lazy to add this in as not a function | ||
660 : | _trace_hull(const Float:origin[3], hull, ignoredent = 0, ignoremonsters = 0) { | ||
661 : | new result = 0; | ||
662 : | engfunc(EngFunc_TraceHull, origin, origin, ignoremonsters, hull, ignoredent > 0 ? ignoredent : 0, 0); | ||
663 : | |||
664 : | if (get_tr2(0, TR_StartSolid)) | ||
665 : | result += 1; | ||
666 : | if (get_tr2(0, TR_AllSolid)) | ||
667 : | result += 2; | ||
668 : | if (!get_tr2(0, TR_InOpen)) | ||
669 : | result += 4; | ||
670 : | |||
671 : | return result; | ||
672 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |