1 |
/* |
/* |
2 |
Grab+ v1.2 |
Grab+ v1.2.3 |
3 |
Copyright (C) 2007 Ian (Juan) Cammarata |
Copyright (C) 2007 Ian (Juan) Cammarata |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify it under |
This program is free software: you can redistribute it and/or modify |
6 |
the terms of the GNU General Public License as published by the Free Software |
it under the terms of the GNU Affero General Public License as |
7 |
Foundation; either version 2 of the License, or (at your option) any later |
published by the Free Software Foundation, either version 3 of the |
8 |
version. |
License, or (at your option) any later version. |
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
This program is distributed in the hope that it will be useful, |
11 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
GNU Affero General Public License for more details. |
14 |
|
|
15 |
You should have received a copy of the GNU General Public License along with |
You should have received a copy of the GNU Affero General Public License |
16 |
this program; go to http://www.opensource.org/licenses/gpl-license.php |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
18 |
|
|
19 |
http://ian.cammarata.us/projects/grab_plus |
http://ian.cammarata.us/projects/grab_plus |
20 |
Nov 06 11:21 |
Nov 16 08:08 |
21 |
|
|
22 |
|
|
23 |
Description: |
Description: |
102 |
Change Log: |
Change Log: |
103 |
Key (+ added | - removed | c changed | f fixed) |
Key (+ added | - removed | c changed | f fixed) |
104 |
|
|
105 |
|
v1.2.3 (Nov ??, 2007) |
106 |
|
c: A few more small optimizations. |
107 |
|
f: Fixed bad message disconnect error when players get choked. ( stupid SVC_DAMAGE define ) |
108 |
|
|
109 |
|
v1.2.2 (Nov 16, 2007) |
110 |
|
c: A few small code optimizations. |
111 |
|
|
112 |
|
v1.2.1 (Nov 12, 2007) |
113 |
|
f: Eliminated two run time warnings in the player prethink function. |
114 |
|
|
115 |
v1.2 (Nov 06, 2007) |
v1.2 (Nov 06, 2007) |
116 |
+: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
+: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
117 |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
133 |
#include <amxmisc> |
#include <amxmisc> |
134 |
#include <fakemeta> |
#include <fakemeta> |
135 |
|
|
136 |
#define VERSION "1.2" |
new const VERSION[ ] = "1.2.3RC" |
137 |
|
new const TRKCVAR[ ] = "grab_plus_version" |
138 |
#define ADMIN ADMIN_LEVEL_A |
#define ADMIN ADMIN_LEVEL_A |
139 |
|
|
140 |
#define TSK_CHKE 50 |
#define TSK_CHKE 50 |
141 |
|
|
|
#define SVC_DAMAGE 19 |
|
142 |
#define SF_FADEOUT 0 |
#define SF_FADEOUT 0 |
143 |
|
|
144 |
new client_data[33][4] |
new client_data[33][4] |
160 |
|
|
161 |
//Pseudo Constants |
//Pseudo Constants |
162 |
new MAXPLAYERS |
new MAXPLAYERS |
163 |
new SVC_SCREENFADE, SVC_SCREENSHAKE |
new SVC_SCREENFADE, SVC_SCREENSHAKE, WTF_DAMAGE |
164 |
|
|
165 |
public plugin_init( ) |
public plugin_init( ) |
166 |
{ |
{ |
167 |
register_plugin( "Grab+", VERSION, "Ian Cammarata" ) |
register_plugin( "Grab+", VERSION, "Ian Cammarata" ) |
168 |
register_cvar( "grab_plus_version", VERSION, FCVAR_SERVER ) |
register_cvar( TRKCVAR, VERSION, FCVAR_SERVER ) |
169 |
set_cvar_string( "grab_plus_version", VERSION ) |
set_cvar_string( TRKCVAR, VERSION ) |
170 |
|
|
171 |
p_enabled = register_cvar( "gp_enabled", "1" ) |
p_enabled = register_cvar( "gp_enabled", "1" ) |
172 |
p_players_only = register_cvar( "gp_players_only", "0" ) |
p_players_only = register_cvar( "gp_players_only", "0" ) |
212 |
|
|
213 |
SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) |
SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) |
214 |
SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) |
SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) |
215 |
|
WTF_DAMAGE = get_user_msgid( "Damage" ) |
|
return PLUGIN_CONTINUE |
|
216 |
} |
} |
217 |
|
|
218 |
public plugin_precache( ) |
public plugin_precache( ) |
219 |
{ |
{ |
220 |
precache_sound( "player/PL_PAIN2.WAV" ) |
precache_sound( "player/PL_PAIN2.WAV" ) |
|
return PLUGIN_CONTINUE |
|
221 |
} |
} |
222 |
|
|
223 |
public fm_player_prethink( id ) |
public fm_player_prethink( id ) |
224 |
{ |
{ |
225 |
|
new target |
226 |
//Search for a target |
//Search for a target |
227 |
if ( client_data[id][GRABBED] == -1 ) |
if ( client_data[id][GRABBED] == -1 ) |
228 |
{ |
{ |
230 |
get_view_pos( id, orig ) |
get_view_pos( id, orig ) |
231 |
ret = vel_by_aim( id, 9999 ) |
ret = vel_by_aim( id, 9999 ) |
232 |
|
|
233 |
for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ret[i] |
ret[0] += orig[0] |
234 |
new target = traceline( orig, ret, id, ret ) |
ret[1] += orig[1] |
235 |
|
ret[2] += orig[2] |
236 |
|
|
237 |
|
target = traceline( orig, ret, id, ret ) |
238 |
|
|
239 |
if( 0 < target <= MAXPLAYERS ) |
if( 0 < target <= MAXPLAYERS ) |
240 |
{ |
{ |
241 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return FMRES_IGNORED |
242 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
243 |
} |
} |
244 |
else if( !get_pcvar_num( p_players_only ) ) |
else if( !get_pcvar_num( p_players_only ) ) |
245 |
{ |
{ |
246 |
new movetype |
new movetype |
247 |
if( target ) |
if( target && pev_valid( target ) ) |
248 |
{ |
{ |
249 |
movetype = pev( target, pev_movetype ) |
movetype = pev( target, pev_movetype ) |
250 |
if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) |
if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) |
251 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
252 |
} |
} |
253 |
else |
else |
254 |
{ |
{ |
255 |
|
target = 0 |
256 |
new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
257 |
while( !target && ent > 0 ) |
while( !target && ent > 0 ) |
258 |
{ |
{ |
265 |
} |
} |
266 |
if( target ) |
if( target ) |
267 |
{ |
{ |
268 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return FMRES_IGNORED |
269 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
270 |
} |
} |
271 |
} |
} |
272 |
} |
} |
273 |
|
|
274 |
|
target = client_data[id][GRABBED] |
275 |
//If they've grabbed something |
//If they've grabbed something |
276 |
if( client_data[id][GRABBED] > 0 ) |
if( target > 0 ) |
277 |
{ |
{ |
|
new target = client_data[id][GRABBED] |
|
278 |
if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) ) |
if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) ) |
279 |
{ |
{ |
280 |
unset_grabbed( id ) |
unset_grabbed( id ) |
281 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
282 |
} |
} |
283 |
|
|
284 |
//Use key choke |
//Use key choke |
286 |
do_choke( id ) |
do_choke( id ) |
287 |
|
|
288 |
//Push and pull |
//Push and pull |
289 |
if ( client_data[id][FLAGS] & CDF_IN_PULL ) |
new cdf = client_data[id][FLAGS] |
290 |
|
if ( cdf & CDF_IN_PULL ) |
291 |
do_pull( id ) |
do_pull( id ) |
292 |
else if ( client_data[id][FLAGS] & CDF_IN_PUSH ) |
else if ( cdf & CDF_IN_PUSH ) |
293 |
do_push( id ) |
do_push( id ) |
294 |
|
|
295 |
grab_think( id ) |
if( target > MAXPLAYERS ) grab_think( id ) |
296 |
} |
} |
|
if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] ) |
|
297 |
|
|
298 |
return PLUGIN_CONTINUE |
//If they're grabbed |
299 |
|
target = client_data[id][GRABBER] |
300 |
|
if( target > 0 ) grab_think( target ) |
301 |
|
|
302 |
|
return FMRES_IGNORED |
303 |
} |
} |
304 |
|
|
305 |
public grab_think ( id ) |
public grab_think( id ) //id of the grabber |
306 |
{ |
{ |
307 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
308 |
|
|
320 |
|
|
321 |
new force = get_pcvar_num( p_grab_force ) |
new force = get_pcvar_num( p_grab_force ) |
322 |
|
|
323 |
for( new i = 0; i < 3; i++ ) |
tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force |
324 |
tvel[i] = ( ( tmpvec[i] + tmpvec2[i] ) - torig[i] ) * force |
tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force |
325 |
|
tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force |
326 |
|
|
327 |
set_pev( target, pev_velocity, tvel ) |
set_pev( target, pev_velocity, tvel ) |
328 |
} |
} |
501 |
public do_choke( id ) |
public do_choke( id ) |
502 |
{ |
{ |
503 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
504 |
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 |
505 |
|
|
506 |
new dmg = get_pcvar_num( p_choke_dmg ) |
new dmg = get_pcvar_num( p_choke_dmg ) |
507 |
new Float:vec[3] |
new Float:vec[3] |
523 |
write_byte( 200 ) //a |
write_byte( 200 ) //a |
524 |
message_end( ) |
message_end( ) |
525 |
|
|
526 |
message_begin( MSG_ONE, SVC_DAMAGE, _, target ) |
message_begin( MSG_ONE, WTF_DAMAGE, _, target ) |
527 |
write_byte( 0 ) //damage armor |
write_byte( 0 ) //damage armor |
528 |
write_byte( dmg ) //damage health |
write_byte( dmg ) //damage health |
529 |
write_long( DMG_CRUSH ) //damage type |
write_long( DMG_CRUSH ) //damage type |
586 |
|
|
587 |
for( new j = 1; j < 11 && !safe; j++ ) |
for( new j = 1; j < 11 && !safe; j++ ) |
588 |
{ |
{ |
589 |
for( i = 0; i < 3; i++ ) torig[i] = orig[i] + tmpvec[i] * j |
torig[0] = orig[0] + tmpvec[i] * j |
590 |
|
torig[1] = orig[1] + tmpvec[i] * j |
591 |
|
torig[2] = orig[2] + tmpvec[i] * j |
592 |
|
|
593 |
traceline( tmpvec, torig, id, trace_ret ) |
traceline( tmpvec, torig, id, trace_ret ) |
594 |
|
|
595 |
if( get_distance_f( trace_ret, torig ) ) break |
if( get_distance_f( trace_ret, torig ) ) break |
682 |
|
|
683 |
stock get_view_pos( const id, Float:vViewPos[3] ) |
stock get_view_pos( const id, Float:vViewPos[3] ) |
684 |
{ |
{ |
685 |
new Float:ofs[3] |
new Float:vOfs[3] |
686 |
pev( id, pev_origin, vViewPos ) |
pev( id, pev_origin, vViewPos ) |
687 |
pev( id, pev_view_ofs, ofs ) |
pev( id, pev_view_ofs, vOfs ) |
688 |
for( new i = 0; i < 3; i++ ) vViewPos[i] += ofs[i] |
|
689 |
|
vViewPos[0] += vOfs[0] |
690 |
|
vViewPos[1] += vOfs[1] |
691 |
|
vViewPos[2] += vOfs[2] |
692 |
} |
} |
693 |
|
|
694 |
stock Float:vel_by_aim( id, speed = 1 ) |
stock Float:vel_by_aim( id, speed = 1 ) |
696 |
new Float:v1[3], Float:vBlah[3] |
new Float:v1[3], Float:vBlah[3] |
697 |
pev( id, pev_v_angle, v1 ) |
pev( id, pev_v_angle, v1 ) |
698 |
engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah ) |
engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah ) |
699 |
for( new i = 0; i < 3; i++ ) v1[i] *= speed |
|
700 |
|
v1[0] *= speed |
701 |
|
v1[1] *= speed |
702 |
|
v1[2] *= speed |
703 |
|
|
704 |
return v1 |
return v1 |
705 |
} |
} |