mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Added crit implementation for players
Now the crit sound will play for players in addition to just mobs. Added a new EntityEvent that functions the same way as EntityEvent::Hurt, but just plays another sound
This commit is contained in:
parent
dbc9313c51
commit
907a9155e6
|
|
@ -5,6 +5,8 @@ class EntityEvent
|
|||
public:
|
||||
static const BYTE JUMP = 1;
|
||||
static const BYTE HURT = 2;
|
||||
static const BYTE CRITICAL_HURT = 19;
|
||||
|
||||
static const BYTE DEATH = 3;
|
||||
static const BYTE START_ATTACKING = 4;
|
||||
static const BYTE STOP_ATTACKING = 5;
|
||||
|
|
|
|||
|
|
@ -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::CRITICAL_HURT);
|
||||
}
|
||||
else {
|
||||
level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT);
|
||||
}
|
||||
if (source != DamageSource::drown) markHurt();
|
||||
if (sourceEntity != nullptr)
|
||||
{
|
||||
|
|
@ -1193,7 +1198,7 @@ void LivingEntity::swing()
|
|||
|
||||
void LivingEntity::handleEntityEvent(byte id)
|
||||
{
|
||||
if (id == EntityEvent::HURT)
|
||||
if ((id == EntityEvent::HURT) || (id == EntityEvent::CRITICAL_HURT))
|
||||
{
|
||||
walkAnimSpeed = 1.5f;
|
||||
|
||||
|
|
@ -1203,10 +1208,12 @@ void LivingEntity::handleEntityEvent(byte id)
|
|||
|
||||
MemSect(31);
|
||||
// 4J-PB -added because villagers have no sounds
|
||||
int iHurtSound=getHurtSound();
|
||||
int iHurtSound = iHurtSound = getHurtSound();;
|
||||
int iCritSound = getCritHurtSound();;
|
||||
if(iHurtSound!=-1)
|
||||
{
|
||||
playSound(iHurtSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
|
||||
if (id == EntityEvent::CRITICAL_HURT) {playSound(iCritSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); }
|
||||
}
|
||||
MemSect(0);
|
||||
hurt(DamageSource::genericSource, 0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue