Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions game/neo/scripts/HudLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,20 @@
"sprint_text_color" "255 255 255 100"
"sprint_color" "255 255 255 150"
}
neo_walking_indicator
{
"fieldName" "neo_walking_indicator"
"visible" "1"

"xpos" "208"
"ypos" "446"
"wide" "24"
"tall" "24"
"color" "255 255 255 200"
"texture" "vgui/hud/player/walkingIndicator"

"barwidth" "0"
}
RoundResult
{
"fieldName" "RoundResult"
Expand Down
2 changes: 2 additions & 0 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,7 @@ set(UNITY_SOURCE_NEO_UI
neo/ui/neo_hud_player_ping.cpp
neo/ui/neo_hud_round_state.cpp
neo/ui/neo_hud_startup_sequence.cpp
neo/ui/neo_hud_walking_indicator.cpp
neo/ui/neo_hud_worldpos_marker.cpp
neo/ui/neo_hud_worldpos_marker_generic.cpp
neo/ui/neo_scoreboard.cpp
Expand Down Expand Up @@ -1706,6 +1707,7 @@ target_sources_grouped(
neo/ui/neo_hud_player_ping.h
neo/ui/neo_hud_round_state.h
neo/ui/neo_hud_startup_sequence.h
neo/ui/neo_hud_walking_indicator.h
neo/ui/neo_hud_worldpos_marker.h
neo/ui/neo_hud_worldpos_marker_generic.h
neo/ui/neo_scoreboard.h
Expand Down
3 changes: 3 additions & 0 deletions src/game/client/neo/c_neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ class C_NEO_Player : public C_HL2MP_Player

bool ValidTakeoverTargetFor(CNEO_Player* pPlayerTakingOver);

bool ShouldPlayerMakeFootsteps(float speed = -1.f);
float SpeedFractionToSoundThreshold(float speed = -1.f);

private:
char m_sNameWithTakeoverContextProcessingBuffer[MAX_PLAYER_NAME_LENGTH];
void CheckAimButtons();
Expand Down
79 changes: 79 additions & 0 deletions src/game/client/neo/ui/neo_hud_walking_indicator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "cbase.h"
#include "neo_hud_walking_indicator.h"

#include "iclientmode.h"
#include <vgui/ISurface.h>

#include "c_neo_player.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

DECLARE_NAMED_HUDELEMENT(CNEOHud_WalkingIndicator, neo_walking_indicator);

NEO_HUD_ELEMENT_DECLARE_FREQ_CVAR(WalkingIndicator, 0.1)

CNEOHud_WalkingIndicator::CNEOHud_WalkingIndicator(const char *pElementName, vgui::Panel *parent)
: CHudElement(pElementName), Panel(parent, pElementName)
{
SetAutoDelete(true);
m_iHideHudElementNumber = NEO_HUD_ELEMENT_WALKING_INDICATOR;

if (parent) {
SetParent(parent);
}
else
{
SetParent(g_pClientMode->GetViewport());
}

SetVisible(true);
}

void CNEOHud_WalkingIndicator::ApplySchemeSettings(vgui::IScheme* pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);

SetBounds(xpos, ypos, wide, tall);
SetFgColor(COLOR_TRANSPARENT);
SetBgColor(COLOR_TRANSPARENT);
}

void CNEOHud_WalkingIndicator::UpdateStateForNeoHudElementDraw()
{
}

void CNEOHud_WalkingIndicator::DrawNeoHudElement()
{
if (!ShouldDraw() || !visible)
return;

C_NEO_Player* pLocalPlayer = C_NEO_Player::GetLocalNEOPlayer();
if (!pLocalPlayer)
return;

C_NEO_Player* pTargetPlayer = pLocalPlayer->IsObserver() && (pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE || pLocalPlayer->GetObserverMode() == OBS_MODE_CHASE) ? static_cast<C_NEO_Player *>(pLocalPlayer->GetObserverTarget()) : pLocalPlayer;
if (!pTargetPlayer)
return;

if (!pTargetPlayer->IsAlive() || !pTargetPlayer->IsWalking())
return;

vgui::surface()->DrawSetTexture(texture);
vgui::surface()->DrawSetColor(color);
vgui::surface()->DrawTexturedRect(0, 0, wide, tall);

if (barwidth)
{
const float percentageTowardsGraceThreshold = pTargetPlayer->SpeedFractionToSoundThreshold();
const float colourGB = 255 - (255 * (percentageTowardsGraceThreshold < 1 ? percentageTowardsGraceThreshold * 0.5f : 1));
vgui::surface()->DrawSetColor(255, colourGB, colourGB, 255);
vgui::surface()->DrawFilledRect(0, tall - (tall * percentageTowardsGraceThreshold), barwidth, tall);
}
}

void CNEOHud_WalkingIndicator::Paint()
{
BaseClass::Paint();
PaintNeoElement();
}
36 changes: 36 additions & 0 deletions src/game/client/neo/ui/neo_hud_walking_indicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include "neo_hud_childelement.h"
#include "hudelement.h"
#include <vgui_controls/Panel.h>

class CNEOHud_WalkingIndicator : public CNEOHud_ChildElement, public CHudElement, public vgui::Panel
{
DECLARE_CLASS_SIMPLE(CNEOHud_WalkingIndicator, Panel);

public:
CNEOHud_WalkingIndicator(const char *pElementName, vgui::Panel *parent = NULL);
void ApplySchemeSettings(vgui::IScheme* pScheme) override;

virtual void Paint() override;

protected:
virtual void UpdateStateForNeoHudElementDraw() override;
virtual void DrawNeoHudElement() override;
virtual ConVar* GetUpdateFrequencyConVar() const override;

private:
CPanelAnimationVarAliasType(bool, visible, "visible", "1", "bool");

CPanelAnimationVarAliasType(int, xpos, "xpos", "r203", "proportional_xpos");
CPanelAnimationVarAliasType(int, ypos, "ypos", "446", "proportional_ypos");
CPanelAnimationVarAliasType(int, wide, "wide", "24", "proportional_xpos");
CPanelAnimationVarAliasType(int, tall, "tall", "24", "proportional_ypos");
CPanelAnimationVarAliasType(Color, color, "color", "150 150 150 40", "Color");
CPanelAnimationVarAliasType(int, texture, "texture", "vgui/hud/player/walkingIndicatorInverted", "textureid");

CPanelAnimationVarAliasType(int, barwidth, "barwidth", "0", "proportional_xpos");

private:
CNEOHud_WalkingIndicator(const CNEOHud_WalkingIndicator&other);
};
32 changes: 32 additions & 0 deletions src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ ConVar sv_neo_warmup_godmode("sv_neo_warmup_godmode", "0", FCVAR_REPLICATED, "If
ConVar bot_class("bot_class", "-1", 0, "Force all bots to spawn with the specified class number, or -1 to disable.", true, NEO_CLASS_RANDOM, true, NEO_CLASS_LOADOUTABLE_COUNT-1);
static void BotChangeClassFn(const CCommand& args);
ConCommand bot_changeclass("bot_changeclass", BotChangeClassFn, "Force all bots to switch to the specified class number.");
static void BotChangeSkinFn(const CCommand& args);
ConCommand bot_changeskin("bot_changeskin", BotChangeSkinFn, "Force all bots to switch to the specified skin number.");

// Bot Cloak Detection Thresholds
// Base detection chance ratio (0.0 - 1.0) for bots to notice a cloaked target based on difficulty
Expand Down Expand Up @@ -4532,3 +4534,33 @@ static void BotChangeClassFn(const CCommand& args)
player->RequestSetClass(botClass);
}
}

static void BotChangeSkinFn(const CCommand& args)
{
constexpr int minValue = NEO_SKIN_FIRST;
constexpr int maxValue = NEO_SKIN__ENUM_COUNT - 1;

const auto nag = [&args]() {
Msg("Format: %s <number between %d and %d>\n", args.Arg(0), minValue, maxValue);
};

if (args.ArgC() != 2)
{
nag();
return;
}

const int botSkin = V_atoi(args.Arg(1));
if (botSkin < minValue || botSkin > maxValue)
{
nag();
return;
}

for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
auto* player = assert_cast<CNEO_Player*>(UTIL_PlayerByIndex(i));
if (player && player->IsBot() && player->GetTeamNumber() >= FIRST_GAME_TEAM)
player->RequestSetSkin(botSkin);
}
}
3 changes: 3 additions & 0 deletions src/game/server/neo/neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ class CNEO_Player : public CHL2MP_Player
bool IsAFK() const;
bool ValidTakeoverTargetFor(CNEO_Player* pPlayerTakingOver);

