[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 12, Tue Nov 6 19:57:19 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:
23  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.
24    
25    
 See it in Action:  
 http://www.game-monitor.com/search.php?search=grab_plus_version&type=variable&game=all&location=all  
   
   
26  Features:  Features:
27  Multilingual  Multilingual
28  Screenfade to indicate grab activity instead of chat spam.  Screenfade to indicate grab activity instead of chat spam.
# Line 105  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 (Nov 02, 2007)  v1.2 (Nov 06, 2007)
105  +: Cvars gp_screen_fade and gp_glow to enable/disable these features.  +: Cvars gp_screen_fade and gp_glow to enable/disable these features.
106  +: Cvar gp_glow_a controls to control alpha of screenfade and glow.  +: Cvar gp_glow_a controls to control alpha of screenfade and glow.
107  +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.  +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.
108  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.
109  c: Made cvar names more consistent by adding more underscores.  c: Made cvar names more consistent by adding more underscores.
110  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).
111    
112  v1.1 (Oct 16, 2007)  v1.1 (Oct 16, 2007)
113  +: Grab a few types of entities other than players.  +: Grab a few types of entities other than players.
# Line 126  Line 122 
122  #include <amxmisc>  #include <amxmisc>
123  #include <fakemeta>  #include <fakemeta>
124    
125  #define VERSION "1.2b6"  #define VERSION "1.2"
126  #define ADMIN ADMIN_LEVEL_A  #define ADMIN ADMIN_LEVEL_A
127    
128  #define TSK_CHKE 50  #define TSK_CHKE 50
# Line 221  Line 217 
217          if ( client_data[id][GRABBED] == -1 )          if ( client_data[id][GRABBED] == -1 )
218          {          {
219                  new Float:orig[3], Float:ret[3]                  new Float:orig[3], Float:ret[3]
220                  pev( id, pev_origin, orig )                  get_view_pos( id, orig )
221                  pev( id, pev_view_ofs, ret )                  ret = vel_by_aim( id, 9999 )
222    
223                  for( new i = 0; i < 3; i++ ) orig[i] += ret[i]                  for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ret[i]
224                  //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 )  
225    
226                  if( 0 < target <= MAXPLAYERS )                  if( 0 < target <= MAXPLAYERS )
227                  {                  {
# Line 301  Line 291 
291          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" )
292    
293          //Move targeted client          //Move targeted client
294          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]
         new len = client_data[id][GRAB_LEN]  
295    
296          pev( id, pev_origin, dest )          get_view_pos( id, tmpvec )
         pev( id, pev_view_ofs, tmpvec )  
297    
298          //velocity_by_aim( id, len, tmpvec2 )          tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
         pev( id, pev_v_angle, tmpvec2 )  
         for( new i = 0; i < 3; i++ ) tmpvec2[i] *= len  
299    
300          torig = get_target_origin_f( target )          torig = get_target_origin_f( target )
301    
302          new force = get_pcvar_num( p_grab_force )          new force = get_pcvar_num( p_grab_force )
303    
304          for( new i = 0; i < 3; i++ )          for( new i = 0; i < 3; i++ )
305          {                  tvel[i] = ( ( tmpvec[i] + tmpvec2[i] ) - torig[i] ) * force
                 dest[i] += tmpvec[i] + tmpvec2[i]  
                 tvel[i] = ( dest[i] - torig[i] ) * force  
         }  
306    
307          set_pev( target, pev_velocity, tvel )          set_pev( target, pev_velocity, tvel )
308  }  }
# Line 381  Line 364 
364          new target = client_data[id][GRABBED]          new target = client_data[id][GRABBED]
365          if( target > 0 )          if( target > 0 )
366          {          {
367                  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 )  
368                  unset_grabbed( id )                  unset_grabbed( id )
369                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
370          }          }
371    
372          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
373  }  }
374    
# Line 581  Line 558 
558          }          }
559    
560          //Safe to tp target to aim spot?          //Safe to tp target to aim spot?
561          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]
562          new bool:safe = false, i          new bool:safe = false, i
563    
564          pev( id, pev_origin, orig )          get_view_pos( id, orig )
565          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  
566    
567          for( new j = 1; j < 11 && !safe; j++ )          for( new j = 1; j < 11 && !safe; j++ )
568          {          {
569                  for( i = 0; i < 3; i++ )                  for( i = 0; i < 3; i++ ) torig[i] = orig[i] + tmpvec[i] * j
570                          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 )  
571    
572                  if( get_distance_f( trace_ret, torig ) ) break                  if( get_distance_f( trace_ret, torig ) ) break
573    
# Line 609  Line 577 
577          }          }
578    
579          //Still not safe? Then find another safe spot somewhere around the grabber          //Still not safe? Then find another safe spot somewhere around the grabber
580            pev( id, pev_origin, orig )
581          new try[3]          new try[3]
582          orig[2] += 2          orig[2] += 2
583          while( try[2] < 3 && !safe )          while( try[2] < 3 && !safe )
# Line 621  Line 590 
590                                  case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )                                  case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
591                          }                          }
592    
593                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 )                  traceline( tmpvec, torig, id, trace_ret )
                 get_tr2( 0, TR_vecEndPos, trace_ret )  
594    
595                  engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )                  engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
596                  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 649 
649          else if( client_data[id][GRABBER] )          else if( client_data[id][GRABBER] )
650                  unset_grabbed( client_data[id][GRABBER] )                  unset_grabbed( client_data[id][GRABBER] )
651  }  }
652    
653    stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
654    {
655            engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
656            get_tr2( 0, TR_vecEndPos, vHitPos )
657            return get_tr2( 0, TR_pHit )
658    }
659    
660    stock get_view_pos( const id, Float:vViewPos[3] )
661    {
662            new Float:ofs[3]
663            pev( id, pev_origin, vViewPos )
664            pev( id, pev_view_ofs, ofs )
665            for( new i = 0; i < 3; i++ ) vViewPos[i] += ofs[i]
666    }
667    
668    stock Float:vel_by_aim( id, speed = 1 )
669    {
670            new Float:v1[3], Float:vBlah[3]
671            pev( id, pev_v_angle, v1 )
672            engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
673            for( new i = 0; i < 3; i++ ) v1[i] *= speed
674            return v1
675    }

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

Contact
ViewVC Help
Powered by ViewVC 1.0.4