[Half-Life AMXX] / grab_plus.sma Repository:
ViewVC logotype

Annotation of /grab_plus.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (view) (download)

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

Contact
ViewVC Help
Powered by ViewVC 1.0.4