bool ShouldPlayerMakeFootsteps(float speed = -1.f);
float SpeedFractionToSoundThreshold(float speed = -1.f);

private:
bool m_bAllowGibbing;

Expand Down
23 changes: 6 additions & 17 deletions src/game/shared/baseplayer_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,29 +693,18 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri
}

#ifdef NEO
// Changing movement direction, looking around, wall-running accelerate the player. Threshold should be lower than regular speed, but higher than walk/aim speed
constexpr float SILENT_THRESHOLD_GRACE = 0.7f;
#endif //NEO
if (!neoPlayer->ShouldPlayerMakeFootsteps(speed))
{
return;
}
#endif // NEO

// play the sound
// 65% volume if ducking
if ( GetFlags() & FL_DUCKING )
{
fvol *= 0.65;
#ifdef NEO
if ((neoPlayer->IsInAim() || neoPlayer->IsWalking()) && speed <= (neoPlayer->GetCrouchSpeed() * SILENT_THRESHOLD_GRACE))
{
return;
}
#endif // NEO
}
#ifdef NEO

else if ((neoPlayer->IsInAim() || neoPlayer->IsWalking()) && speed <= (neoPlayer->GetNormSpeed() * SILENT_THRESHOLD_GRACE))
{
return;
}

#endif
PlayStepSound( feet, psurface, fvol, false );
}

