2019-01-03 01:26:39 +00:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
|
|
|
*
|
|
|
|
* See the file LICENSE attached with the sources for usage details.
|
|
|
|
*
|
|
|
|
****/
|
2016-12-02 23:12:10 +00:00
|
|
|
|
2017-01-07 20:18:15 +00:00
|
|
|
int iTotalPenetrations;
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
TraceAttack_FireSingle
|
|
|
|
|
|
|
|
Fires a single shot that can penetrate some materials
|
|
|
|
=================
|
|
|
|
*/
|
2017-01-07 20:18:15 +00:00
|
|
|
void TraceAttack_FireSingle( vector vPos, vector vAngle ) {
|
|
|
|
static void TraceAttack_Penetrate( vector vPos, vector vAngle ) {
|
|
|
|
if ( iTotalPenetrations > 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TraceAttack_FireSingle( vPos, vAngle );
|
2018-09-20 20:38:01 +00:00
|
|
|
iTotalPenetrations = 1;
|
2017-01-07 20:18:15 +00:00
|
|
|
}
|
2017-07-03 11:55:11 +00:00
|
|
|
traceline( vPos, vPos + ( vAngle * wptTable[ self.weapon ].fRange ), MOVE_HITMODEL, self);
|
2017-01-07 20:18:15 +00:00
|
|
|
|
2019-01-03 01:26:39 +00:00
|
|
|
if (trace_fraction != 1.0) {
|
|
|
|
if ( trace_ent.takedamage == DAMAGE_YES ) {
|
|
|
|
Damage_Apply( trace_ent, self, wptTable[ self.weapon ].iDamage, trace_endpos, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( trace_ent.iBleeds == TRUE ) {
|
|
|
|
Effect_Impact( IMPACT_FLESH, trace_endpos, trace_plane_normal );
|
|
|
|
} else {
|
|
|
|
string sTexture = getsurfacetexture( trace_ent, getsurfacenearpoint( trace_ent, trace_endpos ) );
|
|
|
|
|
|
|
|
switch( (float)hash_get( hashMaterials, sTexture ) ) {
|
|
|
|
case 'G':
|
|
|
|
case 'V':
|
|
|
|
Effect_Impact( IMPACT_METAL, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
case 'P':
|
|
|
|
Effect_Impact( IMPACT_METAL, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
case 'W':
|
|
|
|
Effect_Impact( IMPACT_WOOD, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'Y':
|
|
|
|
Effect_Impact( IMPACT_GLASS, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
Effect_Impact( IMPACT_DEFAULT, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
default:
|
|
|
|
Effect_Impact( IMPACT_DEFAULT, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TraceAttack_Penetrate( trace_endpos + ( v_forward * 2 ), vAngle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TraceAttack_FireSingleLagged( vector vPos, vector vAngle ) {
|
|
|
|
static void TraceAttack_Penetrate( vector vPos, vector vAngle ) {
|
|
|
|
if ( iTotalPenetrations > 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TraceAttack_FireSingle( vPos, vAngle );
|
|
|
|
iTotalPenetrations = 1;
|
|
|
|
}
|
|
|
|
traceline( vPos, vPos + ( vAngle * wptTable[ self.weapon ].fRange ), MOVE_LAGGED | MOVE_HITMODEL, self);
|
|
|
|
|
2017-01-07 20:18:15 +00:00
|
|
|
if (trace_fraction != 1.0) {
|
|
|
|
if ( trace_ent.takedamage == DAMAGE_YES ) {
|
2017-11-11 21:46:04 +00:00
|
|
|
Damage_Apply( trace_ent, self, wptTable[ self.weapon ].iDamage, trace_endpos, FALSE );
|
2017-01-07 20:18:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( trace_ent.iBleeds == TRUE ) {
|
|
|
|
Effect_Impact( IMPACT_FLESH, trace_endpos, trace_plane_normal );
|
|
|
|
} else {
|
|
|
|
string sTexture = getsurfacetexture( trace_ent, getsurfacenearpoint( trace_ent, trace_endpos ) );
|
|
|
|
|
|
|
|
switch( (float)hash_get( hashMaterials, sTexture ) ) {
|
|
|
|
case 'G':
|
|
|
|
case 'V':
|
2017-01-07 20:41:02 +00:00
|
|
|
Effect_Impact( IMPACT_METAL, trace_endpos, trace_plane_normal );
|
2017-01-07 20:18:15 +00:00
|
|
|
TraceAttack_Penetrate( trace_endpos + ( v_forward * 2 ), vAngle );
|
2017-01-07 20:41:02 +00:00
|
|
|
break;
|
2017-01-07 20:18:15 +00:00
|
|
|
case 'M':
|
|
|
|
case 'P':
|
|
|
|
Effect_Impact( IMPACT_METAL, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
case 'W':
|
|
|
|
Effect_Impact( IMPACT_WOOD, trace_endpos, trace_plane_normal );
|
|
|
|
TraceAttack_Penetrate( trace_endpos + ( v_forward * 2 ), vAngle );
|
|
|
|
break;
|
|
|
|
case 'Y':
|
|
|
|
Effect_Impact( IMPACT_GLASS, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
case 'N':
|
2017-01-07 20:41:02 +00:00
|
|
|
Effect_Impact( IMPACT_DEFAULT, trace_endpos, trace_plane_normal );
|
2017-01-11 23:31:19 +00:00
|
|
|
TraceAttack_Penetrate( trace_endpos + ( v_forward * 2 ), vAngle );
|
2017-01-07 20:41:02 +00:00
|
|
|
break;
|
2017-01-07 20:18:15 +00:00
|
|
|
case 'T':
|
|
|
|
default:
|
|
|
|
Effect_Impact( IMPACT_DEFAULT, trace_endpos, trace_plane_normal );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 18:24:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
TraceAttack_FireBullets
|
|
|
|
|
|
|
|
Fire a given amount of shots
|
|
|
|
=================
|
|
|
|
*/
|
2017-01-07 17:01:44 +00:00
|
|
|
void TraceAttack_FireBullets( int iShots, vector vPos ) {
|
|
|
|
vector vDir;
|
2016-12-02 23:12:10 +00:00
|
|
|
makevectors(self.v_angle);
|
2016-12-13 19:15:09 +00:00
|
|
|
|
2017-01-08 15:42:26 +00:00
|
|
|
while ( iShots > 0 ) {
|
2017-01-07 20:18:15 +00:00
|
|
|
iTotalPenetrations = 0;
|
2016-12-02 23:12:10 +00:00
|
|
|
vDir = aim( self, 100000 ) + Math_CRandom()*self.fAccuracy*v_right + Math_CRandom()*self.fAccuracy*v_up;
|
2017-01-07 20:18:15 +00:00
|
|
|
TraceAttack_FireSingle( vPos, vDir );
|
2019-01-03 01:26:39 +00:00
|
|
|
TraceAttack_FireSingleLagged( vPos, vDir );
|
2016-12-02 23:12:10 +00:00
|
|
|
iShots--;
|
|
|
|
}
|
|
|
|
|
|
|
|
dprint( sprintf( "[DEBUG] ACCURACY: %f, %d %d %d\n", self.fAccuracy, vDir_x, vDir_y, vDir_z ));
|
|
|
|
}
|