From deafec874d87b5b1ef0dd7fb094fd7b38634a0db Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 11 Mar 2014 15:14:47 +0100 Subject: [PATCH 1/2] Snowballs now actualy hurt other entities. 3 damage for blazes and 1 for the ender dragon. Otherwise 0 --- src/Entities/ProjectileEntity.cpp | 26 ++++++++++++++++++++++++-- src/Entities/ProjectileEntity.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 03bc0c99d..92890919c 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -655,8 +655,6 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { - // TODO: Apply damage to certain mobs (blaze etc.) and anger all mobs - Destroy(); } @@ -664,6 +662,30 @@ void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFac +void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) +{ + int TotalDamage = 0; + if (a_EntityHit.IsMob()) + { + cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType(); + if (MobType == cMonster::mtBlaze) + { + TotalDamage = 3; + } + else if (MobType == cMonster::mtEnderDragon) + { + TotalDamage = 1; + } + } + a_EntityHit.TakeDamage(dtRangedAttack, m_Creator, TotalDamage, 1); + + Destroy(true); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cBottleOEnchantingEntity : diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index e80592999..840dac871 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -259,6 +259,7 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; + virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; // tolua_begin From ef3c5a97a46212a0f8cd1a05125f4b75e3f32b74 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 11 Mar 2014 16:24:05 +0100 Subject: [PATCH 2/2] TakeDamage now has the cThrownSnowballEntity instead of the creator's object. --- src/Entities/ProjectileEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 92890919c..37238a0c0 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -677,7 +677,7 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & TotalDamage = 1; } } - a_EntityHit.TakeDamage(dtRangedAttack, m_Creator, TotalDamage, 1); + a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); Destroy(true); }