From f905511d9340c6e6935410c93a30af1ddaf4a442 Mon Sep 17 00:00:00 2001 From: mikota Date: Sat, 23 Sep 2023 17:05:57 +0200 Subject: [PATCH 1/2] Recoil rework v2 --- src/shared/player.h | 7 ++++- src/shared/w_ak47.qc | 8 ++--- src/shared/w_aug.qc | 4 +-- src/shared/w_awp.qc | 4 ++- src/shared/w_deagle.qc | 4 +-- src/shared/w_elites.qc | 2 +- src/shared/w_fiveseven.qc | 2 +- src/shared/w_g3sg1.qc | 3 +- src/shared/w_glock18.qc | 5 ++-- src/shared/w_m3.qc | 2 +- src/shared/w_m4a1.qc | 8 ++--- src/shared/w_mac10.qc | 8 ++--- src/shared/w_mp5.qc | 8 ++--- src/shared/w_p228.qc | 6 ++-- src/shared/w_p90.qc | 8 ++--- src/shared/w_para.qc | 8 +++-- src/shared/w_scout.qc | 4 ++- src/shared/w_sg550.qc | 3 +- src/shared/w_sg552.qc | 8 ++--- src/shared/w_tmp.qc | 4 +-- src/shared/w_ump45.qc | 2 +- src/shared/w_usp45.qc | 4 +-- src/shared/w_xm1014.qc | 2 +- src/shared/weapons_cstrike.qc | 56 ++++++++++++++++++++++------------- 24 files changed, 100 insertions(+), 70 deletions(-) diff --git a/src/shared/player.h b/src/shared/player.h index 3c44749..24664d8 100644 --- a/src/shared/player.h +++ b/src/shared/player.h @@ -158,6 +158,7 @@ class player:NSClientPlayer PREDICTED_FLOAT(cs_shottime) PREDICTED_FLOAT(cs_prev_hor_rec) PREDICTED_INT(cs_hor_rec_sign) + PREDICTED_FLOAT(cs_rec_reverse_chance) PREDICTED_FLOAT(anim_top) PREDICTED_FLOAT(anim_top_time) @@ -424,6 +425,7 @@ player::ReceiveEntity(float flIsNew, float flChanged) READENTITY_FLOAT(cs_shottime, PLAYER_CSTIMERS) READENTITY_FLOAT(cs_prev_hor_rec, PLAYER_CSTIMERS) READENTITY_BYTE(cs_hor_rec_sign, PLAYER_CSTIMERS) + READENTITY_FLOAT(cs_rec_reverse_chance, PLAYER_CSTIMERS) if (flChanged & PLAYER_AMMO1 || flChanged & PLAYER_AMMO2 || flChanged & PLAYER_AMMO3) { Weapons_AmmoUpdate(this); HUD_AmmoNotify_Check(this); @@ -488,6 +490,7 @@ player::PredictPreFrame(void) SAVE_STATE(cs_shottime) SAVE_STATE(cs_prev_hor_rec) SAVE_STATE(cs_hor_rec_sign) + SAVE_STATE(cs_rec_reverse_chance) SAVE_STATE(anim_top) SAVE_STATE(anim_top_time) SAVE_STATE(anim_top_delay) @@ -550,6 +553,7 @@ player::PredictPostFrame(void) ROLL_BACK(cs_shottime) ROLL_BACK(cs_prev_hor_rec) ROLL_BACK(cs_hor_rec_sign) + ROLL_BACK(cs_rec_reverse_chance) ROLL_BACK(anim_top) ROLL_BACK(anim_top_time) ROLL_BACK(anim_top_delay) @@ -617,6 +621,7 @@ player::EvaluateEntity(void) EVALUATE_FIELD(cs_shottime, PLAYER_CSTIMERS) EVALUATE_FIELD(cs_prev_hor_rec, PLAYER_CSTIMERS) EVALUATE_FIELD(cs_hor_rec_sign, PLAYER_CSTIMERS) + EVALUATE_FIELD(cs_rec_reverse_chance, PLAYER_CSTIMERS) } /* @@ -688,7 +693,7 @@ player::SendEntity(entity ePEnt, float flChanged) SENDENTITY_FLOAT(cs_shottime, PLAYER_CSTIMERS) SENDENTITY_FLOAT(cs_prev_hor_rec, PLAYER_CSTIMERS) SENDENTITY_BYTE(cs_hor_rec_sign, PLAYER_CSTIMERS) - + SENDENTITY_FLOAT(cs_rec_reverse_chance, PLAYER_CSTIMERS) return (1); } #endif diff --git a/src/shared/w_ak47.qc b/src/shared/w_ak47.qc index 2bb1c70..b90939f 100644 --- a/src/shared/w_ak47.qc +++ b/src/shared/w_ak47.qc @@ -153,7 +153,7 @@ w_ak47_primary(player pl) } - float accuracy = Cstrike_CalculateAccuracy(pl, 110,2.5); + float accuracy = Cstrike_CalculateAccuracy(pl, 30,3)/1.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); - Cstrike_BulletRecoil_ApplyPre(pl,1); + Cstrike_BulletRecoil_ApplyPre(pl,1.2); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_AK47, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,1); + Cstrike_BulletRecoil_ApplyPost(pl,1.2); Sound_Play(pl, CHAN_WEAPON, "weapon_ak47.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 1.5, 1.05); + Cstrike_ShotMultiplierAdd(pl, 1.1f, 0.92f,accuracy*0.5); pl.w_attack_next = 0.0975f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_aug.qc b/src/shared/w_aug.qc index e00359b..26bb74b 100644 --- a/src/shared/w_aug.qc +++ b/src/shared/w_aug.qc @@ -119,7 +119,7 @@ w_aug_primary(player pl) } - float accuracy = Cstrike_CalculateAccuracy(pl, 45,3)*pl.viewzoom; + float accuracy = Cstrike_CalculateAccuracy(pl, 35,2); pl.aug_mag--; int r = (float)input_sequence % 3; @@ -153,7 +153,7 @@ w_aug_primary(player pl) Sound_Play(pl, CHAN_WEAPON, "weapon_aug.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 0.7f, 1.1f); + Cstrike_ShotMultiplierAdd(pl, 0.7f, 1.1f,accuracy); if (pl.viewzoom == 1.0f) { pl.w_attack_next = 0.0825f; } else { diff --git a/src/shared/w_awp.qc b/src/shared/w_awp.qc index e3412c0..32b5349 100644 --- a/src/shared/w_awp.qc +++ b/src/shared/w_awp.qc @@ -209,8 +209,9 @@ w_awp_primary(player pl) return; } - Cstrike_ShotMultiplierAdd(pl, 1, 1); + float accuracy = Cstrike_CalculateAccuracy(pl, -1); + pl.awp_mag--; int r = (float)input_sequence % 3; @@ -243,6 +244,7 @@ w_awp_primary(player pl) Sound_Play(pl, CHAN_WEAPON, "weapon_awp.fire"); #endif + Cstrike_ShotMultiplierAdd(pl, 1, 1,accuracy); pl.w_attack_next = 1.2f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_deagle.qc b/src/shared/w_deagle.qc index 17515d2..afcd787 100644 --- a/src/shared/w_deagle.qc +++ b/src/shared/w_deagle.qc @@ -150,7 +150,7 @@ w_deagle_primary(player pl) return; - float accuracy = Cstrike_CalculateAccuracy(pl, 25,2.2)+0.005; + float accuracy = Cstrike_CalculateAccuracy(pl, 55,1.5)+0.005; int dmg; pl.deagle_mag--; @@ -186,7 +186,7 @@ w_deagle_primary(player pl) Sound_Play(pl, CHAN_WEAPON, "weapon_deagle.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 20, .25); + Cstrike_ShotMultiplierAdd(pl, 10, .35,accuracy*0.5); pl.gflags |= GF_SEMI_TOGGLED; pl.w_attack_next = 0.2f; pl.w_idle_next = pl.w_attack_next; diff --git a/src/shared/w_elites.qc b/src/shared/w_elites.qc index 08620cc..9cc8100 100644 --- a/src/shared/w_elites.qc +++ b/src/shared/w_elites.qc @@ -257,7 +257,7 @@ w_elites_primary(player pl) Cstrike_BulletRecoil_ApplyPost(pl,.9f); Sound_Play(pl, CHAN_WEAPON, "weapon_elites.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 3, .85); + Cstrike_ShotMultiplierAdd(pl, 3, .85,accuracy); pl.gflags |= GF_SEMI_TOGGLED; pl.w_attack_next = 0.13f; pl.w_idle_next = pl.w_attack_next; diff --git a/src/shared/w_fiveseven.qc b/src/shared/w_fiveseven.qc index ae5d312..c3846f2 100644 --- a/src/shared/w_fiveseven.qc +++ b/src/shared/w_fiveseven.qc @@ -156,7 +156,7 @@ w_fiveseven_primary(player pl) Cstrike_BulletRecoil_ApplyPost(pl,0.5f); Sound_Play(pl, CHAN_WEAPON, "weapon_fiveseven.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 10, .4); + Cstrike_ShotMultiplierAdd(pl, 10, .4,accuracy); pl.gflags |= GF_SEMI_TOGGLED; pl.w_attack_next = 0.155f; pl.w_idle_next = pl.w_attack_next; diff --git a/src/shared/w_g3sg1.qc b/src/shared/w_g3sg1.qc index 5473ccc..855d165 100644 --- a/src/shared/w_g3sg1.qc +++ b/src/shared/w_g3sg1.qc @@ -116,8 +116,9 @@ w_g3sg1_primary(player pl) return; } - Cstrike_ShotMultiplierAdd(pl, 1, 1); + float accuracy = Cstrike_CalculateAccuracy(pl, 200); + Cstrike_ShotMultiplierAdd(pl, 1, 1,accuracy); pl.g3sg1_mag--; int r = (float)input_sequence % 2; diff --git a/src/shared/w_glock18.qc b/src/shared/w_glock18.qc index 9b2dc17..a4caf7d 100644 --- a/src/shared/w_glock18.qc +++ b/src/shared/w_glock18.qc @@ -134,6 +134,7 @@ w_glock18_primary(player pl) if (!pl.glock18_mag) return; + float accuracy = Cstrike_CalculateAccuracy(pl, (pl.mode_glock18) ? 75 : 120,1.2); int shotcount = (pl.mode_glock18) ? 3 : 1; int dmg = 0; @@ -143,7 +144,7 @@ w_glock18_primary(player pl) for (int i = 0; i < shotcount; i ++) { - float accuracy = Cstrike_CalculateAccuracy(pl, (pl.mode_glock18) ? 75 : 120,1.2); + accuracy += 0.0035; pl.glock18_mag--; #ifdef SERVER @@ -192,7 +193,7 @@ w_glock18_primary(player pl) } #endif - Cstrike_ShotMultiplierAdd(pl, 2, .7); + Cstrike_ShotMultiplierAdd(pl, 2, .7,accuracy); pl.gflags |= GF_SEMI_TOGGLED; pl.w_idle_next = pl.w_attack_next + 1.0f; } diff --git a/src/shared/w_m3.qc b/src/shared/w_m3.qc index ac69846..b80e23a 100644 --- a/src/shared/w_m3.qc +++ b/src/shared/w_m3.qc @@ -206,7 +206,7 @@ w_m3_primary(player pl) #endif for (int i = 0; i < 9; i++) { - Cstrike_ShotMultiplierAdd(pl, 1, 1); + Cstrike_ShotMultiplierAdd(pl, 1, 1,1); pl.punchangle[0] = -4 * (9 / 6); #ifdef SERVER TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [random(-1,1) * 0.1,random(-1,1) * 0.05], WEAPON_M3, "Impact.BigShot"); diff --git a/src/shared/w_m4a1.qc b/src/shared/w_m4a1.qc index a1931a5..0935124 100644 --- a/src/shared/w_m4a1.qc +++ b/src/shared/w_m4a1.qc @@ -134,7 +134,7 @@ w_m4a1_primary(player pl) } - float accuracy = Cstrike_CalculateAccuracy(pl, 150, 3); + float accuracy = Cstrike_CalculateAccuracy(pl, 60, 3); // accuracy += pl.cs_shotmultiplier*pl.cs_shotmultiplier / 500; pl.m4a1_mag--; @@ -189,12 +189,12 @@ w_m4a1_primary(player pl) dmg = Skill_GetValue("plr_m4a1_dmg", 33); TraceAttack_SetRangeModifier(2.125); TraceAttack_SetPenetrationPower(1); - Cstrike_BulletRecoil_ApplyPre(pl,1); + Cstrike_BulletRecoil_ApplyPre(pl,.96f); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_M4A1, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,1); + Cstrike_BulletRecoil_ApplyPost(pl,.96f); #endif - Cstrike_ShotMultiplierAdd(pl, 1, 1); + Cstrike_ShotMultiplierAdd(pl, 0.8f, 1.025f,accuracy*0.8); pl.w_attack_next = 0.0875f; pl.w_idle_next = 2.0f; } diff --git a/src/shared/w_mac10.qc b/src/shared/w_mac10.qc index a0a6246..c0b77eb 100644 --- a/src/shared/w_mac10.qc +++ b/src/shared/w_mac10.qc @@ -118,7 +118,7 @@ w_mac10_primary(player pl) } - float accuracy = Cstrike_CalculateAccuracy(pl, 80,0.7)+0.009f; + float accuracy = Cstrike_CalculateAccuracy(pl, 50,0.8)+0.0095f; pl.mac10_mag--; int r = (float)input_sequence % 3; @@ -146,13 +146,13 @@ w_mac10_primary(player pl) dmg = Skill_GetValue("plr_mac10_dmg", 29); TraceAttack_SetRangeModifier(1.25); /* 9, but not 10 */ TraceAttack_SetPenetrationPower(1); - Cstrike_BulletRecoil_ApplyPre(pl,1.125); + Cstrike_BulletRecoil_ApplyPre(pl,1.115); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_MAC10, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,1.125); + Cstrike_BulletRecoil_ApplyPost(pl,1.115); Sound_Play(pl, CHAN_WEAPON, "weapon_mac10.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, .8, .9); + Cstrike_ShotMultiplierAdd(pl, 2, 0.7f,accuracy); pl.w_attack_next = 0.07f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_mp5.qc b/src/shared/w_mp5.qc index e292354..cf23da4 100644 --- a/src/shared/w_mp5.qc +++ b/src/shared/w_mp5.qc @@ -116,7 +116,7 @@ w_mp5_primary(player pl) return; - float accuracy = Cstrike_CalculateAccuracy(pl,100,1)+0.004f; + float accuracy = Cstrike_CalculateAccuracy(pl,60,1.25)+0.0045f; pl.mp5_mag--; int r = (float)input_sequence % 3; @@ -144,13 +144,13 @@ w_mp5_primary(player pl) dmg = Skill_GetValue("plr_mp5_dmg", 26); TraceAttack_SetRangeModifier(1.25); /* 9 units but not 10 */ TraceAttack_SetPenetrationPower(1); - Cstrike_BulletRecoil_ApplyPre(pl,.7f); + Cstrike_BulletRecoil_ApplyPre(pl,.825f); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_MP5, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,.7f); + Cstrike_BulletRecoil_ApplyPost(pl,.825f); Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, .5f, 1.5f); + Cstrike_ShotMultiplierAdd(pl, .5f, 1.25f,accuracy); pl.w_attack_next = 0.08f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_p228.qc b/src/shared/w_p228.qc index 3f4aa79..c673067 100644 --- a/src/shared/w_p228.qc +++ b/src/shared/w_p228.qc @@ -151,12 +151,12 @@ 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); - Cstrike_BulletRecoil_ApplyPre(pl,1.2); + Cstrike_BulletRecoil_ApplyPre(pl,1.05); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_P228, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,1.2); + Cstrike_BulletRecoil_ApplyPost(pl,1.05); Sound_Play(pl, CHAN_WEAPON, "weapon_p228.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 6, 0.5f); + Cstrike_ShotMultiplierAdd(pl, 6, 0.5f,accuracy); pl.gflags |= GF_SEMI_TOGGLED; pl.w_attack_next = 0.1425f; diff --git a/src/shared/w_p90.qc b/src/shared/w_p90.qc index 7953eeb..c32e624 100644 --- a/src/shared/w_p90.qc +++ b/src/shared/w_p90.qc @@ -116,7 +116,7 @@ w_p90_primary(player pl) return; - float accuracy = Cstrike_CalculateAccuracy(pl, 50,1)+0.0055; + float accuracy = Cstrike_CalculateAccuracy(pl, 50,1.125)+0.0055; pl.p90_mag--; int r = (float)input_sequence % 3; @@ -144,13 +144,13 @@ w_p90_primary(player pl) dmg = Skill_GetValue("plr_p90_dmg", 26); TraceAttack_SetRangeModifier(1.875); /* 9 but not 10 */ TraceAttack_SetPenetrationPower(1); - Cstrike_BulletRecoil_ApplyPre(pl,1); + Cstrike_BulletRecoil_ApplyPre(pl,.9); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_P90, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,1); + Cstrike_BulletRecoil_ApplyPost(pl,.9); Sound_Play(pl, CHAN_WEAPON, "weapon_p90.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 1.1, 1.1); + Cstrike_ShotMultiplierAdd(pl, 1.1, 1.3,accuracy); pl.w_attack_next = 0.07f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_para.qc b/src/shared/w_para.qc index 5313e88..8bf132d 100644 --- a/src/shared/w_para.qc +++ b/src/shared/w_para.qc @@ -114,8 +114,9 @@ w_para_primary(player pl) if (!pl.para_mag) return; - Cstrike_ShotMultiplierAdd(pl, 1, 1); - float accuracy = Cstrike_CalculateAccuracy(pl, 175); + + float accuracy = Cstrike_CalculateAccuracy(pl, 70); + pl.para_mag--; int r = (float)input_sequence % 2; @@ -140,10 +141,13 @@ w_para_primary(player pl) dmg = Skill_GetValue("plr_para_dmg", 35); TraceAttack_SetRangeModifier(2.125); TraceAttack_SetPenetrationPower(1); + Cstrike_BulletRecoil_ApplyPost(pl,1); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_PARA, "Impact.BigShot"); + Cstrike_BulletRecoil_ApplyPost(pl,1); Sound_Play(pl, CHAN_WEAPON, "weapon_para.fire"); #endif + Cstrike_ShotMultiplierAdd(pl, 1, 1,accuracy); pl.w_attack_next = 0.1f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_scout.qc b/src/shared/w_scout.qc index 4744dbf..ce38c3a 100644 --- a/src/shared/w_scout.qc +++ b/src/shared/w_scout.qc @@ -174,8 +174,9 @@ w_scout_primary(player pl) return; } - Cstrike_ShotMultiplierAdd(pl, 1, 1); + float accuracy = Cstrike_CalculateAccuracy(pl, 200); + pl.scout_mag--; int r = (float)input_sequence % 2; @@ -204,6 +205,7 @@ w_scout_primary(player pl) Sound_Play(pl, CHAN_WEAPON, "weapon_scout.fire"); #endif + Cstrike_ShotMultiplierAdd(pl, 1, 1,accuracy); pl.w_attack_next = 1.25f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_sg550.qc b/src/shared/w_sg550.qc index 29fe8ce..0b4ec25 100644 --- a/src/shared/w_sg550.qc +++ b/src/shared/w_sg550.qc @@ -114,8 +114,9 @@ w_sg550_primary(player pl) if (!pl.sg550_mag) return; - Cstrike_ShotMultiplierAdd(pl, 1, 1); + float accuracy = Cstrike_CalculateAccuracy(pl, 200); + Cstrike_ShotMultiplierAdd(pl, 1, 1,accuracy); pl.sg550_mag--; int r = (float)input_sequence % 2; diff --git a/src/shared/w_sg552.qc b/src/shared/w_sg552.qc index 747c9ee..03c084a 100644 --- a/src/shared/w_sg552.qc +++ b/src/shared/w_sg552.qc @@ -116,7 +116,7 @@ w_sg552_primary(player pl) return; - float accuracy = Cstrike_CalculateAccuracy(pl, 80,3)*pl.viewzoom; + float accuracy = Cstrike_CalculateAccuracy(pl, 75,3)*pl.viewzoom; pl.sg552_mag--; int r = (float)input_sequence % 3; @@ -144,13 +144,13 @@ w_sg552_primary(player pl) dmg = Skill_GetValue("plr_sg552_dmg", 33); TraceAttack_SetRangeModifier(2.125); TraceAttack_SetPenetrationPower(1); - Cstrike_BulletRecoil_ApplyPre(pl,1); + Cstrike_BulletRecoil_ApplyPre(pl,0.726f); TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_SG552, "Impact.BigShot"); - Cstrike_BulletRecoil_ApplyPost(pl,1); + Cstrike_BulletRecoil_ApplyPost(pl,0.725f); Sound_Play(pl, CHAN_WEAPON, "weapon_sg552.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 2.2, 0.9); + Cstrike_ShotMultiplierAdd(pl, 2.2, 0.9,accuracy); if (pl.viewzoom == 1.0f) pl.w_attack_next = 0.0825f; else diff --git a/src/shared/w_tmp.qc b/src/shared/w_tmp.qc index fa1a21d..e71ab2b 100644 --- a/src/shared/w_tmp.qc +++ b/src/shared/w_tmp.qc @@ -116,7 +116,7 @@ w_tmp_primary(player pl) return; - float accuracy = Cstrike_CalculateAccuracy(pl, 30,0.8)+0.0035; + float accuracy = Cstrike_CalculateAccuracy(pl, 30,0.95)+0.0035; pl.tmp_mag--; int r = (float)input_sequence % 3; @@ -150,7 +150,7 @@ w_tmp_primary(player pl) Sound_Play(pl, CHAN_WEAPON, "weapon_tmp.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 0.85, 1.25); + Cstrike_ShotMultiplierAdd(pl, 0.95, 1.25,accuracy); pl.w_attack_next = 0.07f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_ump45.qc b/src/shared/w_ump45.qc index c620621..38469b8 100644 --- a/src/shared/w_ump45.qc +++ b/src/shared/w_ump45.qc @@ -149,7 +149,7 @@ w_ump45_primary(player pl) Cstrike_BulletRecoil_ApplyPost(pl,1.2); Sound_Play(pl, CHAN_WEAPON, "weapon_ump45.fire"); #endif - Cstrike_ShotMultiplierAdd(pl, 1, .9); + Cstrike_ShotMultiplierAdd(pl, 1, .9,accuracy); pl.w_attack_next = 0.105f; pl.w_idle_next = pl.w_attack_next; } diff --git a/src/shared/w_usp45.qc b/src/shared/w_usp45.qc index 2c4552a..92d73ca 100644 --- a/src/shared/w_usp45.qc +++ b/src/shared/w_usp45.qc @@ -135,7 +135,7 @@ w_usp45_primary(player pl) return; - float accuracy = Cstrike_CalculateAccuracy(pl,40,2.2); + float accuracy = Cstrike_CalculateAccuracy(pl,25,2.2); int dmg = 0; pl.usp45_mag--; @@ -204,7 +204,7 @@ w_usp45_primary(player pl) TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_USP45, "Impact.BigShot"); Cstrike_BulletRecoil_ApplyPost(pl,0.625); #endif - Cstrike_ShotMultiplierAdd(pl, 10, 0.4); + Cstrike_ShotMultiplierAdd(pl, 2.5, .5,accuracy*0.5); pl.gflags |= GF_SEMI_TOGGLED; pl.w_attack_next = 0.15f; diff --git a/src/shared/w_xm1014.qc b/src/shared/w_xm1014.qc index 75b36f3..7c4a436 100644 --- a/src/shared/w_xm1014.qc +++ b/src/shared/w_xm1014.qc @@ -206,7 +206,7 @@ w_xm1014_primary(player pl) #endif for (int i = 0; i < 6; i++) { - Cstrike_ShotMultiplierAdd(pl, 1, 1); + Cstrike_ShotMultiplierAdd(pl, 1, 1,1); pl.punchangle[0] = -4 * (6 / 6); #ifdef SERVER TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [random(-1,1) * 0.1,random(-1,1) * 0.05], WEAPON_M3, "Impact.BigShot"); diff --git a/src/shared/weapons_cstrike.qc b/src/shared/weapons_cstrike.qc index a54d37c..ac7ea2a 100644 --- a/src/shared/weapons_cstrike.qc +++ b/src/shared/weapons_cstrike.qc @@ -48,34 +48,47 @@ csweapon_melee_type(player pl) float Cstrike_CalculateMovementInaccuracy(player pl) { float m = 1.0f; - + float maxspeed = 250; + float speedlimit_low = maxspeed/3; + float speedlimit_high = maxspeed/2; + float current_speed = vlen(pl.velocity); + if (current_speed > speedlimit_low) { + if (current_speed > speedlimit_high) { + m = 2.25f; + } else { + m = 1.0f + (current_speed - speedlimit_low)/(speedlimit_high - speedlimit_low); + } + } if (!(pl.flags & FL_ONGROUND)) { m = 2.5f; - } else if (pl.flags & FL_CROUCHING) { - m = 0.75f; - } else if (vlen(pl.velocity) > 120) { - m = 2.25f; + }else if (pl.flags & FL_CROUCHING) { + m *= 0.6f; } - - return m; + return bound(0.75f,m,2.5f); } /* called whenever a cstrike gun fires a successful shot */ void -Cstrike_ShotMultiplierAdd(player pl, float shots, float strength) +Cstrike_ShotMultiplierAdd(player pl, float shots, float strength, float inaccuracy) { int r; - + inaccuracy = bound(.95,inaccuracy*50+0.1,1.6); if (pl.cs_shotmultiplier < 1.6) { + pl.cs_rec_reverse_chance = 0.95f; pl.cs_prev_hor_rec = 0; pl.cs_hor_rec_sign = 1; if (autocvar_guns_random_recoil_direction && pseudorandom() >= 0.5) { pl.cs_hor_rec_sign = -1; } } + pl.cs_rec_reverse_chance -= 0.02f; + if (pl.cs_rec_reverse_chance < 0.1f) { + pl.cs_rec_reverse_chance = 0.1f; + } if (autocvar_guns_random_recoil_direction == 1) { - if (pseudorandom() > 0.82f) { + if (pseudorandom() > pl.cs_rec_reverse_chance) { pl.cs_hor_rec_sign = -pl.cs_hor_rec_sign; + pl.cs_rec_reverse_chance = 0.92f; } } else { if ( pl.cs_shotmultiplier > 9) { @@ -84,28 +97,29 @@ Cstrike_ShotMultiplierAdd(player pl, float shots, float strength) } float new_shotmultiplier = pl.cs_shotmultiplier - + 1.5 + + 1.3 + shots - + pl.cs_shotmultiplier/6 - - pl.cs_shotmultiplier*pl.cs_shotmultiplier/100; + + pl.cs_shotmultiplier/12*(.85+inaccuracy/11) + - pl.cs_shotmultiplier*pl.cs_shotmultiplier/100*(.95+inaccuracy/10); pl.cs_shotmultiplier = bound(0, new_shotmultiplier, 30); float bound_shotmultiplier = bound(0, pl.cs_shotmultiplier, 12); pl.cs_shottime = 0.2f; 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] = -(pl.cs_shotmultiplier)*0.35*(strength*0.9+inaccuracy/9)+0.5; + pl.punchangle[0] -= autocvar_guns_firing_inaccuracy * (1 + 3*inaccuracy * inaccuracy)/19; pl.punchangle[0] *= autocvar_guns_recoil_strength; - if (pl.cs_shotmultiplier < 3) { + if (pl.cs_shotmultiplier < 5) { //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); + float extrapunch = bound(0.6f,shots*strength,0.8f); pl.punchangle[0] -= extrapunch; } float hor_recoil - = pl.cs_shotmultiplier*0.005 - + (pseudorandom() - 0.35)*0.75*autocvar_guns_firing_inaccuracy; + = pl.cs_shotmultiplier/185*(1 + (pseudorandom() - 0.5)/3) + + (pseudorandom() - 0.3)*inaccuracy*inaccuracy*0.5*autocvar_guns_firing_inaccuracy; - hor_recoil *= movement_inaccuracy * strength * autocvar_guns_recoil_strength; + hor_recoil *= 1.2 * movement_inaccuracy * strength * autocvar_guns_recoil_strength; if (pl.cs_hor_rec_sign > 0) { pl.cs_prev_hor_rec += hor_recoil; @@ -151,8 +165,8 @@ Cstrike_CalculateAccuracy(player pl, float divisor, float movement_penalty=1) /* snipers shoot way less accurate overall. */ return (pl.viewzoom < 1.0f) ? (0.0f) : (0.05 * m); } else { - inacc = pl.cs_shotmultiplier*pl.cs_shotmultiplier * autocvar_guns_firing_inaccuracy; - inacc = inacc / divisor / 1000; + inacc = pl.cs_shotmultiplier*(1.25 + pl.cs_shotmultiplier*pl.cs_shotmultiplier*0.3) * autocvar_guns_firing_inaccuracy; + inacc = inacc / divisor / 3100; inacc = inacc * m; if (m > 1) { inacc += m * 0.0025*movement_penalty * autocvar_guns_movement_inaccuracy; From ab4b1922a259c6e22585c85b78939a361cbd12d5 Mon Sep 17 00:00:00 2001 From: mikota Date: Sat, 23 Sep 2023 17:37:54 +0200 Subject: [PATCH 2/2] add FCS prefix to guns cvars --- src/shared/weapons_cstrike.qc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/shared/weapons_cstrike.qc b/src/shared/weapons_cstrike.qc index fd6883d..abbc00c 100644 --- a/src/shared/weapons_cstrike.qc +++ b/src/shared/weapons_cstrike.qc @@ -28,10 +28,10 @@ * to other weapons. */ -var float autocvar_guns_recoil_strength = 1.0f; -var bool autocvar_guns_random_recoil_direction = TRUE; -var float autocvar_guns_movement_inaccuracy = 1.0f; -var float autocvar_guns_firing_inaccuracy = 1.0f; +var float autocvar_fcs_guns_recoil_strength = 1.0f; +var bool autocvar_fcs_guns_random_recoil_direction = TRUE; +var float autocvar_fcs_guns_movement_inaccuracy = 1.0f; +var float autocvar_fcs_guns_firing_inaccuracy = 1.0f; weapontype_t csweapon_ranged_type(player pl) @@ -77,7 +77,7 @@ Cstrike_ShotMultiplierAdd(player pl, float shots, float strength, float inaccura pl.cs_rec_reverse_chance = 0.95f; pl.cs_prev_hor_rec = 0; pl.cs_hor_rec_sign = 1; - if (autocvar_guns_random_recoil_direction && pseudorandom() >= 0.5) { + if (autocvar_fcs_guns_random_recoil_direction && pseudorandom() >= 0.5) { pl.cs_hor_rec_sign = -1; } } @@ -85,7 +85,7 @@ Cstrike_ShotMultiplierAdd(player pl, float shots, float strength, float inaccura if (pl.cs_rec_reverse_chance < 0.1f) { pl.cs_rec_reverse_chance = 0.1f; } - if (autocvar_guns_random_recoil_direction == 1) { + if (autocvar_fcs_guns_random_recoil_direction == 1) { if (pseudorandom() > pl.cs_rec_reverse_chance) { pl.cs_hor_rec_sign = -pl.cs_hor_rec_sign; pl.cs_rec_reverse_chance = 0.92f; @@ -107,8 +107,8 @@ Cstrike_ShotMultiplierAdd(player pl, float shots, float strength, float inaccura float movement_inaccuracy = bound(0.92,Cstrike_CalculateMovementInaccuracy(pl),1.25); pl.punchangle[0] = -(pl.cs_shotmultiplier)*0.35*(strength*0.9+inaccuracy/9)+0.5; - pl.punchangle[0] -= autocvar_guns_firing_inaccuracy * (1 + 3*inaccuracy * inaccuracy)/19; - pl.punchangle[0] *= autocvar_guns_recoil_strength; + pl.punchangle[0] -= autocvar_fcs_guns_firing_inaccuracy * (1 + 3*inaccuracy * inaccuracy)/19; + pl.punchangle[0] *= autocvar_fcs_guns_recoil_strength; if (pl.cs_shotmultiplier < 5) { //here we add extra punchangle for low multiplier values, //so that tapping has more weight to it. @@ -117,9 +117,9 @@ Cstrike_ShotMultiplierAdd(player pl, float shots, float strength, float inaccura } float hor_recoil = pl.cs_shotmultiplier/185*(1 + (pseudorandom() - 0.5)/3) - + (pseudorandom() - 0.3)*inaccuracy*inaccuracy*0.5*autocvar_guns_firing_inaccuracy; + + (pseudorandom() - 0.3)*inaccuracy*inaccuracy*0.5*autocvar_fcs_guns_firing_inaccuracy; - hor_recoil *= 1.2 * movement_inaccuracy * strength * autocvar_guns_recoil_strength; + hor_recoil *= 1.2 * movement_inaccuracy * strength * autocvar_fcs_guns_recoil_strength; if (pl.cs_hor_rec_sign > 0) { pl.cs_prev_hor_rec += hor_recoil; @@ -165,11 +165,11 @@ Cstrike_CalculateAccuracy(player pl, float divisor, float movement_penalty=1) /* snipers shoot way less accurate overall. */ return (pl.viewzoom < 1.0f) ? (0.0f) : (0.05 * m); } else { - inacc = pl.cs_shotmultiplier*(1.25 + pl.cs_shotmultiplier*pl.cs_shotmultiplier*0.3) * autocvar_guns_firing_inaccuracy; + inacc = pl.cs_shotmultiplier*(1.25 + pl.cs_shotmultiplier*pl.cs_shotmultiplier*0.3) * autocvar_fcs_guns_firing_inaccuracy; inacc = inacc / divisor / 3100; inacc = inacc * m; if (m > 1) { - inacc += m * 0.0025*movement_penalty * autocvar_guns_movement_inaccuracy; + inacc += m * 0.0025*movement_penalty * autocvar_fcs_guns_movement_inaccuracy; } else { inacc += m * 0.0025; } @@ -180,12 +180,12 @@ Cstrike_CalculateAccuracy(player pl, float divisor, float movement_penalty=1) void Cstrike_BulletRecoil_ApplyPre(player pl, float strength) { - strength *= autocvar_guns_recoil_strength; + strength *= autocvar_fcs_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; + strength *= autocvar_fcs_guns_recoil_strength; pl.v_angle -= strength*pl.punchangle*(2 - pl.cs_shotmultiplier/100*0.2); }