mirror of https://github.com/FWGS/hlsdk-xash3d
Merge original "Half-Life: Top-Down" source code(Was released here: https://gitlab.com/Sockman/hltopdown).
This commit is contained in:
parent
81fe047f9a
commit
15eefa5f6c
|
@ -154,7 +154,6 @@ int CHud::Redraw( float flTime, int intermission )
|
|||
SPR_DrawAdditive( i, x, y, NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
if( g_iVisibleMouse )
|
||||
{
|
||||
void IN_GetMousePos( int *mx, int *my );
|
||||
|
@ -174,7 +173,6 @@ int CHud::Redraw( float flTime, int intermission )
|
|||
// Draw the logo at 20 fps
|
||||
SPR_DrawAdditive( 0, mx, my, NULL );
|
||||
}
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "camera.h"
|
||||
#include "in_defs.h"
|
||||
|
||||
#include "eiface.h"
|
||||
#include "pmtrace.h"
|
||||
|
||||
float CL_KeyState( kbutton_t *key );
|
||||
|
||||
extern "C"
|
||||
|
@ -26,6 +29,10 @@ extern "C"
|
|||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
extern vec3_t realOrigin;
|
||||
|
||||
extern float realViewOrg[3];
|
||||
|
||||
//-------------------------------------------------- Constants
|
||||
|
||||
#define CAM_DIST_DELTA 1.0
|
||||
|
@ -62,6 +69,13 @@ cvar_t *c_minyaw;
|
|||
cvar_t *c_maxdistance;
|
||||
cvar_t *c_mindistance;
|
||||
|
||||
cvar_t *cam_minDist;
|
||||
cvar_t *cam_maxDist;
|
||||
cvar_t *cam_smooth;
|
||||
cvar_t *cam_lookahead;
|
||||
|
||||
extern float camYaw;
|
||||
|
||||
// pitch, yaw, dist
|
||||
vec3_t cam_ofs;
|
||||
|
||||
|
@ -175,6 +189,27 @@ void DLLEXPORT CAM_Think( void )
|
|||
ext[0] = ext[1] = ext[2] = 0.0;
|
||||
}
|
||||
#endif
|
||||
if( cam_contain->value == 0 )
|
||||
{
|
||||
cam_idealdist->value = cam_maxDist->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
pmtrace_t *trace;
|
||||
Vector startPos = realOrigin + Vector( realViewOrg[0], realViewOrg[1], cam_minDist->value );
|
||||
Vector endPos = realOrigin + Vector( realViewOrg[0], realViewOrg[1], cam_maxDist->value ); // Vector(realOrigin.x + realViewOrg[0], realOrigin.y + realViewOrg[1], realOrigin.z + c
|
||||
trace = gEngfuncs.PM_TraceLine( startPos, endPos, 1, 2, -1 );
|
||||
float traceDist = trace->endpos.z - ( realOrigin.z + 25 ); // Have to add 25 because for whatever reason the trace puts the camera a bit above the object
|
||||
if( cam_smooth->value != 0 )
|
||||
{
|
||||
cam_idealdist->value -= ( cam_idealdist->value - traceDist ) * ( 0.25f );
|
||||
}
|
||||
else
|
||||
{
|
||||
cam_idealdist->value = traceDist;
|
||||
}
|
||||
}
|
||||
|
||||
camAngles[PITCH] = cam_idealpitch->value;
|
||||
camAngles[YAW] = cam_idealyaw->value;
|
||||
dist = cam_idealdist->value;
|
||||
|
@ -351,14 +386,14 @@ void DLLEXPORT CAM_Think( void )
|
|||
|
||||
if( cam_snapto->value )
|
||||
{
|
||||
camAngles[YAW] = cam_idealyaw->value + viewangles[YAW];
|
||||
camAngles[YAW] = cam_idealyaw->value + camYaw; // + viewangles[YAW];
|
||||
camAngles[PITCH] = cam_idealpitch->value + viewangles[PITCH];
|
||||
camAngles[2] = cam_idealdist->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( camAngles[YAW] - viewangles[YAW] != cam_idealyaw->value )
|
||||
camAngles[YAW] = MoveToward( camAngles[YAW], cam_idealyaw->value + viewangles[YAW], CAM_ANGLE_SPEED );
|
||||
if( camAngles[YAW] - camYaw != cam_idealyaw->value )
|
||||
camAngles[YAW] = MoveToward( camAngles[YAW], cam_idealyaw->value + camYaw, CAM_ANGLE_SPEED );
|
||||
|
||||
if( camAngles[PITCH] - viewangles[PITCH] != cam_idealpitch->value )
|
||||
camAngles[PITCH] = MoveToward( camAngles[PITCH], cam_idealpitch->value + viewangles[PITCH], CAM_ANGLE_SPEED );
|
||||
|
@ -459,13 +494,7 @@ void CAM_OutUp( void )
|
|||
void CAM_ToThirdPerson( void )
|
||||
{
|
||||
vec3_t viewangles;
|
||||
#if !defined( _DEBUG )
|
||||
if( gEngfuncs.GetMaxClients() > 1 )
|
||||
{
|
||||
// no thirdperson in multiplayer.
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
gEngfuncs.GetViewAngles( (float *)viewangles );
|
||||
|
||||
if( !cam_thirdperson )
|
||||
|
@ -514,12 +543,13 @@ void CAM_Init( void )
|
|||
gEngfuncs.pfnAddCommand( "-camdistance", CAM_EndDistance );
|
||||
gEngfuncs.pfnAddCommand( "snapto", CAM_ToggleSnapto );
|
||||
|
||||
cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "0", 0 ); // tells camera to go to thirdperson
|
||||
cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "1", 0 ); // tells camera to go to thirdperson
|
||||
cam_snapto = gEngfuncs.pfnRegisterVariable( "cam_snapto", "0", 0 ); // snap to thirdperson view
|
||||
cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "90", 0 ); // thirdperson yaw
|
||||
cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "0", 0 ); // thirperson pitch
|
||||
cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "64", 0 ); // thirdperson distance
|
||||
cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "0", 0 ); // contain camera to world
|
||||
cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "0", 0 ); // thirdperson yaw
|
||||
cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "90", 0 ); // thirperson pitch
|
||||
cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "100", 0 ); // thirdperson distance
|
||||
|
||||
cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "1", FCVAR_ARCHIVE ); // contain camera to world(previously unused/broken, repurposed for top-down stuff)
|
||||
|
||||
c_maxpitch = gEngfuncs.pfnRegisterVariable( "c_maxpitch", "90.0", 0 );
|
||||
c_minpitch = gEngfuncs.pfnRegisterVariable( "c_minpitch", "0.0", 0 );
|
||||
|
@ -527,6 +557,11 @@ void CAM_Init( void )
|
|||
c_minyaw = gEngfuncs.pfnRegisterVariable( "c_minyaw", "-135.0", 0 );
|
||||
c_maxdistance = gEngfuncs.pfnRegisterVariable( "c_maxdistance", "200.0", 0 );
|
||||
c_mindistance = gEngfuncs.pfnRegisterVariable( "c_mindistance", "30.0", 0 );
|
||||
|
||||
cam_minDist = gEngfuncs.pfnRegisterVariable( "cam_minDist", "150", FCVAR_ARCHIVE );
|
||||
cam_maxDist = gEngfuncs.pfnRegisterVariable( "cam_maxDist", "500", FCVAR_ARCHIVE ); // Max dist if dynamic, normal distance if fixed
|
||||
cam_smooth = gEngfuncs.pfnRegisterVariable( "cam_smooth", "1", FCVAR_ARCHIVE ); // smooth camera movement
|
||||
cam_lookahead = gEngfuncs.pfnRegisterVariable( "cam_lookahead", "2", FCVAR_ARCHIVE ); // amount to "look ahead" towards the mouse
|
||||
}
|
||||
|
||||
void CAM_ClearStates( void )
|
||||
|
@ -542,7 +577,7 @@ void CAM_ClearStates( void )
|
|||
cam_in.state = 0;
|
||||
cam_out.state = 0;
|
||||
|
||||
cam_thirdperson = 0;
|
||||
cam_thirdperson = 1;
|
||||
cam_command->value = 0;
|
||||
cam_mousemove=0;
|
||||
|
||||
|
|
|
@ -122,8 +122,10 @@ typedef unsigned int DWORD;
|
|||
|
||||
#define MOUSE_BUTTON_COUNT 5
|
||||
|
||||
float mouse_pos_extern[2];
|
||||
|
||||
// use IN_SetVisibleMouse to set:
|
||||
int iVisibleMouse = 0;
|
||||
int iVisibleMouse = 1;
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
|
@ -149,6 +151,8 @@ extern cvar_t *cl_forwardspeed;
|
|||
extern cvar_t *cl_pitchspeed;
|
||||
extern cvar_t *cl_movespeedkey;
|
||||
|
||||
float camYaw;
|
||||
|
||||
#ifdef _WIN32
|
||||
static double s_flRawInputUpdateTime = 0.0f;
|
||||
static bool m_bRawInput = false;
|
||||
|
@ -633,8 +637,8 @@ void GoldSourceInput::IN_MouseEvent (int mstate)
|
|||
{
|
||||
int i;
|
||||
|
||||
if ( iMouseInUse || iVisibleMouse )
|
||||
return;
|
||||
// if ( iMouseInUse || iVisibleMouse )
|
||||
// return;
|
||||
|
||||
// perform button actions
|
||||
for (i=0 ; i<mouse_buttons ; i++)
|
||||
|
@ -847,7 +851,7 @@ void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd)
|
|||
|
||||
//jjb - this disbles normal mouse control if the user is trying to
|
||||
// move the camera, or if the mouse cursor is visible or if we're in intermission
|
||||
if ( !iMouseInUse && !gHUD.m_iIntermission && !iVisibleMouse )
|
||||
if ( !iMouseInUse && !gHUD.m_iIntermission )
|
||||
{
|
||||
IN_GetMouseDelta( &mx, &my );
|
||||
|
||||
|
@ -869,18 +873,38 @@ void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd)
|
|||
IN_ScaleMouse( &mouse_x, &mouse_y );
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
/*
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
*/
|
||||
|
||||
// Get mouse pos and normalize it to be sent to view.cpp
|
||||
POINT mouse_pos;
|
||||
GetCursorPos( &mouse_pos );
|
||||
|
||||
mouse_pos_extern[0] = mouse_pos.x;
|
||||
mouse_pos_extern[1] = mouse_pos.y;
|
||||
mouse_pos_extern[0] /= ScreenWidth / 2;
|
||||
mouse_pos_extern[1] /= ScreenHeight / 2;
|
||||
mouse_pos_extern[0] -= 1;
|
||||
mouse_pos_extern[1] -= 1;
|
||||
|
||||
viewangles[YAW] = -atan2( double( mouse_pos_extern[1] * ( M_PI / 180 ) ), double( mouse_pos_extern[0] * ( M_PI / 180 ) ) ) * ( 180 / M_PI ) - 90; // I don't know why I have to negate the v
|
||||
|
||||
mouse_pos_extern[0] *= 27;
|
||||
mouse_pos_extern[1] *= 27;
|
||||
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
{
|
||||
/*
|
||||
viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (viewangles[PITCH] > cl_pitchdown->value)
|
||||
viewangles[PITCH] = cl_pitchdown->value;
|
||||
if (viewangles[PITCH] < -cl_pitchup->value)
|
||||
viewangles[PITCH] = -cl_pitchup->value;
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -67,6 +67,12 @@ void VectorAngles( const float *forward, float *angles );
|
|||
|
||||
extern engine_studio_api_t IEngineStudio;
|
||||
|
||||
extern float mouse_pos_extern[2];
|
||||
extern cvar_t *cam_idealdist;
|
||||
extern cvar_t *cam_minDist;
|
||||
|
||||
extern cvar_t *cam_contain;
|
||||
|
||||
/*
|
||||
The view is allowed to move slightly from it's true position for bobbing,
|
||||
but if it exceeds 8 pixels linear distance (spherical, not box), the list of
|
||||
|
@ -84,6 +90,12 @@ extern Vector dead_viewangles;
|
|||
#define CAM_MODE_RELAX 1
|
||||
#define CAM_MODE_FOCUS 2
|
||||
|
||||
vec3_t realOrigin;
|
||||
float realViewOrg[3];
|
||||
float camOffset[3];
|
||||
|
||||
extern cvar_t *cam_lookahead;
|
||||
|
||||
vec3_t v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles;
|
||||
float v_frametime, v_lastDistance;
|
||||
float v_cameraRelaxAngle = 5.0f;
|
||||
|
@ -407,6 +419,9 @@ V_CalcRefdef
|
|||
|
||||
==================
|
||||
*/
|
||||
|
||||
float offSetFactor = 1;
|
||||
|
||||
void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
||||
{
|
||||
cl_entity_t *ent, *view;
|
||||
|
@ -440,7 +455,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
|
||||
// refresh position
|
||||
VectorCopy( pparams->simorg, pparams->vieworg );
|
||||
pparams->vieworg[2] += bob ;
|
||||
//pparams->vieworg[2] += bob ;
|
||||
VectorAdd( pparams->vieworg, pparams->viewheight, pparams->vieworg );
|
||||
|
||||
if( pparams->health <= 0 )
|
||||
|
@ -566,6 +581,50 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
{
|
||||
pparams->vieworg[i] += -ofs[2] * camForward[i];
|
||||
}
|
||||
|
||||
//Calculations and setting externs for in_camera.cpp
|
||||
realOrigin = ent->origin;
|
||||
|
||||
if( cam_contain->value == 1 )
|
||||
{
|
||||
Vector mousePos = Vector(-mouse_pos_extern[1], -mouse_pos_extern[0], 0.0f);
|
||||
|
||||
// Check if the new camera position is in the wall
|
||||
Vector startPoint;
|
||||
|
||||
if( cam_idealdist->value + 25 <= cam_minDist->value )
|
||||
{
|
||||
startPoint = ent->origin + Vector( 0.0f, 0.0f, cam_idealdist->value );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if camera is inside the wall trace from the player's origin
|
||||
startPoint = ent->origin;
|
||||
}
|
||||
|
||||
pmtrace_t *camTrace = gEngfuncs.PM_TraceLine( startPoint, startPoint + mousePos * offSetFactor * cam_lookahead->value, 1, 2, -1 );
|
||||
|
||||
// TODO: fix division
|
||||
|
||||
camOffset[0] = camTrace->endpos.x - startPoint.x;
|
||||
camOffset[1] = camTrace->endpos.y - startPoint.y;
|
||||
|
||||
realViewOrg[0] = camTrace->endpos.x - startPoint.x;
|
||||
realViewOrg[1] = camTrace->endpos.y - startPoint.y;
|
||||
realViewOrg[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
camOffset[0] = -mouse_pos_extern[1] * offSetFactor * cam_lookahead->value;
|
||||
camOffset[1] = -mouse_pos_extern[0] * offSetFactor * cam_lookahead->value;
|
||||
|
||||
realViewOrg[0] = -mouse_pos_extern[1] * offSetFactor * cam_lookahead->value;
|
||||
realViewOrg[1] = -mouse_pos_extern[0] * offSetFactor * cam_lookahead->value;
|
||||
realViewOrg[2] = 0;
|
||||
}
|
||||
|
||||
pparams->vieworg[0] += camOffset[0];
|
||||
pparams->vieworg[1] += camOffset[1];
|
||||
}
|
||||
|
||||
// Give gun our viewangles
|
||||
|
@ -744,10 +803,10 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
pitch /= -3.0;
|
||||
|
||||
// Slam local player's pitch value
|
||||
ent->angles[0] = pitch;
|
||||
ent->curstate.angles[0] = pitch;
|
||||
ent->prevstate.angles[0] = pitch;
|
||||
ent->latched.prevangles[0] = pitch;
|
||||
// ent->angles[0] = pitch;
|
||||
// ent->curstate.angles[0] = pitch;
|
||||
// ent->prevstate.angles[0] = pitch;
|
||||
// ent->latched.prevangles[0] = pitch;
|
||||
}
|
||||
|
||||
// override all previous settings if the viewent isn't the client
|
||||
|
|
|
@ -381,7 +381,7 @@ void CCrossbow::FireSniperBolt()
|
|||
Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
||||
UTIL_MakeVectors( anglesAim );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2;
|
||||
Vector vecDir = gpGlobals->v_forward;
|
||||
Vector vecDir = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // gpGlobals->v_forward;
|
||||
|
||||
UTIL_TraceLine( vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr );
|
||||
|
||||
|
@ -428,7 +428,7 @@ void CCrossbow::FireBolt()
|
|||
|
||||
#ifndef CLIENT_DLL
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2;
|
||||
Vector vecDir = gpGlobals->v_forward;
|
||||
Vector vecDir = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // gpGlobals->v_forward;
|
||||
|
||||
CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate();
|
||||
pBolt->pev->origin = vecSrc;
|
||||
|
@ -462,18 +462,24 @@ void CCrossbow::FireBolt()
|
|||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
|
||||
}
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
extern float offSetFactor;
|
||||
#endif
|
||||
|
||||
void CCrossbow::SecondaryAttack()
|
||||
{
|
||||
if( m_pPlayer->pev->fov != 0 )
|
||||
#ifdef CLIENT_DLL
|
||||
if( offSetFactor != 1 )
|
||||
{
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
||||
offSetFactor = 1;
|
||||
m_fInZoom = 0;
|
||||
}
|
||||
else if( m_pPlayer->pev->fov != 20 )
|
||||
else if( offSetFactor != 5 )
|
||||
{
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 20;
|
||||
offSetFactor = 5;
|
||||
m_fInZoom = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.1;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
|
@ -497,7 +503,7 @@ void CCrossbow::Reload( void )
|
|||
|
||||
void CCrossbow::WeaponIdle( void )
|
||||
{
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM
|
||||
|
||||
ResetEmptySound();
|
||||
|
||||
|
|
|
@ -178,12 +178,17 @@ int CCrowbar::Swing( int fFirst )
|
|||
{
|
||||
int fDidHit = FALSE;
|
||||
|
||||
TraceResult tr;
|
||||
TraceResult tr, tr2;
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
|
||||
|
||||
if( FBitSet( m_pPlayer->pev->flags, FL_DUCKING ) )
|
||||
{
|
||||
vecEnd = vecSrc + ( ( -gpGlobals->v_up + gpGlobals->v_forward ).Normalize() ) * 32;
|
||||
}
|
||||
|
||||
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
@ -240,6 +245,17 @@ int CCrowbar::Swing( int fFirst )
|
|||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
Vector hitAngle;
|
||||
|
||||
if( FBitSet( m_pPlayer->pev->flags, FL_DUCKING ) )
|
||||
{
|
||||
hitAngle = ( ( -gpGlobals->v_up + gpGlobals->v_forward ).Normalize() );
|
||||
}
|
||||
else
|
||||
{
|
||||
hitAngle = gpGlobals->v_forward;
|
||||
}
|
||||
|
||||
// hit
|
||||
fDidHit = TRUE;
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
|
||||
|
@ -261,12 +277,12 @@ int CCrowbar::Swing( int fFirst )
|
|||
#endif
|
||||
{
|
||||
// first swing does full damage
|
||||
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB );
|
||||
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, hitAngle, &tr, DMG_CLUB );
|
||||
}
|
||||
else
|
||||
{
|
||||
// subsequent swings do half
|
||||
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB );
|
||||
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, hitAngle, &tr, DMG_CLUB );
|
||||
}
|
||||
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ void CEgon::Attack( void )
|
|||
}
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
|
||||
int flags;
|
||||
|
@ -472,6 +472,8 @@ void CEgon::WeaponIdle( void )
|
|||
{
|
||||
ResetEmptySound();
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ void CGauss::StartFire( void )
|
|||
float flDamage;
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );;
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition(); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8;
|
||||
|
||||
if( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() )
|
||||
|
@ -547,6 +547,8 @@ void CGauss::WeaponIdle( void )
|
|||
{
|
||||
ResetEmptySound();
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
// play aftershock static discharge
|
||||
if( m_pPlayer->m_flPlayAftershock && m_pPlayer->m_flPlayAftershock < gpGlobals->time )
|
||||
{
|
||||
|
|
|
@ -148,7 +148,7 @@ void CMP5::PrimaryAttack()
|
|||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
Vector vecDir;
|
||||
#ifdef CLIENT_DLL
|
||||
if( !bIsMultiplayer() )
|
||||
|
@ -248,7 +248,7 @@ void CMP5::WeaponIdle( void )
|
|||
{
|
||||
ResetEmptySound();
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
|
130
dlls/player.cpp
130
dlls/player.cpp
|
@ -118,6 +118,7 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] =
|
|||
DEFINE_FIELD( CBasePlayer, m_pTank, FIELD_EHANDLE ),
|
||||
DEFINE_FIELD( CBasePlayer, m_iHideHUD, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CBasePlayer, m_iFOV, FIELD_INTEGER ),
|
||||
DEFINE_ARRAY( CBasePlayer, m_szAnimExtention, FIELD_CHARACTER, 32 )
|
||||
|
||||
//DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games
|
||||
//DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games
|
||||
|
@ -370,11 +371,8 @@ Vector CBasePlayer::GetGunPosition()
|
|||
{
|
||||
//UTIL_MakeVectors( pev->v_angle );
|
||||
//m_HackedGunPos = pev->view_ofs;
|
||||
Vector origin;
|
||||
|
||||
origin = pev->origin + pev->view_ofs;
|
||||
|
||||
return origin;
|
||||
return EyePosition();
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
|
@ -966,6 +964,22 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim )
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_RELOAD:
|
||||
case PLAYER_RELOAD_START:
|
||||
switch( m_Activity )
|
||||
{
|
||||
case ACT_HOVER:
|
||||
case ACT_SWIM:
|
||||
case ACT_HOP:
|
||||
case ACT_LEAP:
|
||||
case ACT_DIESIMPLE:
|
||||
m_IdealActivity = m_Activity;
|
||||
break;
|
||||
default:
|
||||
m_IdealActivity = ACT_RELOAD;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_IDLE:
|
||||
case PLAYER_WALK:
|
||||
if( !FBitSet( pev->flags, FL_ONGROUND ) && ( m_Activity == ACT_HOP || m_Activity == ACT_LEAP ) ) // Still jumping
|
||||
|
@ -1031,11 +1045,46 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim )
|
|||
|
||||
m_Activity = m_IdealActivity;
|
||||
|
||||
pev->sequence = animDesired;
|
||||
ResetSequenceInfo();
|
||||
break;
|
||||
case ACT_RELOAD:
|
||||
if( playerAnim == PLAYER_RELOAD_START )
|
||||
{
|
||||
if( FBitSet( pev->flags, FL_DUCKING ) ) // crouching
|
||||
strcpy( szAnim, "reload_start_c_" );
|
||||
else
|
||||
strcpy( szAnim, "reload_start_" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( FBitSet(pev->flags, FL_DUCKING ) ) // crouching
|
||||
strcpy(szAnim, "reload_c_");
|
||||
else
|
||||
strcpy(szAnim, "reload_");
|
||||
}
|
||||
strcat( szAnim, m_szAnimExtention );
|
||||
animDesired = LookupSequence( szAnim ); // szAnim
|
||||
if( animDesired == -1 )
|
||||
animDesired = 0;
|
||||
|
||||
if( pev->sequence != animDesired || !m_fSequenceLoops )
|
||||
{
|
||||
pev->frame = 0;
|
||||
}
|
||||
|
||||
if( !m_fSequenceLoops )
|
||||
{
|
||||
pev->effects |= EF_NOINTERP;
|
||||
}
|
||||
|
||||
m_Activity = m_IdealActivity;
|
||||
|
||||
pev->sequence = animDesired;
|
||||
ResetSequenceInfo();
|
||||
break;
|
||||
case ACT_WALK:
|
||||
if( m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished )
|
||||
if( ( m_Activity != ACT_RANGE_ATTACK1 && m_Activity != ACT_RELOAD ) || m_fSequenceFinished )
|
||||
{
|
||||
if( FBitSet( pev->flags, FL_DUCKING ) ) // crouching
|
||||
strcpy( szAnim, "crouch_aim_" );
|
||||
|
@ -1506,7 +1555,7 @@ void CBasePlayer::PlayerUse( void )
|
|||
CBaseEntity *pObject = NULL;
|
||||
CBaseEntity *pClosest = NULL;
|
||||
Vector vecLOS;
|
||||
float flMaxDot = VIEW_FIELD_NARROW;
|
||||
float flMaxDot = VIEW_FIELD_WIDE;
|
||||
float flDot;
|
||||
|
||||
UTIL_MakeVectors( pev->v_angle );// so we know which way we are facing
|
||||
|
@ -2500,6 +2549,17 @@ void CBasePlayer::UpdatePlayerSound( void )
|
|||
|
||||
void CBasePlayer::PostThink()
|
||||
{
|
||||
if( ( pev->weapons & ( 1 << WEAPON_SUIT ) ) )
|
||||
{
|
||||
pev->body = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->body = 1;
|
||||
}
|
||||
|
||||
ALERT( at_console, "%s\n", m_szAnimExtention );
|
||||
|
||||
if( g_fGameOver )
|
||||
goto pt_end; // intermission or finale
|
||||
|
||||
|
@ -3001,6 +3061,15 @@ int CBasePlayer::Restore( CRestore &restore )
|
|||
// Barring that, we clear it out here instead of using the incorrect restored time value.
|
||||
m_flNextAttack = UTIL_WeaponTimeBase();
|
||||
#endif
|
||||
if( ( pev->weapons & ( 1 << WEAPON_SUIT ) ) )
|
||||
{
|
||||
pev->body = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->body = 1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -3649,6 +3718,14 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem )
|
|||
SwitchWeapon( pItem );
|
||||
}
|
||||
|
||||
if( ( pev->weapons & ( 1 << WEAPON_SUIT ) ) )
|
||||
{
|
||||
pev->body = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->body = 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else if( gEvilImpulse101 )
|
||||
|
@ -4186,11 +4263,11 @@ void CBasePlayer::EnableControl( BOOL fControl )
|
|||
//=========================================================
|
||||
Vector CBasePlayer::GetAutoaimVector( float flDelta )
|
||||
{
|
||||
if( g_iSkillLevel == SKILL_HARD )
|
||||
/*if( g_iSkillLevel == SKILL_HARD )
|
||||
{
|
||||
UTIL_MakeVectors( pev->v_angle + pev->punchangle );
|
||||
return gpGlobals->v_forward;
|
||||
}
|
||||
}*/
|
||||
|
||||
Vector vecSrc = GetGunPosition();
|
||||
float flDist = 8192;
|
||||
|
@ -4223,38 +4300,23 @@ Vector CBasePlayer::GetAutoaimVector( float flDelta )
|
|||
if( angles.y < -180 )
|
||||
angles.y += 360;
|
||||
|
||||
if( angles.x > 25 )
|
||||
angles.x = 25;
|
||||
if( angles.x < -25 )
|
||||
angles.x = -25;
|
||||
if( angles.y > 12 )
|
||||
angles.y = 12;
|
||||
if( angles.y < -12 )
|
||||
angles.y = -12;
|
||||
if( angles.y > 10 )
|
||||
angles.y = 10;
|
||||
if( angles.y < -10 )
|
||||
angles.y = -10;
|
||||
|
||||
// always use non-sticky autoaim
|
||||
// UNDONE: use sever variable to chose!
|
||||
if( 0 || g_iSkillLevel == SKILL_EASY )
|
||||
{
|
||||
m_vecAutoAim = m_vecAutoAim * 0.67 + angles * 0.33;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vecAutoAim = angles * 0.9;
|
||||
}
|
||||
m_vecAutoAim = m_vecAutoAim + angles; //* 0.67 * 0.33
|
||||
|
||||
// m_vecAutoAim = m_vecAutoAim * 0.99;
|
||||
|
||||
// Don't send across network if sv_aim is 0
|
||||
if( g_psv_aim->value != 0 )
|
||||
if( m_vecAutoAim.x != m_lastx || m_vecAutoAim.y != m_lasty )
|
||||
{
|
||||
if( m_vecAutoAim.x != m_lastx || m_vecAutoAim.y != m_lasty )
|
||||
{
|
||||
SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y );
|
||||
SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y );
|
||||
|
||||
m_lastx = (int)m_vecAutoAim.x;
|
||||
m_lasty = (int)m_vecAutoAim.y;
|
||||
}
|
||||
m_lastx = (int)m_vecAutoAim.x;
|
||||
m_lasty = (int)m_vecAutoAim.y;
|
||||
}
|
||||
|
||||
// ALERT( at_console, "%f %f\n", angles.x, angles.y );
|
||||
|
@ -4282,7 +4344,7 @@ Vector CBasePlayer::AutoaimDeflection( Vector &vecSrc, float flDist, float flDel
|
|||
|
||||
// try all possible entities
|
||||
bestdir = gpGlobals->v_forward;
|
||||
bestdot = flDelta; // +- 10 degrees
|
||||
bestdot = 10; // flDelta; // +- 10 degrees
|
||||
bestent = NULL;
|
||||
|
||||
m_fOnTarget = FALSE;
|
||||
|
@ -4338,7 +4400,7 @@ Vector CBasePlayer::AutoaimDeflection( Vector &vecSrc, float flDist, float flDel
|
|||
if( DotProduct( dir, gpGlobals->v_forward ) < 0 )
|
||||
continue;
|
||||
|
||||
dot = fabs( DotProduct( dir, gpGlobals->v_right ) ) + fabs( DotProduct( dir, gpGlobals->v_up ) ) * 0.5;
|
||||
dot = fabs( DotProduct( dir, gpGlobals->v_right ) ) + fabs( DotProduct( dir, gpGlobals->v_up ) );
|
||||
|
||||
// tweek for distance
|
||||
dot *= 1.0 + 0.2 * ( ( center - vecSrc ).Length() / flDist );
|
||||
|
|
|
@ -68,7 +68,9 @@ typedef enum
|
|||
PLAYER_JUMP,
|
||||
PLAYER_SUPERJUMP,
|
||||
PLAYER_DIE,
|
||||
PLAYER_ATTACK1
|
||||
PLAYER_ATTACK1,
|
||||
PLAYER_RELOAD,
|
||||
PLAYER_RELOAD_START // used for shotgun
|
||||
} PLAYER_ANIM;
|
||||
|
||||
#define MAX_ID_RANGE 2048
|
||||
|
|
|
@ -148,7 +148,7 @@ void CShotgun::PrimaryAttack()
|
|||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
Vector vecDir;
|
||||
|
||||
|
@ -218,7 +218,7 @@ void CShotgun::SecondaryAttack( void )
|
|||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
Vector vecDir;
|
||||
|
||||
|
@ -268,6 +268,7 @@ void CShotgun::Reload( void )
|
|||
// check to see if we're ready to reload
|
||||
if( m_fInSpecialReload == 0 )
|
||||
{
|
||||
m_pPlayer->SetAnimation( PLAYER_RELOAD_START );
|
||||
SendWeaponAnim( SHOTGUN_START_RELOAD );
|
||||
m_fInSpecialReload = 1;
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;
|
||||
|
@ -289,6 +290,7 @@ void CShotgun::Reload( void )
|
|||
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
|
||||
|
||||
SendWeaponAnim( SHOTGUN_RELOAD );
|
||||
m_pPlayer->SetAnimation( PLAYER_RELOAD );
|
||||
|
||||
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
@ -316,7 +318,7 @@ void CShotgun::WeaponIdle( void )
|
|||
{
|
||||
ResetEmptySound();
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
|
||||
{
|
||||
|
|
|
@ -961,6 +961,8 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe
|
|||
|
||||
BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, int body )
|
||||
{
|
||||
m_pPlayer->SetAnimation( PLAYER_RELOAD );
|
||||
|
||||
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -1086,8 +1086,8 @@ void PM_WalkMove()
|
|||
pmtrace_t trace;
|
||||
|
||||
// Copy movement amounts
|
||||
fmove = pmove->cmd.forwardmove;
|
||||
smove = pmove->cmd.sidemove;
|
||||
fmove = ( pmove->cmd.forwardmove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) - ( pmove->cmd.sidemove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
smove = ( pmove->cmd.forwardmove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) + ( pmove->cmd.sidemove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
|
||||
// Zero out z components of movement vectors
|
||||
pmove->forward[2] = 0;
|
||||
|
@ -1363,13 +1363,16 @@ void PM_WaterMove( void )
|
|||
vec3_t temp;
|
||||
pmtrace_t trace;
|
||||
|
||||
float speed, newspeed, addspeed, accelspeed;
|
||||
float speed, newspeed, addspeed, accelspeed, fmove, smove;
|
||||
|
||||
fmove = ( pmove->cmd.forwardmove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) - ( pmove->cmd.sidemove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
smove = ( pmove->cmd.forwardmove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) + ( pmove->cmd.sidemove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
|
||||
//
|
||||
// user intentions
|
||||
//
|
||||
for( i = 0; i < 3; i++ )
|
||||
wishvel[i] = pmove->forward[i] * pmove->cmd.forwardmove + pmove->right[i] * pmove->cmd.sidemove;
|
||||
wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove;
|
||||
|
||||
// Sinking after no other movement occurs
|
||||
if( !pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove )
|
||||
|
@ -1457,8 +1460,8 @@ void PM_AirMove( void )
|
|||
float wishspeed;
|
||||
|
||||
// Copy movement amounts
|
||||
fmove = pmove->cmd.forwardmove;
|
||||
smove = pmove->cmd.sidemove;
|
||||
fmove = ( pmove->cmd.forwardmove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) - ( pmove->cmd.sidemove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
smove = ( pmove->cmd.forwardmove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) + ( pmove->cmd.sidemove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
|
||||
// Zero out z components of movement vectors
|
||||
pmove->forward[2] = 0;
|
||||
|
@ -2128,16 +2131,22 @@ void PM_LadderMove( physent_t *pLadder )
|
|||
|
||||
AngleVectors( pmove->angles, vpn, v_right, NULL );
|
||||
|
||||
float fmove = 0;
|
||||
float smove = 0;
|
||||
|
||||
if( pmove->flags & FL_DUCKING )
|
||||
flSpeed *= PLAYER_DUCKING_MULTIPLIER;
|
||||
if( pmove->cmd.buttons & IN_BACK )
|
||||
forward -= flSpeed;
|
||||
fmove -= flSpeed;
|
||||
if( pmove->cmd.buttons & IN_FORWARD )
|
||||
forward += flSpeed;
|
||||
fmove += flSpeed;
|
||||
if( pmove->cmd.buttons & IN_MOVELEFT )
|
||||
right -= flSpeed;
|
||||
fmove -= flSpeed;
|
||||
if( pmove->cmd.buttons & IN_MOVERIGHT )
|
||||
right += flSpeed;
|
||||
fmove += flSpeed;
|
||||
|
||||
forward = ( fmove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) - ( smove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
right = ( fmove * ( sin( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) ) + ( smove * ( cos( pmove->cmd.viewangles[YAW] * ( M_PI / 180 ) ) ) );
|
||||
|
||||
if( pmove->cmd.buttons & IN_JUMP )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue