Skip to content
This repository was archived by the owner on May 25, 2024. It is now read-only.
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
1 change: 1 addition & 0 deletions mp/game/neo/scripts/weapon_knife.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ WeaponData
"clip_size" "-1"
"primary_ammo" "None"
"secondary_ammo" "None"
"MeleeWeapon" "1"

"weight" "0"
"item_flags" "0"
Expand Down
34 changes: 18 additions & 16 deletions mp/src/game/client/neo/ui/neo_hud_ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,33 +141,35 @@ void CNEOHud_Ammo::DrawAmmo() const
surface()->DrawPrintText(unicodeWepName, textLen);

const int maxClip = activeWep->GetMaxClip1();
if (maxClip != 0)
if (maxClip != 0 && !activeWep->IsMeleeWeapon())
{
const auto ammo = GetAmmoDef()->GetAmmoOfIndex(activeWep->GetPrimaryAmmoType());
const int ammoCount = activeWep->GetOwner()->GetAmmoCount(ammo->pName);
const int numClips = abs(ammoCount / activeWep->GetMaxClip1()); // abs because grenades return negative values (???)
const int numClips = ceil(abs((float)ammoCount / activeWep->GetMaxClip1())); // abs because grenades return negative values (???) // casting division to float in case we have a half-empty mag, rounding up to show the half mag as one more mag

// Render amount of clips remaining. Sort of an approximation, should revisit once unfinished mag "reload dumping" is implemented.
if (numClips != 0)
{
const int maxLen = 4; // support a max of '999' clips, plus '\0'
char clipsText[maxLen]{ '\0' };
itoa(numClips, clipsText, 10);
textLen = V_strlen(clipsText);
wchar_t unicodeClipsText[maxLen]{ L'\0' };
g_pVGuiLocalize->ConvertANSIToUnicode(clipsText, unicodeClipsText, sizeof(unicodeClipsText));

surface()->DrawSetTextPos(m_resX - fontWidth * 1.5 - margin, ypos + fontHeight * 2.5 - margin);
surface()->DrawPrintText(unicodeClipsText, textLen);
}

const int maxLen = 4; // support a max of '999' clips, plus '\0'
char clipsText[maxLen]{ '\0' };
itoa(strcmp(wepName, "MURATA SUPA 7") == 0 ? ammoCount : numClips, clipsText, 10); // If using the Supa7, display total ammo instead of total ammo/size of internal magazine
textLen = V_strlen(clipsText);
wchar_t unicodeClipsText[maxLen]{ L'\0' };
g_pVGuiLocalize->ConvertANSIToUnicode(clipsText, unicodeClipsText, sizeof(unicodeClipsText));

surface()->DrawSetTextPos(m_resX - fontWidth * 1.5 - margin, ypos + fontHeight * 2.5 - margin);
surface()->DrawPrintText(unicodeClipsText, textLen);


// Render the bullet icons representing the amount of bullets in current clip.
if (ammoCount != 0 && activeWep->UsesClipsForAmmo1())
if (activeWep->UsesClipsForAmmo1())
{
// Get character representation of ammo type
char* ammoChar = (char*)activeWep->GetWpnData().szBulletCharacter;

const int maxBulletsInClip = 63 + 1;
char bullets[maxBulletsInClip]{ '\0' };
for (int i = 0, numBulletsInCurClip = activeWep->Clip1(); i < maxBulletsInClip && numBulletsInCurClip != 0; ++i) {
V_strcat_safe(bullets, "a");
V_strcat_safe(bullets, ammoChar);
--numBulletsInCurClip;
}
wchar_t unicodeBullets[maxBulletsInClip]{ L'\0' };
Expand Down
4 changes: 2 additions & 2 deletions mp/src/game/shared/basecombatweapon_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2220,9 +2220,9 @@ void CBaseCombatWeapon::FinishReload( void )
// If I use primary clips, reload primary
if ( UsesClipsForAmmo1() )
{
int primary = MIN( GetMaxClip1() - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
int primary = MIN(GetMaxClip1() - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
m_iClip1 += primary;
pOwner->RemoveAmmo( primary, m_iPrimaryAmmoType);
pOwner->RemoveAmmo(primary, m_iPrimaryAmmoType);
}

// If I use secondary clips, reload secondary
Expand Down
3 changes: 3 additions & 0 deletions mp/src/game/shared/hl2mp/weapon_hl2mpbasehlmpcombatweapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void CBaseHL2MPCombatWeapon::ItemHolsterFrame( void )
{
BaseClass::ItemHolsterFrame();

#ifdef NEO
return;
#endif
// Must be player held
if ( GetOwner() && GetOwner()->IsPlayer() == false )
return;
Expand Down
38 changes: 38 additions & 0 deletions mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,39 @@ bool CNEOBaseCombatWeapon::Reload( void )
#endif
}


//-----------------------------------------------------------------------------
// Purpose: Reload has finished.
//-----------------------------------------------------------------------------
void CNEOBaseCombatWeapon::FinishReload(void)
{
CBaseCombatCharacter* pOwner = GetOwner();

if (pOwner)
{
// If I use primary clips, reload primary
if (UsesClipsForAmmo1())
{
int primary = MIN(GetMaxClip1(), pOwner->GetAmmoCount(m_iPrimaryAmmoType));
m_iClip1 = primary;
pOwner->RemoveAmmo(primary, m_iPrimaryAmmoType);
}

// If I use secondary clips, reload secondary
if (UsesClipsForAmmo2())
{
int secondary = MIN(GetMaxClip2() - m_iClip2, pOwner->GetAmmoCount(m_iSecondaryAmmoType));
m_iClip2 += secondary;
pOwner->RemoveAmmo(secondary, m_iSecondaryAmmoType);
}

if (m_bReloadsSingly)
{
m_bInReload = false;
}
}
}

bool CNEOBaseCombatWeapon::CanBeSelected(void)
{
if (GetWeaponFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY)
Expand Down Expand Up @@ -206,6 +239,11 @@ bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo)

return BaseClass::Holster(pSwitchingTo);
}

void CNEOBaseCombatWeapon::ItemHolsterFrame(void)
{ // Overrides the base class behaviour of reloading the weapon after its been holstered for 3 seconds
return;
}
#endif

void CNEOBaseCombatWeapon::CheckReload(void)
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon
virtual void CheckReload(void);

virtual bool Reload( void );
virtual void FinishReload(void) OVERRIDE;

virtual bool CanBeSelected(void);

Expand Down Expand Up @@ -196,6 +197,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon

#ifdef CLIENT_DLL
virtual bool Holster(CBaseCombatWeapon* pSwitchingTo);
virtual void ItemHolsterFrame() OVERRIDE;
#endif

virtual bool Deploy(void);
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/shared/weapon_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ FileWeaponInfo_t::FileWeaponInfo_t()

#ifdef NEO
vecVmOffset = vec3_origin;
szBulletCharacter[0] = 0;
#endif
}

Expand Down Expand Up @@ -425,6 +426,7 @@ void FileWeaponInfo_t::Parse( KeyValues *pKeyValuesData, const char *szWeaponNam
const float VMOffsetRight = pKeyValuesData->GetFloat("VMOffsetRight");
const float VMOffsetUp = pKeyValuesData->GetFloat("VMOffsetUp");
vecVmOffset = Vector(VMOffsetForward, VMOffsetRight, VMOffsetUp);
Q_strncpy( szBulletCharacter, pKeyValuesData->GetString("BulletCharacter", "a"), MAX_BULLET_CHARACTER);
#endif

bShowUsageHint = ( pKeyValuesData->GetInt( "showusagehint", 0 ) != 0 ) ? true : false;
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/shared/weapon_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int GetWeaponSoundFromString( const char *pszString );
#define MAX_WEAPON_STRING 80
#define MAX_WEAPON_PREFIX 16
#define MAX_WEAPON_AMMO_NAME 32
#define MAX_BULLET_CHARACTER 2

#define WEAPON_PRINTNAME_MISSING "!!! Missing printname on weapon"

Expand Down Expand Up @@ -104,6 +105,7 @@ class FileWeaponInfo_t

#ifdef NEO
Vector vecVmOffset;
char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip
#endif

// Sound blocks
Expand Down