From af39b892cd57f9b2af82e843f12a4d49d047a4a5 Mon Sep 17 00:00:00 2001 From: stiffly Date: Fri, 12 Feb 2016 08:05:35 +0100 Subject: [PATCH] Now plays a "Empty sound", "reload sound" and "hit mark sound" on appropriate occasions. --- assets | 2 +- .../Systems/Weapon/AssaultWeaponBehaviour.h | 3 ++- src/Game/Systems/PlayerSpawnSystem.cpp | 3 +++ .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 23 +++++++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/assets b/assets index 8d180f2a..1e7adc74 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8d180f2a54154191587107e6569bbae0a049be46 +Subproject commit 1e7adc749e02144615a20a82c847d3c8df46ee3d diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 90959d0e..e827b5df 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -34,7 +34,8 @@ private: void fireRound(); void spawnTracer(); float traceRayDistance(glm::vec3 origin, glm::vec3 direction); - void playSound(); + void playFireSound(); + void playEmptySound(); void viewPunch(); void finishReload(); void playShootAnimation(); diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index ac0ecdf3..7a0b46ef 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -175,6 +175,9 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e) if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Spectator")) { return false; } + if (m_PlayerIDs.find(e.Player.ID) == m_PlayerIDs.end()) { + return false; + } SpawnRequest req; req.PlayerID = m_PlayerIDs.at(e.Player.ID); req.Team = cTeam["Team"]; diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index a59397d1..f6320c4c 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -37,6 +37,8 @@ void AssaultWeaponBehaviour::Reload() // Don't reload if we're completly out of ammo if (ammo == 0) { + playEmptySound(); + m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval return; } @@ -121,12 +123,12 @@ void AssaultWeaponBehaviour::fireRound() if (magAmmo <= 0) { Reload(); return; - } + } // Fire magAmmo -= 1; spawnTracer(); - playSound(); + playFireSound(); viewPunch(); playShootAnimation(); bool hit = shoot(cAssaultWeapon["BaseDamage"]); @@ -172,7 +174,7 @@ float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direc } } -void AssaultWeaponBehaviour::playSound() +void AssaultWeaponBehaviour::playFireSound() { if (!IsClient) { return; @@ -184,6 +186,19 @@ void AssaultWeaponBehaviour::playSound() m_EventBroker->Publish(e); } + +void AssaultWeaponBehaviour::playEmptySound() +{ + if (!IsClient) { + return; + } + + Events::PlaySoundOnEntity e; + e.EmitterID = m_Player.ID; + e.FilePath = "Audio/weapon/zeroAmmo.wav"; + m_EventBroker->Publish(e); +} + void AssaultWeaponBehaviour::viewPunch() { EntityWrapper playerCamera = m_Player.FirstChildByName("Camera"); @@ -342,7 +357,7 @@ void AssaultWeaponBehaviour::showHitMarker() if (hitMarkerSpawner.Valid()) { SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner); Events::PlaySoundOnEntity e; - e.EmitterID = hitMarkerSpawner.ID; // This might not be the optimal spawner entity + e.EmitterID = m_Player.ID; e.FilePath = "Audio/weapon/hitclick.wav"; m_EventBroker->Publish(e); }