Spoiler:
Damage4
Spoiler:Right now the Powerup.Expire sound plays AFTER the powerup finishes blinking. (it actually expires)
I want it to play WHILE it's blinking. Is this possible?
SOLUTION: See BlueShadows''s post.
Moderator: GZDoom Developers
Spoiler:
Spoiler:Right now the Powerup.Expire sound plays AFTER the powerup finishes blinking. (it actually expires)
Spoiler:
Spoiler:Maybe some invisible character somewhere messed with the compiler?
Spoiler:Damage4
Spoiler:
The code was written so that the sound plays repeatedly through out the expiration period, not just once. So if your sound is shorter than 4 seconds or so, then it'll play more than once.
Code: Select all
Class PowerDamage4 : PowerDamage
{
private bool soundplayed;
Default
{
Powerup.Color "Purple", 0.25;
DamageFactor "Normal", 4;
Inventory.Icon "QUADA0";
SeeSound "powerups/4equip";
Powerup.Duration -35;
DeathSound "dsempty";
+INVENTORY.ADDITIVETIME;
}
override bool HandlePickup (Inventory item)
{
int savedEffectTics = EffectTics; // Save the powerup's current duration before handling the pickup.
bool res = Super.HandlePickup(item);
// Only allow the sound to be replayed if the powerup's duration changed to be greater than before,
// while at the same time, the new duration is greater than the blinking threshold (we don't want
// the sound to be replayed if the powerup is still expiring with the new duration).
if (res && EffectTics > savedEffectTics && EffectTics > BLINKTHRESHOLD)
{
soundplayed = false;
}
return res;
}
Override void DoEffect()
{
Super.DoEffect();
If(!soundplayed && owner && EffectTics > 0 && EffectTics <= BLINKTHRESHOLD)
{
owner.A_StartSound("powerups/4expire",CHAN_5,CHANF_NOSTOP,1.0,ATTN_NONE);
soundplayed = true;
}
}
}