diff options
author | Rorkh <rorkh@internet.ru> | 2021-09-18 10:18:05 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-10-02 22:18:18 +0200 |
commit | 798fdb07092fceaccfde41d2f27e2756f29f4eda (patch) | |
tree | aaa7f6bd1be6a33e08be230bda3166b31a2b57a2 | |
parent | Spectation: add dedicated pathway for spectator mode (#5303) (diff) | |
download | cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.tar cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.tar.gz cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.tar.bz2 cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.tar.lz cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.tar.xz cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.tar.zst cuberite-798fdb07092fceaccfde41d2f27e2756f29f4eda.zip |
-rw-r--r-- | src/Entities/Entity.cpp | 4 | ||||
-rw-r--r-- | src/Entities/Entity.h | 4 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 21 | ||||
-rw-r--r-- | src/Entities/Player.h | 2 | ||||
-rw-r--r-- | src/Mobs/Skeleton.cpp | 4 | ||||
-rw-r--r-- | src/Mobs/Skeleton.h | 4 |
6 files changed, 22 insertions, 17 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 diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 766899a26..a32d38d03 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -68,7 +68,3 @@ void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle) Super::SpawnOn(a_ClientHandle); a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); } - - - - diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index dfd1a740f..ee9c803c2 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -25,7 +25,3 @@ public: virtual bool IsUndead(void) override { return true; } } ; - - - - |