From 3b35a00397d7919b0613be8f6f756beabad53edc Mon Sep 17 00:00:00 2001 From: TheHyper45 <86074167+TheHyper45@users.noreply.github.com> Date: Sat, 19 Jun 2021 22:25:24 +0100 Subject: Death messages for tamed pets and ocelots are now tamable. (#5243) * Fixing bugs regarding wolfs and ocelots * Death messages appear after killing tamed ocelots and wolfs * Style fix * Added myself to the CONTRIBUTORS file * Removed redundant string initialization * Removed an unsafe cast. * Changed the order of initialization of fields in constuctor of class cOcelot --- src/Entities/Player.cpp | 59 +------------------------------------------------ 1 file changed, 1 insertion(+), 58 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 235433cf8..fcdbcf64c 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -863,65 +863,8 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10); SaveToDisk(); // Save it, yeah the world is a tough place ! - cPluginManager * PluginManager = cRoot::Get()->GetPluginManager(); - if (a_TDI.Attacker == nullptr) - { - const AString DamageText = [&] - { - switch (a_TDI.DamageType) - { - case dtRangedAttack: return "was shot"; - case dtLightning: return "was plasmified by lightining"; - case dtFalling: return GetRandomProvider().RandBool() ? "fell to death" : "hit the ground too hard"; - case dtDrowning: return "drowned"; - case dtSuffocating: return GetRandomProvider().RandBool() ? "git merge'd into a block" : "fused with a block"; - case dtStarving: return "forgot the importance of food"; - case dtCactusContact: return "was impaled on a cactus"; - case dtMagmaContact: return "discovered the floor was lava"; - case dtLavaContact: return "was melted by lava"; - case dtPoisoning: return "died from septicaemia"; - case dtWithering: return "is a husk of their former selves"; - case dtOnFire: return "forgot to stop, drop, and roll"; - case dtFireContact: return "burnt themselves to death"; - case dtInVoid: return "somehow fell out of the world"; - case dtPotionOfHarming: return "was magicked to death"; - case dtEnderPearl: return "misused an ender pearl"; - case dtAdmin: return "was administrator'd"; - case dtExplosion: return "blew up"; - case dtAttack: return "was attacked by thin air"; - case dtEnvironment: return "played too much dress up"; // This is not vanilla - added a own pun - } - UNREACHABLE("Unsupported damage type"); - }(); - AString DeathMessage = Printf("%s %s", GetName().c_str(), DamageText.c_str()); - PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); - if (DeathMessage != AString("")) - { - GetWorld()->BroadcastChatDeath(DeathMessage); - } - } - else if (a_TDI.Attacker->IsPlayer()) - { - cPlayer * Killer = static_cast(a_TDI.Attacker); - AString DeathMessage = Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()); - PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); - if (DeathMessage != AString("")) - { - GetWorld()->BroadcastChatDeath(DeathMessage); - } - } - else - { - AString KillerClass = a_TDI.Attacker->GetClass(); - KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") - AString DeathMessage = Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()); - PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); - if (DeathMessage != AString("")) - { - GetWorld()->BroadcastChatDeath(DeathMessage); - } - } + BroadcastDeathMessage(a_TDI); m_Stats.Custom[CustomStatistic::Deaths]++; m_Stats.Custom[CustomStatistic::TimeSinceDeath] = 0; -- cgit v1.2.3