[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 10, Sun Nov 4 03:44:10 2007 UTC revision 11, Tue Nov 6 18:25:29 2007 UTC
# Line 16  Line 16 
16  --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
17    
18  http://ian.cammarata.us/projects/grab_plus  http://ian.cammarata.us/projects/grab_plus
19  Nov 02 01:52  Nov 06 11:21
20    
21    
22  Description:  Description:
# Line 105  Line 105 
105  Change Log:  Change Log:
106  Key (+ added | - removed | c changed | f fixed)  Key (+ added | - removed | c changed | f fixed)
107    
108  v1.2 (Nov 02, 2007)  v1.2 (Nov 06, 2007)
109  +: Cvars gp_screen_fade and gp_glow to enable/disable these features.  +: Cvars gp_screen_fade and gp_glow to enable/disable these features.
110  +: Cvar gp_glow_a controls to control alpha of screenfade and glow.  +: Cvar gp_glow_a controls to control alpha of screenfade and glow.
111  +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.  +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.
112  c: Removed dependency of engine and fun modules.  Thanks to vittu for doing all the work.  c: Removed dependency of engine and fun modules.  Thanks to vittu for doing most of the work.
113  c: Made cvar names more consistent by adding more underscores.  c: Made cvar names more consistent by adding more underscores.
114  f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7x as well).  f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well).
115    
116  v1.1 (Oct 16, 2007)  v1.1 (Oct 16, 2007)
117  +: Grab a few types of entities other than players.  +: Grab a few types of entities other than players.
# Line 126  Line 126 
126  #include <amxmisc>  #include <amxmisc>
127  #include <fakemeta>  #include <fakemeta>
128    
129  #define VERSION "1.2b6"  #define VERSION "1.2"
130  #define ADMIN ADMIN_LEVEL_A  #define ADMIN ADMIN_LEVEL_A
131    
132  #define TSK_CHKE 50  #define TSK_CHKE 50
# Line 221  Line 221 
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                  for( new i = 0; i < 3; i++ ) orig[i] += ret[i]                  for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ret[i]
228                  //velocity_by_aim( id, 1, ret )                  new target = traceline( orig, ret, id, ret )
                 pev( id, pev_v_angle, 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 )  
229    
230                  if( 0 < target <= MAXPLAYERS )                  if( 0 < target <= MAXPLAYERS )
231                  {                  {
# Line 301  Line 295 
295          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" )
296    
297          //Move targeted client          //Move targeted client
298          new Float:tmpvec[3], Float:tmpvec2[3], Float:dest[3], Float:torig[3], Float:tvel[3]          new Float:tmpvec[3], Float:tmpvec2[3], /*Float:dest[3],*/ Float:torig[3], Float:tvel[3]
         new len = client_data[id][GRAB_LEN]  
299    
300          pev( id, pev_origin, dest )          //pev( id, pev_origin, dest )
301          pev( id, pev_view_ofs, tmpvec )          //pev( id, pev_view_ofs, tmpvec )
302            get_view_pos( id, tmpvec )
303    
304          //velocity_by_aim( id, len, tmpvec2 )          //velocity_by_aim( id, len, tmpvec2 )
305          pev( id, pev_v_angle, tmpvec2 )          //for( new i = 0; i < 3; i++ ) tmpvec2[i] *= len
306          for( new i = 0; i < 3; i++ ) tmpvec2[i] *= len          tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
307    
308          torig = get_target_origin_f( target )          torig = get_target_origin_f( target )
309    
310          new force = get_pcvar_num( p_grab_force )          new force = get_pcvar_num( p_grab_force )
311    
312          for( new i = 0; i < 3; i++ )          for( new i = 0; i < 3; i++ )
313          {                  tvel[i] = ( ( tmpvec[i] + tmpvec2[i] ) - torig[i] ) * force
314                  dest[i] += tmpvec[i] + tmpvec2[i]          /*{
315                    dest[i] = tmpvec[i] + tmpvec2[i]
316                  tvel[i] = ( dest[i] - torig[i] ) * force                  tvel[i] = ( dest[i] - torig[i] ) * force
317          }          }*/
318    
319          set_pev( target, pev_velocity, tvel )          set_pev( target, pev_velocity, tvel )
320  }  }
# Line 381  Line 376 
376          new target = client_data[id][GRABBED]          new target = client_data[id][GRABBED]
377          if( target > 0 )          if( target > 0 )
378          {          {
379                  new Float:vel[3]                  set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) )
                 new len = get_pcvar_num(p_throw_force)  
   
                 //velocity_by_aim( id, get_pcvar_num(p_throw_force), vel )  
                 pev( id, pev_v_angle, vel )  
                 for( new i = 0; i < 3; i++ ) vel[i] *= len  
   
                 set_pev( target, pev_velocity, vel )  
380                  unset_grabbed( id )                  unset_grabbed( id )
381                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
382          }          }
383    
384          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
385  }  }
386    
# Line 581  Line 570 
570          }          }
571    
572          //Safe to tp target to aim spot?          //Safe to tp target to aim spot?
573          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]
574          new bool:safe = false, i          new bool:safe = false, i
575    
576          pev( id, pev_origin, orig )          get_view_pos( id, orig )
577          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_min_dist ), tmpvec2 )  
         new min_dist = get_pcvar_num( p_min_dist )  
         pev( id, pev_v_angle, tmpvec2 )  
         for( new i = 0; i < 3; i++ ) tmpvec2[i] *= min_dist  
578    
579          for( new j = 1; j < 11 && !safe; j++ )          for( new j = 1; j < 11 && !safe; j++ )
580          {          {
581                  for( i = 0; i < 3; i++ )                  for( i = 0; i < 3; i++ ) torig[i] = orig[i] + tmpvec[i] * j
582                          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 )  
583    
584                  if( get_distance_f( trace_ret, torig ) ) break                  if( get_distance_f( trace_ret, torig ) ) break
585    
# Line 609  Line 589 
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 )
# Line 621  Line 602 
602                                  case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )                                  case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
603                          }                          }
604    
605                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 )                  traceline( tmpvec, torig, id, trace_ret )
                 get_tr2( 0, TR_vecEndPos, trace_ret )  
606    
607                  engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )                  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 )                  if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
# Line 681  Line 661 
661          else if( client_data[id][GRABBER] )          else if( client_data[id][GRABBER] )
662                  unset_grabbed( client_data[id][GRABBER] )                  unset_grabbed( client_data[id][GRABBER] )
663  }  }
664    
665    stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
666    {
667            engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
668            get_tr2( 0, TR_vecEndPos, vHitPos )
669            return get_tr2( 0, TR_pHit )
670    }
671    
672    stock get_view_pos( const id, Float:vViewPos[3] )
673    {
674            new Float:ofs[3]
675            pev( id, pev_origin, vViewPos )
676            pev( id, pev_view_ofs, ofs )
677            for( new i = 0; i < 3; i++ ) vViewPos[i] += ofs[i]
678    }
679    
680    stock Float:vel_by_aim( id, speed = 1 )
681    {
682            new Float:v1[3], Float:vBlah[3]
683            pev( id, pev_v_angle, v1 )
684            engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
685            for( new i = 0; i < 3; i++ ) v1[i] *= speed
686            return v1
687    }

Legend:
Removed from v.10  
changed lines
  Added in v.11

Contact
ViewVC Help
Powered by ViewVC 1.0.4