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

Annotation of /grab_plus.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 39 - (view) (download)

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

Contact
ViewVC Help
Powered by ViewVC 1.0.4