[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 9, Fri Nov 2 01:14:09 2007 UTC
# Line 1  Line 1 
1  /*  /*
2  Grab+ v1.1  Grab+ v1.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  Oct 16 21:03  Nov 01 04:16
20    
21    
22  Description:  Description:
# Line 63  Line 63 
63  gp_choketime <1.5|...> Time frequency for choking.  gp_choketime <1.5|...> Time frequency for choking.
64  gp_chokedmg <5|...> Amount of damage done with each choke.  gp_chokedmg <5|...> Amount of damage done with each choke.
65    
66  gp_glow_r <50|0-255> Sets red amount for glow.  gp_screenfade <1|0> Enables/disables screenfade when grabbing.
67  gp_glow_g <0|0-255> Sets green amount for glow.  gp_glow <1|0> Enables/disables glowing for grabbed objects.
68  gp_glow_b <0|0-255> Sets blue amount for glow.  
69    gp_glow_r <50|0-255> Sets red amount for glow and screenfade.
70    gp_glow_g <0|0-255> Sets green amount for glow and screenfade.
71    gp_glow_b <0|0-255> Sets blue amount for glow and screenfade.
72    gp_glow_a <0|0-255> Sets alpha for glow and screenfade.
73    
74    
75  Notes:  Notes:
# Line 119  Line 123 
123  #include <amxmisc>  #include <amxmisc>
124  #include <fakemeta>  #include <fakemeta>
125    
126  #define VERSION "1.2b1"  #define VERSION "1.2b5"
127  #define ADMIN ADMIN_LEVEL_A  #define ADMIN ADMIN_LEVEL_A
128    
129  #define TSK_CHKE 50  #define TSK_CHKE 50
# Line 189  Line 193 
193    
194          register_event( "DeathMsg", "DeathMsg", "a" )          register_event( "DeathMsg", "DeathMsg", "a" )
195    
196            register_forward( FM_PlayerPreThink, "fm_player_prethink" )
197    
198          register_dictionary( "grab_plus.txt" )          register_dictionary( "grab_plus.txt" )
199    
200          MAXPLAYERS = get_maxplayers()          MAXPLAYERS = get_maxplayers()
# Line 205  Line 211 
211          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
212  }  }
213    
214  public client_PreThink( id )  public fm_player_prethink( id )
215  {  {
216          //Search for a target          //Search for a target
217          if ( client_data[id][GRABBED] == -1 )          if ( client_data[id][GRABBED] == -1 )
# Line 215  Line 221 
221                  pev( id, pev_view_ofs, ret )                  pev( id, pev_view_ofs, ret )
222    
223                  for( new i = 0; i < 3; i++ ) orig[i] += ret[i]                  for( new i = 0; i < 3; i++ ) orig[i] += ret[i]
224                  engfunc( EngFunc_GetAimVector, id, 1, ret )                  velocity_by_aim( id, 1, ret )
225                  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 )
226    
227                  new tr = 0                  engfunc( EngFunc_TraceLine, orig, ret, 0, id, 0 )
228                  engfunc( EngFunc_TraceLine, orig, ret, 0, id, tr )                  new target = get_tr2( 0, TR_pHit )
229                  new target = get_tr2( tr, TR_pHit )                  get_tr2( 0, TR_vecEndPos, ret )
                 get_tr2( tr, TR_vecEndPos, ret )  
230    
231                  if( 0 < target <= MAXPLAYERS )                  if( 0 < target <= MAXPLAYERS )
232                  {                  {
# Line 296  Line 301 
301    
302          pev( id, pev_origin, dest )          pev( id, pev_origin, dest )
303          pev( id, pev_view_ofs, tmpvec )          pev( id, pev_view_ofs, tmpvec )
304          engfunc(EngFunc_GetAimVector, id, len, tmpvec2)          velocity_by_aim( id, len, tmpvec2 )
305          torig = get_target_origin_f( target )          torig = get_target_origin_f( target )
306    
307          new force = get_pcvar_num( p_grabforce )          new force = get_pcvar_num( p_grabforce )
# Line 368  Line 373 
373          if( target > 0 )          if( target > 0 )
374          {          {
375                  new Float:pVelocity[3]                  new Float:pVelocity[3]
376                  engfunc( EngFunc_GetAimVector, id, get_pcvar_num( p_throwforce ), pVelocity )                  velocity_by_aim( id, get_pcvar_num(p_throwforce), pVelocity )
377                  set_pev( target, pev_velocity, pVelocity )                  set_pev( target, pev_velocity, pVelocity )
378                  unset_grabbed( id )                  unset_grabbed( id )
379                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 417  Line 422 
422                  set_pev(target, pev_renderfx, kRenderFxGlowShell)                  set_pev(target, pev_renderfx, kRenderFxGlowShell)
423                  set_pev(target, pev_rendercolor, color)                  set_pev(target, pev_rendercolor, color)
424                  set_pev(target, pev_rendermode, kRenderTransColor)                  set_pev(target, pev_rendermode, kRenderTransColor)
425                  set_pev(target, pev_renderamt, get_pcvar_float( p_glow_b ) )                  set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) )
426          }          }
427    
428          if( 0 < target <= MAXPLAYERS )          if( 0 < target <= MAXPLAYERS )
# Line 567  Line 572 
572          pev( id, pev_origin, orig )          pev( id, pev_origin, orig )
573          pev( id, pev_view_ofs, tmpvec )          pev( id, pev_view_ofs, tmpvec )
574          for( i = 0; i < 3; i++ ) tmpvec[i] += orig[i]          for( i = 0; i < 3; i++ ) tmpvec[i] += orig[i]
575          engfunc( EngFunc_GetAimVector, id, get_pcvar_num( p_mindist ), tmpvec2 )          velocity_by_aim( id, get_pcvar_num( p_mindist ), tmpvec2 )
576    
577          for( new j = 1; j < 11 && !safe; j++ )          for( new j = 1; j < 11 && !safe; j++ )
578          {          {
579                  for( i = 0; i < 3; i++ )                  for( i = 0; i < 3; i++ )
580                          torig[i] = tmpvec[i] + tmpvec2[i] * j                          torig[i] = tmpvec[i] + tmpvec2[i] * j
581    
582                  new tr = 0                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 )
583                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr )                  get_tr2( 0, TR_vecEndPos, trace_ret )
                 get_tr2( tr, TR_vecEndPos, trace_ret )  
584    
585                  if( get_distance_f( trace_ret, torig ) ) break                  if( get_distance_f( trace_ret, torig ) ) break
586                  if( !_trace_hull( torig, HULL_HUMAN ) ) safe = true  
587                    engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
588                    if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
589                            safe = true
590          }          }
591    
592          //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 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                  new tr2 = 0                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, 0 )
606                  engfunc( EngFunc_TraceLine, tmpvec, torig, 0, id, tr2 )                  get_tr2( 0, TR_vecEndPos, trace_ret )
                 get_tr2( tr2, TR_vecEndPos, trace_ret )  
607    
608                  if( !_trace_hull( torig, HULL_HUMAN ) && !get_distance_f( trace_ret, torig ) ) safe = true                  engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
609                    if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
610                                    && !get_distance_f( trace_ret, torig ) ) safe = true
611    
612                  try[0]++                  try[0]++
613                  if( try[0] == 3 )                  if( try[0] == 3 )
# Line 654  Line 662 
662          else if( client_data[id][GRABBER] )          else if( client_data[id][GRABBER] )
663                  unset_grabbed( client_data[id][GRABBER] )                  unset_grabbed( client_data[id][GRABBER] )
664  }  }
   
 //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.9

Contact
ViewVC Help
Powered by ViewVC 1.0.4