Notify players with a sound when a player is defeated
Includes alarm_defeated_ally.ogg by @Samulis Reviewed by: @bb Comments by: @Angen Freagarach Differential Revision: https://code.wildfiregames.com/D2860 This was SVN commit r24199.
This commit is contained in:
parent
28c11ab6f2
commit
0f2b00326f
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
||||
<SoundGroup>
|
||||
<Omnipresent>1</Omnipresent>
|
||||
<HeardBy>owner</HeardBy>
|
||||
<Gain>1</Gain>
|
||||
<Priority>100</Priority>
|
||||
<ConeGain>1</ConeGain>
|
BIN
binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.ogg
(Stored with Git LFS)
Normal file
BIN
binaries/data/mods/public/audio/interface/alarm/alarm_defeated_ally.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
||||
<SoundGroup>
|
||||
<Omnipresent>1</Omnipresent>
|
||||
<HeardBy>owner</HeardBy>
|
||||
<Gain>1</Gain>
|
||||
<Priority>100</Priority>
|
||||
<ConeGain>1</ConeGain>
|
||||
<Looping>0</Looping>
|
||||
<RandOrder>1</RandOrder>
|
||||
<RandGain>1</RandGain>
|
||||
<RandPitch>1</RandPitch>
|
||||
<Threshold>1</Threshold>
|
||||
<Path>audio/interface/alarm/</Path>
|
||||
<Sound>alarm_defeated_ally.ogg</Sound>
|
||||
</SoundGroup>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
||||
<SoundGroup>
|
||||
<Omnipresent>1</Omnipresent>
|
||||
<HeardBy>owner</HeardBy>
|
||||
<Gain>1</Gain>
|
||||
<Priority>100</Priority>
|
||||
<ConeGain>1</ConeGain>
|
||||
<Looping>0</Looping>
|
||||
<RandOrder>1</RandOrder>
|
||||
<RandGain>1</RandGain>
|
||||
<RandPitch>1</RandPitch>
|
||||
<Threshold>1</Threshold>
|
||||
<Path>audio/interface/alarm/</Path>
|
||||
<Sound>alarmalert1.ogg</Sound>
|
||||
</SoundGroup>
|
@ -933,4 +933,15 @@ Player.prototype.SetStartingTechnologies = function(techs)
|
||||
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);
|
||||
|
@ -88,6 +88,13 @@
|
||||
</Rates>
|
||||
<Interval>1000</Interval>
|
||||
</ResourceTrickle>
|
||||
<Sound>
|
||||
<SoundGroups>
|
||||
<defeated>interface/alarm/alarm_defeated.xml</defeated>
|
||||
<defeated_ally>interface/alarm/alarm_defeated_ally.xml</defeated_ally>
|
||||
<defeated_enemy>interface/alarm/alarm_defeated_enemy.xml</defeated_enemy>
|
||||
</SoundGroups>
|
||||
</Sound>
|
||||
<StatisticsTracker>
|
||||
<!-- The summary screen and lobby rankings expect these classes, but additional classes may be added. -->
|
||||
<UnitClasses datatype="tokens">
|
||||
|
@ -91,6 +91,13 @@ public:
|
||||
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)
|
||||
|
@ -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)
|
||||
|
@ -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 @@ class ICmpSoundManager : public IComponent
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user