diff --git a/src/d_player.h b/src/d_player.h index 7781046f8..4993fecdf 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -311,6 +311,8 @@ public: int damagecount, bonuscount;// for screen flashing int hazardcount; // for delayed Strife damage int poisoncount; // screen flash for poison damage + FName poisontype; // type of poison damage to apply + FName poisonpaintype; // type of Pain state to enter for poison damage TObjPtr poisoner; // NULL for non-player actors TObjPtr attacker; // who did damage (NULL for floors) int extralight; // so gun flashes light up areas diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 47a971c44..9a85b786d 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1488,6 +1488,15 @@ bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poi { player->poisoncount += poison; player->poisoner = poisoner; + if (poisoner == NULL) + { + player->poisontype = player->poisonpaintype = NAME_None; + } + else + { // We need to record these in case the poisoner disappears before poisoncount reaches 0. + player->poisontype = poisoner->DamageType; + player->poisonpaintype = poisoner->PainType != NAME_None ? poisoner->PainType : poisoner->DamageType; + } if(player->poisoncount > 100) { player->poisoncount = 100; @@ -1528,12 +1537,12 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, && (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch) && !player->morphTics) { // Try to use some inventory health - P_AutoUseHealth (player, damage - player->health+1); + P_AutoUseHealth(player, damage - player->health+1); } player->health -= damage; // mirror mobj health here for Dave if (player->health < 50 && !deathmatch) { - P_AutoUseStrifeHealth (player); + P_AutoUseStrifeHealth(player); } if (player->health < 0) { @@ -1547,30 +1556,35 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, target->health -= damage; if (target->health <= 0) { // Death - if ( player->cheats & CF_BUDDHA ) + if (player->cheats & CF_BUDDHA) { // [SP] Save the player... player->health = target->health = 1; } else { target->special1 = damage; - if (player && inflictor && !player->morphTics) + if (player && !player->morphTics) { // Check for flame death - if ((inflictor->DamageType == NAME_Fire) - && (target->health > -50) && (damage > 25)) + if ((player->poisontype == NAME_Fire) && (target->health > -50) && (damage > 25)) { target->DamageType = NAME_Fire; } - else target->DamageType = inflictor->DamageType; + else + { + target->DamageType = player->poisontype; + } } - target->Die (source, source); + target->Die(source, source); return; } } if (!(level.time&63) && playPainSound) { - FState * painstate = target->FindState(NAME_Pain,((inflictor && inflictor->PainType != NAME_None) ? inflictor->PainType : target->DamageType)); - if (painstate != NULL) target->SetState (painstate); + FState *painstate = target->FindState(NAME_Pain, player->poisonpaintype); + if (painstate != NULL) + { + target->SetState(painstate); + } } /* if((P_Random() < target->info->painchance) diff --git a/src/p_user.cpp b/src/p_user.cpp index 0d7703c03..8d0c84444 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2658,6 +2658,16 @@ void player_t::Serialize (FArchive &arc) << original_cmd << original_oldbuttons; + if (SaveVersion >= 3475) + { + arc << poisontype << poisonpaintype; + } + else if (poisoner != NULL) + { + poisontype = poisoner->DamageType; + poisonpaintype = poisoner->PainType != NAME_None ? poisoner->PainType : poisoner->DamageType; + } + if (isbot) { arc << angle