Fix: Critical Hit Sound Implementation#1141
Open
tylerreese543-lab wants to merge 1 commit intosmartcmd:mainfrom
Open
Fix: Critical Hit Sound Implementation#1141tylerreese543-lab wants to merge 1 commit intosmartcmd:mainfrom
tylerreese543-lab wants to merge 1 commit intosmartcmd:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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