From 1b43575580790f361031802a6bbf80d8bc28d98b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Aug 2022 23:46:09 +0200 Subject: [PATCH] - new method to define obituaries without modifying actors. Adding strings to the language file named OBITUARY_{classname}_{damagetype} or OBITUARY_{classname} will now be detected automatically and override all other definitions. This not only allows damage type aware obituaries but also makes it easier to retroactively add them to mods that have none defined. --- src/playsim/p_interaction.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index 8a8732b3bf..f9d45a05b3 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -188,7 +188,7 @@ void PronounMessage (const char *from, char *to, int pronoun, const char *victim // void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgflags, FName MeansOfDeath) { - FString ret; + FString ret, lookup; char gendermessage[1024]; // No obituaries for non-players, voodoo dolls or when not wanted @@ -239,20 +239,30 @@ void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgf messagename = "$OB_VOODOO"; } - if (attacker != NULL && message == NULL) + if (attacker != nullptr && message == nullptr) { if (attacker == self) { message = "$OB_KILLEDSELF"; } - else + else { - IFVIRTUALPTR(attacker, AActor, GetObituary) + lookup.Format("$Obituary_%s_%s", attacker->GetClass()->TypeName, mod.GetChars()); + if (GStrings[lookup]) message = lookup; + else { - VMValue params[] = { attacker, self, inflictor, mod.GetIndex(), !!(dmgflags & DMG_PLAYERATTACK) }; - VMReturn rett(&ret); - VMCall(func, params, countof(params), &rett, 1); - if (ret.IsNotEmpty()) message = ret; + lookup.Format("$Obituary_%s", attacker->GetClass()->TypeName, mod.GetChars()); + if (GStrings[lookup]) message = lookup; + else + { + IFVIRTUALPTR(attacker, AActor, GetObituary) + { + VMValue params[] = { attacker, self, inflictor, mod.GetIndex(), !!(dmgflags & DMG_PLAYERATTACK) }; + VMReturn rett(&ret); + VMCall(func, params, countof(params), &rett, 1); + if (ret.IsNotEmpty()) message = ret; + } + } } } }