mirror of
https://github.com/cxong/cdogs-sdl.git
synced 2025-07-23 07:23:01 +02:00
Low ammo alert sounds (#362)
This commit is contained in:
BIN
sounds/ammo_low.ogg
Normal file
BIN
sounds/ammo_low.ogg
Normal file
Binary file not shown.
3
sounds/ammo_low.txt
Normal file
3
sounds/ammo_low.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Derived alert.wav by Corsica_S
|
||||
http://freesound.org/people/Corsica_S/sounds/156453/
|
||||
http://creativecommons.org/licenses/by/3.0/
|
BIN
sounds/ammo_none.ogg
Normal file
BIN
sounds/ammo_none.ogg
Normal file
Binary file not shown.
9
sounds/ammo_none.txt
Normal file
9
sounds/ammo_none.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
Derived from
|
||||
|
||||
Error.wav by Autistic Lucario
|
||||
http://freesound.org/people/Autistic%20Lucario/sounds/142608/
|
||||
http://creativecommons.org/licenses/by/3.0/
|
||||
|
||||
GunSLide.wav by RazzDaSpazz
|
||||
http://freesound.org/people/RazzDaSpazz/sounds/155174/
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
@@ -288,12 +288,32 @@ static void HandleGameEvent(
|
||||
{
|
||||
TActor *a = ActorGetByUID(e.u.UseAmmo.UID);
|
||||
if (!a->isInUse || a->dead) break;
|
||||
const int ammoBefore =
|
||||
*(int *)CArrayGet(&a->ammo, e.u.UseAmmo.AmmoId);
|
||||
const Ammo *ammo = AmmoGetById(&gAmmo, e.u.UseAmmo.AmmoId);
|
||||
const bool wasAmmoLow = AmmoIsLow(ammo, ammoBefore);
|
||||
ActorAddAmmo(a, e.u.UseAmmo.AmmoId, -(int)e.u.UseAmmo.Amount);
|
||||
if (e.u.UseAmmo.PlayerUID >= 0)
|
||||
const PlayerData *p = PlayerDataGetByUID(e.u.UseAmmo.PlayerUID);
|
||||
if (p != NULL && p->IsLocal)
|
||||
{
|
||||
HUDNumPopupsAdd(
|
||||
&camera->HUD.numPopups, NUMBER_POPUP_AMMO,
|
||||
e.u.UseAmmo.PlayerUID, -(int)e.u.UseAmmo.Amount);
|
||||
|
||||
// Show low or no ammo notifications
|
||||
const int ammoAfter =
|
||||
*(int *)CArrayGet(&a->ammo, e.u.UseAmmo.AmmoId);
|
||||
const bool isAmmoLow = AmmoIsLow(ammo, ammoAfter);
|
||||
if (ammoAfter == 0)
|
||||
{
|
||||
// No ammo
|
||||
SoundPlay(&gSoundDevice, StrSound("ammo_none"));
|
||||
}
|
||||
else if (!wasAmmoLow && isAmmoLow)
|
||||
{
|
||||
// Low ammo
|
||||
SoundPlay(&gSoundDevice, StrSound("ammo_low"));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user