- 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.
This commit is contained in:
Christoph Oelckers 2022-08-11 23:46:09 +02:00
parent c89ae6358e
commit 1b43575580

View file

@ -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) void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgflags, FName MeansOfDeath)
{ {
FString ret; FString ret, lookup;
char gendermessage[1024]; char gendermessage[1024];
// No obituaries for non-players, voodoo dolls or when not wanted // 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"; messagename = "$OB_VOODOO";
} }
if (attacker != NULL && message == NULL) if (attacker != nullptr && message == nullptr)
{ {
if (attacker == self) if (attacker == self)
{ {
message = "$OB_KILLEDSELF"; 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) }; lookup.Format("$Obituary_%s", attacker->GetClass()->TypeName, mod.GetChars());
VMReturn rett(&ret); if (GStrings[lookup]) message = lookup;
VMCall(func, params, countof(params), &rett, 1); else
if (ret.IsNotEmpty()) message = ret; {
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;
}
}
} }
} }
} }