Brought punchangle into cstrike codebase and adjusted. Fixed console errors due to g_cstrikebulletrecoil. Recoil system tweaks.w
This commit is contained in:
parent
fe57af3876
commit
c7711beca9
17 changed files with 83 additions and 58 deletions
|
@ -201,10 +201,30 @@ class player:NSClientPlayer
|
|||
#endif
|
||||
};
|
||||
|
||||
float punchangle_recovery(float punchangle) {
|
||||
return 0.05 * (-0.2 * pow(1.2, fabs(punchangle)) + 4);
|
||||
}
|
||||
void
|
||||
player::Physics_InputPostMove(void)
|
||||
{
|
||||
super::Physics_InputPostMove();
|
||||
//start of this function is taken from super::Physics_InputPostMove
|
||||
float punch;
|
||||
/* timers, these are predicted and shared across client and server */
|
||||
w_attack_next = max(0, w_attack_next - input_timelength);
|
||||
w_idle_next = max(0, w_idle_next - input_timelength);
|
||||
weapontime += input_timelength;
|
||||
punch = max(0, 1.0f - (input_timelength * 4));
|
||||
if (punchangle[0] < 0) {
|
||||
punchangle[0] += punchangle_recovery(punchangle[0]);
|
||||
}
|
||||
punchangle[1] *= .98;
|
||||
punchangle[2] *= .99;
|
||||
|
||||
/* player animation code */
|
||||
UpdatePlayerAnimation(input_timelength);
|
||||
|
||||
RemoveFlags(FL_FROZEN);
|
||||
ProcessInput();
|
||||
|
||||
#ifdef SERVER
|
||||
if (g_cs_gamestate == GAME_FREEZE) {
|
||||
|
|
|
@ -153,7 +153,7 @@ w_ak47_primary(player pl)
|
|||
}
|
||||
|
||||
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl, 120,2.5);
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl, 110,2.5);
|
||||
pl.ak47_mag--;
|
||||
|
||||
int r = (float)input_sequence % 3;
|
||||
|
@ -181,13 +181,13 @@ w_ak47_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_ak47_dmg", 36);
|
||||
TraceAttack_SetRangeModifier(2.375); /* 18 units!!! */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1.1);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_AK47, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1.1);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_ak47.fire");
|
||||
#endif
|
||||
|
||||
Cstrike_ShotMultiplierAdd(pl, 2, 1.1);
|
||||
Cstrike_ShotMultiplierAdd(pl, 1.5, 1.05);
|
||||
pl.w_attack_next = 0.0975f;
|
||||
pl.w_idle_next = pl.w_attack_next;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ w_aug_primary(player pl)
|
|||
}
|
||||
|
||||
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl, 15,3)*pl.viewzoom;
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl, 45,3)*pl.viewzoom;
|
||||
pl.aug_mag--;
|
||||
|
||||
int r = (float)input_sequence % 3;
|
||||
|
@ -147,13 +147,13 @@ w_aug_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_aug_dmg", 32);
|
||||
TraceAttack_SetRangeModifier(2.125);
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1.15);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1.03);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_AUG, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1.15);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1.03);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_aug.fire");
|
||||
#endif
|
||||
|
||||
Cstrike_ShotMultiplierAdd(pl, 0.7, 1.1);
|
||||
Cstrike_ShotMultiplierAdd(pl, 0.7f, 1.1f);
|
||||
if (pl.viewzoom == 1.0f) {
|
||||
pl.w_attack_next = 0.0825f;
|
||||
} else {
|
||||
|
|
|
@ -180,9 +180,9 @@ w_deagle_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_deagle_dmg", 54);
|
||||
TraceAttack_SetRangeModifier(1.875); /* 14 but not 15 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,0.5);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,0.5);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_DEAGLE, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,0.5);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,0.5);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_deagle.fire");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -252,9 +252,9 @@ w_elites_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_elites_dmg", 45);
|
||||
TraceAttack_SetRangeModifier(1.875); /* 14 but not 15 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,.9f);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,.9f);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_ELITES, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,.9f);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,.9f);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_elites.fire");
|
||||
#endif
|
||||
Cstrike_ShotMultiplierAdd(pl, 3, .85);
|
||||
|
|
|
@ -151,9 +151,9 @@ w_fiveseven_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_fiveseven_dmg", 25);
|
||||
TraceAttack_SetRangeModifier(1.875); /* 14 but not 15 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,0.5f);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,0.5f);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_FIVESEVEN, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,0.5f);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,0.5f);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_fiveseven.fire");
|
||||
#endif
|
||||
Cstrike_ShotMultiplierAdd(pl, 10, .4);
|
||||
|
|
|
@ -150,9 +150,9 @@ w_glock18_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_glock18_dmg", 25);
|
||||
TraceAttack_SetRangeModifier(1.25); /* penetrates 9 units, but not 10 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,0.5);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,0.6);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_GLOCK18, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,0.5);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,0.6);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -189,9 +189,9 @@ w_m4a1_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_m4a1_dmg", 33);
|
||||
TraceAttack_SetRangeModifier(2.125);
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_M4A1, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1);
|
||||
#endif
|
||||
|
||||
Cstrike_ShotMultiplierAdd(pl, 1, 1);
|
||||
|
|
|
@ -146,9 +146,9 @@ w_mac10_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_mac10_dmg", 29);
|
||||
TraceAttack_SetRangeModifier(1.25); /* 9, but not 10 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1.125);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1.125);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_MAC10, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1.125);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1.125);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_mac10.fire");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ w_mp5_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_mp5_dmg", 26);
|
||||
TraceAttack_SetRangeModifier(1.25); /* 9 units but not 10 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,.7f);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,.7f);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_MP5, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,.7f);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,.7f);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.fire");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ w_p228_primary(player pl)
|
|||
return;
|
||||
|
||||
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl, 200,1.6) + 0.005f;
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl, 200,1.6) + 0.004f;
|
||||
int dmg = 0;
|
||||
pl.p228_mag--;
|
||||
|
||||
|
@ -151,15 +151,15 @@ w_p228_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_p228_dmg", 40);
|
||||
TraceAttack_SetRangeModifier(1.5); /* penetrates 11, but not 12 units */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1.2);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1.2);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_P228, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1.2);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1.2);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_p228.fire");
|
||||
#endif
|
||||
Cstrike_ShotMultiplierAdd(pl, 6, 0.5f);
|
||||
|
||||
pl.gflags |= GF_SEMI_TOGGLED;
|
||||
pl.w_attack_next = 0.145f;
|
||||
pl.w_attack_next = 0.1425f;
|
||||
pl.w_idle_next = pl.w_attack_next;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ w_p90_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_p90_dmg", 26);
|
||||
TraceAttack_SetRangeModifier(1.875); /* 9 but not 10 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_P90, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_p90.fire");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ w_sg552_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_sg552_dmg", 33);
|
||||
TraceAttack_SetRangeModifier(2.125);
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_SG552, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_sg552.fire");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -144,13 +144,13 @@ w_tmp_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_tmp_dmg", 26);
|
||||
TraceAttack_SetRangeModifier(1.25); /* 9 but not 10 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,0.9);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,0.8);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_TMP, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,0.9);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,0.8);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_tmp.fire");
|
||||
#endif
|
||||
|
||||
Cstrike_ShotMultiplierAdd(pl, 0.8, 1.35);
|
||||
Cstrike_ShotMultiplierAdd(pl, 0.85, 1.25);
|
||||
pl.w_attack_next = 0.07f;
|
||||
pl.w_idle_next = pl.w_attack_next;
|
||||
}
|
||||
|
|
|
@ -144,9 +144,9 @@ w_ump45_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_ump45_dmg", 30);
|
||||
TraceAttack_SetRangeModifier(0.875); /* 6, but not 7 */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,1.2);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,1.2);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_UMP45, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,1.2);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,1.2);
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_ump45.fire");
|
||||
#endif
|
||||
Cstrike_ShotMultiplierAdd(pl, 1, .9);
|
||||
|
|
|
@ -135,7 +135,7 @@ w_usp45_primary(player pl)
|
|||
return;
|
||||
|
||||
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl,30,2);
|
||||
float accuracy = Cstrike_CalculateAccuracy(pl,40,2.2);
|
||||
int dmg = 0;
|
||||
pl.usp45_mag--;
|
||||
|
||||
|
@ -200,9 +200,9 @@ w_usp45_primary(player pl)
|
|||
dmg = Skill_GetValue("plr_usp45_dmg", 33);
|
||||
TraceAttack_SetRangeModifier(0.79); /* can penetrate 6 but not 7 units */
|
||||
TraceAttack_SetPenetrationPower(1);
|
||||
g_CstrikeBulletRecoil.ApplyPre(pl,0.625);
|
||||
Cstrike_BulletRecoil_ApplyPre(pl,0.625);
|
||||
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_USP45, "Impact.BigShot");
|
||||
g_CstrikeBulletRecoil.ApplyPost(pl,0.625);
|
||||
Cstrike_BulletRecoil_ApplyPost(pl,0.625);
|
||||
#endif
|
||||
Cstrike_ShotMultiplierAdd(pl, 10, 0.4);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Cstrike_CalculateMovementInaccuracy(player pl) {
|
|||
|
||||
/* called whenever a cstrike gun fires a successful shot */
|
||||
void
|
||||
Cstrike_ShotMultiplierAdd(player pl, int shots, float strength)
|
||||
Cstrike_ShotMultiplierAdd(player pl, float shots, float strength)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -74,7 +74,7 @@ Cstrike_ShotMultiplierAdd(player pl, int shots, float strength)
|
|||
}
|
||||
}
|
||||
if (autocvar_guns_random_recoil_direction == 1) {
|
||||
if (pseudorandom() > 0.83) {
|
||||
if (pseudorandom() > 0.82f) {
|
||||
pl.cs_hor_rec_sign = -pl.cs_hor_rec_sign;
|
||||
}
|
||||
} else {
|
||||
|
@ -86,8 +86,8 @@ Cstrike_ShotMultiplierAdd(player pl, int shots, float strength)
|
|||
= pl.cs_shotmultiplier
|
||||
+ 1.5
|
||||
+ shots
|
||||
+ pl.cs_shotmultiplier/5
|
||||
- pl.cs_shotmultiplier*pl.cs_shotmultiplier/90;
|
||||
+ pl.cs_shotmultiplier/6
|
||||
- pl.cs_shotmultiplier*pl.cs_shotmultiplier/100;
|
||||
pl.cs_shotmultiplier = bound(0, new_shotmultiplier, 30);
|
||||
float bound_shotmultiplier = bound(0, pl.cs_shotmultiplier, 12);
|
||||
pl.cs_shottime = 0.2f;
|
||||
|
@ -95,6 +95,12 @@ Cstrike_ShotMultiplierAdd(player pl, int shots, float strength)
|
|||
float movement_inaccuracy = bound(0.92,Cstrike_CalculateMovementInaccuracy(pl),1.25);
|
||||
pl.punchangle[0] = -(pl.cs_shotmultiplier)*0.3*movement_inaccuracy*strength+0.5;
|
||||
pl.punchangle[0] *= autocvar_guns_recoil_strength;
|
||||
if (pl.cs_shotmultiplier < 3) {
|
||||
//here we add extra punchangle for low multiplier values,
|
||||
//so that tapping has more weight to it.
|
||||
float extrapunch = bound(0.7f,shots,1.5);
|
||||
pl.punchangle[0] -= extrapunch;
|
||||
}
|
||||
float hor_recoil
|
||||
= pl.cs_shotmultiplier*0.005
|
||||
+ (pseudorandom() - 0.35)*0.75*autocvar_guns_firing_inaccuracy;
|
||||
|
@ -157,21 +163,19 @@ Cstrike_CalculateAccuracy(player pl, float divisor, float movement_penalty=1)
|
|||
}
|
||||
}
|
||||
|
||||
class CstrikeBulletRecoil {
|
||||
private:
|
||||
float m_flRandomSpread;
|
||||
public:
|
||||
void ApplyPre(player pl, float strength) {
|
||||
m_flRandomSpread = (pseudorandom() - 0.5) * 2.0;
|
||||
strength *= autocvar_guns_recoil_strength;
|
||||
pl.v_angle += strength*pl.punchangle*(2 + pl.cs_shotmultiplier/100*(m_flRandomSpread-0.5));
|
||||
};
|
||||
void ApplyPost(player pl, float strength) {
|
||||
strength *= autocvar_guns_recoil_strength;
|
||||
pl.v_angle -= strength*pl.punchangle*(2 + pl.cs_shotmultiplier/100*(m_flRandomSpread-0.5));
|
||||
};
|
||||
};
|
||||
CstrikeBulletRecoil g_CstrikeBulletRecoil;
|
||||
|
||||
void
|
||||
Cstrike_BulletRecoil_ApplyPre(player pl, float strength) {
|
||||
strength *= autocvar_guns_recoil_strength;
|
||||
pl.v_angle += strength*pl.punchangle*(2 - pl.cs_shotmultiplier/100*0.2);
|
||||
}
|
||||
void
|
||||
Cstrike_BulletRecoil_ApplyPost(player pl, float strength) {
|
||||
strength *= autocvar_guns_recoil_strength;
|
||||
pl.v_angle -= strength*pl.punchangle*(2 - pl.cs_shotmultiplier/100*0.2);
|
||||
}
|
||||
|
||||
|
||||
/* called whenever cstrike guns aren't firing */
|
||||
void
|
||||
Cstrike_ShotMultiplierUpdate(player pl)
|
||||
|
@ -187,5 +191,6 @@ void
|
|||
w_cstrike_weaponrelease(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
pl.punchangle[1] *= 0.95;
|
||||
Cstrike_ShotMultiplierUpdate(pl);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue