mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-30 00:41:24 +00:00
- Blood/Duke/RR/SW: Unify the player's horizon function.
* For Duke/SW, we continually apply `SB_CENTERVIEW` only if it was previously a toggled action, similar to Blood. * For SW, we remove two SW-specific bits (`PF_LOCK_HORIZ` and `PF_LOOKING`) that are no longer needed. * For Duke, we remove `return_to_center` and just use the `SB_CENTERVIEW` action bit as required. * For `sethorizon()`, feature set and adjustment speeds are an averaged out accumulation across Duke/SW: ** GameTicRate is factored in for adjustment decisions to provide consistency for SW being the faster game. ** Adjustment amounts are half way between Duke/SW.
This commit is contained in:
parent
0c4fe5f91b
commit
0ab3b33a6c
25 changed files with 126 additions and 220 deletions
|
@ -1487,3 +1487,69 @@ fixed_t getincangleq16(fixed_t a, fixed_t na)
|
|||
return (na-a);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Player's horizon function, called in processInput() or from gi->GetInput() as required.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust)
|
||||
{
|
||||
// Calculate adjustment as true pitch (Fixed point math really sucks...)
|
||||
double horizAngle = atan2(*q16horiz - IntToFixed(100), IntToFixed(128)) * (512. / pi::pi());
|
||||
|
||||
if (q16horz)
|
||||
{
|
||||
*actions &= ~SB_CENTERVIEW;
|
||||
horizAngle = clamp(horizAngle + FixedToFloat(q16horz), -180, 180);
|
||||
}
|
||||
|
||||
// this is the locked type
|
||||
if (*actions & (SB_AIM_UP|SB_AIM_DOWN))
|
||||
{
|
||||
*actions &= ~SB_CENTERVIEW;
|
||||
double const amount = 250. / GameTicRate;
|
||||
|
||||
if (*actions & SB_AIM_DOWN)
|
||||
horizAngle -= scaleAdjust * amount;
|
||||
|
||||
if (*actions & SB_AIM_UP)
|
||||
horizAngle += scaleAdjust * amount;
|
||||
}
|
||||
|
||||
// this is the unlocked type
|
||||
if (*actions & (SB_LOOK_UP|SB_LOOK_DOWN))
|
||||
{
|
||||
*actions |= SB_CENTERVIEW;
|
||||
double const amount = 500. / GameTicRate;
|
||||
|
||||
if (*actions & SB_LOOK_DOWN)
|
||||
horizAngle -= scaleAdjust * amount;
|
||||
|
||||
if (*actions & SB_LOOK_UP)
|
||||
horizAngle += scaleAdjust * amount;
|
||||
}
|
||||
|
||||
// convert back to Build's horizon
|
||||
*q16horiz = IntToFixed(100) + xs_CRoundToInt(IntToFixed(128) * tan(horizAngle * (pi::pi() / 512.)));
|
||||
|
||||
// return to center if conditions met.
|
||||
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||
{
|
||||
if (*q16horiz < FloatToFixed(99.75) || *q16horiz > FloatToFixed(100.25))
|
||||
{
|
||||
// move *q16horiz back to 100
|
||||
*q16horiz += xs_CRoundToInt(scaleAdjust * (((1000. / GameTicRate) * FRACUNIT) - (*q16horiz * (10. / GameTicRate))));
|
||||
}
|
||||
else
|
||||
{
|
||||
// not looking anymore because *q16horiz is back at 100
|
||||
*q16horiz = IntToFixed(100);
|
||||
*actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
// clamp before returning
|
||||
*q16horiz = clamp(*q16horiz, gi->playerHorizMin(), gi->playerHorizMax());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue