From 39d90d022be68e5c720d86c90565d11faca231f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Dec 2018 09:48:05 +0100 Subject: [PATCH] - made the BUddha checks readable again. --- src/d_player.h | 1 + src/p_interaction.cpp | 13 +++++++------ src/p_user.cpp | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 2a5e3ef60..203e444d0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -105,6 +105,7 @@ public: void PlayAttacking2 (); const char *GetSoundClass () const; + int hasBuddha(); // returns 0 for no buddha, 1 for regular buddha and 2 for strong buddha enum EInvulState { diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 4f9984091..51089352a 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1210,9 +1210,10 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da // but telefragging should still do enough damage to kill the player) // Ignore players that are already dead. // [MC]Buddha2 absorbs telefrag damage, and anything else thrown their way. - if (!(flags & DMG_FORCED) && (((player->cheats & CF_BUDDHA2) || (((player->cheats & CF_BUDDHA) || - (player->mo->FindInventory (PClass::FindActor(NAME_PowerBuddha),true) != nullptr) || - (player->mo->flags7 & MF7_BUDDHA)) && !telefragDamage)) && (player->playerstate != PST_DEAD))) + int buddha = player->mo->hasBuddha(); + if (flags & DMG_FORCED) buddha = 0; + if (telefragDamage && buddha == 1) buddha = 0; + if (buddha) { // If this is a voodoo doll we need to handle the real player as well. player->mo->health = target->health = player->health = 1; @@ -1767,9 +1768,9 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPain target->health -= damage; if (target->health <= 0) { // Death - if ((player->cheats & CF_BUDDHA2) || //Buddha2 is never subjected to telefrag damage thresholds. - ((player->cheats & CF_BUDDHA) || (player->mo->flags7 & MF7_BUDDHA) || - (player->mo->FindInventory(PClass::FindActor(NAME_PowerBuddha), true) != nullptr) && !telefragDamage)) + int buddha = player->mo->hasBuddha(); + if (telefragDamage && buddha == 1) buddha = 0; + if (buddha) { // [SP] Save the player... player->health = target->health = 1; } diff --git a/src/p_user.cpp b/src/p_user.cpp index 5beabf61e..d2a4940d4 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1008,6 +1008,25 @@ const char *APlayerPawn::GetSoundClass() const return SoundClass != NAME_None? SoundClass.GetChars() : "player"; } +//=========================================================================== +// +// APlayerPawn :: hasBuddha +// + +//=========================================================================== + +int APlayerPawn::hasBuddha() +{ + if (player->playerstate == PST_DEAD) return 0; + if (player->cheats & CF_BUDDHA2) return 2; + + if ((player->cheats & CF_BUDDHA) || + (player->mo->flags7 & MF7_BUDDHA) || + player->mo->FindInventory (PClass::FindActor(NAME_PowerBuddha),true) != nullptr) return 1; + + return 0; +} + //=========================================================================== // // APlayerPawn :: GetMaxHealth