From a0204c67221885a72eaa204aa61f7dcb076eab54 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 6 Aug 2017 22:10:29 +0100 Subject: [PATCH] Made P_SpecialStageDamage for the lose 10 rings damaging code shared by spikeballs and SS damage sector special --- src/p_inter.c | 58 +++++++++++++++++++++++++++++++-------------------- src/p_local.h | 1 + src/p_spec.c | 23 +++----------------- 3 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 3ae68814c..4686c68f8 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1493,30 +1493,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_SetMobjState(special, special->info->deathstate); return; case MT_SPECIALSPIKEBALL: - if (!(!useNightsSS && G_IsSpecialStage(gamemap))) // Only for old special stages - { - P_DamageMobj(toucher, special, special, 1, 0); - return; - } - - if (player->powers[pw_invulnerability] || player->powers[pw_flashing] - || player->powers[pw_super]) - return; - if (player->powers[pw_shield] || player->bot) //If One-Hit Shield - { - P_RemoveShield(player); - S_StartSound(toucher, sfx_shldls); // Ba-Dum! Shield loss. - } + if (!useNightsSS && G_IsSpecialStage(gamemap)) // Only for old special stages + P_SpecialStageDamage(player, special, NULL); else - { - P_PlayRinglossSound(toucher); - if (player->rings >= 10) - player->rings -= 10; - else - player->rings = 0; - } - - P_DoPlayerPain(player, special, NULL); + P_DamageMobj(toucher, special, special, 1, 0); return; case MT_EGGMOBILE2_POGO: // sanity checks @@ -3008,6 +2988,38 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN player->rings = 0; } +// +// P_SpecialStageDamage +// +// Do old special stage-style damaging +// Removes 10 rings from the player, or knocks off their shield if they have one. +// If they don't have anything, just knock the player back anyway (this doesn't kill them). +// +void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source) +{ + if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super]) + return; + + if (player->powers[pw_shield] || player->bot) //If One-Hit Shield + { + P_RemoveShield(player); + S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss. + } + else + { + P_PlayRinglossSound(player->mo); + if (player->rings >= 10) + player->rings -= 10; + else + player->rings = 0; + } + + P_DoPlayerPain(player, inflictor, source); + + if (gametype == GT_CTF && player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) + P_PlayerFlagBurst(player, false); +} + /** Damages an object, which may or may not be a player. * For melee attacks, source and inflictor are the same. * diff --git a/src/p_local.h b/src/p_local.h index a2831222a..64ab47975 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -414,6 +414,7 @@ void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duratio void P_ForceConstant(const BasicFF_t *FFInfo); void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End); void P_RemoveShield(player_t *player); +void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source); boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); void P_PlayerRingBurst(player_t *player, INT32 num_rings); /// \todo better fit in p_user.c diff --git a/src/p_spec.c b/src/p_spec.c index 8a3ac0748..03ee30281 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3660,31 +3660,14 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers S_StartSound(player->mo, sfx_itemup); } break; - case 11: // Special Stage Damage - Kind of like a mini-P_DamageMobj() - if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super] || player->exiting || player->bot) + case 11: // Special Stage Damage + if (player->exiting || player->bot) // Don't do anything for bots or players who have just finished break; if (!(player->powers[pw_shield] || player->rings > 0)) // Don't do anything if no shield or rings anyway break; - if (player->powers[pw_shield]) - { - P_RemoveShield(player); - S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss. - } - else if (player->rings > 0) - { - P_PlayRinglossSound(player->mo); - if (player->rings >= 10) - player->rings -= 10; - else - player->rings = 0; - } - - P_DoPlayerPain(player, NULL, NULL); // this does basically everything that was here before - - if (gametype == GT_CTF && player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) - P_PlayerFlagBurst(player, false); + P_SpecialStageDamage(player, NULL, NULL); break; case 12: // Space Countdown if (!(player->powers[pw_shield] & SH_PROTECTWATER) && !player->powers[pw_spacetime])