Question about changing the way pain sounds work
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!)
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!)
-
- Posts: 1
- Joined: Sat Nov 25, 2023 1:47 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
Question about changing the way pain sounds work
So I was wondering if there is any way to change it so that the pain100/pain75/pain50/pain25 sounds are played based on the health percentage instead of them being played the normal way when health is at 100 or below.
-
- Posts: 5019
- Joined: Sun Nov 14, 2010 12:59 am
Re: Question about changing the way pain sounds work
You'll have to create you own function to achieve that:
Code: Select all
class TestPlayer : DoomPlayer
{
void PlayPainSound ()
{
if (player != null && Alternative == null)
{
Sound snd;
int hp = Health * 100 / GetMaxHealth(true);
if (hp < 25)
snd = "*pain25";
else if (hp < 50)
snd = "*pain50";
else if (hp < 75)
snd = "*pain75";
else
snd = "*pain100";
A_StartSound(snd, CHAN_VOICE);
}
}
States
{
Pain:
PLAY G 4;
PLAY G 4 PlayPainSound;
Goto Spawn;
}
}