[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 5, Tue Oct 30 23:44:10 2007 UTC revision 8, Thu Nov 1 11:15:08 2007 UTC
# Line 119  Line 119 
119  #include <amxmisc>  #include <amxmisc>
120  #include <fakemeta>  #include <fakemeta>
121    
122  #define VERSION "1.2b1"  #define VERSION "1.2b4"
123  #define ADMIN ADMIN_LEVEL_A  #define ADMIN ADMIN_LEVEL_A
124    
125  #define TSK_CHKE 50  #define TSK_CHKE 50
# Line 189  Line 189 
189    
190          register_event( "DeathMsg", "DeathMsg", "a" )          register_event( "DeathMsg", "DeathMsg", "a" )
191    
192            register_forward( FM_PlayerPreThink, "fm_player_prethink" )
193    
194          register_dictionary( "grab_plus.txt" )          register_dictionary( "grab_plus.txt" )
195    
196          MAXPLAYERS = get_maxplayers()          MAXPLAYERS = get_maxplayers()
# Line 205  Line 207 
207          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
208  }  }
209    
210  public client_PreThink( id )  public fm_player_prethink( id )
211  {  {
212          //Search for a target          //Search for a target
213          if ( client_data[id][GRABBED] == -1 )          if ( client_data[id][GRABBED] == -1 )
# Line 218  Line 220 
220                  engfunc( EngFunc_GetAimVector, id, 1, ret )                  engfunc( EngFunc_GetAimVector, id, 1, ret )
221                  for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ( ret[i] * 9999 )                  for( new i = 0; i < 3; i++ ) ret[i] = orig[i] + ( ret[i] * 9999 )
222    
223                  new tr = 0                  engfunc( EngFunc_TraceLine, orig, ret, 0, id, 0 )
224                  engfunc( EngFunc_TraceLine, orig, ret, 0, id, tr )                  new target = get_tr2( 0, TR_pHit )
225                  new target = get_tr2( tr, TR_pHit )                  get_tr2( 0, TR_vecEndPos, ret )
                 get_tr2( tr, TR_vecEndPos, ret )  
226    
227                  if( 0 < target <= MAXPLAYERS )                  if( 0 < target <= MAXPLAYERS )
228                  {                  {
# Line 417  Line 418 
418                  set_pev(target, pev_renderfx, kRenderFxGlowShell)                  set_pev(target, pev_renderfx, kRenderFxGlowShell)
419                  set_pev(target, pev_rendercolor, color)                  set_pev(target, pev_rendercolor, color)
420                  set_pev(target, pev_rendermode, kRenderTransColor)                  set_pev(target, pev_rendermode, kRenderTransColor)
421                  set_pev(target, pev_renderamt, get_pcvar_float( p_glow_b ) )                  set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) )
422          }          }
423    
424          if( 0 < target <= MAXPLAYERS )          if( 0 < target <= MAXPLAYERS )
# Line 574  Line 575 
575                  for( i = 0; i < 3; i++ )                  for( i = 0; i < 3; i++ )
576                          torig[i] = tmpvec[i] + tmpvec2[i] * j                          torig[i] = tmpvec[i] + tmpvec2[i] * j
577    
578                  new tr = 0                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 )
579                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr )                  get_tr2( 0, TR_vecEndPos, trace_ret )
                 get_tr2( tr, TR_vecEndPos, trace_ret )  
580    
581                  if( get_distance_f( trace_ret, torig ) ) break                  if( get_distance_f( trace_ret, torig ) ) break
582                  if( !_trace_hull( torig, HULL_HUMAN ) ) safe = true  
583                    engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
584                    if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
585                            safe = true
586          }          }
587    
588          //Still not safe? Then find another safe spot somewhere around the grabber          //Still not safe? Then find another safe spot somewhere around the grabber
# Line 595  Line 598 
598                                  case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )                                  case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
599                          }                          }
600    
601                  new tr2 = 0                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 )
602                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr2 )                  get_tr2( 0, TR_vecEndPos, trace_ret )
                 get_tr2( tr2, TR_vecEndPos, trace_ret )  
603    
604                  if( !_trace_hull( torig, HULL_HUMAN ) && !get_distance_f( trace_ret, torig ) ) safe = true                  engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
605                    if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
606                                    && !get_distance_f( trace_ret, torig ) ) safe = true
607    
608                  try[0]++                  try[0]++
609                  if( try[0] == 3 )                  if( try[0] == 3 )
# Line 654  Line 658 
658          else if( client_data[id][GRABBER] )          else if( client_data[id][GRABBER] )
659                  unset_grabbed( client_data[id][GRABBER] )                  unset_grabbed( client_data[id][GRABBER] )
660  }  }
   
 //Complements of vittu  
 //Complements of fakemeta_util, cause i was too lazy to add this in as not a function  
 _trace_hull(const Float:origin[3], hull, ignoredent = 0, ignoremonsters = 0) {  
         new result = 0;  
         engfunc(EngFunc_TraceHull, origin, origin, ignoremonsters, hull, ignoredent > 0 ? ignoredent : 0, 0);  
   
         if (get_tr2(0, TR_StartSolid))  
                 result += 1;  
         if (get_tr2(0, TR_AllSolid))  
                 result += 2;  
         if (!get_tr2(0, TR_InOpen))  
                 result += 4;  
   
         return result;  
 }  

Legend:
Removed from v.5  
changed lines
  Added in v.8

Contact
ViewVC Help
Powered by ViewVC 1.0.4