TraceAttack: Added support for weapon-specific penetration values.

Counter-Strike now uses those, values are those from CS:S's 2011 weapon
scripts.
This commit is contained in:
Marco Cawthorne 2020-04-23 06:51:39 +02:00
parent ae7da17d0f
commit 051d07fbcf
24 changed files with 37 additions and 5 deletions

View File

@ -24,7 +24,12 @@ void FX_Explosion(vector vecPos);
void FX_GibHuman(vector vecPos);
void Footsteps_Update(void);
void Vox_Broadcast(string sMessage);
void TraceAttack_FireBullets(int , vector, int, vector, int);
void TraceAttack_FireBullets(int,vector,int,vector,int);
#ifdef BULLETPENETRATION
void TraceAttack_SetPenetrationPower(int);
#endif
void Damage_Radius(vector, entity, float, float, int, int);
void Damage_Apply(entity, entity, float, int, int);
void Client_TriggerCamera(entity eTarget, vector vecPos, vector vEndPos, float fResetTime);

View File

@ -102,7 +102,7 @@ TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon)
#ifdef BULLETPENETRATION
if (iTotalPenetrations > 0) {
iTotalPenetrations -= 1;
TraceAttack_FireSingle(trace_endpos + (v_forward * 2), vAngle, iDamage, iWeapon);
TraceAttack_FireSingle(trace_endpos + (v_forward * 2), vAngle, iDamage / 2, iWeapon);
}
#endif
}
@ -115,9 +115,6 @@ TraceAttack_FireBullets(int iShots, vector vecPos, int iDamage, vector vecSpread
makevectors(self.v_angle);
while (iShots > 0) {
#ifdef BULLETPENETRATION
iTotalPenetrations = 2;
#endif
vDir = aim(self, 100000);
#ifndef CSTRIKE
vDir += random(-1,1) * vecSpread[0] * v_right;
@ -142,3 +139,11 @@ TraceAttack_FireBullets(int iShots, vector vecPos, int iDamage, vector vecSpread
iShots--;
}
}
#ifdef BULLETPENETRATION
void
TraceAttack_SetPenetrationPower(int power)
{
iTotalPenetrations = power;
}
#endif

View File

@ -132,6 +132,7 @@ w_ak47_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 36, [accuracy,accuracy], WEAPON_AK47);
pl.ak47_mag--;

View File

@ -133,6 +133,7 @@ w_aug_primary(void)
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
pl.aug_mag--;
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 32, [accuracy,accuracy], WEAPON_AUG);
if (self.flags & FL_CROUCHING)

View File

@ -181,6 +181,7 @@ w_awp_primary(void)
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
pl.awp_mag--;
TraceAttack_SetPenetrationPower(2);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 115, [accuracy,accuracy], WEAPON_AWP);
if (self.flags & FL_CROUCHING)

View File

@ -136,6 +136,7 @@ w_deagle_primary(void)
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
pl.deagle_mag--;
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 54, [accuracy,accuracy], WEAPON_DEAGLE);
if (self.flags & FL_CROUCHING)

View File

@ -146,6 +146,7 @@ w_elites_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 45, [accuracy,accuracy], WEAPON_ELITES);
pl.elites_mag--;

View File

@ -135,6 +135,7 @@ w_fiveseven_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 25, [accuracy,accuracy], WEAPON_FIVESEVEN);
pl.fiveseven_mag--;

View File

@ -130,6 +130,7 @@ w_g3sg1_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(2);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 80, [accuracy,accuracy], WEAPON_G3SG1);
pl.g3sg1_mag--;

View File

@ -153,6 +153,7 @@ w_glock18_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 25, [accuracy,accuracy], WEAPON_GLOCK18);
pl.glock18_mag--;

View File

@ -140,6 +140,7 @@ w_m3_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(9, pl.origin + pl.view_ofs, 26, [accuracy,accuracy], WEAPON_M3);
pl.m3_mag--;

View File

@ -164,6 +164,7 @@ w_m4a1_primary(void)
Sound_Play(pl, CHAN_WEAPON, "weapon_m4a1.fire");
}
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 33, [accuracy,accuracy], WEAPON_M4A1);
if (self.flags & FL_CROUCHING)

View File

@ -131,6 +131,7 @@ w_mac10_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 29, [accuracy,accuracy], WEAPON_MAC10);
pl.mac10_mag--;

View File

@ -135,6 +135,7 @@ w_mp5_primary(void)
return;
}
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 26, [accuracy,accuracy], WEAPON_MP5);
pl.mp5_mag--;

View File

@ -139,6 +139,7 @@ w_p228_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [accuracy,accuracy], WEAPON_P228);
pl.p228_mag--;

View File

@ -132,6 +132,7 @@ w_p90_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 26, [accuracy,accuracy], WEAPON_P90);
pl.p90_mag--;

View File

@ -131,6 +131,7 @@ w_para_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 35, [accuracy,accuracy], WEAPON_PARA);
pl.para_mag--;

View File

@ -180,6 +180,7 @@ w_scout_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(2);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 75, [accuracy,accuracy], WEAPON_SCOUT);
pl.scout_mag--;

View File

@ -131,6 +131,7 @@ w_sg550_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 70, [accuracy,accuracy], WEAPON_SG550);
pl.sg550_mag--;

View File

@ -132,6 +132,7 @@ w_sg552_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(1);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 33, [accuracy,accuracy], WEAPON_SG552);
pl.sg552_mag--;

View File

@ -132,6 +132,7 @@ w_tmp_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 26, [accuracy,accuracy], WEAPON_TMP);
pl.tmp_mag--;

View File

@ -132,6 +132,7 @@ w_ump45_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 30, [accuracy,accuracy], WEAPON_UMP45);
pl.ump45_mag--;

View File

@ -169,6 +169,7 @@ w_usp45_primary(void)
Sound_Play(pl, CHAN_WEAPON, "weapon_usp45.fire");
}
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 33, [accuracy,accuracy], WEAPON_USP45);
if (self.flags & FL_CROUCHING)

View File

@ -142,6 +142,7 @@ w_xm1014_primary(void)
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(6, pl.origin + pl.view_ofs, 22, [accuracy,accuracy], WEAPON_XM1014);
pl.xm1014_mag--;