[Half-Life AMXX] / grab_plus.sma Repository:
ViewVC logotype

Diff of /grab_plus.sma

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12, Tue Nov 6 19:57:19 2007 UTC revision 16, Fri Nov 16 15:12:40 2007 UTC
# Line 1  Line 1 
1  /*  /*
2  Grab+ v1.2  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 it under
# Line 16  Line 16 
16  --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
17    
18  http://ian.cammarata.us/projects/grab_plus  http://ian.cammarata.us/projects/grab_plus
19  Nov 06 11:21  Nov 16 08:08
20    
21    
22  Description:  Description:
# Line 101  Line 101 
101  Change Log:  Change Log:
102  Key (+ added | - removed | c changed | f fixed)  Key (+ added | - removed | c changed | f fixed)
103    
104    v1.2.2 (Nov xx, 2007)
105    c: A few small code optimizations.
106    
107    v1.2.1 (Nov 12, 2007)
108    f: Eliminated two run time warnings in the player prethink function.
109    
110  v1.2 (Nov 06, 2007)  v1.2 (Nov 06, 2007)
111  +: Cvars gp_screen_fade and gp_glow to enable/disable these features.  +: Cvars gp_screen_fade and gp_glow to enable/disable these features.
112  +: Cvar gp_glow_a controls to control alpha of screenfade and glow.  +: Cvar gp_glow_a controls to control alpha of screenfade and glow.
# Line 122  Line 128 
128  #include <amxmisc>  #include <amxmisc>
129  #include <fakemeta>  #include <fakemeta>
130    
131  #define VERSION "1.2"  #define VERSION "1.2.2"
132  #define ADMIN ADMIN_LEVEL_A  #define ADMIN ADMIN_LEVEL_A
133    
134  #define TSK_CHKE 50  #define TSK_CHKE 50
# Line 201  Line 207 
207    
208          SVC_SCREENFADE = get_user_msgid( "ScreenFade" )          SVC_SCREENFADE = get_user_msgid( "ScreenFade" )
209          SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )          SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )
   
         return PLUGIN_CONTINUE  
210  }  }
211    
212  public plugin_precache( )  public plugin_precache( )
213  {  {
214          precache_sound( "player/PL_PAIN2.WAV" )          precache_sound( "player/PL_PAIN2.WAV" )
         return PLUGIN_CONTINUE  
215  }  }
216    
217  public fm_player_prethink( id )  public fm_player_prethink( id )
# Line 220  Line 223 
223                  get_view_pos( id, orig )                  get_view_pos( id, orig )
224                  ret = vel_by_aim( id, 9999 )                  ret = vel_by_aim( id, 9999 )
225    
226                  for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ret[i]                  ret[0] += orig[0]
227                    ret[1] += orig[1]
228                    ret[2] += orig[2]
229    
230                  new target = traceline( orig, ret, id, ret )                  new target = traceline( orig, ret, id, ret )
231    
232                  if( 0 < target <= MAXPLAYERS )                  if( 0 < target <= MAXPLAYERS )
233                  {                  {
234                          if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE                          if( is_grabbed( target, id ) ) return FMRES_IGNORED
235                          set_grabbed( id, target )                          set_grabbed( id, target )
236                  }                  }
237                  else if( !get_pcvar_num( p_players_only ) )                  else if( !get_pcvar_num( p_players_only ) )
238                  {                  {
239                          new movetype                          new movetype
240                          if( target )                          if( target && pev_valid( target ) )
241                          {                          {
242                                  movetype = pev( target, pev_movetype )                                  movetype = pev( target, pev_movetype )
243                                  if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )                                  if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )
244                                          return PLUGIN_CONTINUE                                          return FMRES_IGNORED
245                          }                          }
246                          else                          else
247                          {                          {
248                                    target = 0
249                                  new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )                                  new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )
250                                  while( !target && ent > 0 )                                  while( !target && ent > 0 )
251                                  {                                  {
# Line 251  Line 258 
258                          }                          }
259                          if( target )                          if( target )
260                          {                          {
261                                  if( is_grabbed( target, id ) ) return PLUGIN_CONTINUE                                  if( is_grabbed( target, id ) ) return FMRES_IGNORED
262                                  set_grabbed( id, target )                                  set_grabbed( id, target )
263                          }                          }
264                  }                  }
# Line 263  Line 270 
270                  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 ) ) )
271                  {                  {
272                          unset_grabbed( id )                          unset_grabbed( id )
273                          return PLUGIN_CONTINUE                          return FMRES_IGNORED
274                  }                  }
275    
276                  //Use key choke                  //Use key choke
# Line 280  Line 287 
287          }          }
288          if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] )          if( client_data[id][GRABBER] > 0 ) grab_think( client_data[id][GRABBER] )
289    
290          return PLUGIN_CONTINUE          return FMRES_IGNORED
291  }  }
292    
293  public grab_think ( id )  public grab_think ( id )
# Line 301  Line 308 
308    
309          new force = get_pcvar_num( p_grab_force )          new force = get_pcvar_num( p_grab_force )
310    
311          for( new i = 0; i < 3; i++ )          tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force
312                  tvel[i] = ( ( tmpvec[i] + tmpvec2[i] ) - torig[i] ) * force          tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force
313            tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force
314    
315          set_pev( target, pev_velocity, tvel )          set_pev( target, pev_velocity, tvel )
316  }  }
# Line 566  Line 574 
574    
575          for( new j = 1; j < 11 && !safe; j++ )          for( new j = 1; j < 11 && !safe; j++ )
576          {          {
577                  for( i = 0; i < 3; i++ ) torig[i] = orig[i] + tmpvec[i] * j                  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                  traceline( tmpvec, torig, id, trace_ret )                  traceline( tmpvec, torig, id, trace_ret )
582    
583                  if( get_distance_f( trace_ret, torig ) ) break                  if( get_distance_f( trace_ret, torig ) ) break
# Line 662  Line 673 
673          new Float:ofs[3]          new Float:ofs[3]
674          pev( id, pev_origin, vViewPos )          pev( id, pev_origin, vViewPos )
675          pev( id, pev_view_ofs, ofs )          pev( id, pev_view_ofs, ofs )
676          for( new i = 0; i < 3; i++ ) vViewPos[i] += ofs[i]  
677            vViewPos[0] += ofs[0]
678            vViewPos[1] += ofs[1]
679            vViewPos[2] += ofs[2]
680  }  }
681    
682  stock Float:vel_by_aim( id, speed = 1 )  stock Float:vel_by_aim( id, speed = 1 )
# Line 670  Line 684 
684          new Float:v1[3], Float:vBlah[3]          new Float:v1[3], Float:vBlah[3]
685          pev( id, pev_v_angle, v1 )          pev( id, pev_v_angle, v1 )
686          engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )          engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
687          for( new i = 0; i < 3; i++ ) v1[i] *= speed  
688            v1[0] *= speed
689            v1[1] *= speed
690            v1[2] *= speed
691    
692          return v1          return v1
693  }  }

Legend:
Removed from v.12  
changed lines
  Added in v.16

Contact
ViewVC Help
Powered by ViewVC 1.0.4