Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: CSPlayer new members (physics related) #851

Merged
merged 7 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 56 additions & 9 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,9 +1899,18 @@ void PM_Duck()
return;
}

pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER;
pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER;
pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER;
real_t mult = PLAYER_DUCKING_MULTIPLIER;

#ifdef REGAMEDLL_API
const CCSPlayer* player = UTIL_PlayerByIndex(pmove->player_index + 1)->CSPlayer();

if (player->m_flDuckSpeedMultiplier > 0.0)
mult = player->m_flDuckSpeedMultiplier;
#endif

pmove->cmd.forwardmove *= mult;
pmove->cmd.sidemove *= mult;
pmove->cmd.upmove *= mult;

if (pmove->cmd.buttons & IN_DUCK)
{
Expand Down Expand Up @@ -2015,7 +2024,16 @@ void EXT_FUNC __API_HOOK(PM_LadderMove)(physent_t *pLadder)

if (pmove->flags & FL_DUCKING)
{
flSpeed *= PLAYER_DUCKING_MULTIPLIER;
real_t mult = PLAYER_DUCKING_MULTIPLIER;

#ifdef REGAMEDLL_API
const CCSPlayer* player = UTIL_PlayerByIndex(pmove->player_index + 1)->CSPlayer();
dystopm marked this conversation as resolved.
Show resolved Hide resolved

if (player->m_flDuckSpeedMultiplier > 0.0)
mult = player->m_flDuckSpeedMultiplier;
#endif

flSpeed *= mult;
}

if (pmove->cmd.buttons & IN_BACK)
Expand Down Expand Up @@ -2465,6 +2483,24 @@ void PM_Jump()
{
PM_PlayStepSound(PM_MapTextureTypeStepType(pmove->chtexturetype), fvol);
}

#ifdef REGAMEDLL_API
auto PM_JumpHeight = [&player](bool longjump) -> real_t
#else
auto PM_JumpHeight = [&](bool longjump) -> real_t
dystopm marked this conversation as resolved.
Show resolved Hide resolved
#endif
{
#ifdef REGAMEDLL_API
if (longjump)
{
if(player->m_flLongJumpHeight > 0.0)
return player->m_flLongJumpHeight;
}
else if (player->m_flJumpHeight > 0.0)
return player->m_flJumpHeight;
#endif
return Q_sqrt(2.0 * 800.0f * (longjump ? 56.0f : 45.0f));
};

#ifdef REGAMEDLL_ADD
// See if user can super long jump?
Expand All @@ -2480,23 +2516,34 @@ void PM_Jump()
{
pmove->punchangle[0] = -5.0f;

for (int i = 0; i < 2; i++)
#ifdef REGAMEDLL_API
if (player->m_flLongJumpForce > 0.0)
{
fvel = player->m_flLongJumpForce;
}
else
#endif
{
fvel = PLAYER_LONGJUMP_SPEED * 1.6f;
}

for (int i = 0; i < 2; i++)
{
pmove->velocity[i] = pmove->forward[i] * PLAYER_LONGJUMP_SPEED * 1.6f;
pmove->velocity[i] = pmove->forward[i] * fvel;
}

pmove->velocity[2] = Q_sqrt(2 * 800 * 56.0f);
pmove->velocity[2] = PM_JumpHeight(true);
}
else
{
pmove->velocity[2] = Q_sqrt(2 * 800 * 45.0f);
pmove->velocity[2] = PM_JumpHeight(false);
}
}
else
#endif
{
// NOTE: don't do it in .f (float)
pmove->velocity[2] = Q_sqrt(2.0 * 800.0f * 45.0f);
pmove->velocity[2] = PM_JumpHeight(false);
}

if (pmove->fuser2 > 0.0f)
Expand Down
10 changes: 9 additions & 1 deletion regamedll/public/regamedll/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ class CCSPlayer: public CCSMonster {
m_bAutoBunnyHopping(false),
m_bMegaBunnyJumping(false),
m_bPlantC4Anywhere(false),
m_bSpawnProtectionEffects(false)
m_bSpawnProtectionEffects(false),
m_flJumpHeight(0),
m_flLongJumpHeight(0),
m_flLongJumpForce(0),
m_flDuckSpeedMultiplier(0)
{
m_szModel[0] = '\0';
}
Expand Down Expand Up @@ -136,6 +140,10 @@ class CCSPlayer: public CCSMonster {
bool m_bMegaBunnyJumping;
bool m_bPlantC4Anywhere;
bool m_bSpawnProtectionEffects;
double m_flJumpHeight;
double m_flLongJumpHeight;
double m_flLongJumpForce;
float m_flDuckSpeedMultiplier;
};

// Inlines
Expand Down