Skip to content
Closed
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
9 changes: 9 additions & 0 deletions game/neo/scripts/game_sounds_weapons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,15 @@
// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named reload_<step>; a step's later sounds add _part2, _part3.
// Each file starts just before its first transient

"weapon_zr68.reload_unload"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" ")weapons/zr68/zr68_reload_unload.wav"
}

"weapon_zr68.reload_load"
{
"channel" "CHAN_ITEM"
Expand Down
2 changes: 2 additions & 0 deletions game/neo/scripts/weapon_zr68c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ WeaponData

// Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers
"ReloadPhases" {}
// Chamber capacity is gameplay data; the phase timing comes from neoAssets.
"ChamberedRound" "1"

"TPMuzzleFlashScale" "0.5"

Expand Down
65 changes: 59 additions & 6 deletions src/game/client/neo/ui/neo_hud_ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "iclientmode.h"
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <vgui/IPanel.h>
#include "VGuiMatSurface/IMatSystemSurface.h"
#include "cdll_client_int.h"
#include <vgui_controls/Controls.h>
#include <vgui_controls/ImagePanel.h>
#include <vgui/IScheme.h>
Expand Down Expand Up @@ -160,16 +163,20 @@ void CNEOHud_Ammo::DrawAmmo() const
}

const char* ammoChar = nullptr;
int fireModeWidth = 0, fireModeHeight = 0;
int magSizeMax = 0;
int magSizeCurrent = 0;
// NEO TODO: client tests for the 30+1/30 row and the chamber glyph (fresh, after tactical reload, after drop).
// a gun with a chamber counts the magazine in the row, and the round icon of the fire-mode glyph shows the chamber
const bool hasChamber = activeWep->HasChamberSlot();

if ((activeWep->UsesClipsForAmmo1() && !(activeWep->GetNeoWepBits() & NEO_WEP_THROWABLE)) || (activeWep->GetNeoWepBits() & NEO_WEP_BALC))
{
char fireModeText[2]{ '\0' };

ammoChar = activeWep->GetNEOWpnData().szBulletCharacter;
magSizeMax = activeWep->GetMaxClip1();
magSizeCurrent = activeWep->Clip1();
magSizeMax = hasChamber ? activeWep->MagazineCapacity() : activeWep->GetMaxClip1();
magSizeCurrent = hasChamber ? activeWep->RoundsInMagazine() : activeWep->Clip1();

if(activeWep)
{
Expand All @@ -188,8 +195,16 @@ void CNEOHud_Ammo::DrawAmmo() const
g_pVGuiLocalize->ConvertANSIToUnicode(fireModeText, unicodeFireModeText, sizeof(unicodeFireModeText));

surface()->DrawSetTextFont(m_hFireModeFont);
surface()->DrawSetTextPos(icon_xpos + xpos, icon_ypos + ypos);
surface()->DrawPrintText(unicodeFireModeText, V_wcslen(unicodeFireModeText));
if (hasChamber)
{
surface()->GetTextSize(m_hFireModeFont, unicodeFireModeText, fireModeWidth, fireModeHeight);
DrawFireModeWithChamber(unicodeFireModeText, fireModeHeight, activeWep->IsRoundChambered());
}
else
{
surface()->DrawSetTextPos(icon_xpos + xpos, icon_ypos + ypos);
surface()->DrawPrintText(unicodeFireModeText, V_wcslen(unicodeFireModeText));
}
}
} else
{
Expand All @@ -216,8 +231,16 @@ void CNEOHud_Ammo::DrawAmmo() const
surface()->DrawSetTextFont(m_hBulletFont);
surface()->DrawSetTextPos(digit_xpos + xpos, digit_ypos + ypos);
wchar_t bullets[22];
V_swprintf_safe(bullets, L"%i/%i", magSizeCurrent, magSizeMax);
surface()->DrawPrintText(bullets, (int)(magSizeCurrent == 0 ? 1 : log10(magSizeCurrent) + 1) + (int)(log10(magSizeMax) + 1) + 1);
if (hasChamber && activeWep->IsRoundChambered())
{
V_swprintf_safe(bullets, L"%i+1/%i", magSizeCurrent, magSizeMax);
surface()->DrawPrintText(bullets, V_wcslen(bullets));
}
else
{
V_swprintf_safe(bullets, L"%i/%i", magSizeCurrent, magSizeMax);
surface()->DrawPrintText(bullets, (int)(magSizeCurrent == 0 ? 1 : log10(magSizeCurrent) + 1) + (int)(log10(magSizeMax) + 1) + 1);
}
return;
}

Expand Down Expand Up @@ -290,6 +313,36 @@ void CNEOHud_Ammo::DrawAmmo() const
}
}

