Tweaks to some sections of the code that recognise what shields the player has. Specifically:

* introducing the new friend, SH_FORCEHP (which is used as a bitmask to get the extra hitpoints of a force-shield user)
* P_DamageMobj now considers the unimplemented shield constants as well as the implemented ones.
This commit is contained in:
toasterbabe 2016-09-30 12:15:22 +01:00
parent d6a404e1ef
commit 011af0daff
5 changed files with 17 additions and 8 deletions

View File

@ -196,6 +196,7 @@ typedef enum
SH_FIREFLOWER = 0x100,
// The force shield uses the lower 8 bits to count how many hits are left.
SH_FORCE = 0x200,
SH_FORCEHP = 0xFF, // to be used as a bitmask only
SH_STACK = SH_FIREFLOWER,
SH_NOSTACK = ~SH_STACK

View File

@ -2972,20 +2972,28 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && (maptol & TOL_NIGHTS))
return false;
#define shieldtype (player->powers[pw_shield] & SH_NOSTACK)
switch (damagetype)
{
case DMG_WATER:
if (shieldtype == SH_BUBBLEWRAP
|| shieldtype == SH_ELEMENTAL)
return false; // Invincible to water damage
break;
case DMG_FIRE:
if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)
return false; // Invincible to water/fire damage
if (shieldtype == SH_FLAMEAURA
|| shieldtype == SH_ELEMENTAL)
return false; // Invincible to fire damage
break;
case DMG_ELECTRIC:
if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT)
if (shieldtype == SH_ATTRACT
|| shieldtype == SH_THUNDERCOIN)
return false; // Invincible to electric damage
break;
default:
break;
}
#undef shieldtype
}
if (player->pflags & PF_NIGHTSMODE) // NiGHTS damage handling

View File

@ -6326,9 +6326,9 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield)
return false;
}
if (shield == SH_FORCE && thing->movecount != (thing->target->player->powers[pw_shield] & 0xFF))
if (shield == SH_FORCE && thing->movecount != (thing->target->player->powers[pw_shield] & SH_FORCEHP))
{
thing->movecount = (thing->target->player->powers[pw_shield] & 0xFF);
thing->movecount = (thing->target->player->powers[pw_shield] & SH_FORCEHP);
if (thing->movecount < 1)
{
if (thing->info->painstate)

View File

@ -1392,7 +1392,7 @@ void P_SpawnShieldOrb(player_t *player)
if (player->powers[pw_shield] & SH_FORCE)
{
//Copy and pasted from P_ShieldLook in p_mobj.c
shieldobj->movecount = (player->powers[pw_shield] & 0xFF);
shieldobj->movecount = (player->powers[pw_shield] & SH_FORCEHP);
if (shieldobj->movecount < 1)
{
if (shieldobj->info->painstate)
@ -6950,7 +6950,7 @@ static void P_MovePlayer(player_t *player)
#endif
dashangle += ANGLE_180;
P_ResetPlayer(player);
player->homing = 2 + ((player->powers[pw_shield] & SH_NOSTACK) - SH_FORCE); // might get ridiculous with 256 hitpoints, don't you think?
player->homing = 2 + (player->powers[pw_shield] & SH_FORCEHP); // might get ridiculous with 256 hitpoints, don't you think?
S_StartSound(player->mo, sfx_s3k47);
P_SetPlayerMobjState(player->mo, S_PLAY_SPIN);
player->pflags |= PF_SPINNING|PF_THOKKED|PF_SHIELDABILITY;

View File

@ -800,7 +800,7 @@ static void ST_drawFirstPersonHUD(void)
// Graue 06-18-2004: no V_NOSCALESTART, no SCX, no SCY, snap to right
if (player->powers[pw_shield] & SH_FORCE)
{
if ((player->powers[pw_shield] & 0xFF) > 0 || leveltime & 1)
if ((player->powers[pw_shield] & SH_FORCEHP) > 0 || leveltime & 1)
p = forceshield;
}
else switch (player->powers[pw_shield] & SH_NOSTACK)