1 |
/* |
/* |
2 |
Grab+ v1.2 |
Grab+ v1.2.4 |
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 01 04:16 |
Nov 21 11:03 |
21 |
|
|
22 |
|
|
23 |
Description: |
Description: |
24 |
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. |
25 |
|
|
26 |
|
|
|
See it in Action: |
|
|
http://www.game-monitor.com/search.php?search=grab_plus_version&type=variable&game=all&location=all |
|
|
|
|
|
|
|
27 |
Features: |
Features: |
28 |
Multilingual |
Multilingual |
29 |
Screenfade to indicate grab activity instead of chat spam. |
Screenfade to indicate grab activity instead of chat spam. |
44 |
|
|
45 |
+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. |
46 |
|
|
47 |
+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) |
48 |
drop - Throws the grabbed with 1500 velocity. (cvar: gp_throwforce) |
drop - Throws the grabbed with 1500 velocity. (cvar: gp_throw_force) |
49 |
|
|
50 |
|
|
51 |
Cvars (First value is default): |
Cvars (First value is default): |
52 |
gp_enabled <1|0> Enables all plugin functionality. |
gp_enabled <1|0> Enables all plugin functionality. |
53 |
gp_playersonly <0|1> Disables admins grabbing entities other than players. |
gp_players_only <0|1> Disables admins grabbing entities other than players. |
54 |
|
|
55 |
gp_min_dist <90|...> Min distance between the grabber and grabbed. |
gp_min_dist <90|...> Min distance between the grabber and grabbed. |
56 |
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. |
57 |
gp_throwforce <1500|...> Sets the power used when throwing players. |
gp_throw_force <1500|...> Sets the power used when throwing players. |
58 |
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. |
59 |
|
|
60 |
gp_choketime <1.5|...> Time frequency for choking. |
gp_choke_time <1.5|...> Time frequency for choking. |
61 |
gp_chokedmg <5|...> Amount of damage done with each choke. |
gp_choke_dmg <5|...> Amount of damage done with each choke. |
62 |
|
gp_auto_choke <1|0> Enable/disable choking automatically with +pull command. |
63 |
|
|
64 |
gp_screenfade <1|0> Enables/disables screenfade when grabbing. |
gp_screen_fade <1|0> Enables/disables screenfade when grabbing. |
65 |
gp_glow <1|0> Enables/disables glowing for grabbed objects. |
gp_glow <1|0> Enables/disables glowing for grabbed objects. |
66 |
|
|
67 |
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. |
95 |
French (100%) - Thanks to connorr |
French (100%) - Thanks to connorr |
96 |
German (100%) - Thanks to SchlumPF* |
German (100%) - Thanks to SchlumPF* |
97 |
Russian (100%) - Thanks to `666 |
Russian (100%) - Thanks to `666 |
98 |
Spanish (100%) - Hope these don't suck. |
Spanish (100%) - Thanks to RenXO |
99 |
Swedish (100%) - Thanks to Bend3r |
Swedish (100%) - Thanks to Bend3r |
100 |
|
|
101 |
|
|
102 |
Change Log: |
Change Log: |
103 |
Key (+ added | - removed | c changed | f fixed) |
Key (+ added | - removed | c changed | f fixed) |
104 |
|
|
105 |
v1.2 (Nov ??, 2007) |
v1.2.4 (Feb 18, 2007) |
106 |
+: Cvars gp_screenfade and gp_glow to enable/disable these features. |
f: Killing player with choke in some mods bugged out really bad. |
107 |
|
|
108 |
|
v1.2.3 (Nov 21, 2007) |
109 |
|
c: A few more small optimizations. |
110 |
|
f: Bloodstream for choke wasn't aligned with player. |
111 |
|
f: Bad message disconnect error when players were choked. ( stupid SVC_DAMAGE define ) |
112 |
|
|
113 |
|
v1.2.2 (Nov 16, 2007) |
114 |
|
c: A few small code optimizations. |
115 |
|
|
116 |
|
v1.2.1 (Nov 12, 2007) |
117 |
|
f: Eliminated two run time warnings in the player prethink function. |
118 |
|
|
119 |
|
v1.2 (Nov 06, 2007) |
120 |
|
+: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
121 |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
122 |
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. |
123 |
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. |
124 |
|
c: Made cvar names more consistent by adding more underscores. |
125 |
|
f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well). |
126 |
|
|
127 |
v1.1 (Oct 16, 2007) |
v1.1 (Oct 16, 2007) |
128 |
+: Grab a few types of entities other than players. |
+: Grab a few types of entities other than players. |
129 |
+: Cvar gp_playersonly. |
+: Cvar gp_players_only. |
130 |
|
|
131 |
v1.0 (Oct 13, 2007) |
v1.0 (Oct 13, 2007) |
132 |
!: Initial release |
!: Initial release |
137 |
#include <amxmisc> |
#include <amxmisc> |
138 |
#include <fakemeta> |
#include <fakemeta> |
139 |
|
|
140 |
#define VERSION "1.2b5" |
new const VERSION[ ] = "1.2.4b1" |
141 |
|
new const TRKCVAR[ ] = "grab_plus_version" |
142 |
#define ADMIN ADMIN_LEVEL_A |
#define ADMIN ADMIN_LEVEL_A |
143 |
|
|
144 |
#define TSK_CHKE 50 |
#define TSK_CHKE 50 |
145 |
|
|
|
#define SVC_DAMAGE 19 |
|
146 |
#define SF_FADEOUT 0 |
#define SF_FADEOUT 0 |
147 |
|
|
148 |
new client_data[33][4] |
new client_data[33][4] |
156 |
#define CDF_NO_CHOKE (1<<2) |
#define CDF_NO_CHOKE (1<<2) |
157 |
|
|
158 |
//Cvar Pointers |
//Cvar Pointers |
159 |
new p_enabled, p_playersonly |
new p_enabled, p_players_only |
160 |
new p_throwforce, p_mindist, p_speed, p_grabforce |
new p_throw_force, p_min_dist, p_speed, p_grab_force |
161 |
new p_choketime, p_chokedmg |
new p_choke_time, p_choke_dmg, p_auto_choke |
162 |
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 |
163 |
new p_fade, p_glow |
new p_fade, p_glow |
164 |
|
|
165 |
//Pseudo Constants |
//Pseudo Constants |
166 |
new MAXPLAYERS |
new MAXPLAYERS |
167 |
new SVC_SCREENFADE, SVC_SCREENSHAKE |
new SVC_SCREENFADE, SVC_SCREENSHAKE, WTF_DAMAGE |
168 |
|
|
169 |
public plugin_init( ) |
public plugin_init( ) |
170 |
{ |
{ |
171 |
register_plugin( "Grab+", VERSION, "Ian Cammarata" ) |
register_plugin( "Grab+", VERSION, "Ian Cammarata" ) |
172 |
register_cvar( "grab_plus_version", VERSION, FCVAR_SERVER ) |
register_cvar( TRKCVAR, VERSION, FCVAR_SERVER ) |
173 |
set_cvar_string( "grab_plus_version", VERSION ) |
set_cvar_string( TRKCVAR, VERSION ) |
174 |
|
|
175 |
p_enabled = register_cvar( "gp_enabled", "1" ) |
p_enabled = register_cvar( "gp_enabled", "1" ) |
176 |
p_playersonly = register_cvar( "gp_playersonly", "0" ) |
p_players_only = register_cvar( "gp_players_only", "0" ) |
177 |
|
|
178 |
p_mindist = register_cvar ( "gp_min_dist", "90" ) |
p_min_dist = register_cvar ( "gp_min_dist", "90" ) |
179 |
p_throwforce = register_cvar( "gp_throwforce", "1500" ) |
p_throw_force = register_cvar( "gp_throw_force", "1500" ) |
180 |
p_grabforce = register_cvar( "gp_grabforce", "8" ) |
p_grab_force = register_cvar( "gp_grab_force", "8" ) |
181 |
p_speed = register_cvar( "gp_speed", "5" ) |
p_speed = register_cvar( "gp_speed", "5" ) |
182 |
|
|
183 |
p_choketime = register_cvar( "gp_choketime", "1.5" ) |
p_choke_time = register_cvar( "gp_choke_time", "1.5" ) |
184 |
p_chokedmg = register_cvar( "gp_chokedmg", "5" ) |
p_choke_dmg = register_cvar( "gp_choke_dmg", "5" ) |
185 |
|
p_auto_choke = register_cvar( "gp_auto_choke", "1" ) |
186 |
|
|
187 |
p_glow_r = register_cvar( "gp_glow_r", "50" ) |
p_glow_r = register_cvar( "gp_glow_r", "50" ) |
188 |
p_glow_g = register_cvar( "gp_glow_g", "0" ) |
p_glow_g = register_cvar( "gp_glow_g", "0" ) |
189 |
p_glow_b = register_cvar( "gp_glow_b", "0" ) |
p_glow_b = register_cvar( "gp_glow_b", "0" ) |
190 |
p_glow_a = register_cvar( "gp_glow_a", "200" ) |
p_glow_a = register_cvar( "gp_glow_a", "200" ) |
191 |
|
|
192 |
p_fade = register_cvar( "gp_screenfade", "1" ) |
p_fade = register_cvar( "gp_screen_fade", "1" ) |
193 |
p_glow = register_cvar( "gp_glow", "1" ) |
p_glow = register_cvar( "gp_glow", "1" ) |
194 |
|
|
195 |
register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
216 |
|
|
217 |
SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) |
SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) |
218 |
SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) |
SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) |
219 |
|
WTF_DAMAGE = get_user_msgid( "Damage" ) |
|
return PLUGIN_CONTINUE |
|
220 |
} |
} |
221 |
|
|
222 |
public plugin_precache( ) |
public plugin_precache( ) |
223 |
{ |
{ |
224 |
precache_sound( "player/PL_PAIN2.WAV" ) |
precache_sound( "player/PL_PAIN2.WAV" ) |
|
return PLUGIN_CONTINUE |
|
225 |
} |
} |
226 |
|
|
227 |
public fm_player_prethink( id ) |
public fm_player_prethink( id ) |
228 |
{ |
{ |
229 |
|
new target |
230 |
//Search for a target |
//Search for a target |
231 |
if ( client_data[id][GRABBED] == -1 ) |
if ( client_data[id][GRABBED] == -1 ) |
232 |
{ |
{ |
233 |
new Float:orig[3], Float:ret[3] |
new Float:orig[3], Float:ret[3] |
234 |
pev( id, pev_origin, orig ) |
get_view_pos( id, orig ) |
235 |
pev( id, pev_view_ofs, ret ) |
ret = vel_by_aim( id, 9999 ) |
236 |
|
|
237 |
|
ret[0] += orig[0] |
238 |
|
ret[1] += orig[1] |
239 |
|
ret[2] += orig[2] |
240 |
|
|
241 |
for( new i = 0; i < 3; i++ ) orig[i] += ret[i] |
target = traceline( orig, ret, id, ret ) |
|
velocity_by_aim( id, 1, 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 ) |
|
242 |
|
|
243 |
if( 0 < target <= MAXPLAYERS ) |
if( 0 < target <= MAXPLAYERS ) |
244 |
{ |
{ |
245 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return FMRES_IGNORED |
246 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
247 |
} |
} |
248 |
else if( !get_pcvar_num( p_playersonly ) ) |
else if( !get_pcvar_num( p_players_only ) ) |
249 |
{ |
{ |
250 |
new movetype |
new movetype |
251 |
if( target ) |
if( target && pev_valid( target ) ) |
252 |
{ |
{ |
253 |
movetype = pev( target, pev_movetype ) |
movetype = pev( target, pev_movetype ) |
254 |
if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) |
if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) |
255 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
256 |
} |
} |
257 |
else |
else |
258 |
{ |
{ |
259 |
|
target = 0 |
260 |
new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
261 |
while( !target && ent > 0 ) |
while( !target && ent > 0 ) |
262 |
{ |
{ |
269 |
} |
} |
270 |
if( target ) |
if( target ) |
271 |
{ |
{ |
272 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return FMRES_IGNORED |
273 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
274 |
} |
} |
275 |
} |
} |
276 |
} |
} |
277 |
|
|
278 |
|
target = client_data[id][GRABBED] |
279 |
//If they've grabbed something |
//If they've grabbed something |
280 |
if( client_data[id][GRABBED] > 0 ) |
if( target > 0 ) |
281 |
{ |
{ |
|
new target = client_data[id][GRABBED] |
|
282 |
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 ) ) ) |
283 |
{ |
{ |
284 |
unset_grabbed( id ) |
unset_grabbed( id ) |
285 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
286 |
} |
} |
287 |
|
|
288 |
//Use key choke |
//Use key choke |
290 |
do_choke( id ) |
do_choke( id ) |
291 |
|
|
292 |
//Push and pull |
//Push and pull |
293 |
if ( client_data[id][FLAGS] & CDF_IN_PULL ) |
new cdf = client_data[id][FLAGS] |
294 |
|
if ( cdf & CDF_IN_PULL ) |
295 |
do_pull( id ) |
do_pull( id ) |
296 |
else if ( client_data[id][FLAGS] & CDF_IN_PUSH ) |
else if ( cdf & CDF_IN_PUSH ) |
297 |
do_push( id ) |
do_push( id ) |
298 |
|
|
299 |
grab_think( id ) |
if( target > MAXPLAYERS ) grab_think( id ) |
300 |
} |
} |
|
if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] ) |
|
301 |
|
|
302 |
return PLUGIN_CONTINUE |
//If they're grabbed |
303 |
|
target = client_data[id][GRABBER] |
304 |
|
if( target > 0 ) grab_think( target ) |
305 |
|
|
306 |
|
return FMRES_IGNORED |
307 |
} |
} |
308 |
|
|
309 |
public grab_think ( id ) |
public grab_think( id ) //id of the grabber |
310 |
{ |
{ |
311 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
312 |
|
|
314 |
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" ) |
315 |
|
|
316 |
//Move targeted client |
//Move targeted client |
317 |
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] |
318 |
new len = client_data[id][GRAB_LEN] |
|
319 |
|
get_view_pos( id, tmpvec ) |
320 |
|
|
321 |
|
tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] ) |
322 |
|
|
|
pev( id, pev_origin, dest ) |
|
|
pev( id, pev_view_ofs, tmpvec ) |
|
|
velocity_by_aim( id, len, tmpvec2 ) |
|
323 |
torig = get_target_origin_f( target ) |
torig = get_target_origin_f( target ) |
324 |
|
|
325 |
new force = get_pcvar_num( p_grabforce ) |
new force = get_pcvar_num( p_grab_force ) |
326 |
|
|
327 |
for( new i = 0; i < 3; i++ ) |
tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force |
328 |
{ |
tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force |
329 |
dest[i] += tmpvec[i] + tmpvec2[i] |
tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force |
|
tvel[i] = ( dest[i] - torig[i] ) * force |
|
|
} |
|
330 |
|
|
331 |
set_pev( target, pev_velocity, tvel ) |
set_pev( target, pev_velocity, tvel ) |
332 |
} |
} |
388 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
389 |
if( target > 0 ) |
if( target > 0 ) |
390 |
{ |
{ |
391 |
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 ) |
|
392 |
unset_grabbed( id ) |
unset_grabbed( id ) |
393 |
return PLUGIN_HANDLED |
return PLUGIN_HANDLED |
394 |
} |
} |
395 |
|
|
396 |
return PLUGIN_CONTINUE |
return PLUGIN_CONTINUE |
397 |
} |
} |
398 |
|
|
448 |
pev( target, pev_origin, torig ) |
pev( target, pev_origin, torig ) |
449 |
pev( id, pev_origin, orig ) |
pev( id, pev_origin, orig ) |
450 |
client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) |
client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) |
451 |
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 ) |
452 |
} |
} |
453 |
|
|
454 |
public push( id ) |
public push( id ) |
489 |
|
|
490 |
public do_pull( id ) |
public do_pull( id ) |
491 |
{ |
{ |
492 |
new mindist = get_pcvar_num( p_mindist ) |
new mindist = get_pcvar_num( p_min_dist ) |
493 |
new len = client_data[id][GRAB_LEN] |
new len = client_data[id][GRAB_LEN] |
494 |
|
|
495 |
if( len > mindist ) |
if( len > mindist ) |
498 |
if( len < mindist ) len = mindist |
if( len < mindist ) len = mindist |
499 |
client_data[id][GRAB_LEN] = len |
client_data[id][GRAB_LEN] = len |
500 |
} |
} |
501 |
else do_choke( id ) |
else if( get_pcvar_num( p_auto_choke ) ) |
502 |
|
do_choke( id ) |
503 |
} |
} |
504 |
|
|
505 |
public do_choke( id ) |
public do_choke( id ) |
507 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
508 |
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 |
509 |
|
|
510 |
new dmg = get_pcvar_num( p_chokedmg ) |
new dmg = get_pcvar_num( p_choke_dmg ) |
511 |
new Float:vec[3] |
new vec[3] |
512 |
get_target_origin_f( target ) |
FVecIVec( get_target_origin_f( target ), vec ) |
513 |
|
|
514 |
message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target ) |
message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target ) |
515 |
write_short( 999999 ) //amount |
write_short( 999999 ) //amount |
527 |
write_byte( 200 ) //a |
write_byte( 200 ) //a |
528 |
message_end( ) |
message_end( ) |
529 |
|
|
530 |
message_begin( MSG_ONE, SVC_DAMAGE, _, target ) |
message_begin( MSG_ONE, WTF_DAMAGE, _, target ) |
531 |
write_byte( 0 ) //damage armor |
write_byte( 0 ) //damage armor |
532 |
write_byte( dmg ) //damage health |
write_byte( dmg ) //damage health |
533 |
write_long( DMG_CRUSH ) //damage type |
write_long( DMG_CRUSH ) //damage type |
534 |
write_coord( floatround( vec[0] ) ) //origin[x] |
write_coord( vec[0] ) //origin[x] |
535 |
write_coord( floatround( vec[1] ) ) //origin[y] |
write_coord( vec[1] ) //origin[y] |
536 |
write_coord( floatround( vec[2] ) ) //origin[z] |
write_coord( vec[2] ) //origin[z] |
537 |
message_end( ) |
message_end( ) |
538 |
|
|
539 |
message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) |
message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) |
540 |
write_byte( TE_BLOODSTREAM ) |
write_byte( TE_BLOODSTREAM ) |
541 |
write_coord( floatround( vec[0] ) ) //pos.x |
write_coord( vec[0] ) //pos.x |
542 |
write_coord( floatround( vec[1] ) ) //pos.y |
write_coord( vec[1] ) //pos.y |
543 |
write_coord( floatround( vec[2] ) + 15 ) //pos.z |
write_coord( vec[2] + 15 ) //pos.z |
544 |
write_coord( random_num( 0, 255 ) ) //vec.x |
write_coord( random_num( 0, 255 ) ) //vec.x |
545 |
write_coord( random_num( 0, 255 ) ) //vec.y |
write_coord( random_num( 0, 255 ) ) //vec.y |
546 |
write_coord( random_num( 0, 255 ) ) //vec.z |
write_coord( random_num( 0, 255 ) ) //vec.z |
549 |
message_end( ) |
message_end( ) |
550 |
|
|
551 |
new health = pev( target, pev_health ) - dmg |
new health = pev( target, pev_health ) - dmg |
|
set_pev( target, pev_health, float( health ) ) |
|
552 |
if( health < 1 ) dllfunc( DLLFunc_ClientKill, target ) |
if( health < 1 ) dllfunc( DLLFunc_ClientKill, target ) |
553 |
|
else { |
554 |
|
set_pev( target, pev_health, float( health ) ) |
555 |
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 ) |
556 |
|
} |
557 |
|
|
558 |
client_data[id][FLAGS] ^= CDF_NO_CHOKE |
client_data[id][FLAGS] ^= CDF_NO_CHOKE |
559 |
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 ) |
560 |
} |
} |
561 |
|
|
562 |
public clear_no_choke( tskid ) |
public clear_no_choke( tskid ) |
583 |
} |
} |
584 |
|
|
585 |
//Safe to tp target to aim spot? |
//Safe to tp target to aim spot? |
586 |
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] |
587 |
new bool:safe = false, i |
new bool:safe = false, i |
588 |
|
|
589 |
pev( id, pev_origin, orig ) |
get_view_pos( id, orig ) |
590 |
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 ) |
|
591 |
|
|
592 |
for( new j = 1; j < 11 && !safe; j++ ) |
for( new j = 1; j < 11 && !safe; j++ ) |
593 |
{ |
{ |
594 |
for( i = 0; i < 3; i++ ) |
torig[0] = orig[0] + tmpvec[i] * j |
595 |
torig[i] = tmpvec[i] + tmpvec2[i] * j |
torig[1] = orig[1] + tmpvec[i] * j |
596 |
|
torig[2] = orig[2] + tmpvec[i] * j |
597 |
|
|
598 |
engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 ) |
traceline( tmpvec, torig, id, trace_ret ) |
|
get_tr2( 0, TR_vecEndPos, trace_ret ) |
|
599 |
|
|
600 |
if( get_distance_f( trace_ret, torig ) ) break |
if( get_distance_f( trace_ret, torig ) ) break |
601 |
|
|
605 |
} |
} |
606 |
|
|
607 |
//Still not safe? Then find another safe spot somewhere around the grabber |
//Still not safe? Then find another safe spot somewhere around the grabber |
608 |
|
pev( id, pev_origin, orig ) |
609 |
new try[3] |
new try[3] |
610 |
orig[2] += 2 |
orig[2] += 2 |
611 |
while( try[2] < 3 && !safe ) |
while( try[2] < 3 && !safe ) |
618 |
case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) |
case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) |
619 |
} |
} |
620 |
|
|
621 |
engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 ) |
traceline( tmpvec, torig, id, trace_ret ) |
|
get_tr2( 0, TR_vecEndPos, trace_ret ) |
|
622 |
|
|
623 |
engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) |
engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) |
624 |
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 ) |
677 |
else if( client_data[id][GRABBER] ) |
else if( client_data[id][GRABBER] ) |
678 |
unset_grabbed( client_data[id][GRABBER] ) |
unset_grabbed( client_data[id][GRABBER] ) |
679 |
} |
} |
680 |
|
|
681 |
|
stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] ) |
682 |
|
{ |
683 |
|
engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 ) |
684 |
|
get_tr2( 0, TR_vecEndPos, vHitPos ) |
685 |
|
return get_tr2( 0, TR_pHit ) |
686 |
|
} |
687 |
|
|
688 |
|
stock get_view_pos( const id, Float:vViewPos[3] ) |
689 |
|
{ |
690 |
|
new Float:vOfs[3] |
691 |
|
pev( id, pev_origin, vViewPos ) |
692 |
|
pev( id, pev_view_ofs, vOfs ) |
693 |
|
|
694 |
|
vViewPos[0] += vOfs[0] |
695 |
|
vViewPos[1] += vOfs[1] |
696 |
|
vViewPos[2] += vOfs[2] |
697 |
|
} |
698 |
|
|
699 |
|
stock Float:vel_by_aim( id, speed = 1 ) |
700 |
|
{ |
701 |
|
new Float:v1[3], Float:vBlah[3] |
702 |
|
pev( id, pev_v_angle, v1 ) |
703 |
|
engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah ) |
704 |
|
|
705 |
|
v1[0] *= speed |
706 |
|
v1[1] *= speed |
707 |
|
v1[2] *= speed |
708 |
|
|
709 |
|
return v1 |
710 |
|
} |