mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-04-22 10:57:25 +00:00
fixed crowbar sounds(HLS Fixed init)
This commit is contained in:
parent
387ecab0f3
commit
8d3f0b06ac
@ -6,8 +6,6 @@
|
|||||||
//=============================================================================//
|
//=============================================================================//
|
||||||
|
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
#include "convar.h"
|
|
||||||
#include "iconvar.h"
|
|
||||||
#include "hl1mp_basecombatweapon_shared.h"
|
#include "hl1mp_basecombatweapon_shared.h"
|
||||||
|
|
||||||
#ifdef CLIENT_DLL
|
#ifdef CLIENT_DLL
|
||||||
@ -18,8 +16,6 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "soundent.h"
|
#include "soundent.h"
|
||||||
#endif
|
#endif
|
||||||
#include "decals.h"
|
|
||||||
#include "hl1_basecombatweapon_shared.h"
|
|
||||||
|
|
||||||
#include "gamerules.h"
|
#include "gamerules.h"
|
||||||
#include "ammodef.h"
|
#include "ammodef.h"
|
||||||
@ -27,33 +23,29 @@
|
|||||||
#include "in_buttons.h"
|
#include "in_buttons.h"
|
||||||
|
|
||||||
#include "vstdlib/random.h"
|
#include "vstdlib/random.h"
|
||||||
//For CrowbarVolume function
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
extern ConVar sk_plr_dmg_crowbar;
|
extern ConVar sk_plr_dmg_crowbar;
|
||||||
|
|
||||||
//new conVars for crowbar
|
|
||||||
//Crowbar Sounds
|
//Crowbar Sounds
|
||||||
ConVar hl1_crowbar_sound("hl1_crowbar_sound", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_sound;
|
||||||
ConVar hl1_crowbar_concrete("hl1_crowbar_concrete", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_concrete;
|
||||||
ConVar hl1_crowbar_metal("hl1_crowbar_metal", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_metal;
|
||||||
ConVar hl1_crowbar_dirt("hl1_crowbar_dirt", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_dirt;
|
||||||
ConVar hl1_crowbar_vent("hl1_crowbar_vent", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_vent;
|
||||||
ConVar hl1_crowbar_grate("hl1_crowbar_grate", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_grate;
|
||||||
ConVar hl1_crowbar_tile("hl1_crowbar_tile", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_tile;
|
||||||
ConVar hl1_crowbar_wood("hl1_crowbar_wood", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_wood;
|
||||||
ConVar hl1_crowbar_glass("hl1_crowbar_glass", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_glass;
|
||||||
ConVar hl1_crowbar_computer("hl1_crowbar_computer", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_computer;
|
||||||
|
|
||||||
ConVar hl1_crowbar_concrete_vol("hl1_crowbar_concrete_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_concrete_vol;
|
||||||
ConVar hl1_crowbar_metal_vol("hl1_crowbar_metal_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_metal_vol;
|
||||||
ConVar hl1_crowbar_dirt_vol("hl1_crowbar_dirt_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_dirt_vol;
|
||||||
ConVar hl1_crowbar_vent_vol("hl1_crowbar_vent_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_vent_vol;
|
||||||
ConVar hl1_crowbar_grate_vol("hl1_crowbar_grate_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_grate_vol;
|
||||||
ConVar hl1_crowbar_tile_vol("hl1_crowbar_tile_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_wood_vol;
|
||||||
ConVar hl1_crowbar_wood_vol("hl1_crowbar_wood_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_glass_vol;
|
||||||
ConVar hl1_crowbar_glass_vol("hl1_crowbar_glass_vol", "1", FCVAR_NONE, NULL);
|
extern ConVar hl1_crowbar_computer_vol;
|
||||||
ConVar hl1_crowbar_computer_vol("hl1_crowbar_computer_vol", "1", FCVAR_NONE, NULL);
|
|
||||||
|
|
||||||
#define CROWBAR_RANGE 64.0f
|
#define CROWBAR_RANGE 64.0f
|
||||||
#define CROWBAR_REFIRE_MISS 0.5f
|
#define CROWBAR_REFIRE_MISS 0.5f
|
||||||
@ -64,69 +56,9 @@ ConVar hl1_crowbar_computer_vol("hl1_crowbar_computer_vol", "1", FCVAR_NONE, NUL
|
|||||||
#define CWeaponCrowbar C_WeaponCrowbar
|
#define CWeaponCrowbar C_WeaponCrowbar
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct TextureVolume
|
|
||||||
{
|
|
||||||
char type;
|
|
||||||
ConVar* enabledVar;
|
|
||||||
ConVar* volumeVar;
|
|
||||||
};
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// CWeaponCrowbar
|
// CWeaponCrowbar
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Define texture types and their associated ConVars
|
|
||||||
TextureVolume textureVolumes[] = {
|
|
||||||
{CHAR_TEX_CONCRETE, &hl1_crowbar_concrete, &hl1_crowbar_concrete_vol},
|
|
||||||
{CHAR_TEX_METAL, &hl1_crowbar_metal, &hl1_crowbar_metal_vol},
|
|
||||||
{CHAR_TEX_DIRT, &hl1_crowbar_dirt, &hl1_crowbar_dirt_vol},
|
|
||||||
{CHAR_TEX_VENT, &hl1_crowbar_vent, &hl1_crowbar_vent_vol},
|
|
||||||
{CHAR_TEX_GRATE, &hl1_crowbar_grate, &hl1_crowbar_grate_vol},
|
|
||||||
{CHAR_TEX_TILE, &hl1_crowbar_tile, &hl1_crowbar_tile_vol},
|
|
||||||
{CHAR_TEX_WOOD, &hl1_crowbar_wood, &hl1_crowbar_wood_vol},
|
|
||||||
{CHAR_TEX_GLASS, &hl1_crowbar_glass, &hl1_crowbar_glass_vol},
|
|
||||||
{CHAR_TEX_COMPUTER, &hl1_crowbar_computer, &hl1_crowbar_computer_vol}
|
|
||||||
};
|
|
||||||
|
|
||||||
float GetCrowbarVolume(const trace_t &ptr)
|
|
||||||
{
|
|
||||||
if (!hl1_crowbar_sound.GetBool())
|
|
||||||
return 0.0f;
|
|
||||||
|
|
||||||
float fvol = 0.0;
|
|
||||||
// Assume we determine the texture type based on entity properties or surface data
|
|
||||||
char mType = 0;
|
|
||||||
|
|
||||||
if (ptr.surface.name)
|
|
||||||
{
|
|
||||||
// Check the surface name for certain substrings to classify texture types
|
|
||||||
if (strstr(ptr.surface.name, "concrete")) mType = CHAR_TEX_CONCRETE;
|
|
||||||
else if (strstr(ptr.surface.name, "metal")) mType = CHAR_TEX_METAL;
|
|
||||||
else if (strstr(ptr.surface.name, "dirt")) mType = CHAR_TEX_DIRT;
|
|
||||||
else if (strstr(ptr.surface.name, "vent")) mType = CHAR_TEX_VENT;
|
|
||||||
else if (strstr(ptr.surface.name, "grate")) mType = CHAR_TEX_GRATE;
|
|
||||||
else if (strstr(ptr.surface.name, "tile")) mType = CHAR_TEX_TILE;
|
|
||||||
else if (strstr(ptr.surface.name, "wood")) mType = CHAR_TEX_WOOD;
|
|
||||||
else if (strstr(ptr.surface.name, "glass")) mType = CHAR_TEX_GLASS;
|
|
||||||
else if (strstr(ptr.surface.name, "computer")) mType = CHAR_TEX_COMPUTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& tv : textureVolumes)
|
|
||||||
{
|
|
||||||
if (mType == tv.type && tv.enabledVar->GetBool())
|
|
||||||
{
|
|
||||||
fvol = tv.volumeVar->GetFloat() / 10;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CBaseEntity* pEntity = ptr.m_pEnt;
|
|
||||||
if (pEntity && FClassnameIs(pEntity, "func_breakable"))
|
|
||||||
{
|
|
||||||
fvol /= 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fvol;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CWeaponCrowbar : public CBaseHL1MPCombatWeapon
|
class CWeaponCrowbar : public CBaseHL1MPCombatWeapon
|
||||||
{
|
{
|
||||||
@ -134,7 +66,7 @@ class CWeaponCrowbar : public CBaseHL1MPCombatWeapon
|
|||||||
public:
|
public:
|
||||||
DECLARE_NETWORKCLASS();
|
DECLARE_NETWORKCLASS();
|
||||||
DECLARE_PREDICTABLE();
|
DECLARE_PREDICTABLE();
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLLhl1_crowbar_tile_vol
|
||||||
DECLARE_DATADESC();
|
DECLARE_DATADESC();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -152,7 +84,7 @@ private:
|
|||||||
virtual void Swing( void );
|
virtual void Swing( void );
|
||||||
virtual void Hit( void );
|
virtual void Hit( void );
|
||||||
virtual void ImpactEffect( void );
|
virtual void ImpactEffect( void );
|
||||||
void ImpactSound( CBaseEntity *pHitEntity);
|
void ImpactSound( CBaseEntity *pHitEntity , trace_t &hitTrace );
|
||||||
virtual Activity ChooseIntersectionPointAndActivity( trace_t &hitTrace, const Vector &mins, const Vector &maxs, CBasePlayer *pOwner );
|
virtual Activity ChooseIntersectionPointAndActivity( trace_t &hitTrace, const Vector &mins, const Vector &maxs, CBasePlayer *pOwner );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -238,7 +170,7 @@ void CWeaponCrowbar::ItemPostFrame( void )
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void CWeaponCrowbar::PrimaryAttack()
|
void CWeaponCrowbar::PrimaryAttack()
|
||||||
{
|
{
|
||||||
this->Swing();
|
Swing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -273,7 +205,7 @@ void CWeaponCrowbar::Hit( void )
|
|||||||
TraceAttackToTriggers( CTakeDamageInfo( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ), m_traceHit.startpos, m_traceHit.endpos, hitDirection );
|
TraceAttackToTriggers( CTakeDamageInfo( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ), m_traceHit.startpos, m_traceHit.endpos, hitDirection );
|
||||||
|
|
||||||
//Play an impact sound
|
//Play an impact sound
|
||||||
ImpactSound( pHitEntity );
|
ImpactSound( pHitEntity , m_traceHit );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -286,7 +218,7 @@ void CWeaponCrowbar::Hit( void )
|
|||||||
// Input : pHitEntity - entity that we hit
|
// Input : pHitEntity - entity that we hit
|
||||||
// assumes pHitEntity is not null
|
// assumes pHitEntity is not null
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CWeaponCrowbar::ImpactSound( CBaseEntity *pHitEntity )
|
void CWeaponCrowbar::ImpactSound( CBaseEntity *pHitEntity , trace_t &hitTrace )
|
||||||
{
|
{
|
||||||
bool bIsWorld = ( pHitEntity->entindex() == 0 );
|
bool bIsWorld = ( pHitEntity->entindex() == 0 );
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLL
|
||||||
@ -295,18 +227,22 @@ void CWeaponCrowbar::ImpactSound( CBaseEntity *pHitEntity )
|
|||||||
bIsWorld |= pHitEntity->Classify() == CLASS_NONE || pHitEntity->Classify() == CLASS_MACHINE;
|
bIsWorld |= pHitEntity->Classify() == CLASS_NONE || pHitEntity->Classify() == CLASS_MACHINE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
trace_t Trace;
|
|
||||||
memset(&Trace, 0, sizeof(trace_t));
|
|
||||||
Trace.m_pEnt = pHitEntity;
|
|
||||||
|
|
||||||
float m_SoundTexture = GetCrowbarVolume(Trace);
|
|
||||||
if (bIsWorld)
|
if (bIsWorld)
|
||||||
{
|
{
|
||||||
WeaponSound(MELEE_HIT_WORLD, m_SoundTexture);
|
switch (random->RandomInt(0, 1))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
UTIL_EmitAmbientSound(GetOwner()->entindex(), GetOwner()->GetAbsOrigin(), "weapons/cbar_hit1.wav", 0.5, SNDLVL_GUNFIRE, 0, 98 + random->RandomInt(0, 3));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
UTIL_EmitAmbientSound(GetOwner()->entindex(), GetOwner()->GetAbsOrigin(), "weapons/cbar_hit2.wav", 0.5, SNDLVL_GUNFIRE, 0, 98 + random->RandomInt(0, 3));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WeaponSound(MELEE_HIT, m_SoundTexture);
|
WeaponSound(MELEE_HIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ using namespace vgui;
|
|||||||
|
|
||||||
COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : PropertyPage(parent, nullptr)
|
COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : PropertyPage(parent, nullptr)
|
||||||
{
|
{
|
||||||
|
#ifndef ANDROID // TODO: Android
|
||||||
// Create the slider for aspect ratio adjustments
|
// Create the slider for aspect ratio adjustments
|
||||||
m_pAspectRatioSlider = new CCvarSlider(
|
m_pAspectRatioSlider = new CCvarSlider(
|
||||||
this,
|
this,
|
||||||
@ -38,7 +39,7 @@ COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : Property
|
|||||||
|
|
||||||
m_aspectRatioLabel = new TextEntry(this, "AspectRatioLabel");
|
m_aspectRatioLabel = new TextEntry(this, "AspectRatioLabel");
|
||||||
m_aspectRatioLabel->AddActionSignalTarget(this);
|
m_aspectRatioLabel->AddActionSignalTarget(this);
|
||||||
|
#endif
|
||||||
m_pChangeCheatFlag = new CCvarToggleCheckButton(
|
m_pChangeCheatFlag = new CCvarToggleCheckButton(
|
||||||
this , "ChangeCheatFlag" , "Change Cheat Flag" , "sv_cheats"
|
this , "ChangeCheatFlag" , "Change Cheat Flag" , "sv_cheats"
|
||||||
);
|
);
|
||||||
|
@ -75,6 +75,7 @@ private:
|
|||||||
vgui::Label *m_pTouchPitchSensitivityPreLabel;
|
vgui::Label *m_pTouchPitchSensitivityPreLabel;
|
||||||
vgui::TextEntry *m_pTouchYawSensitivityLabel;
|
vgui::TextEntry *m_pTouchYawSensitivityLabel;
|
||||||
vgui::TextEntry *m_pTouchPitchSensitivityLabel; */
|
vgui::TextEntry *m_pTouchPitchSensitivityLabel; */
|
||||||
|
|
||||||
vgui::TextEntry *m_aspectRatioLabel;
|
vgui::TextEntry *m_aspectRatioLabel;
|
||||||
CCvarToggleCheckButton *m_pChangeCheatFlag;
|
CCvarToggleCheckButton *m_pChangeCheatFlag;
|
||||||
CCvarSlider *m_pAspectRatioSlider;
|
CCvarSlider *m_pAspectRatioSlider;
|
||||||
|
@ -1070,7 +1070,7 @@ COptionsSubVideo::COptionsSubVideo(vgui::Panel *parent) : PropertyPage(parent, N
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int iNormalItemID = m_pAspectRatio->AddItem( "lemonparty.org", NULL );
|
int iNormalItemID = m_pAspectRatio->AddItem( "NULL", NULL );
|
||||||
m_pAspectRatio->ActivateItem( iNormalItemID );
|
m_pAspectRatio->ActivateItem( iNormalItemID );
|
||||||
|
|
||||||
m_pGammaButton->SetEnabled(false);
|
m_pGammaButton->SetEnabled(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user