// The fire-mode glyph's top rows are a round icon (bullet or shell), its letter sits below them
static constexpr float FIRE_MODE_ROUND_ICON_HEIGHT = 0.184f;

// Draw the fire-mode glyph with its round icon lit while a round is chambered, in the empty color otherwise;
// the letter keeps the text color. Two passes, each clipped to its part of the glyph
void CNEOHud_Ammo::DrawFireModeWithChamber(const wchar_t *pszGlyph, int iGlyphTall, bool bChambered) const
{
const int iX = icon_xpos + xpos;
const int iY = icon_ypos + ypos;
int iScreenX = 0, iScreenY = 0;
vgui::ipanel()->GetAbsPos(GetVPanel(), iScreenX, iScreenY);
const int iSplitY = iScreenY + iY + static_cast<int>(iGlyphTall * FIRE_MODE_ROUND_ICON_HEIGHT + 0.5f);

int iLeft, iTop, iRight, iBottom;
bool bClippingDisabled;
g_pMatSystemSurface->GetClippingRect(iLeft, iTop, iRight, iBottom, bClippingDisabled);

g_pMatSystemSurface->SetClippingRect(iLeft, iTop, iRight, Min(iBottom, iSplitY));
surface()->DrawSetTextColor(bChambered ? ammo_color : emptied_ammo_color);
surface()->DrawSetTextPos(iX, iY);
surface()->DrawPrintText(pszGlyph, V_wcslen(pszGlyph));

g_pMatSystemSurface->SetClippingRect(iLeft, Max(iTop, iSplitY), iRight, iBottom);
surface()->DrawSetTextColor(ammo_text_color);
surface()->DrawSetTextPos(iX, iY);
surface()->DrawPrintText(pszGlyph, V_wcslen(pszGlyph));

g_pMatSystemSurface->SetClippingRect(iLeft, iTop, iRight, iBottom);
}

void CNEOHud_Ammo::DrawNeoHudElement()
{
auto *localPlayer = C_NEO_Player::GetLocalNEOPlayer();
Expand Down
1 change: 1 addition & 0 deletions src/game/client/neo/ui/neo_hud_ammo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CNEOHud_Ammo : public CNEOHud_ChildElement, public CHudElement, public vgu

private:
void DrawAmmo() const;
void DrawFireModeWithChamber(const wchar_t *pszGlyph, int iGlyphTall, bool bChambered) const;
void DrawHeatMeter(C_NEOBaseCombatWeapon* activeWep) const;

private:
Expand Down
9 changes: 9 additions & 0 deletions src/game/server/neo/bot/neo_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,13 @@ void CNEOBot::EquipBestWeaponForThreat(const CKnownEntity* threat, const bool bN
if (EquipRequiredWeapon())
return;

// A switch would only delay the reload that is about to refill the clip
auto *pActiveWeapon = static_cast<CNEOBaseCombatWeapon *>(GetActiveWeapon());
if (pActiveWeapon && pActiveWeapon->IsReloadPastUnload())
{
return;
}

// -------------------------------------------------------------------------------

CNEOBaseCombatWeapon* primaryWeapon = static_cast<CNEOBaseCombatWeapon *>(Weapon_GetSlot(0));
Expand Down Expand Up @@ -1813,6 +1820,8 @@ void CNEOBot::ReloadIfLowClip(bool bForceReload)
return;
}

// NEO TODO: with a chamber slot 30 of 31 counts as full here, and 29+1 (clip 30) never reloads by bot
// logic. Accepted for now; revisit the threshold later.
if (myWeapon->Clip1() >= myWeapon->GetMaxClip1())
{
return;
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CNEOWeaponInfo::CNEOWeaponInfo()
m_flPenetration = 0.f;
m_bDropOnDeath = true;
iAimFOV = 0;
m_bChamberedRound = false;

m_flVMFov = m_flVMAimFov = 0.f;
m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin;
Expand Down Expand Up @@ -114,6 +115,7 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName
m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 );
m_flReloadReadyBeforeEnd = pKeyValuesData->GetFloat( "ReloadReadyBeforeEnd", 0.0f );
ParseReloadPhases(pKeyValuesData->FindKey("ReloadPhases"));
m_bChamberedRound = pKeyValuesData->GetBool("ChamberedRound", false);

const char *notFoundStr = "notfound";
Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING);
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo
int m_iBullets;
float m_flCycleTime;
float m_flReloadReadyBeforeEnd;
// A closed-bolt weapon retains a chambered round when reloading with rounds left.
bool m_bChamberedRound;
// Empty: the weapon reloads without phases. Allocated only for scripts with a ReloadPhases block.
CUtlVector<ReloadPhaseTable_t> m_reloadTables;
char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm
Expand Down
Loading
Loading