Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: game/client/c_prop_vehicle.cpp
- ===================================================================
- --- game/client/c_prop_vehicle.cpp (revision 1)
- +++ game/client/c_prop_vehicle.cpp (working copy)
- @@ -228,6 +228,11 @@
- #define TRIANGULATED_CROSSHAIR 1
- +int C_PropVehicleDriveable::Speed()
- +{
- + return m_nSpeed;
- +}
- +
- void C_PropVehicleDriveable::DrawHudElements( )
- {
- CHudTexture *pIcon;
- Index: game/client/c_prop_vehicle.h
- ===================================================================
- --- game/client/c_prop_vehicle.h (revision 1)
- +++ game/client/c_prop_vehicle.h (working copy)
- @@ -73,6 +73,8 @@
- // Mark the shadow as dirty while the vehicle is being driven
- virtual void ClientThink( void );
- + virtual int Speed();
- +
- // C_PropVehicleDriveable
- public:
- Index: game/client/c_vehicle_choreo_generic.cpp
- ===================================================================
- --- game/client/c_vehicle_choreo_generic.cpp (revision 1)
- +++ game/client/c_vehicle_choreo_generic.cpp (working copy)
- @@ -74,6 +74,7 @@
- virtual bool IsPredicted() const { return false; }
- virtual void ItemPostFrame( C_BasePlayer *pPlayer ) {}
- virtual bool IsSelfAnimating() { return false; };
- + virtual int Speed() { return 0; }
- private:
- Index: game/client/c_vehicle_jeep.cpp
- ===================================================================
- --- game/client/c_vehicle_jeep.cpp (revision 1)
- +++ game/client/c_vehicle_jeep.cpp (working copy)
- @@ -41,6 +41,7 @@
- ConVarRef r_JeepFOV( "r_JeepFOV" );
- m_ViewSmoothingData.flFOV = r_JeepFOV.GetFloat();
- +
- }
- //-----------------------------------------------------------------------------
- Index: game/client/hl2/c_vehicle_cannon.cpp
- ===================================================================
- --- game/client/hl2/c_vehicle_cannon.cpp (revision 1)
- +++ game/client/hl2/c_vehicle_cannon.cpp (working copy)
- @@ -50,6 +50,7 @@
- virtual int GetPrimaryAmmoClip() const { return -1; }
- virtual bool PrimaryAmmoUsesClips() const { return false; }
- virtual int GetJoystickResponseCurve() const { return 0; }
- + virtual int Speed() { return 0; }
- public:
- Index: game/client/hl2/c_vehicle_crane.h
- ===================================================================
- --- game/client/hl2/c_vehicle_crane.h (revision 1)
- +++ game/client/hl2/c_vehicle_crane.h (working copy)
- @@ -47,6 +47,7 @@
- virtual int GetPrimaryAmmoClip() const { return -1; }
- virtual bool PrimaryAmmoUsesClips() const { return false; }
- virtual int GetJoystickResponseCurve() const { return 0; }
- + virtual int Speed() { return 0; }
- public:
- Index: game/client/hl2/c_vehicle_prisoner_pod.cpp
- ===================================================================
- --- game/client/hl2/c_vehicle_prisoner_pod.cpp (revision 1)
- +++ game/client/hl2/c_vehicle_prisoner_pod.cpp (working copy)
- @@ -68,6 +68,7 @@
- virtual int GetPrimaryAmmoClip() const { return -1; }
- virtual bool PrimaryAmmoUsesClips() const { return false; }
- virtual int GetJoystickResponseCurve() const { return 0; }
- + virtual int Speed() { return 0; }
- public:
- Index: game/client/hl2/hud_ammo.cpp
- ===================================================================
- --- game/client/hl2/hud_ammo.cpp (revision 1)
- +++ game/client/hl2/hud_ammo.cpp (working copy)
- @@ -44,7 +44,7 @@
- void UpdateAmmoDisplays();
- void UpdatePlayerAmmo( C_BasePlayer *player );
- void UpdateVehicleAmmo( C_BasePlayer *player, IClientVehicle *pVehicle );
- -
- +
- private:
- CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
- CHandle< C_BaseEntity > m_hCurrentVehicle;
- @@ -75,7 +75,7 @@
- {
- m_iAmmo = -1;
- m_iAmmo2 = -1;
- -
- +
- m_iconPrimaryAmmo = NULL;
- wchar_t *tempString = g_pVGuiLocalize->Find("#Valve_Hud_AMMO");
- @@ -127,7 +127,7 @@
- if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
- {
- hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
- - hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );
- + hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );
- SetPaintEnabled(false);
- SetPaintBackgroundEnabled(false);
- @@ -189,6 +189,12 @@
- void CHudAmmo::UpdateVehicleAmmo( C_BasePlayer *player, IClientVehicle *pVehicle )
- {
- + // HudSpeed overrides this.
- + SetPaintEnabled(false);
- + SetPaintBackgroundEnabled(false);
- + return;
- +
- + /*
- m_hCurrentActiveWeapon = NULL;
- CBaseEntity *pVehicleEnt = pVehicle->GetVehicleEnt();
- @@ -244,6 +250,7 @@
- g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponChanged");
- m_hCurrentVehicle = pVehicleEnt;
- }
- + */
- }
- //-----------------------------------------------------------------------------
- @@ -345,7 +352,7 @@
- // Figure out where we're going to put this
- int x = text_xpos + ( nLabelWidth - m_iconPrimaryAmmo->Width() ) / 2;
- int y = text_ypos - ( nLabelHeight + ( m_iconPrimaryAmmo->Height() / 2 ) );
- -
- +
- m_iconPrimaryAmmo->DrawSelf( x, y, GetFgColor() );
- }
- #endif // HL2MP
- @@ -486,17 +493,16 @@
- g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseSecondaryAmmo");
- }
- m_hCurrentActiveWeapon = wpn;
- -
- +
- // Get the icon we should be displaying
- m_iconSecondaryAmmo = gWR.GetAmmoIconFromWeapon( m_hCurrentActiveWeapon->GetSecondaryAmmoType() );
- }
- }
- -
- +
- private:
- CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
- CHudTexture *m_iconSecondaryAmmo;
- int m_iAmmo;
- };
- -DECLARE_HUDELEMENT( CHudSecondaryAmmo );
- -
- +DECLARE_HUDELEMENT( CHudSecondaryAmmo );
- \ No newline at end of file
- Index: game/client/hl2/hud_speed.cpp
- ===================================================================
- --- game/client/hl2/hud_speed.cpp (revision 0)
- +++ game/client/hl2/hud_speed.cpp (revision 0)
- @@ -0,0 +1,121 @@
- +#include "cbase.h"
- +#include "hud.h"
- +#include "hudelement.h"
- +#include "hud_macros.h"
- +#include "hud_numericdisplay.h"
- +#include "iclientmode.h"
- +#include "iclientvehicle.h"
- +#include <vgui_controls/AnimationController.h>
- +#include <vgui/ILocalize.h>
- +#include <vgui/ISurface.h>
- +#include "ihudlcd.h"
- +
- +// memdbgon must be the last include file in a .cpp file!!!
- +#include "tier0/memdbgon.h"
- +
- +using namespace vgui;
- +
- +//-----------------------------------------------------------------------------
- +// Purpose: Displays current ammunition level
- +//-----------------------------------------------------------------------------
- +class CHudSpeed : public CHudNumericDisplay, public CHudElement
- +{
- + DECLARE_CLASS_SIMPLE( CHudSpeed, CHudNumericDisplay );
- +
- +public:
- + CHudSpeed( const char *pElementName );
- + void Init( void );
- + void VidInit( void );
- + void Reset();
- +
- + virtual void Paint( void );
- +
- +protected:
- + virtual void OnThink();
- +
- +private:
- + CHandle< C_BaseEntity > m_hCurrentVehicle;
- +};
- +
- +DECLARE_HUDELEMENT( CHudSpeed );
- +
- +//-----------------------------------------------------------------------------
- +// Purpose: Constructor
- +//-----------------------------------------------------------------------------
- +CHudSpeed::CHudSpeed( const char *pElementName ) : BaseClass(NULL, "HudSpeed"), CHudElement( pElementName )
- +{
- + SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT | HIDEHUD_WEAPONSELECTION );
- +
- + hudlcd->SetGlobalStat( "(speed_vehicle)", "0" );
- +}
- +
- +//-----------------------------------------------------------------------------
- +// Purpose:
- +//-----------------------------------------------------------------------------
- +void CHudSpeed::Init( void )
- +{
- + SetLabelText(L"Speed");
- +}
- +
- +//-----------------------------------------------------------------------------
- +// Purpose:
- +//-----------------------------------------------------------------------------
- +void CHudSpeed::VidInit( void )
- +{
- +}
- +
- +//-----------------------------------------------------------------------------
- +// Purpose: Resets hud after save/restore
- +//-----------------------------------------------------------------------------
- +void CHudSpeed::Reset()
- +{
- + BaseClass::Reset();
- + m_hCurrentVehicle = NULL;
- +
- + OnThink();
- +}
- +
- +//-----------------------------------------------------------------------------
- +// Purpose: called every frame to get ammo info from the weapon
- +//-----------------------------------------------------------------------------
- +void CHudSpeed::OnThink()
- +{
- + C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
- + IClientVehicle *pVehicle = player ? player->GetVehicle() : NULL;
- +
- + if ( pVehicle )
- + {
- + CBaseEntity *pVehicleEnt = pVehicle->GetVehicleEnt();
- +
- + if ( !pVehicleEnt )
- + {
- + SetPaintEnabled(false);
- + SetPaintBackgroundEnabled(false);
- + SetShouldDisplayValue(false);
- + return;
- + }
- +
- + m_hCurrentVehicle = pVehicleEnt;
- +
- + SetShouldDisplayValue(true);
- + SetPaintEnabled(true);
- + SetPaintBackgroundEnabled(true);
- +
- + SetDisplayValue( (int)((float)pVehicle->Speed() * 1.4) );
- + }
- + else
- + {
- + SetPaintEnabled(false);
- + SetPaintBackgroundEnabled(false);
- + SetShouldDisplayValue(false);
- + return;
- + }
- +}
- +
- +//-----------------------------------------------------------------------------
- +// Purpose: We add an icon into the
- +//-----------------------------------------------------------------------------
- +void CHudSpeed::Paint( void )
- +{
- + BaseClass::Paint();
- +}
- \ No newline at end of file
- Index: game/client/iclientvehicle.h
- ===================================================================
- --- game/client/iclientvehicle.h (revision 1)
- +++ game/client/iclientvehicle.h (working copy)
- @@ -46,6 +46,8 @@
- // Allows vehicles to choose their own curves for players using joysticks
- virtual int GetJoystickResponseCurve() const = 0;
- + virtual int Speed() = 0;
- +
- #ifdef HL2_CLIENT_DLL
- // Ammo in the vehicles
- virtual int GetPrimaryAmmoType() const = 0;
- Index: game/server/hl2/vehicle_crane.cpp
- ===================================================================
- --- game/server/hl2/vehicle_crane.cpp (revision 1)
- +++ game/server/hl2/vehicle_crane.cpp (working copy)
- @@ -852,7 +852,7 @@
- //-----------------------------------------------------------------------------
- void CPropCrane::InputForcePlayerIn( inputdata_t &inputdata )
- {
- - CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
- + CBasePlayer *pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
- if ( pPlayer && !m_hPlayer )
- {
- GetServerVehicle()->HandlePassengerEntry( pPlayer, 0 );
- @@ -1115,3 +1115,6 @@
- return pCraneTip;
- }
- +
- +
- +
- Index: game/server/hl2/vehicle_crane.h
- ===================================================================
- --- game/server/hl2/vehicle_crane.h (revision 1)
- +++ game/server/hl2/vehicle_crane.h (working copy)
- @@ -88,6 +88,7 @@
- virtual bool IsPassengerEntering( void ) { return false; } // NOTE: This mimics the scenario HL2 would have seen
- virtual bool IsPassengerExiting( void ) { return false; }
- + virtual int Speed() { return 0; }
- protected:
- CPropCrane *GetCrane( void );
- Index: game/server/hl2/vehicle_prisoner_pod.cpp
- ===================================================================
- --- game/server/hl2/vehicle_prisoner_pod.cpp (revision 1)
- +++ game/server/hl2/vehicle_prisoner_pod.cpp (working copy)
- @@ -61,6 +61,7 @@
- virtual bool IsPassengerEntering( void ) { return false; } // NOTE: This mimics the scenario HL2 would have seen
- virtual bool IsPassengerExiting( void ) { return false; }
- + virtual int Speed() { return 0; }
- protected:
- @@ -595,8 +596,8 @@
- CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator );
- if ( pPassenger == NULL )
- {
- - // Activator was not a player, just grab the singleplayer player.
- - pPassenger = UTIL_PlayerByIndex( 1 );
- + // Activator was not a player, just grab the nearest player.
- + pPassenger = UTIL_GetNearestPlayer(GetAbsOrigin());
- if ( pPassenger == NULL )
- return;
- }
- @@ -622,8 +623,8 @@
- CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator );
- if ( pPassenger == NULL )
- {
- - // Activator was not a player, just grab the singleplayer player.
- - pPassenger = UTIL_PlayerByIndex( 1 );
- + // Activator was not a player, just grab the nearest player.
- + pPassenger = UTIL_GetNearestPlayer(GetAbsOrigin());
- if ( pPassenger == NULL )
- return;
- }
- Index: game/server/hl2/vehicle_viewcontroller.cpp
- ===================================================================
- --- game/server/hl2/vehicle_viewcontroller.cpp (revision 1)
- +++ game/server/hl2/vehicle_viewcontroller.cpp (working copy)
- @@ -134,7 +134,7 @@
- //-----------------------------------------------------------------------------
- void CPropVehicleViewController::InputForcePlayerIn( inputdata_t &inputdata )
- {
- - CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
- + CBasePlayer *pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
- if ( !pPlayer )
- return;
- Index: game/server/vehicle_base.cpp
- ===================================================================
- --- game/server/vehicle_base.cpp (revision 1)
- +++ game/server/vehicle_base.cpp (working copy)
- @@ -1137,6 +1137,11 @@
- }
- }
- +int CFourWheelServerVehicle::Speed()
- +{
- + return m_pVehicle->m_flSpeed;
- +}
- +
- //-----------------------------------------------------------------------------
- // Purpose: Modify the player view/camera while in a vehicle
- //-----------------------------------------------------------------------------
- Index: game/server/vehicle_base.h
- ===================================================================
- --- game/server/vehicle_base.h (revision 1)
- +++ game/server/vehicle_base.h (working copy)
- @@ -57,6 +57,7 @@
- CPropVehicleDriveable *GetFourWheelVehicle( void );
- bool GetWheelContactPoint( int nWheelIndex, Vector &vecPos );
- + int Speed();
- public:
- virtual void SetVehicle( CBaseEntity *pVehicle );
- Index: game/shared/IVehicle.h
- ===================================================================
- --- game/shared/IVehicle.h (revision 1)
- +++ game/shared/IVehicle.h (working copy)
- @@ -41,6 +41,8 @@
- // Process input
- virtual void ItemPostFrame( CBasePlayer *pPlayer ) = 0;
- +
- + virtual int Speed() = 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement