From 432928bf477780bb3c179e93445a12db3d671ea3 Mon Sep 17 00:00:00 2001 From: driAn Date: Sun, 25 May 2008 14:26:32 +0000 Subject: [PATCH] grenade bounce sound flood limited git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2107 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/weapon.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 7072e34d..8ba0434b 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -553,6 +553,7 @@ grenadeent::grenadeent (playerent *owner, int millis) bouncetype = BT_NADE; maxspeed = 30.0f; rotspeed = 6.0f; + lastcollision = 0; } void grenadeent::explode() @@ -629,7 +630,15 @@ void grenadeent::moveoutsidebbox(const vec &direction, playerent *boundingbox) void grenadeent::destroy() { explode(); } bool grenadeent::applyphysics() { return nadestate==NS_THROWED; } -void grenadeent::oncollision() { if(nadestate==NS_THROWED) playsound(S_GRENADEBOUNCE1+rnd(2), this, 0, 0); } + +void grenadeent::oncollision() +{ + if(nadestate==NS_THROWED && (!lastcollision || lastmillis-lastcollision>50)) + { + playsound(S_GRENADEBOUNCE1+rnd(2), this, 0, 0); + lastcollision = lastmillis; + } +} // grenades