summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp4
-rw-r--r--src/Entities/Entity.h4
-rw-r--r--src/Entities/Player.cpp21
-rw-r--r--src/Entities/Player.h2
4 files changed, 22 insertions, 9 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index a5b1fae8f..74b184c54 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -396,7 +396,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (a_TDI.Attacker != nullptr)
{
- a_TDI.Attacker->Killed(this);
+ a_TDI.Attacker->Killed(*this, a_TDI.DamageType);
}
return true;
@@ -570,7 +570,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (a_TDI.Attacker != nullptr)
{
- a_TDI.Attacker->Killed(this);
+ a_TDI.Attacker->Killed(*this, a_TDI.DamageType);
}
}
return true;
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 285ae8fac..941d07339 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -351,8 +351,8 @@ public:
// tolua_begin
- /** Called when the entity kills another entity */
- virtual void Killed(cEntity * a_Victim) {}
+ /** Called when the entity kills another entity. */
+ virtual void Killed(const cEntity & a_Victim, eDamageType a_DamageType) {}
/** Heals the specified amount of HPs */
virtual void Heal(int a_HitPoints);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 1ca37c105..b4d806c4f 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -883,23 +883,36 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
-void cPlayer::Killed(cEntity * a_Victim)
+void cPlayer::Killed(const cEntity & a_Victim, eDamageType a_DamageType)
{
cScoreboard & ScoreBoard = m_World->GetScoreBoard();
- if (a_Victim->IsPlayer())
+ if (a_Victim.IsPlayer())
{
m_Stats.Custom[CustomStatistic::PlayerKills]++;
ScoreBoard.AddPlayerScore(GetName(), cObjective::otPlayerKillCount, 1);
}
- else if (a_Victim->IsMob())
+ else if (a_Victim.IsMob())
{
- if (static_cast<cMonster *>(a_Victim)->GetMobFamily() == cMonster::mfHostile)
+ const auto & Monster = static_cast<const cMonster &>(a_Victim);
+
+ if (Monster.GetMobFamily() == cMonster::mfHostile)
{
AwardAchievement(CustomStatistic::AchKillEnemy);
}
+ if ((Monster.GetMobType() == eMonsterType::mtSkeleton) && (a_DamageType == eDamageType::dtRangedAttack))
+ {
+ const double DistX = GetPosX() - Monster.GetPosX();
+ const double DistZ = GetPosZ() - Monster.GetPosZ();
+
+ if ((DistX * DistX + DistZ * DistZ) >= 2500.0)
+ {
+ AwardAchievement(CustomStatistic::AchSnipeSkeleton);
+ }
+ }
+
m_Stats.Custom[CustomStatistic::MobKills]++;
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 971731ca4..d71fedec5 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -410,7 +410,7 @@ public:
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
- virtual void Killed(cEntity * a_Victim) override;
+ virtual void Killed(const cEntity & a_Victim, eDamageType a_DamageType) override;
void Respawn(void); // tolua_export