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