1
0
Fork 0

Snipe skeleton achievment

This commit is contained in:
Rorkh 2021-09-18 13:18:05 +05:00 committed by Tiger Wang
parent 028a5735c5
commit 798fdb0709
6 changed files with 22 additions and 17 deletions

View File

@ -396,7 +396,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (a_TDI.Attacker != nullptr) if (a_TDI.Attacker != nullptr)
{ {
a_TDI.Attacker->Killed(this); a_TDI.Attacker->Killed(*this, a_TDI.DamageType);
} }
return true; return true;
@ -570,7 +570,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (a_TDI.Attacker != nullptr) if (a_TDI.Attacker != nullptr)
{ {
a_TDI.Attacker->Killed(this); a_TDI.Attacker->Killed(*this, a_TDI.DamageType);
} }
} }
return true; return true;

View File

@ -351,8 +351,8 @@ public:
// tolua_begin // tolua_begin
/** Called when the entity kills another entity */ /** Called when the entity kills another entity. */
virtual void Killed(cEntity * a_Victim) {} virtual void Killed(const cEntity & a_Victim, eDamageType a_DamageType) {}
/** Heals the specified amount of HPs */ /** Heals the specified amount of HPs */
virtual void Heal(int a_HitPoints); virtual void Heal(int a_HitPoints);

View File

@ -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(); cScoreboard & ScoreBoard = m_World->GetScoreBoard();
if (a_Victim->IsPlayer()) if (a_Victim.IsPlayer())
{ {
m_Stats.Custom[CustomStatistic::PlayerKills]++; m_Stats.Custom[CustomStatistic::PlayerKills]++;
ScoreBoard.AddPlayerScore(GetName(), cObjective::otPlayerKillCount, 1); 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); 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]++; m_Stats.Custom[CustomStatistic::MobKills]++;
} }

View File

@ -410,7 +410,7 @@ public:
virtual void KilledBy(TakeDamageInfo & a_TDI) override; 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 void Respawn(void); // tolua_export

View File

@ -68,7 +68,3 @@ void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle)
Super::SpawnOn(a_ClientHandle); Super::SpawnOn(a_ClientHandle);
a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW));
} }

View File

@ -25,7 +25,3 @@ public:
virtual bool IsUndead(void) override { return true; } virtual bool IsUndead(void) override { return true; }
} ; } ;