Parent Directory | Revision Log
Revision 12 - (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 | 11 | Nov 06 11:21 |
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 : | Features: | ||
27 : | Multilingual | ||
28 : | Screenfade to indicate grab activity instead of chat spam. | ||
29 : | Can grab players off a ladder. | ||
30 : | Automatically choke by holding down +pull while at min distance. | ||
31 : | Choke with use key. | ||
32 : | Throw with drop. | ||
33 : | Can't have mutliple admins grabbing the same player. | ||
34 : | Auto drop on death. | ||
35 : | Grab entities other than players, such as bombs, weapons, and hostages. | ||
36 : | |||
37 : | |||
38 : | Commands: | ||
39 : | |||
40 : | +grab : Grab something for as long as you hold down the key. | ||
41 : | grab_toggle : Same as +grab but toggles. | ||
42 : | amx_grab <name> : Grab client by name or id and teleport them to you. Use +grab or grab_toggle key to release. | ||
43 : | |||
44 : | +pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button. | ||
45 : | |||
46 : | 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) |
47 : | drop - Throws the grabbed with 1500 velocity. (cvar: gp_throw_force) | ||
48 : | ian | 1 | |
49 : | |||
50 : | Cvars (First value is default): | ||
51 : | gp_enabled <1|0> Enables all plugin functionality. | ||
52 : | ian | 10 | gp_players_only <0|1> Disables admins grabbing entities other than players. |
53 : | ian | 1 | |
54 : | gp_min_dist <90|...> Min distance between the grabber and grabbed. | ||
55 : | ian | 10 | gp_grab_force <8|...> Sets the amount of force used when grabbing players. |
56 : | gp_throw_force <1500|...> Sets the power used when throwing players. | ||
57 : | ian | 1 | gp_speed <5|...> How fast the grabbed moves when using push and pull. |
58 : | |||
59 : | ian | 10 | gp_choke_time <1.5|...> Time frequency for choking. |
60 : | gp_choke_dmg <5|...> Amount of damage done with each choke. | ||
61 : | gp_auto_choke <1|0> Enable/disable choking automatically with +pull command. | ||
62 : | ian | 1 | |
63 : | ian | 10 | gp_screen_fade <1|0> Enables/disables screenfade when grabbing. |
64 : | ian | 9 | gp_glow <1|0> Enables/disables glowing for grabbed objects. |
65 : | ian | 1 | |
66 : | ian | 9 | gp_glow_r <50|0-255> Sets red amount for glow and screenfade. |
67 : | gp_glow_g <0|0-255> Sets green amount for glow and screenfade. | ||
68 : | gp_glow_b <0|0-255> Sets blue amount for glow and screenfade. | ||
69 : | gp_glow_a <0|0-255> Sets alpha for glow and screenfade. | ||
70 : | ian | 1 | |
71 : | ian | 9 | |
72 : | ian | 1 | Notes: |
73 : | Make sure you place the grab_plus.txt file in addons\amxmodx\data\lang | ||
74 : | |||
75 : | |||
76 : | Credits: | ||
77 : | ian | 5 | Thanks to vittu for contributing code (changed all engine/fun module stuff to fakemeta). |
78 : | |||
79 : | ian | 1 | Thanks to all the coders who worked on the original Jedi Force Grab plugin for all their ideas: |
80 : | SpaceDude | ||
81 : | KCE | ||
82 : | KRoTaL | ||
83 : | BOB_SLAYER | ||
84 : | kosmo111 | ||
85 : | |||
86 : | |||
87 : | Supported Languages: | ||
88 : | 1337 (100%) - Thanks to l337newb | ||
89 : | Brazilian Portuguese (100%) - Thanks to Arion | ||
90 : | Danish (100%) - Thanks to nellerbabz | ||
91 : | Dutch (100%) - Thanks to BlackMilk | ||
92 : | English (100%) | ||
93 : | Finnish (100%) - Thanks to Pro Patria Finland | ||
94 : | French (100%) - Thanks to connorr | ||
95 : | German (100%) - Thanks to SchlumPF* | ||
96 : | Russian (100%) - Thanks to `666 | ||
97 : | Spanish (100%) - Hope these don't suck. | ||
98 : | Swedish (100%) - Thanks to Bend3r | ||
99 : | |||
100 : | |||
101 : | Change Log: | ||
102 : | Key (+ added | - removed | c changed | f fixed) | ||
103 : | |||
104 : | ian | 11 | v1.2 (Nov 06, 2007) |
105 : | ian | 10 | +: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
106 : | ian | 5 | +: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
107 : | ian | 10 | +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command. |
108 : | ian | 11 | c: Removed dependency of engine and fun modules. Thanks to vittu for doing most of the work. |
109 : | ian | 10 | c: Made cvar names more consistent by adding more underscores. |
110 : | ian | 11 | f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well). |
111 : | ian | 5 | |
112 : | ian | 1 | v1.1 (Oct 16, 2007) |
113 : | +: Grab a few types of entities other than players. | ||
114 : | ian | 10 | +: Cvar gp_players_only. |
115 : | ian | 1 | |
116 : | v1.0 (Oct 13, 2007) | ||
117 : | !: Initial release | ||
118 : | |||
119 : | */ | ||
120 : | |||
121 : | #include <amxmodx> | ||
122 : | #include <amxmisc> | ||
123 : | #include <fakemeta> | ||
124 : | |||
125 : | ian | 11 | #define VERSION "1.2" |
126 : | ian | 1 | #define ADMIN ADMIN_LEVEL_A |
127 : | |||
128 : | #define TSK_CHKE 50 | ||
129 : | |||
130 : | ian | 5 | #define SVC_DAMAGE 19 |
131 : | ian | 1 | #define SF_FADEOUT 0 |
132 : | |||
133 : | new client_data[33][4] | ||
134 : | #define GRABBED 0 | ||
135 : | #define GRABBER 1 | ||
136 : | #define GRAB_LEN 2 | ||
137 : | #define FLAGS 3 | ||
138 : | |||
139 : | #define CDF_IN_PUSH (1<<0) | ||
140 : | #define CDF_IN_PULL (1<<1) | ||
141 : | #define CDF_NO_CHOKE (1<<2) | ||
142 : | |||
143 : | //Cvar Pointers | ||
144 : | ian | 10 | new p_enabled, p_players_only |
145 : | new p_throw_force, p_min_dist, p_speed, p_grab_force | ||
146 : | new p_choke_time, p_choke_dmg, p_auto_choke | ||
147 : | ian | 5 | new p_glow_r, p_glow_b, p_glow_g, p_glow_a |
148 : | new p_fade, p_glow | ||
149 : | ian | 1 | |
150 : | //Pseudo Constants | ||
151 : | new MAXPLAYERS | ||
152 : | ian | 5 | new SVC_SCREENFADE, SVC_SCREENSHAKE |
153 : | ian | 1 | |
154 : | public plugin_init( ) | ||
155 : | { | ||
156 : | register_plugin( "Grab+", VERSION, "Ian Cammarata" ) | ||
157 : | register_cvar( "grab_plus_version", VERSION, FCVAR_SERVER ) | ||
158 : | set_cvar_string( "grab_plus_version", VERSION ) | ||
159 : | |||
160 : | p_enabled = register_cvar( "gp_enabled", "1" ) | ||
161 : | ian | 10 | p_players_only = register_cvar( "gp_players_only", "0" ) |
162 : | ian | 1 | |
163 : | ian | 10 | p_min_dist = register_cvar ( "gp_min_dist", "90" ) |
164 : | p_throw_force = register_cvar( "gp_throw_force", "1500" ) | ||
165 : | p_grab_force = register_cvar( "gp_grab_force", "8" ) | ||
166 : | ian | 1 | p_speed = register_cvar( "gp_speed", "5" ) |
167 : | |||
168 : | ian | 10 | p_choke_time = register_cvar( "gp_choke_time", "1.5" ) |
169 : | p_choke_dmg = register_cvar( "gp_choke_dmg", "5" ) | ||
170 : | p_auto_choke = register_cvar( "gp_auto_choke", "1" ) | ||
171 : | ian | 1 | |
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 | 10 | p_fade = register_cvar( "gp_screen_fade", "1" ) |
178 : | ian | 5 | 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 | 11 | get_view_pos( id, orig ) |
221 : | ret = vel_by_aim( id, 9999 ) | ||
222 : | ian | 1 | |
223 : | ian | 11 | for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ret[i] |
224 : | new target = traceline( orig, ret, id, 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 : | ian | 10 | else if( !get_pcvar_num( p_players_only ) ) |
232 : | ian | 1 | { |
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 : | ian | 12 | new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3] |
295 : | ian | 1 | |
296 : | ian | 11 | get_view_pos( id, tmpvec ) |
297 : | ian | 10 | |
298 : | ian | 11 | tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] ) |
299 : | ian | 10 | |
300 : | ian | 1 | torig = get_target_origin_f( target ) |
301 : | |||
302 : | ian | 10 | new force = get_pcvar_num( p_grab_force ) |
303 : | ian | 1 | |
304 : | for( new i = 0; i < 3; i++ ) | ||
305 : | ian | 11 | tvel[i] = ( ( tmpvec[i] + tmpvec2[i] ) - torig[i] ) * force |
306 : | ian | 1 | |
307 : | ian | 5 | set_pev( target, pev_velocity, tvel ) |
308 : | ian | 1 | } |
309 : | |||
310 : | stock Float:get_target_origin_f( id ) | ||
311 : | { | ||
312 : | new Float:orig[3] | ||
313 : | ian | 5 | pev( id, pev_origin, orig ) |
314 : | ian | 1 | |
315 : | //If grabbed is not a player, move origin to center | ||
316 : | if( id > MAXPLAYERS ) | ||
317 : | { | ||
318 : | new Float:mins[3], Float:maxs[3] | ||
319 : | ian | 5 | pev( id, pev_mins, mins ) |
320 : | pev( id, pev_maxs, maxs ) | ||
321 : | ian | 1 | |
322 : | if( !mins[2] ) orig[2] += maxs[2] / 2 | ||
323 : | } | ||
324 : | |||
325 : | return orig | ||
326 : | } | ||
327 : | |||
328 : | public grab_toggle( id, level, cid ) | ||
329 : | { | ||
330 : | if( !client_data[id][GRABBED] ) grab( id, level, cid ) | ||
331 : | else unset_grabbed( id ) | ||
332 : | |||
333 : | return PLUGIN_HANDLED | ||
334 : | } | ||
335 : | |||
336 : | public grab( id, level, cid ) | ||
337 : | { | ||
338 : | if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED | ||
339 : | |||
340 : | if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1 | ||
341 : | screenfade_in( id ) | ||
342 : | |||
343 : | return PLUGIN_HANDLED | ||
344 : | } | ||
345 : | |||
346 : | public screenfade_in( id ) | ||
347 : | { | ||
348 : | ian | 5 | if( get_pcvar_num( p_fade ) ) |
349 : | { | ||
350 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, id ) | ||
351 : | write_short( 10000 ) //duration | ||
352 : | write_short( 0 ) //hold | ||
353 : | write_short( SF_FADE_IN + SF_FADE_ONLYONE ) //flags | ||
354 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
355 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
356 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
357 : | write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a | ||
358 : | message_end( ) | ||
359 : | } | ||
360 : | ian | 1 | } |
361 : | |||
362 : | public throw( id ) | ||
363 : | { | ||
364 : | new target = client_data[id][GRABBED] | ||
365 : | if( target > 0 ) | ||
366 : | { | ||
367 : | ian | 11 | set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) ) |
368 : | ian | 1 | unset_grabbed( id ) |
369 : | return PLUGIN_HANDLED | ||
370 : | } | ||
371 : | ian | 11 | |
372 : | ian | 1 | return PLUGIN_CONTINUE |
373 : | } | ||
374 : | |||
375 : | public unset_grabbed( id ) | ||
376 : | { | ||
377 : | new target = client_data[id][GRABBED] | ||
378 : | if( target > 0 && pev_valid( target ) ) | ||
379 : | { | ||
380 : | ian | 5 | set_pev( target, pev_renderfx, kRenderFxNone ) |
381 : | set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} ) | ||
382 : | set_pev( target, pev_rendermode, kRenderNormal ) | ||
383 : | set_pev( target, pev_renderamt, 16.0 ) | ||
384 : | |||
385 : | ian | 1 | if( 0 < target <= MAXPLAYERS ) |
386 : | client_data[target][GRABBER] = 0 | ||
387 : | } | ||
388 : | client_data[id][GRABBED] = 0 | ||
389 : | |||
390 : | ian | 5 | if( get_pcvar_num( p_fade ) ) |
391 : | { | ||
392 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, id ) | ||
393 : | write_short( 10000 ) //duration | ||
394 : | write_short( 0 ) //hold | ||
395 : | write_short( SF_FADEOUT ) //flags | ||
396 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
397 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
398 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
399 : | write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a | ||
400 : | message_end( ) | ||
401 : | } | ||
402 : | ian | 1 | } |
403 : | |||
404 : | //Grabs onto someone | ||
405 : | public set_grabbed( id, target ) | ||
406 : | { | ||
407 : | ian | 5 | if( get_pcvar_num( p_glow ) ) |
408 : | { | ||
409 : | new Float:color[3] | ||
410 : | color[0] = get_pcvar_float( p_glow_r ) | ||
411 : | color[1] = get_pcvar_float( p_glow_g ) | ||
412 : | color[2] = get_pcvar_float( p_glow_b ) | ||
413 : | ian | 6 | set_pev( target, pev_renderfx, kRenderFxGlowShell ) |
414 : | set_pev( target, pev_rendercolor, color ) | ||
415 : | set_pev( target, pev_rendermode, kRenderTransColor ) | ||
416 : | set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) ) | ||
417 : | ian | 5 | } |
418 : | ian | 1 | |
419 : | if( 0 < target <= MAXPLAYERS ) | ||
420 : | client_data[target][GRABBER] = id | ||
421 : | client_data[id][FLAGS] = 0 | ||
422 : | client_data[id][GRABBED] = target | ||
423 : | ian | 5 | new Float:torig[3], Float:orig[3] |
424 : | pev( target, pev_origin, torig ) | ||
425 : | pev( id, pev_origin, orig ) | ||
426 : | client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) | ||
427 : | 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 ) |
428 : | ian | 1 | } |
429 : | |||
430 : | public push( id ) | ||
431 : | { | ||
432 : | client_data[id][FLAGS] ^= CDF_IN_PUSH | ||
433 : | return PLUGIN_HANDLED | ||
434 : | } | ||
435 : | |||
436 : | public pull( id ) | ||
437 : | { | ||
438 : | client_data[id][FLAGS] ^= CDF_IN_PULL | ||
439 : | return PLUGIN_HANDLED | ||
440 : | } | ||
441 : | |||
442 : | public push2( id ) | ||
443 : | { | ||
444 : | if( client_data[id][GRABBED] > 0 ) | ||
445 : | { | ||
446 : | do_push( id ) | ||
447 : | return PLUGIN_HANDLED | ||
448 : | } | ||
449 : | return PLUGIN_CONTINUE | ||
450 : | } | ||
451 : | |||
452 : | public pull2( id ) | ||
453 : | { | ||
454 : | if( client_data[id][GRABBED] > 0 ) | ||
455 : | { | ||
456 : | do_pull( id ) | ||
457 : | return PLUGIN_HANDLED | ||
458 : | } | ||
459 : | return PLUGIN_CONTINUE | ||
460 : | } | ||
461 : | |||
462 : | public do_push( id ) | ||
463 : | if( client_data[id][GRAB_LEN] < 9999 ) | ||
464 : | client_data[id][GRAB_LEN] += get_pcvar_num( p_speed ) | ||
465 : | |||
466 : | public do_pull( id ) | ||
467 : | { | ||
468 : | ian | 10 | new mindist = get_pcvar_num( p_min_dist ) |
469 : | ian | 1 | new len = client_data[id][GRAB_LEN] |
470 : | |||
471 : | if( len > mindist ) | ||
472 : | { | ||
473 : | len -= get_pcvar_num( p_speed ) | ||
474 : | if( len < mindist ) len = mindist | ||
475 : | client_data[id][GRAB_LEN] = len | ||
476 : | } | ||
477 : | ian | 10 | else if( get_pcvar_num( p_auto_choke ) ) |
478 : | do_choke( id ) | ||
479 : | ian | 1 | } |
480 : | |||
481 : | public do_choke( id ) | ||
482 : | { | ||
483 : | new target = client_data[id][GRABBED] | ||
484 : | if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return | ||
485 : | |||
486 : | ian | 10 | new dmg = get_pcvar_num( p_choke_dmg ) |
487 : | ian | 1 | new Float:vec[3] |
488 : | get_target_origin_f( target ) | ||
489 : | |||
490 : | message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target ) | ||
491 : | write_short( 999999 ) //amount | ||
492 : | write_short( 9999 ) //duration | ||
493 : | write_short( 999 ) //frequency | ||
494 : | message_end( ) | ||
495 : | |||
496 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, target ) | ||
497 : | write_short( 9999 ) //duration | ||
498 : | write_short( 100 ) //hold | ||
499 : | write_short( SF_FADE_MODULATE ) //flags | ||
500 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
501 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
502 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
503 : | write_byte( 200 ) //a | ||
504 : | message_end( ) | ||
505 : | |||
506 : | message_begin( MSG_ONE, SVC_DAMAGE, _, target ) | ||
507 : | write_byte( 0 ) //damage armor | ||
508 : | write_byte( dmg ) //damage health | ||
509 : | write_long( DMG_CRUSH ) //damage type | ||
510 : | write_coord( floatround( vec[0] ) ) //origin[x] | ||
511 : | write_coord( floatround( vec[1] ) ) //origin[y] | ||
512 : | write_coord( floatround( vec[2] ) ) //origin[z] | ||
513 : | message_end( ) | ||
514 : | |||
515 : | message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) | ||
516 : | write_byte( TE_BLOODSTREAM ) | ||
517 : | write_coord( floatround( vec[0] ) ) //pos.x | ||
518 : | write_coord( floatround( vec[1] ) ) //pos.y | ||
519 : | write_coord( floatround( vec[2] ) + 15 ) //pos.z | ||
520 : | write_coord( random_num( 0, 255 ) ) //vec.x | ||
521 : | write_coord( random_num( 0, 255 ) ) //vec.y | ||
522 : | write_coord( random_num( 0, 255 ) ) //vec.z | ||
523 : | write_byte( 70 ) //col index | ||
524 : | write_byte( random_num( 50, 250 ) ) //speed | ||
525 : | message_end( ) | ||
526 : | |||
527 : | new health = pev( target, pev_health ) - dmg | ||
528 : | set_pev( target, pev_health, float( health ) ) | ||
529 : | if( health < 1 ) dllfunc( DLLFunc_ClientKill, target ) | ||
530 : | |||
531 : | emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM ) | ||
532 : | |||
533 : | client_data[id][FLAGS] ^= CDF_NO_CHOKE | ||
534 : | ian | 10 | set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id ) |
535 : | ian | 1 | } |
536 : | |||
537 : | public clear_no_choke( tskid ) | ||
538 : | { | ||
539 : | new id = tskid - TSK_CHKE | ||
540 : | client_data[id][FLAGS] ^= CDF_NO_CHOKE | ||
541 : | } | ||
542 : | |||
543 : | //Grabs the client and teleports them to the admin | ||
544 : | public force_grab(id, level, cid) | ||
545 : | { | ||
546 : | if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED | ||
547 : | |||
548 : | new arg[33] | ||
549 : | read_argv( 1, arg, 32 ) | ||
550 : | |||
551 : | new targetid = cmd_target( id, arg, 1 ) | ||
552 : | |||
553 : | if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED | ||
554 : | if( !is_user_alive( targetid ) ) | ||
555 : | { | ||
556 : | client_print( id, print_console, "[AMXX] %L", id, "COULDNT" ) | ||
557 : | return PLUGIN_HANDLED | ||
558 : | } | ||
559 : | |||
560 : | //Safe to tp target to aim spot? | ||
561 : | ian | 11 | new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3] |
562 : | ian | 1 | new bool:safe = false, i |
563 : | |||
564 : | ian | 11 | get_view_pos( id, orig ) |
565 : | tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) ) | ||
566 : | ian | 1 | |
567 : | for( new j = 1; j < 11 && !safe; j++ ) | ||
568 : | { | ||
569 : | ian | 11 | for( i = 0; i < 3; i++ ) torig[i] = orig[i] + tmpvec[i] * j |
570 : | traceline( tmpvec, torig, id, trace_ret ) | ||
571 : | ian | 5 | |
572 : | ian | 1 | if( get_distance_f( trace_ret, torig ) ) break |
573 : | ian | 8 | |
574 : | engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) | ||
575 : | if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) ) | ||
576 : | safe = true | ||
577 : | ian | 1 | } |
578 : | |||
579 : | //Still not safe? Then find another safe spot somewhere around the grabber | ||
580 : | ian | 11 | pev( id, pev_origin, orig ) |
581 : | ian | 1 | new try[3] |
582 : | orig[2] += 2 | ||
583 : | while( try[2] < 3 && !safe ) | ||
584 : | { | ||
585 : | for( i = 0; i < 3; i++ ) | ||
586 : | switch( try[i] ) | ||
587 : | { | ||
588 : | case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 ) | ||
589 : | case 1 : torig[i] = orig[i] | ||
590 : | case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) | ||
591 : | } | ||
592 : | |||
593 : | ian | 11 | traceline( tmpvec, torig, id, trace_ret ) |
594 : | ian | 1 | |
595 : | ian | 8 | engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) |
596 : | if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) | ||
597 : | && !get_distance_f( trace_ret, torig ) ) safe = true | ||
598 : | ian | 5 | |
599 : | ian | 1 | try[0]++ |
600 : | if( try[0] == 3 ) | ||
601 : | { | ||
602 : | try[0] = 0 | ||
603 : | try[1]++ | ||
604 : | if( try[1] == 3 ) | ||
605 : | { | ||
606 : | try[1] = 0 | ||
607 : | try[2]++ | ||
608 : | } | ||
609 : | } | ||
610 : | } | ||
611 : | |||
612 : | if( safe ) | ||
613 : | { | ||
614 : | ian | 5 | set_pev( targetid, pev_origin, torig ) |
615 : | ian | 1 | set_grabbed( id, targetid ) |
616 : | screenfade_in( id ) | ||
617 : | } | ||
618 : | else client_print( id, print_chat, "[AMXX] %L", id, "COULDNT" ) | ||
619 : | |||
620 : | return PLUGIN_HANDLED | ||
621 : | } | ||
622 : | |||
623 : | public is_grabbed( target, grabber ) | ||
624 : | { | ||
625 : | for( new i = 1; i <= MAXPLAYERS; i++ ) | ||
626 : | if( client_data[i][GRABBED] == target ) | ||
627 : | { | ||
628 : | client_print( grabber, print_chat, "[AMXX] %L", grabber, "ALREADY" ) | ||
629 : | unset_grabbed( grabber ) | ||
630 : | return true | ||
631 : | } | ||
632 : | return false | ||
633 : | } | ||
634 : | |||
635 : | public DeathMsg( ) | ||
636 : | kill_grab( read_data( 2 ) ) | ||
637 : | |||
638 : | public client_disconnect( id ) | ||
639 : | { | ||
640 : | kill_grab( id ) | ||
641 : | return PLUGIN_CONTINUE | ||
642 : | } | ||
643 : | |||
644 : | public kill_grab( id ) | ||
645 : | { | ||
646 : | //If given client has grabbed, or has a grabber, unset it | ||
647 : | if( client_data[id][GRABBED] ) | ||
648 : | unset_grabbed( id ) | ||
649 : | else if( client_data[id][GRABBER] ) | ||
650 : | unset_grabbed( client_data[id][GRABBER] ) | ||
651 : | } | ||
652 : | ian | 11 | |
653 : | stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] ) | ||
654 : | { | ||
655 : | engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 ) | ||
656 : | get_tr2( 0, TR_vecEndPos, vHitPos ) | ||
657 : | return get_tr2( 0, TR_pHit ) | ||
658 : | } | ||
659 : | |||
660 : | stock get_view_pos( const id, Float:vViewPos[3] ) | ||
661 : | { | ||
662 : | new Float:ofs[3] | ||
663 : | pev( id, pev_origin, vViewPos ) | ||
664 : | pev( id, pev_view_ofs, ofs ) | ||
665 : | for( new i = 0; i < 3; i++ ) vViewPos[i] += ofs[i] | ||
666 : | } | ||
667 : | |||
668 : | stock Float:vel_by_aim( id, speed = 1 ) | ||
669 : | { | ||
670 : | new Float:v1[3], Float:vBlah[3] | ||
671 : | pev( id, pev_v_angle, v1 ) | ||
672 : | engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah ) | ||
673 : | for( new i = 0; i < 3; i++ ) v1[i] *= speed | ||
674 : | return v1 | ||
675 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |