Index: ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeat.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeat.xml
+++ ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeat.xml
@@ -1,13 +0,0 @@
-
-
- 1
- 100
- 1
- 0
- 1
- 1
- 1
- 1
- audio/interface/alarm/
- alarmdefeat_1.ogg
-
Index: ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated.xml
+++ ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated.xml
@@ -0,0 +1,15 @@
+
+
+ 1
+ owner
+ 1
+ 100
+ 1
+ 0
+ 1
+ 1
+ 1
+ 1
+ audio/interface/alarm/
+ alarmdefeat_1.ogg
+
Index: ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.xml
+++ ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.xml
@@ -0,0 +1,15 @@
+
+
+ 1
+ owner
+ 1
+ 100
+ 1
+ 0
+ 1
+ 1
+ 1
+ 1
+ audio/interface/alarm/
+ alarm_defeated_ally.ogg
+
Index: ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated_enemy.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated_enemy.xml
+++ ps/trunk/binaries/data/mods/public/audio/interface/alarm/alarm_defeated_enemy.xml
@@ -0,0 +1,15 @@
+
+
+ 1
+ owner
+ 1
+ 100
+ 1
+ 0
+ 1
+ 1
+ 1
+ 1
+ audio/interface/alarm/
+ alarmalert1.ogg
+
Index: ps/trunk/binaries/data/mods/public/simulation/components/Player.js
===================================================================
--- ps/trunk/binaries/data/mods/public/simulation/components/Player.js
+++ ps/trunk/binaries/data/mods/public/simulation/components/Player.js
@@ -933,4 +933,15 @@
this.startingTechnologies = techs;
};
+Player.prototype.OnGlobalPlayerDefeated = function(msg)
+{
+ let cmpSound = Engine.QueryInterface(this.entity, IID_Sound);
+ if (!cmpSound)
+ return;
+
+ let soundGroup = cmpSound.GetSoundGroup(this.playerID === msg.playerId ? "defeated" : this.IsAlly(msg.playerId) ? "defeated_ally" : this.state === "won" ? "won" : "defeated_enemy");
+ if (soundGroup)
+ Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager).PlaySoundGroupForPlayer(soundGroup, this.playerID);
+};
+
Engine.RegisterComponentType(IID_Player, "Player", Player);
Index: ps/trunk/binaries/data/mods/public/simulation/templates/special/player/player.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/simulation/templates/special/player/player.xml
+++ ps/trunk/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: ps/trunk/source/simulation2/components/CCmpSoundManager.cpp
===================================================================
--- ps/trunk/source/simulation2/components/CCmpSoundManager.cpp
+++ ps/trunk/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: ps/trunk/source/simulation2/components/ICmpSoundManager.h
===================================================================
--- ps/trunk/source/simulation2/components/ICmpSoundManager.h
+++ ps/trunk/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
@@ -30,18 +30,25 @@
public:
/**
* Start playing audio defined by a sound group file.
- * @param name VFS path of sound group .xml, relative to audio/
- * @param source entity emitting the sound (used for positioning)
+ * @param name VFS path of sound group .xml, relative to audio/.
+ * @param source entity emitting the sound (used for positioning).
*/
virtual void PlaySoundGroup(const std::wstring& name, entity_id_t source) = 0;
/**
* Start playing audio defined by a sound group file.
- * @param name VFS path of sound group .xml, relative to audio/
- * @param sourcePos 3d position of the sound emitter
+ * @param name VFS path of sound group .xml, relative to audio/.
+ * @param sourcePos 3d position of the sound emitter.
*/
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: ps/trunk/source/simulation2/components/ICmpSoundManager.cpp
===================================================================
--- ps/trunk/source/simulation2/components/ICmpSoundManager.cpp
+++ ps/trunk/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)