Skip to content

Fix: Critical Hit Sound Implementation#1141

Open
tylerreese543-lab wants to merge 1 commit intosmartcmd:mainfrom
tylerreese543-lab:critical-hit-fix
Open

Fix: Critical Hit Sound Implementation#1141
tylerreese543-lab wants to merge 1 commit intosmartcmd:mainfrom
tylerreese543-lab:critical-hit-fix

Conversation

@tylerreese543-lab
Copy link

Description

Implements the critical hit sound for both players and mobs.

Changes

Added the "eSoundType_DAMAGE_CRITICAL" enum.
Added LivingEntity::getCriticalSound() which returns an eSoundType, being the DAMAGE_CRITICAL variant.
Added the EntityEvent::HURT_CRITICAL event enumerator.
Added critical.mp3 to the damage sounds.
Added functionality for critical hits to be played.
Added the "_isCritical" flag for DamageSources.
Changed LivingEntity::handleEntityEvent to account for critical hits.

Previous Behavior

No critical hit was programmed prior, would display particles but no sound would play.

Root Cause

There was no way to differentiate between critical and normal hits when taking actual damage and playing sound.

New Behavior

Now, DamageSources can carry whether the attack was a critical one or not. Plays a sound accordingly
Sends EntityEvent::HURT or EntityEvent::HURT_CRITICAL depending on the DamageSource data
Uses the getCriticalSound() function to retrieve the proper sound and plays it alongside the getHurtSound().

Fix Implementation

DamageSource::setisCritical() is called based on the "bCrit" variable in Player::attack(), before sending it to "LivingEntity::hurt()"
Uses DamageSource::isCritical() to check whether the attack was a critical one.
This is used to determine which EntityEvent to broadcast.
This is also used to determine whether to play the critical sound in "LivingEntity::hurt()"

AI Use Disclosure

No AI

Related Issues

@tylerreese543-lab tylerreese543-lab changed the title Fix: Critical Hit Sound Implementaiton Fix: Critical Hit Sound Implementation Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant