diff options
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Entity.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c4f61ad1e..858f9e0de 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -2420,11 +2420,22 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) GetWorld()->BroadcastChatDeath(DeathMessage); } } - else + // This will trigger if a player/tamed pet has been killed by another mob/tamed pet. + else if (a_TDI.Attacker->IsMob()) { - 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", Name.c_str(), KillerClass.c_str()); + cMonster * Monster = static_cast<cMonster *>(a_TDI.Attacker); + + AString DeathMessage; + if (Monster->HasCustomName()) + { + DeathMessage = Printf("%s was killed by %s", Name.c_str(), Monster->GetCustomName().c_str()); + } + else + { + AString KillerName = AString(NamespaceSerializer::Prettify(Monster->GetMobType(), Monster->IsTame())); + DeathMessage = Printf("%s was killed by a %s", Name.c_str(), KillerName.c_str()); + } + PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); if (DeathMessage != AString("")) { |