Features: added bits for iuser3 for prevent duck like HL

Fix wrong calc duck fraction
This commit is contained in:
s1lent 2017-11-23 00:12:46 +07:00
parent 83c3429240
commit a43269b6a4
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
2 changed files with 26 additions and 8 deletions

View File

@ -69,6 +69,7 @@ const int DEFAULT_FOV = 90; // the default field of view
#define PLAYER_FREEZE_TIME_OVER BIT(1) #define PLAYER_FREEZE_TIME_OVER BIT(1)
#define PLAYER_IN_BOMB_ZONE BIT(2) #define PLAYER_IN_BOMB_ZONE BIT(2)
#define PLAYER_HOLDING_SHIELD BIT(3) #define PLAYER_HOLDING_SHIELD BIT(3)
#define PLAYER_PREVENT_DUCK BIT(4)
#define MENU_KEY_1 BIT(0) #define MENU_KEY_1 BIT(0)
#define MENU_KEY_2 BIT(1) #define MENU_KEY_2 BIT(1)

View File

@ -1851,8 +1851,6 @@ void PM_UnDuck()
void PM_Duck() void PM_Duck()
{ {
float_precision duckFraction;
int buttonsChanged = (pmove->oldbuttons ^ pmove->cmd.buttons); // These buttons have changed this frame int buttonsChanged = (pmove->oldbuttons ^ pmove->cmd.buttons); // These buttons have changed this frame
int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed"
@ -1868,6 +1866,20 @@ void PM_Duck()
pmove->oldbuttons &= ~IN_DUCK; pmove->oldbuttons &= ~IN_DUCK;
} }
#ifdef REGAMEDLL_FIXES
// Prevent ducking if the iuser3 variable is contain PLAYER_PREVENT_DUCK
if ((pmove->iuser3 & PLAYER_PREVENT_DUCK) == PLAYER_PREVENT_DUCK)
{
// Try to unduck
if (pmove->flags & FL_DUCKING)
{
PM_UnDuck();
}
return;
}
#endif
if (pmove->dead || !(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING)) if (pmove->dead || !(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING))
{ {
return; return;
@ -1883,11 +1895,9 @@ void PM_Duck()
{ {
// Use 1 second so super long jump will work // Use 1 second so super long jump will work
pmove->flDuckTime = 1000; pmove->flDuckTime = 1000;
pmove->bInDuck = true; pmove->bInDuck = TRUE;
} }
float_precision time = Q_max(0.0, (1.0 - pmove->flDuckTime / 1000.0));
if (pmove->bInDuck) if (pmove->bInDuck)
{ {
// Finish ducking immediately if duck time is over or not on ground // Finish ducking immediately if duck time is over or not on ground
@ -1918,13 +1928,20 @@ void PM_Duck()
} }
else else
{ {
float_precision duckFraction = PM_VEC_VIEW;
float_precision time = (1.0 - pmove->flDuckTime / 1000.0);
// Calc parametric time
if (time >= 0.0) {
duckFraction = PM_SplineFraction(time, (1.0 / TIME_TO_DUCK));
}
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
float fMore = (pmove->_player_mins[1] - pmove->_player_mins[0]); float fMore = (pmove->_player_mins[1][2] - pmove->_player_mins[0][2]);
#else #else
float fMore = (PM_VEC_DUCK_HULL_MIN - PM_VEC_HULL_MIN); float fMore = (PM_VEC_DUCK_HULL_MIN - PM_VEC_HULL_MIN);
#endif #endif
// Calc parametric time
duckFraction = PM_SplineFraction(time, (1.0 / TIME_TO_DUCK));
pmove->view_ofs[2] = ((PM_VEC_DUCK_VIEW - fMore) * duckFraction) + (PM_VEC_VIEW * (1 - duckFraction)); pmove->view_ofs[2] = ((PM_VEC_DUCK_VIEW - fMore) * duckFraction) + (PM_VEC_VIEW * (1 - duckFraction));
} }
} }