diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 9f1765418..9a3d8e0c0 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -724,6 +724,41 @@ LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayerWeapon, KickBack, (float up_base, float la void EXT_FUNC CBasePlayerWeapon::__API_HOOK(KickBack)(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change) { +#ifdef REGAMEDLL_ADD + real_t flKickUp = up_base; + float flKickLateral = lateral_base; + + if (m_iShotsFired > 1) // consider == 0 case + { + flKickUp += m_iShotsFired * up_modifier; + flKickLateral += m_iShotsFired * lateral_modifier; + } + + if (up_max == 0.0f) // boundaryless vertical kick + { + m_pPlayer->pev->punchangle.x -= flKickUp; + } + else if (m_pPlayer->pev->punchangle.x > -up_max) // do not kick when already out of boundaries + { + m_pPlayer->pev->punchangle.x = Q_max(m_pPlayer->pev->punchangle.x - flKickUp, -up_max); + } + + if (lateral_max == 0.0f) // boundaryless horizontal kick + { + m_pPlayer->pev->punchangle.y += flKickLateral * (m_iDirection * 2 - 1); + } + else if (Q_fabs(m_pPlayer->pev->punchangle.y) < lateral_max) // do not kick when already out of boundaries + { + m_pPlayer->pev->punchangle.y = (m_iDirection == 1) ? + Q_min(m_pPlayer->pev->punchangle.y + flKickLateral, lateral_max) : + Q_max(m_pPlayer->pev->punchangle.y - flKickLateral, -lateral_max); + } + + if (direction_change > 0 && !RANDOM_LONG(0, direction_change)) // be sure to not waste RNG consumption + { + m_iDirection = !m_iDirection; + } +#else real_t flKickUp; float flKickLateral; @@ -764,6 +799,7 @@ void EXT_FUNC CBasePlayerWeapon::__API_HOOK(KickBack)(float up_base, float later { m_iDirection = !m_iDirection; } +#endif } void CBasePlayerWeapon::FireRemaining(int &shotsFired, float &shootTime, BOOL bIsGlock) diff --git a/regamedll/dlls/wpn_shared/wpn_awp.cpp b/regamedll/dlls/wpn_shared/wpn_awp.cpp index 0e31bd548..3cf4e437e 100644 --- a/regamedll/dlls/wpn_shared/wpn_awp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_awp.cpp @@ -189,7 +189,11 @@ void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2.0f; +#endif } void CAWP::Reload() diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index 7dbed0c6b..e9bbc7132 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -177,7 +177,11 @@ void CDEAGLE::DEAGLEFire(float flSpread, float flCycleTime, BOOL fUseSemi) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2; +#endif ResetPlayerShieldAnim(); } diff --git a/regamedll/dlls/wpn_shared/wpn_elite.cpp b/regamedll/dlls/wpn_shared/wpn_elite.cpp index 05428d8ed..845b5f278 100644 --- a/regamedll/dlls/wpn_shared/wpn_elite.cpp +++ b/regamedll/dlls/wpn_shared/wpn_elite.cpp @@ -200,7 +200,11 @@ void CELITE::ELITEFire(float flSpread, float flCycleTime, BOOL fUseSemi) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2.0f; +#endif } void CELITE::Reload() diff --git a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp index 31f211f08..4f07b840e 100644 --- a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp +++ b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp @@ -176,7 +176,11 @@ void CFiveSeven::FiveSevenFire(float flSpread, float flCycleTime, BOOL fUseSemi) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2.0f; +#endif ResetPlayerShieldAnim(); } diff --git a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp index 5351d0f78..b7e36b09f 100644 --- a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp @@ -185,8 +185,15 @@ void CG3SG1::G3SG1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; +#ifdef REGAMEDLL_ADD + m_iDirection = 1; // force positive Y addition + KickBack(UTIL_SharedRandomFloat(m_pPlayer->random_seed + 4, 0.75, 1.75) + m_pPlayer->pev->punchangle.x * 0.25f, + UTIL_SharedRandomFloat(m_pPlayer->random_seed + 5, -0.75, 0.75), + 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomFloat(m_pPlayer->random_seed + 4, 0.75, 1.75) + m_pPlayer->pev->punchangle.x * 0.25f; m_pPlayer->pev->punchangle.y += UTIL_SharedRandomFloat(m_pPlayer->random_seed + 5, -0.75, 0.75); +#endif } void CG3SG1::Reload() diff --git a/regamedll/dlls/wpn_shared/wpn_glock18.cpp b/regamedll/dlls/wpn_shared/wpn_glock18.cpp index c2f5399d5..b879ef858 100644 --- a/regamedll/dlls/wpn_shared/wpn_glock18.cpp +++ b/regamedll/dlls/wpn_shared/wpn_glock18.cpp @@ -253,6 +253,9 @@ void CGLOCK18::GLOCK18Fire(float flSpread, float flCycleTime, BOOL bFireBurst) m_flGlock18Shoot = gpGlobals->time + 0.1f; } +#ifdef REGAMEDLL_ADD + KickBack(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); // dummy call, API useful +#endif ResetPlayerShieldAnim(); } diff --git a/regamedll/dlls/wpn_shared/wpn_m3.cpp b/regamedll/dlls/wpn_shared/wpn_m3.cpp index 3251ae9a1..64ad7c5f0 100644 --- a/regamedll/dlls/wpn_shared/wpn_m3.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m3.cpp @@ -167,10 +167,17 @@ void CM3::PrimaryAttack() m_fInSpecialReload = 0; +#ifdef REGAMEDLL_ADD + if (m_pPlayer->pev->flags & FL_ONGROUND) + KickBack(UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 4, 6), 0.0, 0.0, 0.0, 0.0, 0.0, 0); + else + KickBack(UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 8, 11), 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else if (m_pPlayer->pev->flags & FL_ONGROUND) m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 4, 6); else m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 8, 11); +#endif m_pPlayer->m_flEjectBrass = gpGlobals->time + 0.45f; } diff --git a/regamedll/dlls/wpn_shared/wpn_p228.cpp b/regamedll/dlls/wpn_shared/wpn_p228.cpp index b64f5fcf3..1343671cb 100644 --- a/regamedll/dlls/wpn_shared/wpn_p228.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p228.cpp @@ -176,7 +176,11 @@ void CP228::P228Fire(float flSpread, float flCycleTime, BOOL fUseSemi) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2; +#endif ResetPlayerShieldAnim(); } diff --git a/regamedll/dlls/wpn_shared/wpn_scout.cpp b/regamedll/dlls/wpn_shared/wpn_scout.cpp index fd9456624..ec7c1a196 100644 --- a/regamedll/dlls/wpn_shared/wpn_scout.cpp +++ b/regamedll/dlls/wpn_shared/wpn_scout.cpp @@ -181,7 +181,11 @@ void CSCOUT::SCOUTFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2.0f; +#endif } void CSCOUT::Reload() diff --git a/regamedll/dlls/wpn_shared/wpn_sg550.cpp b/regamedll/dlls/wpn_shared/wpn_sg550.cpp index 8263e98a8..efad9e082 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg550.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg550.cpp @@ -188,8 +188,15 @@ void CSG550::SG550Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; +#ifdef REGAMEDLL_ADD + m_iDirection = 1; // force positive Y addition + KickBack(UTIL_SharedRandomFloat(m_pPlayer->random_seed + 4, 0.75, 1.75) + m_pPlayer->pev->punchangle.x * 0.25, + UTIL_SharedRandomFloat(m_pPlayer->random_seed + 5, -0.75, 0.75), + 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomFloat(m_pPlayer->random_seed + 4, 0.75, 1.25) + m_pPlayer->pev->punchangle.x * 0.25; m_pPlayer->pev->punchangle.y += UTIL_SharedRandomFloat(m_pPlayer->random_seed + 5, -0.75, 0.75); +#endif } void CSG550::Reload() diff --git a/regamedll/dlls/wpn_shared/wpn_usp.cpp b/regamedll/dlls/wpn_shared/wpn_usp.cpp index 0d830d690..5a474f652 100644 --- a/regamedll/dlls/wpn_shared/wpn_usp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_usp.cpp @@ -239,7 +239,11 @@ void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; +#ifdef REGAMEDLL_ADD + KickBack(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else m_pPlayer->pev->punchangle.x -= 2.0f; +#endif ResetPlayerShieldAnim(); } diff --git a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp index ec7a01dee..a4e4304eb 100644 --- a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp +++ b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp @@ -166,10 +166,17 @@ void CXM1014::PrimaryAttack() m_fInSpecialReload = 0; +#ifdef REGAMEDLL_ADD + if (m_pPlayer->pev->flags & FL_ONGROUND) + KickBack(UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 3, 5), 0.0, 0.0, 0.0, 0.0, 0.0, 0); + else + KickBack(UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 7, 10), 0.0, 0.0, 0.0, 0.0, 0.0, 0); +#else if (m_pPlayer->pev->flags & FL_ONGROUND) m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 3, 5); else m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 7, 10); +#endif } void CXM1014::Reload()