Index: binaries/data/mods/public/audio/interface/alarm/alarm_ally_defeated.xml =================================================================== --- binaries/data/mods/public/audio/interface/alarm/alarm_ally_defeated.xml +++ binaries/data/mods/public/audio/interface/alarm/alarm_ally_defeated.xml @@ -0,0 +1,15 @@ + + + 1 + owner + 1 + 100 + 1 + 0 + 1 + 1 + 1 + 1 + audio/interface/alarm/ + alarmalert2.ogg + Index: binaries/data/mods/public/audio/interface/alarm/alarm_defeat.xml =================================================================== --- binaries/data/mods/public/audio/interface/alarm/alarm_defeat.xml +++ 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: binaries/data/mods/public/audio/interface/alarm/alarm_defeated.xml =================================================================== --- binaries/data/mods/public/audio/interface/alarm/alarm_defeated.xml +++ binaries/data/mods/public/audio/interface/alarm/alarm_defeated.xml @@ -1,5 +1,7 @@ + 1 + owner 1 100 1 @@ -9,5 +11,5 @@ 1 1 audio/interface/alarm/ - alarmdefeat_1.ogg + alarmalert0.ogg Index: binaries/data/mods/public/audio/interface/alarm/alarm_enemy_defeated.xml =================================================================== --- binaries/data/mods/public/audio/interface/alarm/alarm_enemy_defeated.xml +++ binaries/data/mods/public/audio/interface/alarm/alarm_enemy_defeated.xml @@ -0,0 +1,15 @@ + + + 1 + owner + 1 + 100 + 1 + 0 + 1 + 1 + 1 + 1 + audio/interface/alarm/ + 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 @@ -920,4 +920,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) ? "ally_defeated" : "enemy_defeated"); + cmpSoundManager.PlaySoundGroupForPlayer(soundGroup, this.entity); +}; + + 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 @@ -89,29 +89,36 @@ 1000 + + + interface/alarm/alarm_defeated.xml + interface/alarm/alarm_ally_defeated.xml + interface/alarm/alarm_enemy_defeated.xml + + - - - Infantry - Worker - FemaleCitizen - Cavalry - Champion - Hero - Siege - Ship - Domestic - Trader - - - House - Economic - Outpost - Military - Fortress - CivCentre - Wonder - + + + Infantry + Worker + FemaleCitizen + Cavalry + Champion + Hero + Siege + Ship + Domestic + Trader + + + House + Economic + Outpost + Military + Fortress + CivCentre + Wonder + 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 std::wstring& name, entity_id_t player) + { + if (!g_SoundManager) + return; + g_SoundManager->PlayAsGroup(name, CVector3D(0.f, 0.f, 0.f), player, true); + } + 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 std::wstring& name, entity_id_t player) = 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_2("PlaySoundGroupForPlayer", void, ICmpSoundManager, PlaySoundGroupForPlayer, std::wstring, entity_id_t) DEFINE_INTERFACE_METHOD_0("StopMusic", void, ICmpSoundManager, StopMusic) END_INTERFACE_WRAPPER(SoundManager)