fix: Implement missing critical hit sound (#1141)
* Fix * Crit Sound Now Plays On Death * Revert BuildVer.h --------- Co-authored-by: Loki <lokio.casebstv@gmail.com>
This commit is contained in:
@@ -831,7 +831,12 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
|
||||
|
||||
if (sound)
|
||||
{
|
||||
level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT);
|
||||
if (source->isCritical()) {
|
||||
level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT_CRITICAL);
|
||||
}
|
||||
else {
|
||||
level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT);
|
||||
}
|
||||
if (source != DamageSource::drown) markHurt();
|
||||
if (sourceEntity != nullptr)
|
||||
{
|
||||
@@ -854,12 +859,19 @@ 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
|
||||
{
|
||||
if (sound) playSound(getHurtSound(), getSoundVolume(), getVoicePitch());
|
||||
if (sound) {
|
||||
if (source->isCritical()) playSound(getCriticalSound(), getSoundVolume(), getVoicePitch());
|
||||
playSound(getHurtSound(), getSoundVolume(), getVoicePitch());
|
||||
}
|
||||
}
|
||||
MemSect(0);
|
||||
|
||||
@@ -926,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)
|
||||
@@ -959,7 +975,10 @@ int LivingEntity::getHurtSound()
|
||||
{
|
||||
return eSoundType_DAMAGE_HURT;
|
||||
}
|
||||
|
||||
int LivingEntity::getCriticalSound()
|
||||
{
|
||||
return eSoundType_DAMAGE_CRITICAL;
|
||||
}
|
||||
int LivingEntity::getDeathSound()
|
||||
{
|
||||
return eSoundType_DAMAGE_HURT;
|
||||
@@ -1181,7 +1200,8 @@ void LivingEntity::swing()
|
||||
|
||||
void LivingEntity::handleEntityEvent(byte id)
|
||||
{
|
||||
if (id == EntityEvent::HURT)
|
||||
//These gotta be in parentheses
|
||||
if ((id == EntityEvent::HURT) || (id == EntityEvent::HURT_CRITICAL))
|
||||
{
|
||||
walkAnimSpeed = 1.5f;
|
||||
|
||||
@@ -1191,19 +1211,30 @@ void LivingEntity::handleEntityEvent(byte id)
|
||||
|
||||
MemSect(31);
|
||||
// 4J-PB -added because villagers have no sounds
|
||||
int iHurtSound=getHurtSound();
|
||||
int iHurtSound = getHurtSound();
|
||||
int iCritSound = getCriticalSound();
|
||||
if(iHurtSound!=-1)
|
||||
{
|
||||
playSound(iHurtSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
|
||||
}
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user