16 |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
17 |
|
|
18 |
http://ian.cammarata.us/projects/grab_plus |
http://ian.cammarata.us/projects/grab_plus |
19 |
Nov 01 04:16 |
Nov 06 11:21 |
20 |
|
|
21 |
|
|
22 |
Description: |
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. |
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 |
|
|
|
See it in Action: |
|
|
http://www.game-monitor.com/search.php?search=grab_plus_version&type=variable&game=all&location=all |
|
|
|
|
|
|
|
26 |
Features: |
Features: |
27 |
Multilingual |
Multilingual |
28 |
Screenfade to indicate grab activity instead of chat spam. |
Screenfade to indicate grab activity instead of chat spam. |
43 |
|
|
44 |
+pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button. |
+pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button. |
45 |
|
|
46 |
+use : Chokes the grabbed (it damages the grabbed with 5 (cvar: gp_chokedmg) hp per 1.5 (cvar: gp_choketime) seconds) |
+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_throwforce) |
drop - Throws the grabbed with 1500 velocity. (cvar: gp_throw_force) |
48 |
|
|
49 |
|
|
50 |
Cvars (First value is default): |
Cvars (First value is default): |
51 |
gp_enabled <1|0> Enables all plugin functionality. |
gp_enabled <1|0> Enables all plugin functionality. |
52 |
gp_playersonly <0|1> Disables admins grabbing entities other than players. |
gp_players_only <0|1> Disables admins grabbing entities other than players. |
53 |
|
|
54 |
gp_min_dist <90|...> Min distance between the grabber and grabbed. |
gp_min_dist <90|...> Min distance between the grabber and grabbed. |
55 |
gp_grabforce <8|...> Sets the amount of force used when grabbing players. |
gp_grab_force <8|...> Sets the amount of force used when grabbing players. |
56 |
gp_throwforce <1500|...> Sets the power used when throwing players. |
gp_throw_force <1500|...> Sets the power used when throwing players. |
57 |
gp_speed <5|...> How fast the grabbed moves when using push and pull. |
gp_speed <5|...> How fast the grabbed moves when using push and pull. |
58 |
|
|
59 |
gp_choketime <1.5|...> Time frequency for choking. |
gp_choke_time <1.5|...> Time frequency for choking. |
60 |
gp_chokedmg <5|...> Amount of damage done with each choke. |
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 |
|
|
63 |
gp_screenfade <1|0> Enables/disables screenfade when grabbing. |
gp_screen_fade <1|0> Enables/disables screenfade when grabbing. |
64 |
gp_glow <1|0> Enables/disables glowing for grabbed objects. |
gp_glow <1|0> Enables/disables glowing for grabbed objects. |
65 |
|
|
66 |
gp_glow_r <50|0-255> Sets red amount for glow and screenfade. |
gp_glow_r <50|0-255> Sets red amount for glow and screenfade. |
101 |
Change Log: |
Change Log: |
102 |
Key (+ added | - removed | c changed | f fixed) |
Key (+ added | - removed | c changed | f fixed) |
103 |
|
|
104 |
v1.2 (Nov ??, 2007) |
v1.2 (Nov 06, 2007) |
105 |
+: Cvars gp_screenfade and gp_glow to enable/disable these features. |
+: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
106 |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
107 |
c: Removed dependency of engine and fun modules. Thanks to vittu for doing all the work. |
+: Cvar gp_auto_choke to enable/disable choking automatically with +pull command. |
108 |
f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7x as well). |
c: Removed dependency of engine and fun modules. Thanks to vittu for doing most of the work. |
109 |
|
c: Made cvar names more consistent by adding more underscores. |
110 |
|
f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well). |
111 |
|
|
112 |
v1.1 (Oct 16, 2007) |
v1.1 (Oct 16, 2007) |
113 |
+: Grab a few types of entities other than players. |
+: Grab a few types of entities other than players. |
114 |
+: Cvar gp_playersonly. |
+: Cvar gp_players_only. |
115 |
|
|
116 |
v1.0 (Oct 13, 2007) |
v1.0 (Oct 13, 2007) |
117 |
!: Initial release |
!: Initial release |
122 |
#include <amxmisc> |
#include <amxmisc> |
123 |
#include <fakemeta> |
#include <fakemeta> |
124 |
|
|
125 |
#define VERSION "1.2b5" |
#define VERSION "1.2" |
126 |
#define ADMIN ADMIN_LEVEL_A |
#define ADMIN ADMIN_LEVEL_A |
127 |
|
|
128 |
#define TSK_CHKE 50 |
#define TSK_CHKE 50 |
141 |
#define CDF_NO_CHOKE (1<<2) |
#define CDF_NO_CHOKE (1<<2) |
142 |
|
|
143 |
//Cvar Pointers |
//Cvar Pointers |
144 |
new p_enabled, p_playersonly |
new p_enabled, p_players_only |
145 |
new p_throwforce, p_mindist, p_speed, p_grabforce |
new p_throw_force, p_min_dist, p_speed, p_grab_force |
146 |
new p_choketime, p_chokedmg |
new p_choke_time, p_choke_dmg, p_auto_choke |
147 |
new p_glow_r, p_glow_b, p_glow_g, p_glow_a |
new p_glow_r, p_glow_b, p_glow_g, p_glow_a |
148 |
new p_fade, p_glow |
new p_fade, p_glow |
149 |
|
|
158 |
set_cvar_string( "grab_plus_version", VERSION ) |
set_cvar_string( "grab_plus_version", VERSION ) |
159 |
|
|
160 |
p_enabled = register_cvar( "gp_enabled", "1" ) |
p_enabled = register_cvar( "gp_enabled", "1" ) |
161 |
p_playersonly = register_cvar( "gp_playersonly", "0" ) |
p_players_only = register_cvar( "gp_players_only", "0" ) |
162 |
|
|
163 |
p_mindist = register_cvar ( "gp_min_dist", "90" ) |
p_min_dist = register_cvar ( "gp_min_dist", "90" ) |
164 |
p_throwforce = register_cvar( "gp_throwforce", "1500" ) |
p_throw_force = register_cvar( "gp_throw_force", "1500" ) |
165 |
p_grabforce = register_cvar( "gp_grabforce", "8" ) |
p_grab_force = register_cvar( "gp_grab_force", "8" ) |
166 |
p_speed = register_cvar( "gp_speed", "5" ) |
p_speed = register_cvar( "gp_speed", "5" ) |
167 |
|
|
168 |
p_choketime = register_cvar( "gp_choketime", "1.5" ) |
p_choke_time = register_cvar( "gp_choke_time", "1.5" ) |
169 |
p_chokedmg = register_cvar( "gp_chokedmg", "5" ) |
p_choke_dmg = register_cvar( "gp_choke_dmg", "5" ) |
170 |
|
p_auto_choke = register_cvar( "gp_auto_choke", "1" ) |
171 |
|
|
172 |
p_glow_r = register_cvar( "gp_glow_r", "50" ) |
p_glow_r = register_cvar( "gp_glow_r", "50" ) |
173 |
p_glow_g = register_cvar( "gp_glow_g", "0" ) |
p_glow_g = register_cvar( "gp_glow_g", "0" ) |
174 |
p_glow_b = register_cvar( "gp_glow_b", "0" ) |
p_glow_b = register_cvar( "gp_glow_b", "0" ) |
175 |
p_glow_a = register_cvar( "gp_glow_a", "200" ) |
p_glow_a = register_cvar( "gp_glow_a", "200" ) |
176 |
|
|
177 |
p_fade = register_cvar( "gp_screenfade", "1" ) |
p_fade = register_cvar( "gp_screen_fade", "1" ) |
178 |
p_glow = register_cvar( "gp_glow", "1" ) |
p_glow = register_cvar( "gp_glow", "1" ) |
179 |
|
|
180 |
register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
217 |
if ( client_data[id][GRABBED] == -1 ) |
if ( client_data[id][GRABBED] == -1 ) |
218 |
{ |
{ |
219 |
new Float:orig[3], Float:ret[3] |
new Float:orig[3], Float:ret[3] |
220 |
pev( id, pev_origin, orig ) |
get_view_pos( id, orig ) |
221 |
pev( id, pev_view_ofs, ret ) |
ret = vel_by_aim( id, 9999 ) |
222 |
|
|
223 |
for( new i = 0; i < 3; i++ ) orig[i] += ret[i] |
for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ret[i] |
224 |
velocity_by_aim( id, 1, ret ) |
new target = traceline( orig, ret, id, ret ) |
|
for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ( ret[i] * 9999 ) |
|
|
|
|
|
engfunc( EngFunc_TraceLine, orig, ret, 0, id, 0 ) |
|
|
new target = get_tr2( 0, TR_pHit ) |
|
|
get_tr2( 0, TR_vecEndPos, ret ) |
|
225 |
|
|
226 |
if( 0 < target <= MAXPLAYERS ) |
if( 0 < target <= MAXPLAYERS ) |
227 |
{ |
{ |
228 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
229 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
230 |
} |
} |
231 |
else if( !get_pcvar_num( p_playersonly ) ) |
else if( !get_pcvar_num( p_players_only ) ) |
232 |
{ |
{ |
233 |
new movetype |
new movetype |
234 |
if( target ) |
if( target ) |
291 |
if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" ) |
if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" ) |
292 |
|
|
293 |
//Move targeted client |
//Move targeted client |
294 |
new Float:tmpvec[3], Float:tmpvec2[3], Float:dest[3], Float:torig[3], Float:tvel[3] |
new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3] |
295 |
new len = client_data[id][GRAB_LEN] |
|
296 |
|
get_view_pos( id, tmpvec ) |
297 |
|
|
298 |
|
tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] ) |
299 |
|
|
|
pev( id, pev_origin, dest ) |
|
|
pev( id, pev_view_ofs, tmpvec ) |
|
|
velocity_by_aim( id, len, tmpvec2 ) |
|
300 |
torig = get_target_origin_f( target ) |
torig = get_target_origin_f( target ) |
301 |
|
|
302 |
new force = get_pcvar_num( p_grabforce ) |
new force = get_pcvar_num( p_grab_force ) |
303 |
|
|
304 |
for( new i = 0; i < 3; i++ ) |
for( new i = 0; i < 3; i++ ) |
305 |
{ |
tvel[i] = ( ( tmpvec[i] + tmpvec2[i] ) - torig[i] ) * force |
|
dest[i] += tmpvec[i] + tmpvec2[i] |
|
|
tvel[i] = ( dest[i] - torig[i] ) * force |
|
|
} |
|
306 |
|
|
307 |
set_pev( target, pev_velocity, tvel ) |
set_pev( target, pev_velocity, tvel ) |
308 |
} |
} |
364 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
365 |
if( target > 0 ) |
if( target > 0 ) |
366 |
{ |
{ |
367 |
new Float:pVelocity[3] |
set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) ) |
|
velocity_by_aim( id, get_pcvar_num(p_throwforce), pVelocity ) |
|
|
set_pev( target, pev_velocity, pVelocity ) |
|
368 |
unset_grabbed( id ) |
unset_grabbed( id ) |
369 |
return PLUGIN_HANDLED |
return PLUGIN_HANDLED |
370 |
} |
} |
371 |
|
|
372 |
return PLUGIN_CONTINUE |
return PLUGIN_CONTINUE |
373 |
} |
} |
374 |
|
|
424 |
pev( target, pev_origin, torig ) |
pev( target, pev_origin, torig ) |
425 |
pev( id, pev_origin, orig ) |
pev( id, pev_origin, orig ) |
426 |
client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) |
client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) |
427 |
if( client_data[id][GRAB_LEN] < get_pcvar_num( p_mindist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_mindist ) |
if( client_data[id][GRAB_LEN] < get_pcvar_num( p_min_dist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_min_dist ) |
428 |
} |
} |
429 |
|
|
430 |
public push( id ) |
public push( id ) |
465 |
|
|
466 |
public do_pull( id ) |
public do_pull( id ) |
467 |
{ |
{ |
468 |
new mindist = get_pcvar_num( p_mindist ) |
new mindist = get_pcvar_num( p_min_dist ) |
469 |
new len = client_data[id][GRAB_LEN] |
new len = client_data[id][GRAB_LEN] |
470 |
|
|
471 |
if( len > mindist ) |
if( len > mindist ) |
474 |
if( len < mindist ) len = mindist |
if( len < mindist ) len = mindist |
475 |
client_data[id][GRAB_LEN] = len |
client_data[id][GRAB_LEN] = len |
476 |
} |
} |
477 |
else do_choke( id ) |
else if( get_pcvar_num( p_auto_choke ) ) |
478 |
|
do_choke( id ) |
479 |
} |
} |
480 |
|
|
481 |
public do_choke( id ) |
public do_choke( id ) |
483 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
484 |
if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return |
if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return |
485 |
|
|
486 |
new dmg = get_pcvar_num( p_chokedmg ) |
new dmg = get_pcvar_num( p_choke_dmg ) |
487 |
new Float:vec[3] |
new Float:vec[3] |
488 |
get_target_origin_f( target ) |
get_target_origin_f( target ) |
489 |
|
|
531 |
emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM ) |
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 |
client_data[id][FLAGS] ^= CDF_NO_CHOKE |
534 |
set_task( get_pcvar_float( p_choketime ), "clear_no_choke", TSK_CHKE + id ) |
set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id ) |
535 |
} |
} |
536 |
|
|
537 |
public clear_no_choke( tskid ) |
public clear_no_choke( tskid ) |
558 |
} |
} |
559 |
|
|
560 |
//Safe to tp target to aim spot? |
//Safe to tp target to aim spot? |
561 |
new Float:tmpvec[3], Float:tmpvec2[3], Float:orig[3], Float:torig[3], Float:trace_ret[3] |
new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3] |
562 |
new bool:safe = false, i |
new bool:safe = false, i |
563 |
|
|
564 |
pev( id, pev_origin, orig ) |
get_view_pos( id, orig ) |
565 |
pev( id, pev_view_ofs, tmpvec ) |
tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) ) |
|
for( i = 0; i < 3; i++ ) tmpvec[i] += orig[i] |
|
|
velocity_by_aim( id, get_pcvar_num( p_mindist ), tmpvec2 ) |
|
566 |
|
|
567 |
for( new j = 1; j < 11 && !safe; j++ ) |
for( new j = 1; j < 11 && !safe; j++ ) |
568 |
{ |
{ |
569 |
for( i = 0; i < 3; i++ ) |
for( i = 0; i < 3; i++ ) torig[i] = orig[i] + tmpvec[i] * j |
570 |
torig[i] = tmpvec[i] + tmpvec2[i] * j |
traceline( tmpvec, torig, id, trace_ret ) |
|
|
|
|
engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 ) |
|
|
get_tr2( 0, TR_vecEndPos, trace_ret ) |
|
571 |
|
|
572 |
if( get_distance_f( trace_ret, torig ) ) break |
if( get_distance_f( trace_ret, torig ) ) break |
573 |
|
|
577 |
} |
} |
578 |
|
|
579 |
//Still not safe? Then find another safe spot somewhere around the grabber |
//Still not safe? Then find another safe spot somewhere around the grabber |
580 |
|
pev( id, pev_origin, orig ) |
581 |
new try[3] |
new try[3] |
582 |
orig[2] += 2 |
orig[2] += 2 |
583 |
while( try[2] < 3 && !safe ) |
while( try[2] < 3 && !safe ) |
590 |
case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) |
case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) |
591 |
} |
} |
592 |
|
|
593 |
engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 ) |
traceline( tmpvec, torig, id, trace_ret ) |
|
get_tr2( 0, TR_vecEndPos, trace_ret ) |
|
594 |
|
|
595 |
engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) |
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 ) |
if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) |
649 |
else if( client_data[id][GRABBER] ) |
else if( client_data[id][GRABBER] ) |
650 |
unset_grabbed( client_data[id][GRABBER] ) |
unset_grabbed( client_data[id][GRABBER] ) |
651 |
} |
} |
652 |
|
|
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 |
|
} |