traceattack: made it so that accuracy is a parameter.

w_shotgun: support for spread, fire
w_glock: support for spread.
w_mp5: spread...
w_python: ditto
This commit is contained in:
Marco Cawthorne 2019-03-02 00:15:00 +01:00
parent afb78fd1ac
commit fdc4227d00
15 changed files with 35 additions and 15 deletions

View file

@ -14,7 +14,7 @@ void Effect_Impact( int iType, vector vPos, vector vNormal );
void Effect_CreateExplosion( vector vPos );
void Footsteps_Update( void );
void TraceAttack_FireBullets( int iShots, vector vPos, int iDamage);
void TraceAttack_FireBullets( int iShots, vector vPos, int iDamage, vector vecAccuracy);
void Damage_Radius( vector vOrigin, entity eAttacker, float fDamage, float fRadius, int iCheckClip );
void Damage_Apply( entity eTarget, entity eAttacker, float fDamage, vector vHitPos, int iSkipArmor );
void Client_TriggerCamera( entity eTarget, vector vPos, vector vEndPos, float fResetTime );

View file

@ -141,18 +141,16 @@ TraceAttack_FireBullets
Fire a given amount of shots
=================
*/
void TraceAttack_FireBullets(int iShots, vector vPos, int iDamage)
void TraceAttack_FireBullets(int iShots, vector vPos, int iDamage, vector vecAccuracy)
{
vector vDir;
makevectors(self.v_angle);
while (iShots > 0) {
iTotalPenetrations = 0;
#ifdef CSTRIKE
vDir = aim(self, 100000) + Math_CRandom()*self.fAccuracy*v_right + Math_CRandom()*self.fAccuracy*v_up;
#else
vDir = aim(self, 100000);
#endif
vDir = aim(self, 100000) + Math_CRandom()*vecAccuracy[0]*v_right + Math_CRandom()*vecAccuracy[1]*v_up;
//TraceAttack_FireSingle(vPos, vDir, iDamage);
TraceAttack_FireSingleLagged(vPos, vDir, iDamage);
iShots--;

View file

@ -133,7 +133,7 @@ float BaseGun_PrimaryFire( void ) {
BaseGun_ShotMultiplierHandle( wptTable[ self.weapon ].iBullets );
BaseGun_AccuracyCalc();
TraceAttack_FireBullets( wptTable[ self.weapon ].iBullets, ( self.origin + self.view_ofs ), wptTable[self.weapon].iDamage );
TraceAttack_FireBullets( wptTable[ self.weapon ].iBullets, ( self.origin + self.view_ofs ), wptTable[self.weapon].iDamage, [self.fAccuracy, self.fAccuracy] );
Animation_ShootWeapon( self );
self.(wptTable[ self.weapon ].iMagfld) -= 1;

View file

@ -86,7 +86,7 @@ void WeaponGLOCK18_PrimaryFire( void ) {
if ( self.iMag_GLOCK18 ) {
BaseGun_ShotMultiplierHandle( 1 );
BaseGun_AccuracyCalc();
TraceAttack_FireBullets( 1, ( self.origin + self.view_ofs ), 25 );
TraceAttack_FireBullets( 1, ( self.origin + self.view_ofs ), 25, [self.fAccuracy,self.fAccuracy]);
self.iMag_GLOCK18 -= 1;
}
}

View file

@ -12,8 +12,6 @@
#define PHY_JUMP_CHAIN 100
#define PHY_JUMP_CHAINDECAY 50
#define FL_JUMPRELEASED 4096
/*FIXME: jumptime should use the time global, as time intervals are not predictable - decrement it based upon input_timelength*/
.float jumptime;
.float waterlevel;

View file

@ -90,7 +90,7 @@ void w_glock_primary(void)
return;
}
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.01,0,01]);
pl.glock_mag--;
@ -126,7 +126,7 @@ void w_glock_secondary(void)
return;
}
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.1,0,1]);
pl.glock_mag--;

View file

@ -76,7 +76,12 @@ void w_mp5_primary(void)
Weapons_ViewPunchAngle([random(-2, 2),0,0]);
#else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 5);
/* Singleplayer is more accurate */
if (cvar("sv_clientslots") == 1) {
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.02618,0.02618]);
} else {
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.05234,0.05234]);
}
if (random() < 0.5) {
Weapons_PlaySound(pl, CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM);

View file

@ -69,7 +69,7 @@ void w_python_primary(void)
}
#ifdef SSQC
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [0.00873, 0.00873]);
#endif
Weapons_ViewAnimation(PYTHON_FIRE1);

View file

@ -64,6 +64,16 @@ void w_shotgun_primary(void)
Weapons_PlaySound(pl, CHAN_WEAPON, "weapons/sbarrel1.wav", 1, ATTN_NORM);
Weapons_ViewAnimation(SHOTGUN_FIRE1);
Weapons_ViewPunchAngle([-5,0,0]);
#ifdef SSQC
/* Singleplayer is more accurate */
if (cvar("sv_clientslots") == 1) {
TraceAttack_FireBullets(6, pl.origin + pl.view_ofs, 5, [0.08716,0.08716]);
} else {
TraceAttack_FireBullets(4, pl.origin + pl.view_ofs, 5, [0.08716,0.04362]);
}
#endif
pl.w_attack_next = Math_Time() + 0.75;
pl.w_idle_next = Math_Time() + 2.5f;
}
@ -74,6 +84,15 @@ void w_shotgun_secondary(void)
return;
}
#ifdef SSQC
/* Singleplayer is more accurate */
if (cvar("sv_clientslots") == 1) {
TraceAttack_FireBullets(12, pl.origin + pl.view_ofs, 5, [0.08716,0.08716]);
} else {
TraceAttack_FireBullets(8, pl.origin + pl.view_ofs, 5, [0.17365,0.04362]);
}
#endif
Weapons_PlaySound(pl, CHAN_WEAPON, "weapons/dbarrel1.wav", 1, ATTN_NORM);
Weapons_ViewAnimation(SHOTGUN_FIRE2);
Weapons_ViewPunchAngle([-10,0,0]);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.