Expand Down
1 change: 1 addition & 0 deletions src/game/shared/neo/neo_gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ enum NeoHudElements : NEO_HUD_BITS_UNDERLYING_TYPE {
NEO_HUD_ELEMENT_SCOREBOARD = (static_cast<NEO_HUD_BITS_UNDERLYING_TYPE>(1) << 14),
NEO_HUD_ELEMENT_PLAYER_PING = (static_cast<NEO_HUD_BITS_UNDERLYING_TYPE>(1) << 15),
NEO_HUD_ELEMENT_WORLDPOS_MARKER_ENT = (static_cast<NEO_HUD_BITS_UNDERLYING_TYPE>(1) << 16),
NEO_HUD_ELEMENT_WALKING_INDICATOR = (static_cast<NEO_HUD_BITS_UNDERLYING_TYPE>(1) << 17),
};

enum NeoSpectateEvent {
Expand Down
53 changes: 53 additions & 0 deletions src/game/shared/neo/neo_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,57 @@ CBaseEntity *CNEO_Player::FindUseEntity()
}

return pNearest;
}

// Changing movement direction, looking around, wall-running accelerate the player. Raise the threshold.
constexpr float SILENT_THRESHOLD_GRACE = 0.7f;
#define MAX_SILENT_SPEED SILENT_THRESHOLD_GRACE * (GetFlags() & FL_DUCKING ? GetCrouchSpeed() : GetNormSpeed())
bool CNEO_Player::ShouldPlayerMakeFootsteps(float speed) // Could simply always get speed from the player, but didnt want to risk changing the behavior of UpdateStepSound in baseplayer_shared
{
if (speed < 0)
{
speed = GetAbsVelocity().Length();
}

if (const bool canBeSilent = IsInAim() || IsWalking();
!canBeSilent)
{
return true;
}

if (speed <= MAX_SILENT_SPEED)
{
return false;
}

return true;
}

float CNEO_Player::SpeedFractionToSoundThreshold(float speed)
{
if (speed < 0)
{
speed = GetAbsVelocity().Length();
}

if (const bool canBeSilent = IsInAim() || IsWalking())
{
const float bottom = GetPlayerMaxSpeed();
if (speed < bottom)
{
return 0.f;
}

float top = MAX_SILENT_SPEED;
if (speed > top)
{
return 1.f;
}

top -= bottom;
speed -= bottom;
return top != 0 ? speed / top : 1.f;
}

return 1.f;
}