diff --git a/src/info.c b/src/info.c index 85a9589c9..b991e6825 100644 --- a/src/info.c +++ b/src/info.c @@ -1670,7 +1670,7 @@ state_t states[NUMSTATES] = {SPR_TVAT, 2, 18, {A_RingShield},0, 0, S_NULL}, // S_ATTRACT_ICON2 {SPR_TVFO, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_FORCE_ICON2}, // S_FORCE_ICON1 - {SPR_TVFO, 2, 18, {A_ForceShield}, 0, 0, S_NULL}, // S_FORCE_ICON2 + {SPR_TVFO, 2, 18, {A_ForceShield}, 1, 0, S_NULL}, // S_FORCE_ICON2 {SPR_TVAR, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_ARMAGEDDON_ICON2}, // S_ARMAGEDDON_ICON1 {SPR_TVAR, 2, 18, {A_BombShield}, 0, 0, S_NULL}, // S_ARMAGEDDON_ICON2 diff --git a/src/p_enemy.c b/src/p_enemy.c index 6345a89c4..900547ccb 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3324,29 +3324,19 @@ void A_WaterShield(mobj_t *actor) S_StartSound(player->mo, actor->info->seesound); else S_StartSound(player->mo, sfx_itemup); - - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - player->powers[pw_underwater] = 0; - - if (player->powers[pw_spacetime] > 1) - { - player->powers[pw_spacetime] = 0; - P_RestoreMusic(player); - } } // Function: A_ForceShield // // Description: Awards the player a force shield. // -// var1 = unused +// var1 = Number of additional hitpoints to give // var2 = unused // void A_ForceShield(mobj_t *actor) { player_t *player; + INT32 locvar1 = var1; #ifdef HAVE_BLUA if (LUA_CallAction("A_ForceShield", actor)) @@ -3358,51 +3348,18 @@ void A_ForceShield(mobj_t *actor) return; } + if (locvar1 < 0 || locvar1 > SH_FORCEHP) + { + CONS_Debug(DBG_GAMELOGIC, "Invalid number of additional hitpoints.\n"); + return; + } + player = actor->target->player; - //can't use P_SwitchShield(player, SH_FORCE) - special case - - if (mariomode) - { - mobj_t *scoremobj = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + (player->mo->height / 2), MT_SCORE); - P_SetMobjState(scoremobj, mobjinfo[MT_SCORE].spawnstate+3); // 1000 - P_AddPlayerScore(player, 1000); - } - - if (!(player->powers[pw_shield] & SH_FORCE)) - { - // Just in case. - if (player->pflags & PF_SHIELDABILITY) - { - player->pflags &= ~PF_SHIELDABILITY; - player->homing = 0; - } - - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_FIREFLOWER - && !(player->powers[pw_super] || (mariomode && player->powers[pw_invulnerability]))) - { - player->mo->color = player->skincolor; - G_GhostAddColor(GHC_NORMAL); - } - - S_StartSound(player->mo, actor->info->seesound); - } - else if (!mariomode) + if (P_SwitchShield(player, SH_FORCE|locvar1)) S_StartSound(player->mo, actor->info->seesound); else S_StartSound(player->mo, sfx_itemup); - - if ((player->powers[pw_shield] & SH_FORCE) && (player->powers[pw_shield] & SH_FORCEHP)) - return; // if you have a force shield with at least 2hp already, let's not go any further. - - if (mariomode) - { - player->mo->movecount = player->powers[pw_shield]; - player->powers[pw_marioflashing] = MARIOFLASHINGTICS; - } - - player->powers[pw_shield] = SH_FORCE|(mariomode ? SH_MUSHROOM : player->powers[pw_shield] & SH_STACK)|0x01; - P_SpawnShieldOrb(player); } // Function: A_PityShield diff --git a/src/p_user.c b/src/p_user.c index 8ceef8d6e..589e5e3c7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1443,10 +1443,16 @@ void P_SpawnShieldOrb(player_t *player) // // Returns whether to play a normal sound or an itemup. // -// Not for use if shieldtype would be SH_FORCE. -// boolean P_SwitchShield(player_t *player, UINT16 shieldtype) { + boolean donthavealready = (shieldtype & SH_FORCE) + ? (!(player->powers[pw_shield] & SH_FORCE) || (player->powers[pw_shield] & SH_FORCEHP) < (shieldtype & ~SH_FORCE)) + : ((player->powers[pw_shield] & SH_NOSTACK) != shieldtype); + + boolean stopshieldability = (shieldtype & SH_FORCE) + ? (!(player->powers[pw_shield] & SH_FORCE)) + : true; + if (mariomode) { mobj_t *scoremobj = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + (player->mo->height / 2), MT_SCORE); @@ -1454,7 +1460,7 @@ boolean P_SwitchShield(player_t *player, UINT16 shieldtype) P_AddPlayerScore(player, 1000); } - if ((player->powers[pw_shield] & SH_NOSTACK) != shieldtype) + if (donthavealready) { if (mariomode) { @@ -1463,9 +1469,9 @@ boolean P_SwitchShield(player_t *player, UINT16 shieldtype) } // Just in case. - if (player->pflags & PF_SHIELDABILITY) + if (stopshieldability && player->pflags & PF_SHIELDABILITY) { - player->pflags &= ~PF_SPINNING|PF_SHIELDABILITY; // They'll still have PF_THOKKED... + player->pflags &= ~(PF_SPINNING|PF_SHIELDABILITY); // They'll still have PF_THOKKED... player->homing = 0; if (player->powers[pw_shield] & SH_FORCE) // Dash. { @@ -1486,6 +1492,20 @@ boolean P_SwitchShield(player_t *player, UINT16 shieldtype) player->powers[pw_shield] = shieldtype|(mariomode ? SH_MUSHROOM : player->powers[pw_shield] & SH_STACK); P_SpawnShieldOrb(player); + + if (shieldtype & SH_PROTECTWATER) + { + if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) + P_RestoreMusic(player); + + player->powers[pw_underwater] = 0; + + if (player->powers[pw_spacetime] > 1) + { + player->powers[pw_spacetime] = 0; + P_RestoreMusic(player); + } + } return true; } return (!mariomode);