Index: binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.xml
===================================================================
--- binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.xml
+++ binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.xml
@@ -1,5 +1,7 @@
+ 1
+ owner
1
100
1
@@ -9,5 +11,5 @@
1
1
audio/interface/alarm/
- alarmdefeat_1.ogg
+ alarmalert2.ogg
Index: binaries/data/mods/public/audio/interface/alarm/alarm_defeated_enemy.xml
===================================================================
--- binaries/data/mods/public/audio/interface/alarm/alarm_defeated_enemy.xml
+++ binaries/data/mods/public/audio/interface/alarm/alarm_defeated_enemy.xml
@@ -1,5 +1,7 @@
+ 1
+ owner
1
100
1
@@ -9,5 +11,5 @@
1
1
audio/interface/alarm/
- alarmdefeat_1.ogg
+ alarmalert1.ogg
Index: binaries/data/mods/public/simulation/components/Player.js
===================================================================
--- binaries/data/mods/public/simulation/components/Player.js
+++ binaries/data/mods/public/simulation/components/Player.js
@@ -933,4 +933,16 @@
this.startingTechnologies = techs;
};
+Player.prototype.OnGlobalPlayerDefeated = function(msg)
+{
+ let cmpSound = Engine.QueryInterface(this.entity, IID_Sound);
+ if (!cmpSound)
+ return;
+
+ let cmpSoundManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager);
+ let soundGroup = cmpSound.GetSoundGroup(this.playerID === msg.playerId ? "defeated" : this.IsAlly(msg.playerId) ? "defeated_ally" : this.state === "won" ? "won" : "defeated_enemy");
+ if (soundGroup)
+ cmpSoundManager.PlaySoundGroupForPlayer(soundGroup, this.playerID);
+};
+
Engine.RegisterComponentType(IID_Player, "Player", Player);
Index: binaries/data/mods/public/simulation/templates/special/player/player.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/special/player/player.xml
+++ binaries/data/mods/public/simulation/templates/special/player/player.xml
@@ -88,6 +88,13 @@
1000
+
+
+ interface/alarm/alarm_defeated.xml
+ interface/alarm/alarm_defeated_ally.xml
+ interface/alarm/alarm_defeated_enemy.xml
+
+
Index: source/simulation2/components/CCmpSoundManager.cpp
===================================================================
--- source/simulation2/components/CCmpSoundManager.cpp
+++ source/simulation2/components/CCmpSoundManager.cpp
@@ -91,6 +91,13 @@
g_SoundManager->PlayAsGroup(name, CVector3D(sourcePos), INVALID_ENTITY, false);
}
+ virtual void PlaySoundGroupForPlayer(const VfsPath& groupPath, const player_id_t playerId) const
+ {
+ if (!g_SoundManager)
+ return;
+ g_SoundManager->PlayAsGroup(groupPath, CVector3D(0.f, 0.f, 0.f), INVALID_ENTITY, GetSimContext().GetCurrentDisplayedPlayer() == playerId);
+ }
+
virtual void StopMusic()
{
if (!g_SoundManager)
Index: source/simulation2/components/ICmpSoundManager.h
===================================================================
--- source/simulation2/components/ICmpSoundManager.h
+++ source/simulation2/components/ICmpSoundManager.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Wildfire Games.
+/* Copyright (C) 2020 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -42,6 +42,13 @@
*/
virtual void PlaySoundGroupAtPosition(const std::wstring& name, const CFixedVector3D& sourcePos) = 0;
+ /**
+ * Start playing audio defined by a sound group file for a player
+ * @param name VFS path of sound group .xml, relative to audio/
+ * @param player the player entity
+ */
+ virtual void PlaySoundGroupForPlayer(const VfsPath& groupPath, const player_id_t playerId) const = 0;
+
virtual void StopMusic() = 0;
DECLARE_INTERFACE_TYPE(SoundManager)
Index: source/simulation2/components/ICmpSoundManager.cpp
===================================================================
--- source/simulation2/components/ICmpSoundManager.cpp
+++ source/simulation2/components/ICmpSoundManager.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Wildfire Games.
+/* Copyright (C) 2020 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -24,5 +24,6 @@
BEGIN_INTERFACE_WRAPPER(SoundManager)
DEFINE_INTERFACE_METHOD_2("PlaySoundGroup", void, ICmpSoundManager, PlaySoundGroup, std::wstring, entity_id_t)
DEFINE_INTERFACE_METHOD_2("PlaySoundGroupAtPosition", void, ICmpSoundManager, PlaySoundGroupAtPosition, std::wstring, CFixedVector3D)
+DEFINE_INTERFACE_METHOD_CONST_2("PlaySoundGroupForPlayer", void, ICmpSoundManager, PlaySoundGroupForPlayer, VfsPath, player_id_t)
DEFINE_INTERFACE_METHOD_0("StopMusic", void, ICmpSoundManager, StopMusic)
END_INTERFACE_WRAPPER(SoundManager)