diff --git a/dlls/item/CItemBattery.cpp b/dlls/item/CItemBattery.cpp index 32fd7cb8..d0384abf 100644 --- a/dlls/item/CItemBattery.cpp +++ b/dlls/item/CItemBattery.cpp @@ -80,7 +80,8 @@ class CItemBattery : public CItem if (pct > 0) pct--; - snprintf(szcharge, 64, "!HEV_%1dP", pct); + if (pct > 0) + snprintf(szcharge, 64, "!HEV_%1dP", pct); //EMIT_SOUND_SUIT(ENT(pev), szcharge); pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC); diff --git a/dlls/monster/CBodyGuard.cpp b/dlls/monster/CBodyGuard.cpp index 308f66cc..7da5a442 100644 --- a/dlls/monster/CBodyGuard.cpp +++ b/dlls/monster/CBodyGuard.cpp @@ -440,8 +440,10 @@ Schedule_t* CBodyGuard::GetScheduleOfType(int Type) } return &slGruntRangeAttack1C[0]; // prevent crouching or angry idle animations default: - return wasSpinning ? &slMinigunSpindown[0] : CBaseGrunt::GetScheduleOfType(Type); + break; } + + return wasSpinning ? &slMinigunSpindown[0] : CBaseGrunt::GetScheduleOfType(Type); } int CBodyGuard::GetActivitySequence(Activity NewActivity) { diff --git a/dlls/player/CBasePlayer.cpp b/dlls/player/CBasePlayer.cpp index 0435cbe0..48fe1897 100644 --- a/dlls/player/CBasePlayer.cpp +++ b/dlls/player/CBasePlayer.cpp @@ -443,6 +443,8 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flArmor; flArmor = (flDamage - flNew) * flBonus; + + float oldArmor = pev->armorvalue; // Does this use more armor than we have? if (flArmor > pev->armorvalue) @@ -456,6 +458,15 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, pev->armorvalue -= flArmor; flDamage = flNew; + + + if (oldArmor > 0 && pev->armorvalue < 1) { + SetSuitUpdate("!HEV_E0", FALSE, SUIT_NEXT_IN_30SEC); // armor compromised + } + else if (oldArmor - pev->armorvalue > 50) { + // heavy hit + SetSuitUpdate("!HEV_E4", FALSE, SUIT_NEXT_IN_30SEC); // hev damage sustained + } } // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that @@ -1426,6 +1437,7 @@ void CBasePlayer::WaterMove() { if (pev->dmgtime < gpGlobals->time) { TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 10 * pev->waterlevel, DMG_BURN); + SetSuitUpdate("!HEV_FIRE", FALSE, SUIT_NEXT_IN_1MIN); // extreme heat damage pev->dmgtime = gpGlobals->time + 1.0f; } } @@ -2881,7 +2893,13 @@ void CBasePlayer::CheckSuitUpdate() m_flSuitUpdate = 0; } } - + +bool IsBatteryUpdateSuitSentence(const char* name) { + int len = strlen(name); + return len >= 7 && len <= 8 && strstr(name, "!HEV_") == name + && isdigit(name[5]) && ((isdigit(name[6]) && name[7] == 'P') || name[6] == 'P'); +} + // add sentence to suit playlist queue. if fgroup is true, then // name is a sentence group (HEV_AA), otherwise name is a specific // sentence name ie: !HEV_AA0. If iNoRepeat is specified in @@ -2893,11 +2911,6 @@ void CBasePlayer::SetSuitUpdate(const char *name, int fgroup, int iNoRepeatTime) int isentence; int iempty = -1; - - // Ignore suit updates if no suit - if ( !(pev->weapons & (1<weapons & (1<time; } - // find empty spot in queue, or overwrite last spot - - m_rgSuitPlayList[m_iSuitPlayNext++] = isentence; - if (m_iSuitPlayNext == CSUITPLAYLIST) - m_iSuitPlayNext = 0; + bool replacedExisting = false; + if (IsBatteryUpdateSuitSentence(name)) { + for (int i = 0; i < CSUITPLAYLIST; i++) { + if (!m_rgSuitPlayList[i]) { + continue; + } + + char sentence[CBSENTENCENAME_MAX + 1]; + strcpy_safe(sentence, "!", CBSENTENCENAME_MAX + 1); + strcat_safe(sentence, gszallsentencenames[m_rgSuitPlayList[i]], CBSENTENCENAME_MAX + 1); + + if (IsBatteryUpdateSuitSentence(sentence)) { + m_rgSuitPlayList[i] = isentence; + replacedExisting = true; + break; + } + } + } + + if (!replacedExisting) { + // find empty spot in queue, or overwrite last spot + m_rgSuitPlayList[m_iSuitPlayNext++] = isentence; + if (m_iSuitPlayNext == CSUITPLAYLIST) + m_iSuitPlayNext = 0; + } if (m_flSuitUpdate <= gpGlobals->time) { @@ -3476,6 +3512,9 @@ void CBasePlayer::Spawn( void ) DropAllInventoryItems(false, true); ApplyEffects(); + + // don't play suit sounds for items given when spawning + SetSuitUpdate(NULL, FALSE, 0); } void CBasePlayer :: Precache( void ) @@ -4556,6 +4595,10 @@ void CBasePlayer :: UpdateClientData( void ) { m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; m_iFlashBattery--; + + if (m_iFlashBattery < 8) { + SetSuitUpdate("!HEV_0P", FALSE, SUIT_NEXT_IN_1MIN); + } if (!m_iFlashBattery) FlashlightTurnOff(); diff --git a/dlls/weapon/CDisplacer.cpp b/dlls/weapon/CDisplacer.cpp index 9abb3006..599dbb18 100644 --- a/dlls/weapon/CDisplacer.cpp +++ b/dlls/weapon/CDisplacer.cpp @@ -367,7 +367,7 @@ void CDisplacer::FireThink() if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", TRUE, SUIT_REPEAT_OK); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, SUIT_REPEAT_OK); } #endif @@ -476,7 +476,7 @@ void CDisplacer::AltFireThink() //if (0 == GetMagazine1()) { if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) - m_pPlayer->SetSuitUpdate("!HEV_AMO0", TRUE, SUIT_REPEAT_OK); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase(); diff --git a/dlls/weapon/CEgon.cpp b/dlls/weapon/CEgon.cpp index 212cab91..600a48a0 100644 --- a/dlls/weapon/CEgon.cpp +++ b/dlls/weapon/CEgon.cpp @@ -125,6 +125,10 @@ void CEgon::Holster( int skiplocal /* = 0 */ ) m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; SendWeaponAnim( EGON_HOLSTER ); + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0) { + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, SUIT_REPEAT_OK); + } + EndAttack(); } diff --git a/dlls/weapon/CGauss.cpp b/dlls/weapon/CGauss.cpp index fa234482..377a83e2 100644 --- a/dlls/weapon/CGauss.cpp +++ b/dlls/weapon/CGauss.cpp @@ -150,6 +150,10 @@ void CGauss::Holster( int skiplocal /* = 0 */ ) m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0) { + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, SUIT_REPEAT_OK); + } + SendWeaponAnim( GAUSS_HOLSTER ); m_fInAttack = 0; } diff --git a/dlls/weapon/CRpg.cpp b/dlls/weapon/CRpg.cpp index cf20be49..5ac61642 100644 --- a/dlls/weapon/CRpg.cpp +++ b/dlls/weapon/CRpg.cpp @@ -575,6 +575,10 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) SendWeaponAnim( RPG_HOLSTER1 ); + if (m_iClip == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0) { + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, SUIT_REPEAT_OK); + } + #ifndef CLIENT_DLL CLaserSpot* m_pSpot = (CLaserSpot*)m_hSpot.GetEntity(); if (m_pSpot)