1
1
forked from 0ad/0ad

Allow to play different sounds based on what attacked you

Discussed with: @Lion.Kanzen
Sound by: @Samulis
Reviewed by: @Freagarach
Differential Revision: https://code.wildfiregames.com/D2859
This was SVN commit r23989.
This commit is contained in:
Stan 2020-08-21 10:45:37 +00:00
parent 7d180bcf14
commit 2627714c07
6 changed files with 39 additions and 4 deletions

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<SoundGroup>
<Omnipresent>1</Omnipresent>
<HeardBy>owner</HeardBy>
<Gain>0.35</Gain>
<Priority>100</Priority>
<ConeGain>1</ConeGain>
<Looping>0</Looping>
<RandOrder>1</RandOrder>
<RandGain>1</RandGain>
<GainUpper>0.35</GainUpper>
<GainLower>0.30</GainLower>
<RandPitch>1</RandPitch>
<Threshold>1</Threshold>
<Path>audio/interface/alarm/</Path>
<Sound>alarm_attacked_gaia_01.ogg</Sound>
</SoundGroup>

Binary file not shown.

View File

@ -7,7 +7,8 @@ const g_EffectReceiver = {
},
"Capture": {
"IID": "IID_Capturable",
"method": "Capture"
"method": "Capture",
"sound": "capture"
},
"ApplyStatus": {
"IID": "IID_StatusEffectsReceiver",

View File

@ -50,12 +50,12 @@ AttackDetection.prototype.OnGlobalAttacked = function(msg)
Engine.PostMessage(msg.target, MT_MinimapPing);
this.AttackAlert(msg.target, msg.attacker, msg.attackerOwner);
this.AttackAlert(msg.target, msg.attacker, msg.type, msg.attackerOwner);
};
//// External interface ////
AttackDetection.prototype.AttackAlert = function(target, attacker, attackerOwner)
AttackDetection.prototype.AttackAlert = function(target, attacker, type, attackerOwner)
{
let playerID = Engine.QueryInterface(this.entity, IID_Player).GetPlayerID();
@ -127,7 +127,15 @@ AttackDetection.prototype.AttackAlert = function(target, attacker, attackerOwner
"attacker": atkOwner,
"targetIsDomesticAnimal": targetIsDomesticAnimal
});
PlaySound("attacked", target);
let soundGroup = "attacked";
if (g_EffectReceiver[type] && g_EffectReceiver[type].sound)
soundGroup += '_' + g_EffectReceiver[type].sound;
if (attackerOwner === 0)
soundGroup += "_gaia";
PlaySound(soundGroup, target);
};
AttackDetection.prototype.GetSuppressionTime = function()

View File

@ -133,6 +133,9 @@
<constructed>interface/complete/building/complete_universal.xml</constructed>
<death>attack/destruction/building_collapse_large.xml</death>
<attacked>interface/alarm/alarm_attackplayer.xml</attacked>
<attacked_gaia>interface/alarm/alarm_attacked_gaia.xml</attacked_gaia>
<attacked_capture>interface/alarm/alarm_attackplayer.xml</attacked_capture>
<attacked_capture_gaia>interface/alarm/alarm_attacked_gaia.xml</attacked_capture_gaia>
<attack_ranged>attack/weapon/bow_attack.xml</attack_ranged>
<attack_impact_ranged>attack/impact/arrow_impact.xml</attack_impact_ranged>
</SoundGroups>

View File

@ -104,6 +104,9 @@
<Sound>
<SoundGroups>
<attacked>interface/alarm/alarm_attackplayer.xml</attacked>
<attacked_gaia>interface/alarm/alarm_attacked_gaia.xml</attacked_gaia>
<attacked_capture>interface/alarm/alarm_attackplayer.xml</attacked_capture>
<attacked_capture_gaia>interface/alarm/alarm_attacked_gaia.xml</attacked_capture_gaia>
<attack_slaughter>attack/weapon/sword_attack.xml</attack_slaughter>
</SoundGroups>
</Sound>