This commit is contained in:
arsenicviscera 2026-03-11 03:57:34 -07:00
parent 1036b7368e
commit 3896c7d8a0
10 changed files with 48 additions and 8 deletions

View file

@ -223,6 +223,8 @@ const WCHAR *ConsoleSoundEngine::wchSoundNames[eSoundType_MAX]=
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we have to do a new sound bank
// instead, we'll add the sounds as new ones and change the code to reference them
L"fire.new_ignite",
L"damage.critical", //eSoundType_DAMAGE_CRITICAL,
};

View file

@ -1,7 +1,7 @@
#pragma once
#define VER_PRODUCTBUILD 560
#define VER_PRODUCTVERSION_STR_W L"DEV (unknown version)"
#define VER_PRODUCTVERSION_STR_W L""
#define VER_FILEVERSION_STR_W VER_PRODUCTVERSION_STR_W
#define VER_BRANCHVERSION_STR_W L"UNKNOWN BRANCH"
#define VER_BRANCHVERSION_STR_W L"UNKNOWN/"
#define VER_NETWORK VER_PRODUCTBUILD

View file

@ -124,6 +124,7 @@ DamageSource::DamageSource(ChatPacket::EChatPacketMessage msgId, ChatPacket::ECh
_isProjectile = false;
_isMagic = false;
_isExplosion = false;
_isCritical = false;
//this->msgId = msgId;
m_msgId = msgId;
@ -153,7 +154,15 @@ DamageSource *DamageSource::bypassInvul()
_bypassInvul = true;
return this;
}
bool DamageSource::isCritical()
{
return _isCritical;
}
DamageSource *DamageSource::setIsCritical()
{
_isCritical = true;
return this;
}
DamageSource *DamageSource::setIsFire()
{
isFireSource = true;

View file

@ -47,8 +47,11 @@ private:
bool _scalesWithDifficulty;
bool _isMagic;
bool _isExplosion;
bool _isCritical;
public:
bool isCritical();
DamageSource *setIsCritical();
bool isProjectile();
DamageSource *setProjectile();
bool isExplosion();

View file

@ -5,6 +5,8 @@ class EntityEvent
public:
static const BYTE JUMP = 1;
static const BYTE HURT = 2;
//New
static const BYTE HURT_CRITICAL = 19;
static const BYTE DEATH = 3;
static const BYTE START_ATTACKING = 4;
static const BYTE STOP_ATTACKING = 5;

View file

@ -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)
{
@ -859,7 +864,10 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
}
else
{
if (sound) playSound(getHurtSound(), getSoundVolume(), getVoicePitch());
if (sound) {
if (source->isCritical()) playSound(getCriticalSound(), getSoundVolume(), getVoicePitch());
playSound(getHurtSound(), getSoundVolume(), getVoicePitch());
}
}
MemSect(0);
@ -959,7 +967,10 @@ int LivingEntity::getHurtSound()
{
return eSoundType_DAMAGE_HURT;
}
int LivingEntity::getCriticalSound()
{
return eSoundType_DAMAGE_CRITICAL;
}
int LivingEntity::getDeathSound()
{
return eSoundType_DAMAGE_HURT;
@ -1181,7 +1192,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,11 +1203,16 @@ 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);
}

View file

@ -185,6 +185,7 @@ public:
virtual void knockback(shared_ptr<Entity> source, float dmg, double xd, double zd);
protected:
virtual int getCriticalSound();
virtual int getHurtSound();
virtual int getDeathSound();

View file

@ -1631,6 +1631,10 @@ void Player::attack(shared_ptr<Entity> entity)
}
DamageSource *damageSource = DamageSource::playerAttack(dynamic_pointer_cast<Player>(shared_from_this()));
if (bCrit) {
damageSource->setIsCritical();
}
bool wasHurt = entity->hurt(damageSource, dmg);
delete damageSource;
if (wasHurt)

View file

@ -213,6 +213,8 @@ enum eSOUND_TYPE
eSoundType_FIRE_NEWIGNITE,
eSoundType_DAMAGE_CRITICAL,
eSoundType_MAX
};