Skip to content

Commit

Permalink
- Exhumed: And same for health pickup process.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Mar 24, 2023
1 parent 16c2fa3 commit 24b2134
Showing 1 changed file with 46 additions and 53 deletions.
99 changes: 46 additions & 53 deletions source/games/exhumed/src/playerpickups.cpp
Expand Up @@ -81,11 +81,6 @@ static DExhumedActor* feebtag(const DVector3& pos, sectortype* pSector, int nVal
//
//---------------------------------------------------------------------------

enum
{
kPickupHealth = 4,
};

void doPlayerItemPickups(Player* const pPlayer)
{
const auto pPlayerActor = pPlayer->pActor;
Expand All @@ -106,7 +101,6 @@ void doPlayerItemPickups(Player* const pPlayer)
int nSound = -1;
int nAmount = 0;
int nWeapon = 0;
int pickFlag = 0;

const auto doConsoleMessage = [&]()
{
Expand Down Expand Up @@ -175,6 +169,49 @@ void doPlayerItemPickups(Player* const pPlayer)
doConsoleMessage();
}
};
const auto doPickupHealth = [&]()
{
if (nAmount <= 0 || (!(nFlags & 2)))
{
if (!pPlayer->invincibility || nAmount > 0)
{
pPlayer->nHealth += nAmount;

if (pPlayer->nHealth > 800)
{
pPlayer->nHealth = 800;
}
else if (pPlayer->nHealth < 0)
{
nSound = -1;
StartDeathSeq(pPlayer->nPlayer, 0);
}
}

if (statBase == 12)
{
pPickupActor->spr.hitag = 0;
pPickupActor->spr.picnum++;
ChangeActorStat(pPickupActor, 0);
doConsoleMessage();
}
else
{
if (statBase != 14)
{
nSound = 21;
}
else
{
tintRed = tintGreen;
nSound = 22;
tintGreen = 0;
}

doProcessPickup();
}
}
};

switch (itemtype)
{
Expand Down Expand Up @@ -258,18 +295,18 @@ void doPlayerItemPickups(Player* const pPlayer)
{
nSound = 20;
nAmount = 40;
pickFlag |= kPickupHealth;
doPickupHealth();
}
break;

case 7: // Blood Bowl
nAmount = 160;
pickFlag |= kPickupHealth;
doPickupHealth();
break;

case 8: // Cobra Venom Bowl
nAmount = -200;
pickFlag |= kPickupHealth;
doPickupHealth();
break;

case 11: // Bubble Nest
Expand Down Expand Up @@ -463,50 +500,6 @@ void doPlayerItemPickups(Player* const pPlayer)
DeleteActor(pPickupActor);
break;
}

if (pickFlag & kPickupHealth)
{
if (nAmount <= 0 || (!(nFlags & 2)))
{
if (!pPlayer->invincibility || nAmount > 0)
{
pPlayer->nHealth += nAmount;

if (pPlayer->nHealth > 800)
{
pPlayer->nHealth = 800;
}
else if (pPlayer->nHealth < 0)
{
nSound = -1;
StartDeathSeq(pPlayer->nPlayer, 0);
}
}

if (statBase == 12)
{
pPickupActor->spr.hitag = 0;
pPickupActor->spr.picnum++;
ChangeActorStat(pPickupActor, 0);
doConsoleMessage();
}
else
{
if (statBase != 14)
{
nSound = 21;
}
else
{
tintRed = tintGreen;
nSound = 22;
tintGreen = 0;
}

doProcessPickup();
}
}
}
}
}
}
Expand Down

0 comments on commit 24b2134

Please sign in to comment.