mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-13 15:18:00 +03:00
Extend KickBack functionalities (#980)
This commit is contained in:
parent
77a3f2b25b
commit
c48be87474
@ -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<real_t>(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)
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user