From 1da432ba23da062cf35120053af631aa812e20b7 Mon Sep 17 00:00:00 2001 From: stiffly Date: Fri, 12 Feb 2016 04:03:03 +0100 Subject: [PATCH 1/3] WIP sounds --- assets | 2 +- include/Game/Systems/Weapon/AssaultWeaponBehaviour.h | 1 + src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/assets b/assets index 078e014f..8d180f2a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 078e014f3d24a100c4cb544ac6807aa2b54149b2 +Subproject commit 8d180f2a54154191587107e6569bbae0a049be46 diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 915854ff..90959d0e 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -6,6 +6,7 @@ #include "Core/EPlayerDamage.h" #include "Core/EShoot.h" + class AssaultWeaponBehaviour : public WeaponBehaviour { public: diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 54c3a590..a59397d1 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -43,6 +43,10 @@ void AssaultWeaponBehaviour::Reload() m_Reloading = true; m_ReloadTimer = cAssaultWeapon["ReloadTime"]; playReloadAnimation(); + Events::PlaySoundOnEntity e; + e.EmitterID = cAssaultWeapon.EntityID; + e.FilePath = "Audio/weapon/reload.wav"; + m_EventBroker->Publish(e); } void AssaultWeaponBehaviour::Update(double dt) @@ -337,5 +341,9 @@ void AssaultWeaponBehaviour::showHitMarker() EntityWrapper hitMarkerSpawner = m_Player.FirstChildByName("HitMarkerSpawner"); if (hitMarkerSpawner.Valid()) { SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner); + Events::PlaySoundOnEntity e; + e.EmitterID = hitMarkerSpawner.ID; // This might not be the optimal spawner entity + e.FilePath = "Audio/weapon/hitclick.wav"; + m_EventBroker->Publish(e); } } From af39b892cd57f9b2af82e843f12a4d49d047a4a5 Mon Sep 17 00:00:00 2001 From: stiffly Date: Fri, 12 Feb 2016 08:05:35 +0100 Subject: [PATCH 2/3] 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); } From 3d4a7de59d8b510d5cce2d23664c726bbb908eca Mon Sep 17 00:00:00 2001 From: stiffly Date: Fri, 12 Feb 2016 08:19:47 +0100 Subject: [PATCH 3/3] MiniDump.cpp was not added to CMakeLists.txt. --- src/Game/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Game/CMakeLists.txt b/src/Game/CMakeLists.txt index f188d7fa..d8ba8599 100644 --- a/src/Game/CMakeLists.txt +++ b/src/Game/CMakeLists.txt @@ -36,6 +36,7 @@ source_group(Network FILES ${SOURCE_FILES_Network}) set(SOURCE_FILES ${SOURCE_FILES} "Game.cpp" + "MiniDump.cpp" ${SOURCE_FILES_Systems} ${SOURCE_FILES_Systems_Weapon} ${SOURCE_FILES_Events}