diff --git a/mp/game/neo/scripts/weapon_knife.txt b/mp/game/neo/scripts/weapon_knife.txt index 88af742de..321fc170d 100644 --- a/mp/game/neo/scripts/weapon_knife.txt +++ b/mp/game/neo/scripts/weapon_knife.txt @@ -14,6 +14,7 @@ WeaponData "clip_size" "-1" "primary_ammo" "None" "secondary_ammo" "None" + "MeleeWeapon" "1" "weight" "0" "item_flags" "0" diff --git a/mp/src/game/client/neo/ui/neo_hud_ammo.cpp b/mp/src/game/client/neo/ui/neo_hud_ammo.cpp index cbf13dab6..c0c352ef8 100644 --- a/mp/src/game/client/neo/ui/neo_hud_ammo.cpp +++ b/mp/src/game/client/neo/ui/neo_hud_ammo.cpp @@ -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' }; diff --git a/mp/src/game/shared/basecombatweapon_shared.cpp b/mp/src/game/shared/basecombatweapon_shared.cpp index 683f972e1..99f1b5dc2 100644 --- a/mp/src/game/shared/basecombatweapon_shared.cpp +++ b/mp/src/game/shared/basecombatweapon_shared.cpp @@ -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 diff --git a/mp/src/game/shared/hl2mp/weapon_hl2mpbasehlmpcombatweapon.cpp b/mp/src/game/shared/hl2mp/weapon_hl2mpbasehlmpcombatweapon.cpp index 361a53f14..650badb0a 100644 --- a/mp/src/game/shared/hl2mp/weapon_hl2mpbasehlmpcombatweapon.cpp +++ b/mp/src/game/shared/hl2mp/weapon_hl2mpbasehlmpcombatweapon.cpp @@ -59,6 +59,9 @@ void CBaseHL2MPCombatWeapon::ItemHolsterFrame( void ) { BaseClass::ItemHolsterFrame(); +#ifdef NEO + return; +#endif // Must be player held if ( GetOwner() && GetOwner()->IsPlayer() == false ) return; diff --git a/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index c815fe25f..36b0d31c9 100644 --- a/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -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) @@ -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) diff --git a/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 48dbedcc6..b8494b026 100644 --- a/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/mp/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -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); @@ -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); diff --git a/mp/src/game/shared/weapon_parse.cpp b/mp/src/game/shared/weapon_parse.cpp index bb0b7e431..52456dfde 100644 --- a/mp/src/game/shared/weapon_parse.cpp +++ b/mp/src/game/shared/weapon_parse.cpp @@ -349,6 +349,7 @@ FileWeaponInfo_t::FileWeaponInfo_t() #ifdef NEO vecVmOffset = vec3_origin; + szBulletCharacter[0] = 0; #endif } @@ -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; diff --git a/mp/src/game/shared/weapon_parse.h b/mp/src/game/shared/weapon_parse.h index 3eff43b74..1a39d8b81 100644 --- a/mp/src/game/shared/weapon_parse.h +++ b/mp/src/game/shared/weapon_parse.h @@ -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" @@ -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