(Try to) fix auto-heal sounds stacking when hit multiple times in one tic.

This commit is contained in:
Mari the Deer 2022-11-15 11:47:07 +01:00
commit f9eef83dff
3 changed files with 16 additions and 4 deletions

View file

@ -15,6 +15,8 @@ Class SWWMArmor : Armor abstract
FlagDef NoDrain : SArmorFlags, 2; // amount is not drained, will always reduce as long as amount is non-zero
// useful for powerup-given armors
transient int lastautousetic; // accumulated damage can make the use sounds stack
Default
{
+INVENTORY.AUTOACTIVATE;
@ -94,7 +96,11 @@ Class SWWMArmor : Armor abstract
damage = newdamage;
if ( (amount <= (MaxAmount-default.Amount)) && (Owner.CountInv(parent) > 0) )
{
if ( GetDefaultByType(parent).UseSound ) Owner.A_StartSound(GetDefaultByType(parent).UseSound,CHAN_ITEMEXTRA,CHANF_OVERLAP,.6);
if ( GetDefaultByType(parent).UseSound && (lastautousetic < gametic) )
{
Owner.A_StartSound(GetDefaultByType(parent).UseSound,CHAN_ITEMEXTRA,CHANF_OVERLAP,.6);
lastautousetic = gametic;
}
int tgive = 0;
while ( (amount <= (MaxAmount-default.Amount)) && (Owner.CountInv(parent) > 0) )
{

View file

@ -13,6 +13,8 @@ Class SWWMHealth : Inventory abstract
Property GiveHealth : giveme;
transient int lastautousetic; // accumulated damage can make the use sounds stack
override void AttachToOwner( Actor other )
{
Super.AttachToOwner(other);
@ -127,7 +129,11 @@ Class SWWMHealth : Inventory abstract
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
if ( hnd ) hnd.tookdamage[Owner.PlayerNumber()] = true;
}
if ( ((Owner.player == players[consoleplayer]) || bBigPowerup) ) Owner.A_StartSound(UseSound,CHAN_ITEMEXTRA,CHANF_OVERLAP);
if ( ((Owner.player == players[consoleplayer]) || bBigPowerup) && (lastautousetic < gametic) )
{
Owner.A_StartSound(UseSound,CHAN_ITEMEXTRA,CHANF_OVERLAP);
lastautousetic = gametic;
}
int tgive = 0;
bool morethanonce = false;
while ( (Amount > 0) && (newdamage > 0) )