Crit Sound Now Plays On Death

This commit is contained in:
arsenicviscera 2026-03-14 16:38:39 -07:00
parent 3896c7d8a0
commit 18003c98a6
2 changed files with 19 additions and 4 deletions

View file

@ -7,6 +7,7 @@ public:
static const BYTE HURT = 2;
//New
static const BYTE HURT_CRITICAL = 19;
static const BYTE DEATH_CRITICAL = 20;
static const BYTE DEATH = 3;
static const BYTE START_ATTACKING = 4;
static const BYTE STOP_ATTACKING = 5;

View file

@ -859,7 +859,11 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
MemSect(31);
if (getHealth() <= 0)
{
if (sound) playSound(getDeathSound(), getSoundVolume(), getVoicePitch());
if (sound) {
//New: both death AND hurt sounds should play critical sound as well.
if (source->isCritical()) playSound(getCriticalSound(), getSoundVolume(), getVoicePitch());
playSound(getDeathSound(), getSoundVolume(), getVoicePitch());
};
die(source);
}
else
@ -934,7 +938,11 @@ void LivingEntity::die(DamageSource *source)
}
}
level->broadcastEntityEvent(shared_from_this(), EntityEvent::DEATH);
if (source->isCritical()) {
level->broadcastEntityEvent(shared_from_this(), EntityEvent::DEATH_CRITICAL);
} else {
level->broadcastEntityEvent(shared_from_this(), EntityEvent::DEATH);
}
}
void LivingEntity::dropEquipment(bool byPlayer, int playerBonusLevel)
@ -1209,18 +1217,24 @@ void LivingEntity::handleEntityEvent(byte id)
{
playSound(iHurtSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
}
if(iCritSound!=-1 && id == EntityEvent::HURT_CRITICAL)
if(iCritSound!=-1 && (id == EntityEvent::HURT_CRITICAL))
{
playSound(iCritSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
}
MemSect(0);
hurt(DamageSource::genericSource, 0);
}
else if (id == EntityEvent::DEATH)
else if ((id == EntityEvent::DEATH) || (id == EntityEvent::DEATH_CRITICAL))
{
MemSect(31);
// 4J-PB -added because villagers have no sounds
int iDeathSound=getDeathSound();
int iCritSound = getCriticalSound();
if (iCritSound != -1 && (id == EntityEvent::DEATH_CRITICAL))
{
playSound(iCritSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
}
if(iDeathSound!=-1)
{
playSound(iDeathSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);