Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Minecraft.Client/Common/Audio/SoundNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};


Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/Common/BuildVer.h
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
11 changes: 10 additions & 1 deletion Minecraft.World/DamageSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions Minecraft.World/DamageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ class DamageSource
bool _scalesWithDifficulty;
bool _isMagic;
bool _isExplosion;
bool _isCritical;

public:
bool isCritical();
DamageSource *setIsCritical();
bool isProjectile();
DamageSource *setProjectile();
bool isExplosion();
Expand Down
2 changes: 2 additions & 0 deletions Minecraft.World/EntityEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 22 additions & 5 deletions Minecraft.World/LivingEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions Minecraft.World/LivingEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class LivingEntity : public Entity
virtual void knockback(shared_ptr<Entity> source, float dmg, double xd, double zd);

protected:
virtual int getCriticalSound();
virtual int getHurtSound();
virtual int getDeathSound();

Expand Down
4 changes: 4 additions & 0 deletions Minecraft.World/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Minecraft.World/SoundTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ enum eSOUND_TYPE

eSoundType_FIRE_NEWIGNITE,

eSoundType_DAMAGE_CRITICAL,

eSoundType_MAX
};

Expand Down
Loading