1 |
/* |
/* |
2 |
Grab+ v1.1 |
Grab+ v1.2.2 |
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 |
Oct 16 21:03 |
Nov 16 08:08 |
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 |
gp_glow_r <50|0-255> Sets red amount for glow. |
|
64 |
gp_glow_g <0|0-255> Sets green amount for glow. |
gp_screen_fade <1|0> Enables/disables screenfade when grabbing. |
65 |
gp_glow_b <0|0-255> Sets blue amount for glow. |
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. |
68 |
|
gp_glow_g <0|0-255> Sets green amount for glow and screenfade. |
69 |
|
gp_glow_b <0|0-255> Sets blue amount for glow and screenfade. |
70 |
|
gp_glow_a <0|0-255> Sets alpha for glow and screenfade. |
71 |
|
|
72 |
|
|
73 |
Notes: |
Notes: |
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.2 (Nov 16, 2007) |
106 |
+: Cvars gp_screenfade and gp_glow to enable/disable these features. |
c: A few small code optimizations. |
107 |
|
|
108 |
|
v1.2.1 (Nov 12, 2007) |
109 |
|
f: Eliminated two run time warnings in the player prethink function. |
110 |
|
|
111 |
|
v1.2 (Nov 06, 2007) |
112 |
|
+: Cvars gp_screen_fade and gp_glow to enable/disable these features. |
113 |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
+: Cvar gp_glow_a controls to control alpha of screenfade and glow. |
114 |
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. |
115 |
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. |
116 |
|
c: Made cvar names more consistent by adding more underscores. |
117 |
|
f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well). |
118 |
|
|
119 |
v1.1 (Oct 16, 2007) |
v1.1 (Oct 16, 2007) |
120 |
+: Grab a few types of entities other than players. |
+: Grab a few types of entities other than players. |
121 |
+: Cvar gp_playersonly. |
+: Cvar gp_players_only. |
122 |
|
|
123 |
v1.0 (Oct 13, 2007) |
v1.0 (Oct 13, 2007) |
124 |
!: Initial release |
!: Initial release |
129 |
#include <amxmisc> |
#include <amxmisc> |
130 |
#include <fakemeta> |
#include <fakemeta> |
131 |
|
|
132 |
#define VERSION "1.2b2" |
#define VERSION "1.2.2" |
133 |
#define ADMIN ADMIN_LEVEL_A |
#define ADMIN ADMIN_LEVEL_A |
134 |
|
|
135 |
#define TSK_CHKE 50 |
#define TSK_CHKE 50 |
148 |
#define CDF_NO_CHOKE (1<<2) |
#define CDF_NO_CHOKE (1<<2) |
149 |
|
|
150 |
//Cvar Pointers |
//Cvar Pointers |
151 |
new p_enabled, p_playersonly |
new p_enabled, p_players_only |
152 |
new p_throwforce, p_mindist, p_speed, p_grabforce |
new p_throw_force, p_min_dist, p_speed, p_grab_force |
153 |
new p_choketime, p_chokedmg |
new p_choke_time, p_choke_dmg, p_auto_choke |
154 |
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 |
155 |
new p_fade, p_glow |
new p_fade, p_glow |
156 |
|
|
165 |
set_cvar_string( "grab_plus_version", VERSION ) |
set_cvar_string( "grab_plus_version", VERSION ) |
166 |
|
|
167 |
p_enabled = register_cvar( "gp_enabled", "1" ) |
p_enabled = register_cvar( "gp_enabled", "1" ) |
168 |
p_playersonly = register_cvar( "gp_playersonly", "0" ) |
p_players_only = register_cvar( "gp_players_only", "0" ) |
169 |
|
|
170 |
p_mindist = register_cvar ( "gp_min_dist", "90" ) |
p_min_dist = register_cvar ( "gp_min_dist", "90" ) |
171 |
p_throwforce = register_cvar( "gp_throwforce", "1500" ) |
p_throw_force = register_cvar( "gp_throw_force", "1500" ) |
172 |
p_grabforce = register_cvar( "gp_grabforce", "8" ) |
p_grab_force = register_cvar( "gp_grab_force", "8" ) |
173 |
p_speed = register_cvar( "gp_speed", "5" ) |
p_speed = register_cvar( "gp_speed", "5" ) |
174 |
|
|
175 |
p_choketime = register_cvar( "gp_choketime", "1.5" ) |
p_choke_time = register_cvar( "gp_choke_time", "1.5" ) |
176 |
p_chokedmg = register_cvar( "gp_chokedmg", "5" ) |
p_choke_dmg = register_cvar( "gp_choke_dmg", "5" ) |
177 |
|
p_auto_choke = register_cvar( "gp_auto_choke", "1" ) |
178 |
|
|
179 |
p_glow_r = register_cvar( "gp_glow_r", "50" ) |
p_glow_r = register_cvar( "gp_glow_r", "50" ) |
180 |
p_glow_g = register_cvar( "gp_glow_g", "0" ) |
p_glow_g = register_cvar( "gp_glow_g", "0" ) |
181 |
p_glow_b = register_cvar( "gp_glow_b", "0" ) |
p_glow_b = register_cvar( "gp_glow_b", "0" ) |
182 |
p_glow_a = register_cvar( "gp_glow_a", "200" ) |
p_glow_a = register_cvar( "gp_glow_a", "200" ) |
183 |
|
|
184 |
p_fade = register_cvar( "gp_screenfade", "1" ) |
p_fade = register_cvar( "gp_screen_fade", "1" ) |
185 |
p_glow = register_cvar( "gp_glow", "1" ) |
p_glow = register_cvar( "gp_glow", "1" ) |
186 |
|
|
187 |
register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." ) |
200 |
|
|
201 |
register_event( "DeathMsg", "DeathMsg", "a" ) |
register_event( "DeathMsg", "DeathMsg", "a" ) |
202 |
|
|
203 |
|
register_forward( FM_PlayerPreThink, "fm_player_prethink" ) |
204 |
|
|
205 |
register_dictionary( "grab_plus.txt" ) |
register_dictionary( "grab_plus.txt" ) |
206 |
|
|
207 |
MAXPLAYERS = get_maxplayers() |
MAXPLAYERS = get_maxplayers() |
208 |
|
|
209 |
SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) |
SVC_SCREENFADE = get_user_msgid( "ScreenFade" ) |
210 |
SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) |
SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" ) |
|
|
|
|
return PLUGIN_CONTINUE |
|
211 |
} |
} |
212 |
|
|
213 |
public plugin_precache( ) |
public plugin_precache( ) |
214 |
{ |
{ |
215 |
precache_sound( "player/PL_PAIN2.WAV" ) |
precache_sound( "player/PL_PAIN2.WAV" ) |
|
return PLUGIN_CONTINUE |
|
216 |
} |
} |
217 |
|
|
218 |
public client_PreThink( id ) |
public fm_player_prethink( id ) |
219 |
{ |
{ |
220 |
//Search for a target |
//Search for a target |
221 |
if ( client_data[id][GRABBED] == -1 ) |
if ( client_data[id][GRABBED] == -1 ) |
222 |
{ |
{ |
223 |
new Float:orig[3], Float:ret[3] |
new Float:orig[3], Float:ret[3] |
224 |
pev( id, pev_origin, orig ) |
get_view_pos( id, orig ) |
225 |
pev( id, pev_view_ofs, ret ) |
ret = vel_by_aim( id, 9999 ) |
226 |
|
|
227 |
|
ret[0] += orig[0] |
228 |
|
ret[1] += orig[1] |
229 |
|
ret[2] += orig[2] |
230 |
|
|
231 |
for( new i = 0; i < 3; i++ ) orig[i] += ret[i] |
new target = traceline( orig, ret, id, ret ) |
|
engfunc( EngFunc_GetAimVector, id, 1, ret ) |
|
|
for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ( ret[i] * 9999 ) |
|
|
|
|
|
new tr = 0 |
|
|
engfunc( EngFunc_TraceLine, orig, ret, 0, id, tr ) |
|
|
new target = get_tr2( tr, TR_pHit ) |
|
|
get_tr2( tr, TR_vecEndPos, ret ) |
|
232 |
|
|
233 |
if( 0 < target <= MAXPLAYERS ) |
if( 0 < target <= MAXPLAYERS ) |
234 |
{ |
{ |
235 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return FMRES_IGNORED |
236 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
237 |
} |
} |
238 |
else if( !get_pcvar_num( p_playersonly ) ) |
else if( !get_pcvar_num( p_players_only ) ) |
239 |
{ |
{ |
240 |
new movetype |
new movetype |
241 |
if( target ) |
if( target && pev_valid( target ) ) |
242 |
{ |
{ |
243 |
movetype = pev( target, pev_movetype ) |
movetype = pev( target, pev_movetype ) |
244 |
if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) |
if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) ) |
245 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
246 |
} |
} |
247 |
else |
else |
248 |
{ |
{ |
249 |
|
target = 0 |
250 |
new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 ) |
251 |
while( !target && ent > 0 ) |
while( !target && ent > 0 ) |
252 |
{ |
{ |
259 |
} |
} |
260 |
if( target ) |
if( target ) |
261 |
{ |
{ |
262 |
if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE |
if( is_grabbed( target, id ) ) return FMRES_IGNORED |
263 |
set_grabbed( id, target ) |
set_grabbed( id, target ) |
264 |
} |
} |
265 |
} |
} |
271 |
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 ) ) ) |
272 |
{ |
{ |
273 |
unset_grabbed( id ) |
unset_grabbed( id ) |
274 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
275 |
} |
} |
276 |
|
|
277 |
//Use key choke |
//Use key choke |
288 |
} |
} |
289 |
if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] ) |
if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] ) |
290 |
|
|
291 |
return PLUGIN_CONTINUE |
return FMRES_IGNORED |
292 |
} |
} |
293 |
|
|
294 |
public grab_think ( id ) |
public grab_think ( id ) |
299 |
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" ) |
300 |
|
|
301 |
//Move targeted client |
//Move targeted client |
302 |
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] |
303 |
new len = client_data[id][GRAB_LEN] |
|
304 |
|
get_view_pos( id, tmpvec ) |
305 |
|
|
306 |
|
tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] ) |
307 |
|
|
|
pev( id, pev_origin, dest ) |
|
|
pev( id, pev_view_ofs, tmpvec ) |
|
|
engfunc( EngFunc_GetAimVector, id, len, tmpvec2 ) |
|
308 |
torig = get_target_origin_f( target ) |
torig = get_target_origin_f( target ) |
309 |
|
|
310 |
new force = get_pcvar_num( p_grabforce ) |
new force = get_pcvar_num( p_grab_force ) |
311 |
|
|
312 |
for( new i = 0; i < 3; i++ ) |
tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force |
313 |
{ |
tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force |
314 |
dest[i] += tmpvec[i] + tmpvec2[i] |
tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force |
|
tvel[i] = ( dest[i] - torig[i] ) * force |
|
|
} |
|
315 |
|
|
316 |
set_pev( target, pev_velocity, tvel ) |
set_pev( target, pev_velocity, tvel ) |
317 |
} |
} |
373 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
374 |
if( target > 0 ) |
if( target > 0 ) |
375 |
{ |
{ |
376 |
new Float:pVelocity[3] |
set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) ) |
|
engfunc( EngFunc_GetAimVector, id, get_pcvar_num( p_throwforce ), pVelocity ) |
|
|
set_pev( target, pev_velocity, pVelocity ) |
|
377 |
unset_grabbed( id ) |
unset_grabbed( id ) |
378 |
return PLUGIN_HANDLED |
return PLUGIN_HANDLED |
379 |
} |
} |
380 |
|
|
381 |
return PLUGIN_CONTINUE |
return PLUGIN_CONTINUE |
382 |
} |
} |
383 |
|
|
433 |
pev( target, pev_origin, torig ) |
pev( target, pev_origin, torig ) |
434 |
pev( id, pev_origin, orig ) |
pev( id, pev_origin, orig ) |
435 |
client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) |
client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) ) |
436 |
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 ) |
437 |
} |
} |
438 |
|
|
439 |
public push( id ) |
public push( id ) |
474 |
|
|
475 |
public do_pull( id ) |
public do_pull( id ) |
476 |
{ |
{ |
477 |
new mindist = get_pcvar_num( p_mindist ) |
new mindist = get_pcvar_num( p_min_dist ) |
478 |
new len = client_data[id][GRAB_LEN] |
new len = client_data[id][GRAB_LEN] |
479 |
|
|
480 |
if( len > mindist ) |
if( len > mindist ) |
483 |
if( len < mindist ) len = mindist |
if( len < mindist ) len = mindist |
484 |
client_data[id][GRAB_LEN] = len |
client_data[id][GRAB_LEN] = len |
485 |
} |
} |
486 |
else do_choke( id ) |
else if( get_pcvar_num( p_auto_choke ) ) |
487 |
|
do_choke( id ) |
488 |
} |
} |
489 |
|
|
490 |
public do_choke( id ) |
public do_choke( id ) |
492 |
new target = client_data[id][GRABBED] |
new target = client_data[id][GRABBED] |
493 |
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 |
494 |
|
|
495 |
new dmg = get_pcvar_num( p_chokedmg ) |
new dmg = get_pcvar_num( p_choke_dmg ) |
496 |
new Float:vec[3] |
new Float:vec[3] |
497 |
get_target_origin_f( target ) |
get_target_origin_f( target ) |
498 |
|
|
540 |
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 ) |
541 |
|
|
542 |
client_data[id][FLAGS] ^= CDF_NO_CHOKE |
client_data[id][FLAGS] ^= CDF_NO_CHOKE |
543 |
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 ) |
544 |
} |
} |
545 |
|
|
546 |
public clear_no_choke( tskid ) |
public clear_no_choke( tskid ) |
567 |
} |
} |
568 |
|
|
569 |
//Safe to tp target to aim spot? |
//Safe to tp target to aim spot? |
570 |
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] |
571 |
new bool:safe = false, i |
new bool:safe = false, i |
572 |
|
|
573 |
pev( id, pev_origin, orig ) |
get_view_pos( id, orig ) |
574 |
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] |
|
|
engfunc( EngFunc_GetAimVector, id, get_pcvar_num( p_mindist ), tmpvec2 ) |
|
575 |
|
|
576 |
for( new j = 1; j < 11 && !safe; j++ ) |
for( new j = 1; j < 11 && !safe; j++ ) |
577 |
{ |
{ |
578 |
for( i = 0; i < 3; i++ ) |
torig[0] = orig[0] + tmpvec[i] * j |
579 |
torig[i] = tmpvec[i] + tmpvec2[i] * j |
torig[1] = orig[1] + tmpvec[i] * j |
580 |
|
torig[2] = orig[2] + tmpvec[i] * j |
581 |
|
|
582 |
new tr = 0 |
traceline( tmpvec, torig, id, trace_ret ) |
|
engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr ) |
|
|
get_tr2( tr, TR_vecEndPos, trace_ret ) |
|
583 |
|
|
584 |
if( get_distance_f( trace_ret, torig ) ) break |
if( get_distance_f( trace_ret, torig ) ) break |
585 |
if( !_trace_hull( torig, HULL_HUMAN ) ) safe = true |
|
586 |
|
engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) |
587 |
|
if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) ) |
588 |
|
safe = true |
589 |
} |
} |
590 |
|
|
591 |
//Still not safe? Then find another safe spot somewhere around the grabber |
//Still not safe? Then find another safe spot somewhere around the grabber |
592 |
|
pev( id, pev_origin, orig ) |
593 |
new try[3] |
new try[3] |
594 |
orig[2] += 2 |
orig[2] += 2 |
595 |
while( try[2] < 3 && !safe ) |
while( try[2] < 3 && !safe ) |
602 |
case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) |
case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 ) |
603 |
} |
} |
604 |
|
|
605 |
new tr2 = 0 |
traceline( tmpvec, torig, id, trace_ret ) |
|
engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr2 ) |
|
|
get_tr2( tr2, TR_vecEndPos, trace_ret ) |
|
606 |
|
|
607 |
if( !_trace_hull( torig, HULL_HUMAN ) && !get_distance_f( trace_ret, torig ) ) safe = true |
engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 ) |
608 |
|
if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) |
609 |
|
&& !get_distance_f( trace_ret, torig ) ) safe = true |
610 |
|
|
611 |
try[0]++ |
try[0]++ |
612 |
if( try[0] == 3 ) |
if( try[0] == 3 ) |
662 |
unset_grabbed( client_data[id][GRABBER] ) |
unset_grabbed( client_data[id][GRABBER] ) |
663 |
} |
} |
664 |
|
|
665 |
//Complements of vittu |
stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] ) |
666 |
//Complements of fakemeta_util, cause i was too lazy to add this in as not a function |
{ |
667 |
_trace_hull(const Float:origin[3], hull, ignoredent = 0, ignoremonsters = 0) { |
engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 ) |
668 |
new result = 0; |
get_tr2( 0, TR_vecEndPos, vHitPos ) |
669 |
engfunc(EngFunc_TraceHull, origin, origin, ignoremonsters, hull, ignoredent > 0 ? ignoredent : 0, 0); |
return get_tr2( 0, TR_pHit ) |
670 |
|
} |
671 |
if (get_tr2(0, TR_StartSolid)) |
|
672 |
result += 1; |
stock get_view_pos( const id, Float:vViewPos[3] ) |
673 |
if (get_tr2(0, TR_AllSolid)) |
{ |
674 |
result += 2; |
new Float:ofs[3] |
675 |
if (!get_tr2(0, TR_InOpen)) |
pev( id, pev_origin, vViewPos ) |
676 |
result += 4; |
pev( id, pev_view_ofs, ofs ) |
677 |
|
|
678 |
|
vViewPos[0] += ofs[0] |
679 |
|
vViewPos[1] += ofs[1] |
680 |
|
vViewPos[2] += ofs[2] |
681 |
|
} |
682 |
|
|
683 |
|
stock Float:vel_by_aim( id, speed = 1 ) |
684 |
|
{ |
685 |
|
new Float:v1[3], Float:vBlah[3] |
686 |
|
pev( id, pev_v_angle, v1 ) |
687 |
|
engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah ) |
688 |
|
|
689 |
|
v1[0] *= speed |
690 |
|
v1[1] *= speed |
691 |
|
v1[2] *= speed |
692 |
|
|
693 |
return result; |
return v1 |
694 |
} |
} |