From 7e6a5c1448fe4f8c2efdb813e4ba685414f1b450 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Jul 2013 11:02:35 +0200 Subject: [PATCH] - added damage type specific extreme death and extreme crash states. Order of labels is 'Death.extreme.damagetype' ('XDeath.damagetype') and 'Crash.extreme.damagetype'. - fixed: Damage of type 'extreme' did not get recorded as an extreme death for the mugshot code. - changed: extreme deaths now only get recorded when an extreme death state was actually used, to ensure that the crash state being used is the correct one associated with the death state. --- src/p_interaction.cpp | 61 +++++++++++++++++++++++++++++++++---------- src/p_mobj.cpp | 10 ++++++- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index c46cb40f74..cc4c9aece6 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -657,10 +657,37 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) FState *diestate = NULL; + int gibhealth = GibHealth(); + bool extremelydead = ((health < gibhealth || flags4 & MF4_EXTREMEDEATH) && !(flags4 & MF4_NOEXTREMEDEATH)); + + // Special check for 'extreme' damage type to ensure that it gets recorded properly as an extreme death for subsequent checks. + if (DamageType == NAME_Extreme) + { + extremelydead = true; + DamageType = NAME_None; + } + + // find the appropriate death state. The order is: + // + // 1. If damagetype is not 'none' and death is extreme, try a damage type specific extreme death state + // 2. If no such state is found or death is not extreme try a damage type specific normal death state + // 3. If damagetype is 'ice' and actor is a monster or player, try the generic freeze death (unless prohibited) + // 4. If no state has been found and death is extreme, try the extreme death state + // 5. If no such state is found or death is not extreme try the regular death state. + // 6. If still no state has been found, destroy the actor immediately. if (DamageType != NAME_None) { - diestate = FindState (NAME_Death, DamageType, true); + if (extremelydead) + { + FName labels[] = { NAME_Death, NAME_Extreme, DamageType }; + diestate = FindState(3, labels, true); + } + if (diestate == NULL) + { + diestate = FindState (NAME_Death, DamageType, true); + if (diestate != NULL) extremelydead = false; + } if (diestate == NULL) { if (DamageType == NAME_Ice) @@ -669,6 +696,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) if (!deh.NoAutofreeze && !(flags4 & MF4_NOICEDEATH) && (player || (flags3 & MF3_ISMONSTER))) { diestate = FindState(NAME_GenericFreezeDeath); + extremelydead = false; } } } @@ -676,8 +704,6 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) if (diestate == NULL) { int flags4 = inflictor == NULL ? 0 : inflictor->flags4; - - int gibhealth = GibHealth(); // Don't pass on a damage type this actor cannot handle. // (most importantly, prevent barrels from passing on ice damage.) @@ -687,26 +713,33 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) DamageType = NAME_None; } - if ((health < gibhealth || flags4 & MF4_EXTREMEDEATH) && !(flags4 & MF4_NOEXTREMEDEATH)) + if (extremelydead) { // Extreme death diestate = FindState (NAME_Death, NAME_Extreme, true); - // If a non-player, mark as extremely dead for the crash state. - if (diestate != NULL && player == NULL && health >= gibhealth) - { - health = gibhealth - 1; - } - // For players, mark the appropriate flag. - else if (player != NULL) - { - player->cheats |= CF_EXTREMELYDEAD; - } } if (diestate == NULL) { // Normal death + extremelydead = false; diestate = FindState (NAME_Death); } } + if (extremelydead) + { + // We'll only get here if an actual extreme death state was used. + + // For players, mark the appropriate flag. + if (player != NULL) + { + player->cheats |= CF_EXTREMELYDEAD; + } + // If a non-player, mark as extremely dead for the crash state. + else if (health >= gibhealth) + { + health = gibhealth - 1; + } + } + if (diestate != NULL) { SetState (diestate); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 41b41aec67..3b11ec415d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5922,7 +5922,15 @@ void AActor::Crash() if (DamageType != NAME_None) { - crashstate = FindState(NAME_Crash, DamageType, true); + if (health < GibHealth()) + { // Extreme death + FName labels[] = { NAME_Crash, NAME_Extreme, DamageType }; + crashstate = FindState (3, labels, true); + } + if (crashstate == NULL) + { // Normal death + crashstate = FindState(NAME_Crash, DamageType, true); + } } if (crashstate == NULL) {