- more player code exported
This commit is contained in:
parent
10deb5ce56
commit
6e25c34fda
7 changed files with 238 additions and 224 deletions
218
src/p_user.cpp
218
src/p_user.cpp
|
|
@ -2520,200 +2520,6 @@ void P_DeathThink (player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// PROC P_CrouchMove
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void P_CrouchMove(player_t * player, int direction)
|
||||
{
|
||||
double defaultheight = player->mo->FullHeight;
|
||||
double savedheight = player->mo->Height;
|
||||
double crouchspeed = direction * CROUCHSPEED;
|
||||
double oldheight = player->viewheight;
|
||||
|
||||
player->crouchdir = (signed char) direction;
|
||||
player->crouchfactor += crouchspeed;
|
||||
|
||||
// check whether the move is ok
|
||||
player->mo->Height = defaultheight * player->crouchfactor;
|
||||
if (!P_TryMove(player->mo, player->mo->Pos(), false, NULL))
|
||||
{
|
||||
player->mo->Height = savedheight;
|
||||
if (direction > 0)
|
||||
{
|
||||
// doesn't fit
|
||||
player->crouchfactor -= crouchspeed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
player->mo->Height = savedheight;
|
||||
|
||||
player->crouchfactor = clamp(player->crouchfactor, 0.5, 1.);
|
||||
player->viewheight = player->mo->ViewHeight * player->crouchfactor;
|
||||
player->crouchviewdelta = player->viewheight - player->mo->ViewHeight;
|
||||
|
||||
// Check for eyes going above/below fake floor due to crouching motion.
|
||||
P_CheckFakeFloorTriggers(player->mo, player->mo->Z() + oldheight, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// PROC P_CheckFOV
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void P_CheckFOV(player_t *player)
|
||||
{
|
||||
// [RH] Zoom the player's FOV
|
||||
float desired = player->DesiredFOV;
|
||||
// Adjust FOV using on the currently held weapon.
|
||||
if (player->playerstate != PST_DEAD && // No adjustment while dead.
|
||||
player->ReadyWeapon != NULL && // No adjustment if no weapon.
|
||||
player->ReadyWeapon->FOVScale != 0) // No adjustment if the adjustment is zero.
|
||||
{
|
||||
// A negative scale is used to prevent G_AddViewAngle/G_AddViewPitch
|
||||
// from scaling with the FOV scale.
|
||||
desired *= fabsf(player->ReadyWeapon->FOVScale);
|
||||
}
|
||||
if (player->FOV != desired)
|
||||
{
|
||||
if (fabsf(player->FOV - desired) < 7.f)
|
||||
{
|
||||
player->FOV = desired;
|
||||
}
|
||||
else
|
||||
{
|
||||
float zoom = MAX(7.f, fabsf(player->FOV - desired) * 0.025f);
|
||||
if (player->FOV > desired)
|
||||
{
|
||||
player->FOV = player->FOV - zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->FOV = player->FOV + zoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// PROC P_CheckCheats
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void P_CheckCheats(player_t *player)
|
||||
{
|
||||
// No-clip cheat
|
||||
if ((player->cheats & (CF_NOCLIP | CF_NOCLIP2)) == CF_NOCLIP2)
|
||||
{ // No noclip2 without noclip
|
||||
player->cheats &= ~CF_NOCLIP2;
|
||||
}
|
||||
if (player->cheats & (CF_NOCLIP | CF_NOCLIP2) || (player->mo->GetDefault()->flags & MF_NOCLIP))
|
||||
{
|
||||
player->mo->flags |= MF_NOCLIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->mo->flags &= ~MF_NOCLIP;
|
||||
}
|
||||
if (player->cheats & CF_NOCLIP2)
|
||||
{
|
||||
player->mo->flags |= MF_NOGRAVITY;
|
||||
}
|
||||
else if (!(player->mo->flags2 & MF2_FLY) && !(player->mo->GetDefault()->flags & MF_NOGRAVITY))
|
||||
{
|
||||
player->mo->flags &= ~MF_NOGRAVITY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// PROC P_CheckFrozen
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
bool P_CheckFrozen(player_t *player)
|
||||
{
|
||||
auto cmd = &player->cmd;
|
||||
bool totallyfrozen = P_IsPlayerTotallyFrozen(player);
|
||||
|
||||
// [RH] Being totally frozen zeros out most input parameters.
|
||||
if (totallyfrozen)
|
||||
{
|
||||
if (gamestate == GS_TITLELEVEL)
|
||||
{
|
||||
cmd->ucmd.buttons = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->ucmd.buttons &= BT_USE;
|
||||
}
|
||||
cmd->ucmd.pitch = 0;
|
||||
cmd->ucmd.yaw = 0;
|
||||
cmd->ucmd.roll = 0;
|
||||
cmd->ucmd.forwardmove = 0;
|
||||
cmd->ucmd.sidemove = 0;
|
||||
cmd->ucmd.upmove = 0;
|
||||
player->turnticks = 0;
|
||||
}
|
||||
else if (player->cheats & CF_FROZEN)
|
||||
{
|
||||
cmd->ucmd.forwardmove = 0;
|
||||
cmd->ucmd.sidemove = 0;
|
||||
cmd->ucmd.upmove = 0;
|
||||
}
|
||||
return totallyfrozen;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// PROC P_CheckCrouch
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void P_CheckCrouch(player_t *player, bool totallyfrozen)
|
||||
{
|
||||
if (player->cmd.ucmd.buttons & BT_JUMP)
|
||||
{
|
||||
player->cmd.ucmd.buttons &= ~BT_CROUCH;
|
||||
}
|
||||
if (player->CanCrouch() && player->health > 0 && level.IsCrouchingAllowed())
|
||||
{
|
||||
if (!totallyfrozen)
|
||||
{
|
||||
int crouchdir = player->crouching;
|
||||
|
||||
if (crouchdir == 0)
|
||||
{
|
||||
crouchdir = (player->cmd.ucmd.buttons & BT_CROUCH) ? -1 : 1;
|
||||
}
|
||||
else if (player->cmd.ucmd.buttons & BT_CROUCH)
|
||||
{
|
||||
player->crouching = 0;
|
||||
}
|
||||
if (crouchdir == 1 && player->crouchfactor < 1 &&
|
||||
player->mo->Top() < player->mo->ceilingz)
|
||||
{
|
||||
P_CrouchMove(player, 1);
|
||||
}
|
||||
else if (crouchdir == -1 && player->crouchfactor > 0.5)
|
||||
{
|
||||
P_CrouchMove(player, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player->Uncrouch();
|
||||
}
|
||||
|
||||
player->crouchoffset = -(player->mo->ViewHeight) * (1 - player->crouchfactor);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// PROC P_CheckMusicChange
|
||||
|
|
@ -3069,30 +2875,6 @@ void P_HandleMovement(player_t *player)
|
|||
}
|
||||
|
||||
|
||||
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckFOV)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||
P_CheckFOV(self->player);
|
||||
return 0;
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckCheats)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||
P_CheckCheats(self->player);
|
||||
return 0;
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckFrozen)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||
ACTION_RETURN_BOOL(P_CheckFrozen(self->player));
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckCrouch)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||
PARAM_BOOL(totally);
|
||||
P_CheckCrouch(self->player, totally);
|
||||
return 0;
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckMusicChange)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue