Compare commits

..

1 Commits

Author SHA1 Message Date
I#Oleg
6af4b8cf0c
Merge f792ec4b30 into 29985681a1 2025-01-15 09:30:32 +00:00
5 changed files with 115 additions and 65 deletions

View File

@ -6,6 +6,8 @@
//=============================================================================//
#include "cbase.h"
#include "convar.h"
#include "iconvar.h"
#include "hl1mp_basecombatweapon_shared.h"
#ifdef CLIENT_DLL
@ -16,6 +18,8 @@
#include "player.h"
#include "soundent.h"
#endif
#include "decals.h"
#include "hl1_basecombatweapon_shared.h"
#include "gamerules.h"
#include "ammodef.h"
@ -23,29 +27,33 @@
#include "in_buttons.h"
#include "vstdlib/random.h"
//For CrowbarVolume function
#include <string.h>
extern ConVar sk_plr_dmg_crowbar;
//new conVars for crowbar
//Crowbar Sounds
extern ConVar hl1_crowbar_sound;
extern ConVar hl1_crowbar_concrete;
extern ConVar hl1_crowbar_metal;
extern ConVar hl1_crowbar_dirt;
extern ConVar hl1_crowbar_vent;
extern ConVar hl1_crowbar_grate;
extern ConVar hl1_crowbar_tile;
extern ConVar hl1_crowbar_wood;
extern ConVar hl1_crowbar_glass;
extern ConVar hl1_crowbar_computer;
ConVar hl1_crowbar_sound("hl1_crowbar_sound", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_concrete("hl1_crowbar_concrete", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_metal("hl1_crowbar_metal", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_dirt("hl1_crowbar_dirt", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_vent("hl1_crowbar_vent", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_grate("hl1_crowbar_grate", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_tile("hl1_crowbar_tile", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_wood("hl1_crowbar_wood", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_glass("hl1_crowbar_glass", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_computer("hl1_crowbar_computer", "1", FCVAR_NONE, NULL);
extern ConVar hl1_crowbar_concrete_vol;
extern ConVar hl1_crowbar_metal_vol;
extern ConVar hl1_crowbar_dirt_vol;
extern ConVar hl1_crowbar_vent_vol;
extern ConVar hl1_crowbar_grate_vol;
extern ConVar hl1_crowbar_wood_vol;
extern ConVar hl1_crowbar_glass_vol;
extern ConVar hl1_crowbar_computer_vol;
ConVar hl1_crowbar_concrete_vol("hl1_crowbar_concrete_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_metal_vol("hl1_crowbar_metal_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_dirt_vol("hl1_crowbar_dirt_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_vent_vol("hl1_crowbar_vent_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_grate_vol("hl1_crowbar_grate_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_tile_vol("hl1_crowbar_tile_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_wood_vol("hl1_crowbar_wood_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_glass_vol("hl1_crowbar_glass_vol", "1", FCVAR_NONE, NULL);
ConVar hl1_crowbar_computer_vol("hl1_crowbar_computer_vol", "1", FCVAR_NONE, NULL);
#define CROWBAR_RANGE 64.0f
#define CROWBAR_REFIRE_MISS 0.5f
@ -56,9 +64,69 @@ extern ConVar hl1_crowbar_computer_vol;
#define CWeaponCrowbar C_WeaponCrowbar
#endif
struct TextureVolume
{
char type;
ConVar* enabledVar;
ConVar* volumeVar;
};
//-----------------------------------------------------------------------------
// 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
{
@ -66,7 +134,7 @@ class CWeaponCrowbar : public CBaseHL1MPCombatWeapon
public:
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
#ifndef CLIENT_DLLhl1_crowbar_tile_vol
#ifndef CLIENT_DLL
DECLARE_DATADESC();
#endif
@ -84,7 +152,7 @@ private:
virtual void Swing( void );
virtual void Hit( void );
virtual void ImpactEffect( void );
void ImpactSound( CBaseEntity *pHitEntity , trace_t &hitTrace );
void ImpactSound( CBaseEntity *pHitEntity);
virtual Activity ChooseIntersectionPointAndActivity( trace_t &hitTrace, const Vector &mins, const Vector &maxs, CBasePlayer *pOwner );
public:
@ -170,7 +238,7 @@ void CWeaponCrowbar::ItemPostFrame( void )
//------------------------------------------------------------------------------
void CWeaponCrowbar::PrimaryAttack()
{
Swing();
this->Swing();
}
@ -205,7 +273,7 @@ void CWeaponCrowbar::Hit( void )
TraceAttackToTriggers( CTakeDamageInfo( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ), m_traceHit.startpos, m_traceHit.endpos, hitDirection );
//Play an impact sound
ImpactSound( pHitEntity , m_traceHit );
ImpactSound( pHitEntity );
}
#endif
@ -218,7 +286,7 @@ void CWeaponCrowbar::Hit( void )
// Input : pHitEntity - entity that we hit
// assumes pHitEntity is not null
//-----------------------------------------------------------------------------
void CWeaponCrowbar::ImpactSound( CBaseEntity *pHitEntity , trace_t &hitTrace )
void CWeaponCrowbar::ImpactSound( CBaseEntity *pHitEntity )
{
bool bIsWorld = ( pHitEntity->entindex() == 0 );
#ifndef CLIENT_DLL
@ -227,23 +295,19 @@ void CWeaponCrowbar::ImpactSound( CBaseEntity *pHitEntity , trace_t &hitTrace )
bIsWorld |= pHitEntity->Classify() == CLASS_NONE || pHitEntity->Classify() == CLASS_MACHINE;
}
#endif
trace_t Trace;
memset(&Trace, 0, sizeof(trace_t));
Trace.m_pEnt = pHitEntity;
float m_SoundTexture = GetCrowbarVolume(Trace);
if (bIsWorld)
{
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
{
WeaponSound(MELEE_HIT);
}
{
WeaponSound(MELEE_HIT_WORLD, m_SoundTexture);
}
else
{
WeaponSound(MELEE_HIT, m_SoundTexture);
}
}
Activity CWeaponCrowbar::ChooseIntersectionPointAndActivity( trace_t &hitTrace, const Vector &mins, const Vector &maxs, CBasePlayer *pOwner )
@ -405,4 +469,4 @@ void CWeaponCrowbar::Swing( void )
//Send the anim
SendWeaponAnim( m_nHitActivity );
pOwner->SetAnimation( PLAYER_ATTACK1 );
}
}

View File

@ -233,10 +233,6 @@ $Project "GameUI"
$File "OptionsSubVideo.h"
$File "OptionsSubVoice.cpp"
$File "OptionsSubVoice.h"
$File "OptionsSubModificcation.cpp"
$File "OptionsSubModificcation.h"
}
$Folder "Link Libraries"

View File

@ -10,13 +10,11 @@
#include "OptionsSubModification.h"
#include "CvarSlider.h"
#include "CvarToggleCheckButton.h"
#include "EngineInterface.h"
#include <KeyValues.h>
#include <vgui/IScheme.h>
#include "tier1/convar.h"
#include "vgui_controls/Controls.h"
#include <vgui_controls/TextEntry.h>
// memdbgon must be the last include file in a .cpp file!!!
@ -26,9 +24,8 @@ using namespace vgui;
COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : PropertyPage(parent, nullptr)
{
#ifndef ANDROID // TODO: Android
// Create the slider for aspect ratio adjustments
m_pAspectRatioSlider = new CCvarSlider(
m_pEnableModificationsCheckBox = new CCvarSlider(
this,
"AspectRatioSlider",
"Aspect Ratio",
@ -36,17 +33,13 @@ COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : Property
"r_aspectratio",
true // Allow fractional values
);
m_aspectRatioLabel = new TextEntry(this, "AspectRatioLabel");
m_aspectRatioLabel->AddActionSignalTarget(this);
#endif
m_pChangeCheatFlag = new CCvarToggleCheckButton(
this , "ChangeCheatFlag" , "Change Cheat Flag" , "sv_cheats"
);
// Load settings from the associated resource file
LoadControlSettings("Resource\\OptionsSubModification.res");
UpdateLabel(m_pAspectRatioSlider, m_aspectRatioLabel);
UpdateLabel(m_pEnableModificationsCheckBox, m_aspectRatioLabel);
}
COptionsSubModification::~COptionsSubModification() = default;
@ -61,7 +54,7 @@ void COptionsSubModification::OnTextChanged(Panel *panel)
int numParsed = sscanf(buf, "%f", &fValue);
if ((numParsed == 1) && (fValue >= 0.0f))
{
m_pAspectRatioSlider->SetSliderValue(fValue);
m_pEnableModificationsCheckBox->SetSliderValue(fValue);
PostActionSignal(new KeyValues("ApplyButtonEnable"));
}
}
@ -71,8 +64,8 @@ void COptionsSubModification::OnTextChanged(Panel *panel)
//-----------------------------------------------------------------------------
void COptionsSubModification::OnResetData()
{
m_pAspectRatioSlider->Reset();
m_pChangeCheatFlag->Reset();
m_pEnableModificationsCheckBox->Reset();
// m_aspectRatioLabel->Reset();
}
//-----------------------------------------------------------------------------
@ -80,9 +73,8 @@ void COptionsSubModification::OnResetData()
//-----------------------------------------------------------------------------
void COptionsSubModification::OnApplyChanges()
{
m_pAspectRatioSlider->ApplyChanges();
m_pChangeCheatFlag->ApplyChanges();
m_pEnableModificationsCheckBox->ApplyChanges();
// m_aspectRatioLabel->ApplyChanges();
}
//-----------------------------------------------------------------------------
@ -93,9 +85,9 @@ void COptionsSubModification::OnControlModified(Panel *panel)
PostActionSignal(new KeyValues("ApplyButtonEnable"));
// Update the label based on slider changes
if (panel == m_pAspectRatioSlider && m_pAspectRatioSlider->HasBeenModified())
if (panel == m_pEnableModificationsCheckBox && m_pEnableModificationsCheckBox->HasBeenModified())
{
UpdateLabel(m_pAspectRatioSlider, m_aspectRatioLabel);
UpdateLabel(m_pEnableModificationsCheckBox, m_aspectRatioLabel);
}
}

View File

@ -75,10 +75,8 @@ private:
vgui::Label *m_pTouchPitchSensitivityPreLabel;
vgui::TextEntry *m_pTouchYawSensitivityLabel;
vgui::TextEntry *m_pTouchPitchSensitivityLabel; */
vgui::TextEntry *m_aspectRatioLabel;
CCvarToggleCheckButton *m_pChangeCheatFlag;
CCvarSlider *m_pAspectRatioSlider;
CCvarSlider *m_pEnableModificationsCheckBox;
};
#endif // OPTIONS_SUB_MODIFICATION_H

View File

@ -1070,7 +1070,7 @@ COptionsSubVideo::COptionsSubVideo(vgui::Panel *parent) : PropertyPage(parent, N
break;
}
#else
int iNormalItemID = m_pAspectRatio->AddItem( "NULL", NULL );
int iNormalItemID = m_pAspectRatio->AddItem( "lemonparty.org", NULL );
m_pAspectRatio->ActivateItem( iNormalItemID );
m_pGammaButton->SetEnabled(false);