Parent Directory | Revision Log
Revision 20 - (view) (download)
1 : | ian | 1 | /* |
2 : | ian | 16 | Grab+ v1.2.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 | 16 | Nov 16 08:08 |
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 | 20 | v1.2.2 (Nov 16, 2007) |
105 : | ian | 16 | c: A few small code optimizations. |
106 : | |||
107 : | ian | 15 | v1.2.1 (Nov 12, 2007) |
108 : | ian | 16 | f: Eliminated two run time warnings in the player prethink function. |
109 : | ian | 15 | |
110 : | ian | 11 | v1.2 (Nov 06, 2007) |
111 : | ian | 10 | +: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
112 : | ian | 5 | +: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
113 : | ian | 10 | +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command. |
114 : | ian | 11 | c: Removed dependency of engine and fun modules. Thanks to vittu for doing most of the work. |
115 : | ian | 10 | c: Made cvar names more consistent by adding more underscores. |
116 : | ian | 11 | f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well). |
117 : | ian | 5 | |
118 : | ian | 1 | v1.1 (Oct 16, 2007) |
119 : | +: Grab a few types of entities other than players. | ||
120 : | ian | 10 | +: Cvar gp_players_only. |
121 : | ian | 1 | |
122 : | v1.0 (Oct 13, 2007) | ||
123 : | !: Initial release | ||
124 : | |||
125 : | */ | ||
126 : | |||
127 : | #include <amxmodx> | ||
128 : | #include <amxmisc> | ||
129 : | #include <fakemeta> | ||
130 : | |||
131 : | ian | 16 | #define VERSION "1.2.2" |
132 : | ian | 1 | #define ADMIN ADMIN_LEVEL_A |
133 : | |||
134 : | #define TSK_CHKE 50 | ||
135 : | |||
136 : | ian | 5 | #define SVC_DAMAGE 19 |
137 : | ian | 1 | #define SF_FADEOUT 0 |
138 : | |||
139 : | new client_data[33][4] | ||
140 : | #define GRABBED 0 | ||
141 : | #define GRABBER 1 | ||
142 : | #define GRAB_LEN 2 | ||
143 : | #define FLAGS 3 | ||
144 : | |||
145 : | #define CDF_IN_PUSH (1<<0) | ||
146 : | #define CDF_IN_PULL (1<<1) | ||
147 : | #define CDF_NO_CHOKE (1<<2) | ||
148 : | |||
149 : | //Cvar Pointers | ||
150 : | ian | 10 | new p_enabled, p_players_only |
151 : | new p_throw_force, p_min_dist, p_speed, p_grab_force | ||
152 : | new p_choke_time, p_choke_dmg, p_auto_choke | ||
153 : | ian | 5 | new p_glow_r, p_glow_b, p_glow_g, p_glow_a |
154 : | new p_fade, p_glow | ||
155 : | ian | 1 | |
156 : | //Pseudo Constants | ||
157 : | new MAXPLAYERS | ||
158 : | ian | 5 | new SVC_SCREENFADE, SVC_SCREENSHAKE |
159 : | ian | 1 | |
160 : | public plugin_init( ) | ||
161 : | { | ||
162 : | register_plugin( "Grab+", VERSION, "Ian Cammarata" ) | ||
163 : | register_cvar( "grab_plus_version", VERSION, FCVAR_SERVER ) | ||
164 : | set_cvar_string( "grab_plus_version", VERSION ) | ||
165 : | |||
166 : | p_enabled = register_cvar( "gp_enabled", "1" ) | ||
167 : | ian | 10 | p_players_only = register_cvar( "gp_players_only", "0" ) |
168 : | ian | 1 | |
169 : | ian | 10 | p_min_dist = register_cvar ( "gp_min_dist", "90" ) |
170 : | p_throw_force = register_cvar( "gp_throw_force", "1500" ) | ||
171 : | p_grab_force = register_cvar( "gp_grab_force", "8" ) | ||
172 : | ian | 1 | p_speed = register_cvar( "gp_speed", "5" ) |
173 : | |||
174 : | ian | 10 | p_choke_time = register_cvar( "gp_choke_time", "1.5" ) |
175 : | p_choke_dmg = register_cvar( "gp_choke_dmg", "5" ) | ||
176 : | p_auto_choke = register_cvar( "gp_auto_choke", "1" ) | ||
177 : | ian | 1 | |
178 : | p_glow_r = register_cvar( "gp_glow_r", "50" ) | ||
179 : | p_glow_g = register_cvar( "gp_glow_g", "0" ) | ||
180 : | p_glow_b = register_cvar( "gp_glow_b", "0" ) | ||
181 : | ian | 5 | p_glow_a = register_cvar( "gp_glow_a", "200" ) |
182 : | ian | 1 | |
183 : | ian | 10 | p_fade = register_cvar( "gp_screen_fade", "1" ) |
184 : | ian | 5 | p_glow = register_cvar( "gp_glow", "1" ) |
185 : | |||
186 : | ian | 1 | register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
187 : | register_clcmd( "grab_toggle", "grab_toggle", ADMIN, "press once to grab and again to release" ) | ||
188 : | register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" ) | ||
189 : | register_clcmd( "-grab", "unset_grabbed" ) | ||
190 : | |||
191 : | register_clcmd( "+push", "push", ADMIN, "bind a key to +push" ) | ||
192 : | register_clcmd( "-push", "push" ) | ||
193 : | register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" ) | ||
194 : | register_clcmd( "-pull", "pull" ) | ||
195 : | register_clcmd( "push", "push2" ) | ||
196 : | register_clcmd( "pull", "pull2" ) | ||
197 : | |||
198 : | register_clcmd( "drop" ,"throw" ) | ||
199 : | |||
200 : | register_event( "DeathMsg", "DeathMsg", "a" ) | ||
201 : | |||
202 : | ian | 8 | register_forward( FM_PlayerPreThink, "fm_player_prethink" ) |
203 : | |||
204 : | ian | 1 | register_dictionary( "grab_plus.txt" ) |
205 : | |||
206 : | MAXPLAYERS = get_maxplayers() | ||
207 : | |||
208 : | SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) | ||
209 : | SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) | ||
210 : | } | ||
211 : | |||
212 : | public plugin_precache( ) | ||
213 : | { | ||
214 : | precache_sound( "player/PL_PAIN2.WAV" ) | ||
215 : | } | ||
216 : | |||
217 : | ian | 8 | public fm_player_prethink( id ) |
218 : | ian | 1 | { |
219 : | //Search for a target | ||
220 : | if ( client_data[id][GRABBED] == -1 ) | ||
221 : | { | ||
222 : | new Float:orig[3], Float:ret[3] | ||
223 : | ian | 11 | get_view_pos( id, orig ) |
224 : | ret = vel_by_aim( id, 9999 ) | ||
225 : | ian | 1 | |
226 : | ian | 16 | ret[0] += orig[0] |
227 : | ret[1] += orig[1] | ||
228 : | ret[2] += orig[2] | ||
229 : | |||
230 : | ian | 11 | new target = traceline( orig, ret, id, ret ) |
231 : | ian | 1 | |
232 : | if( 0 < target <= MAXPLAYERS ) | ||
233 : | { | ||
234 : | ian | 15 | if( is_grabbed( target, id ) ) return FMRES_IGNORED |
235 : | ian | 1 | set_grabbed( id, target ) |
236 : | } | ||
237 : | ian | 10 | else if( !get_pcvar_num( p_players_only ) ) |
238 : | ian | 1 | { |
239 : | new movetype | ||
240 : | ian | 15 | if( target && pev_valid( target ) ) |
241 : | ian | 1 | { |
242 : | movetype = pev( target, pev_movetype ) | ||
243 : | if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) | ||
244 : | ian | 15 | return FMRES_IGNORED |
245 : | ian | 1 | } |
246 : | else | ||
247 : | { | ||
248 : | ian | 15 | target = 0 |
249 : | ian | 5 | new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
250 : | ian | 1 | while( !target && ent > 0 ) |
251 : | { | ||
252 : | movetype = pev( ent, pev_movetype ) | ||
253 : | if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) | ||
254 : | && ent != id ) | ||
255 : | target = ent | ||
256 : | ian | 5 | ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 ) |
257 : | ian | 1 | } |
258 : | } | ||
259 : | if( target ) | ||
260 : | { | ||
261 : | ian | 15 | if( is_grabbed( target, id ) ) return FMRES_IGNORED |
262 : | ian | 1 | set_grabbed( id, target ) |
263 : | } | ||
264 : | } | ||
265 : | } | ||
266 : | //If they've grabbed something | ||
267 : | if( client_data[id][GRABBED] > 0 ) | ||
268 : | { | ||
269 : | new target = client_data[id][GRABBED] | ||
270 : | if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) ) | ||
271 : | { | ||
272 : | unset_grabbed( id ) | ||
273 : | ian | 15 | return FMRES_IGNORED |
274 : | ian | 1 | } |
275 : | |||
276 : | //Use key choke | ||
277 : | if( pev( id, pev_button ) & IN_USE ) | ||
278 : | do_choke( id ) | ||
279 : | |||
280 : | //Push and pull | ||
281 : | if ( client_data[id][FLAGS] & CDF_IN_PULL ) | ||
282 : | do_pull( id ) | ||
283 : | else if ( client_data[id][FLAGS] & CDF_IN_PUSH ) | ||
284 : | do_push( id ) | ||
285 : | |||
286 : | grab_think( id ) | ||
287 : | } | ||
288 : | if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] ) | ||
289 : | |||
290 : | ian | 15 | return FMRES_IGNORED |
291 : | ian | 1 | } |
292 : | |||
293 : | public grab_think ( id ) | ||
294 : | { | ||
295 : | new target = client_data[id][GRABBED] | ||
296 : | |||
297 : | //Keep grabbed clients from sticking to ladders | ||
298 : | if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" ) | ||
299 : | |||
300 : | //Move targeted client | ||
301 : | ian | 12 | new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3] |
302 : | ian | 1 | |
303 : | ian | 11 | get_view_pos( id, tmpvec ) |
304 : | ian | 10 | |
305 : | ian | 11 | tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] ) |
306 : | ian | 10 | |
307 : | ian | 1 | torig = get_target_origin_f( target ) |
308 : | |||
309 : | ian | 10 | new force = get_pcvar_num( p_grab_force ) |
310 : | ian | 1 | |
311 : | ian | 16 | tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force |
312 : | tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force | ||
313 : | tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force | ||
314 : | ian | 1 | |
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 : | ian | 11 | set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) ) |
376 : | ian | 1 | unset_grabbed( id ) |
377 : | return PLUGIN_HANDLED | ||
378 : | } | ||
379 : | ian | 11 | |
380 : | ian | 1 | return PLUGIN_CONTINUE |
381 : | } | ||
382 : | |||
383 : | public unset_grabbed( id ) | ||
384 : | { | ||
385 : | new target = client_data[id][GRABBED] | ||
386 : | if( target > 0 && pev_valid( target ) ) | ||
387 : | { | ||
388 : | ian | 5 | set_pev( target, pev_renderfx, kRenderFxNone ) |
389 : | set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} ) | ||
390 : | set_pev( target, pev_rendermode, kRenderNormal ) | ||
391 : | set_pev( target, pev_renderamt, 16.0 ) | ||
392 : | |||
393 : | ian | 1 | if( 0 < target <= MAXPLAYERS ) |
394 : | client_data[target][GRABBER] = 0 | ||
395 : | } | ||
396 : | client_data[id][GRABBED] = 0 | ||
397 : | |||
398 : | ian | 5 | if( get_pcvar_num( p_fade ) ) |
399 : | { | ||
400 : | message_begin( MSG_ONE, SVC_SCREENFADE, _, id ) | ||
401 : | write_short( 10000 ) //duration | ||
402 : | write_short( 0 ) //hold | ||
403 : | write_short( SF_FADEOUT ) //flags | ||
404 : | write_byte( get_pcvar_num( p_glow_r ) ) //r | ||
405 : | write_byte( get_pcvar_num( p_glow_g ) ) //g | ||
406 : | write_byte( get_pcvar_num( p_glow_b ) ) //b | ||
407 : | write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a | ||
408 : | message_end( ) | ||
409 : | } | ||
410 : | ian | 1 | } |
411 : | |||
412 : | //Grabs onto someone | ||
413 : | public set_grabbed( id, target ) | ||
414 : | { | ||
415 : | ian | 5 | if( get_pcvar_num( p_glow ) ) |
416 : | { | ||
417 : | new Float:color[3] | ||
418 : | color[0] = get_pcvar_float( p_glow_r ) | ||
419 : | color[1] = get_pcvar_float( p_glow_g ) | ||
420 : | color[2] = get_pcvar_float( p_glow_b ) | ||
421 : | ian | 6 | set_pev( target, pev_renderfx, kRenderFxGlowShell ) |
422 : | set_pev( target, pev_rendercolor, color ) | ||
423 : | set_pev( target, pev_rendermode, kRenderTransColor ) | ||
424 : | set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) ) | ||
425 : | ian | 5 | } |
426 : | ian | 1 | |
427 : | if( 0 < target <= MAXPLAYERS ) | ||
428 : | client_data[target][GRABBER] = id | ||
429 : | client_data[id][FLAGS] = 0 | ||
430 : | client_data[id][GRABBED] = target | ||
431 : | ian | 5 | new Float:torig[3], Float:orig[3] |
432 : | pev( target, pev_origin, torig ) | ||
433 : | pev( id, pev_origin, orig ) | ||
434 : | client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) | ||
435 : | 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 ) |
436 : | ian | 1 | } |
437 : | |||
438 : | public push( id ) | ||
439 : | { | ||
440 : | client_data[id][FLAGS] ^= CDF_IN_PUSH | ||
441 : | return PLUGIN_HANDLED | ||
442 : | } | ||
443 : | |||
444 : | public pull( id ) | ||
445 : | { | ||
446 : | client_data[id][FLAGS] ^= CDF_IN_PULL | ||
447 : | return PLUGIN_HANDLED | ||
448 : | } | ||
449 : | |||
450 : | public push2( id ) | ||
451 : | { | ||
452 : | if( client_data[id][GRABBED] > 0 ) | ||
453 : | { | ||
454 : | do_push( id ) | ||
455 : | return PLUGIN_HANDLED | ||
456 : | } | ||
457 : | return PLUGIN_CONTINUE | ||
458 : | } | ||
459 : | |||
460 : | public pull2( id ) | ||
461 : | { | ||
462 : | if( client_data[id][GRABBED] > 0 ) | ||
463 : | { | ||
464 : | do_pull( id ) | ||
465 : | return PLUGIN_HANDLED | ||
466 : | } | ||
467 : | return PLUGIN_CONTINUE | ||
468 : | } | ||
469 : | |||
470 : | public do_push( id ) | ||
471 : | if( client_data[id][GRAB_LEN] < 9999 ) | ||
472 : | client_data[id][GRAB_LEN] += get_pcvar_num( p_speed ) | ||
473 : | |||
474 : | public do_pull( id ) | ||
475 : | { | ||
476 : | ian | 10 | new mindist = get_pcvar_num( p_min_dist ) |
477 : | ian | 1 | new len = client_data[id][GRAB_LEN] |
478 : | |||
479 : | if( len > mindist ) | ||
480 : | { | ||
481 : | len -= get_pcvar_num( p_speed ) | ||
482 : | if( len < mindist ) len = mindist | ||
483 : | client_data[id][GRAB_LEN] = len | ||
484 : | } | ||
485 : | ian | 10 | else if( get_pcvar_num( p_auto_choke ) ) |
486 : | do_choke( id ) | ||
487 : | ian | 1 | } |
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 : | ian | 10 | new dmg = get_pcvar_num( p_choke_dmg ) |
495 : | ian | 1 | 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 : | ian | 10 | set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id ) |
543 : | ian | 1 | } |
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 : | ian | 11 | new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3] |
570 : | ian | 1 | new bool:safe = false, i |
571 : | |||
572 : | ian | 11 | get_view_pos( id, orig ) |
573 : | tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) ) | ||
574 : | ian | 1 | |
575 : | for( new j = 1; j < 11 && !safe; j++ ) | ||
576 : | { | ||
577 : | ian | 16 | torig[0] = orig[0] + tmpvec[i] * j |
578 : | torig[1] = orig[1] + tmpvec[i] * j | ||
579 : | torig[2] = orig[2] + tmpvec[i] * j | ||
580 : | |||
581 : | ian | 11 | traceline( tmpvec, torig, id, trace_ret ) |
582 : | ian | 5 | |
583 : | ian | 1 | if( get_distance_f( trace_ret, torig ) ) break |
584 : | ian | 8 | |
585 : | engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) | ||
586 : | if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) ) | ||
587 : | safe = true | ||
588 : | ian | 1 | } |
589 : | |||
590 : | //Still not safe? Then find another safe spot somewhere around the grabber | ||
591 : | ian | 11 | pev( id, pev_origin, orig ) |
592 : | ian | 1 | new try[3] |
593 : | orig[2] += 2 | ||
594 : | while( try[2] < 3 && !safe ) | ||
595 : | { | ||
596 : | for( i = 0; i < 3; i++ ) | ||
597 : | switch( try[i] ) | ||
598 : | { | ||
599 : | case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 ) | ||
600 : | case 1 : torig[i] = orig[i] | ||
601 : | case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) | ||
602 : | } | ||
603 : | |||
604 : | ian | 11 | traceline( tmpvec, torig, id, trace_ret ) |
605 : | ian | 1 | |
606 : | ian | 8 | 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 : | && !get_distance_f( trace_ret, torig ) ) safe = true | ||
609 : | ian | 5 | |
610 : | ian | 1 | try[0]++ |
611 : | if( try[0] == 3 ) | ||
612 : | { | ||
613 : | try[0] = 0 | ||
614 : | try[1]++ | ||
615 : | if( try[1] == 3 ) | ||
616 : | { | ||
617 : | try[1] = 0 | ||
618 : | try[2]++ | ||
619 : | } | ||
620 : | } | ||
621 : | } | ||
622 : | |||
623 : | if( safe ) | ||
624 : | { | ||
625 : | ian | 5 | set_pev( targetid, pev_origin, torig ) |
626 : | ian | 1 | set_grabbed( id, targetid ) |
627 : | screenfade_in( id ) | ||
628 : | } | ||
629 : | else client_print( id, print_chat, "[AMXX] %L", id, "COULDNT" ) | ||
630 : | |||
631 : | return PLUGIN_HANDLED | ||
632 : | } | ||
633 : | |||
634 : | public is_grabbed( target, grabber ) | ||
635 : | { | ||
636 : | for( new i = 1; i <= MAXPLAYERS; i++ ) | ||
637 : | if( client_data[i][GRABBED] == target ) | ||
638 : | { | ||
639 : | client_print( grabber, print_chat, "[AMXX] %L", grabber, "ALREADY" ) | ||
640 : | unset_grabbed( grabber ) | ||
641 : | return true | ||
642 : | } | ||
643 : | return false | ||
644 : | } | ||
645 : | |||
646 : | public DeathMsg( ) | ||
647 : | kill_grab( read_data( 2 ) ) | ||
648 : | |||
649 : | public client_disconnect( id ) | ||
650 : | { | ||
651 : | kill_grab( id ) | ||
652 : | return PLUGIN_CONTINUE | ||
653 : | } | ||
654 : | |||
655 : | public kill_grab( id ) | ||
656 : | { | ||
657 : | //If given client has grabbed, or has a grabber, unset it | ||
658 : | if( client_data[id][GRABBED] ) | ||
659 : | unset_grabbed( id ) | ||
660 : | else if( client_data[id][GRABBER] ) | ||
661 : | unset_grabbed( client_data[id][GRABBER] ) | ||
662 : | } | ||
663 : | ian | 11 | |
664 : | stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] ) | ||
665 : | { | ||
666 : | engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 ) | ||
667 : | get_tr2( 0, TR_vecEndPos, vHitPos ) | ||
668 : | return get_tr2( 0, TR_pHit ) | ||
669 : | } | ||
670 : | |||
671 : | stock get_view_pos( const id, Float:vViewPos[3] ) | ||
672 : | { | ||
673 : | new Float:ofs[3] | ||
674 : | pev( id, pev_origin, vViewPos ) | ||
675 : | pev( id, pev_view_ofs, ofs ) | ||
676 : | ian | 16 | |
677 : | vViewPos[0] += ofs[0] | ||
678 : | vViewPos[1] += ofs[1] | ||
679 : | vViewPos[2] += ofs[2] | ||
680 : | ian | 11 | } |
681 : | |||
682 : | stock Float:vel_by_aim( id, speed = 1 ) | ||
683 : | { | ||
684 : | new Float:v1[3], Float:vBlah[3] | ||
685 : | pev( id, pev_v_angle, v1 ) | ||
686 : | engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah ) | ||
687 : | ian | 16 | |
688 : | v1[0] *= speed | ||
689 : | v1[1] *= speed | ||
690 : | v1[2] *= speed | ||
691 : | |||
692 : | ian | 11 | return v1 |
693 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |