Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Moderator:GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
9 posts
• Page 1 of 1
yum13241
Posts: 547
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Thanks! For future readers: Make sure to comment out the DeathSound.
HOLD UP! Even though I set the DeathSound to "dsempty" the expire sound now plays twice; once while it's blinking, and another time when it's actually gone.
yum13241 wrote: ↑Wed Dec 07, 2022 9:21 am
HOLD UP! Even though I set the DeathSound to "dsempty" the expire sound now plays twice; once while it's blinking, and another time when it's actually gone.
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.
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;
}
}
}