mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 20:40:39 +00:00
- Exhumed: Move doPickupHealth()
lambda out of doPlayerPickupItems()
.
This commit is contained in:
parent
d5a0dd3d80
commit
66c4a753d9
1 changed files with 49 additions and 43 deletions
|
@ -167,6 +167,54 @@ static void doPickupWeapon(Player* pPlayer, DExhumedActor* pPickupActor, int nIt
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void doPickupHealth(Player* pPlayer, DExhumedActor* pPickupActor, int nItem, const int nAmount, int nSound)
|
||||
{
|
||||
if (nAmount <= 0 || pPlayer->nHealth < 800)
|
||||
{
|
||||
int tintRed = 0, tintGreen = 16;
|
||||
|
||||
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 (nItem == 12)
|
||||
{
|
||||
pPickupActor->spr.hitag = 0;
|
||||
pPickupActor->spr.picnum++;
|
||||
ChangeActorStat(pPickupActor, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nItem == 14)
|
||||
{
|
||||
tintRed = tintGreen;
|
||||
tintGreen = 0;
|
||||
}
|
||||
|
||||
doPickupDestroy(pPickupActor, nItem);
|
||||
}
|
||||
|
||||
doPickupNotification(pPlayer, nItem, nSound, tintRed, tintGreen);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void doPlayerItemPickups(Player* const pPlayer)
|
||||
{
|
||||
const auto pPlayerActor = pPlayer->pActor;
|
||||
|
@ -184,48 +232,6 @@ void doPlayerItemPickups(Player* const pPlayer)
|
|||
static constexpr int healArray[] = {40, 160, -200};
|
||||
static constexpr int ammoArray[] = {1, 3, 2};
|
||||
|
||||
const auto doPickupHealth = [=](const int nAmount, int nSound)
|
||||
{
|
||||
if (nAmount <= 0 || (!(nFlags & 2)))
|
||||
{
|
||||
int tintRed = 0, tintGreen = 16;
|
||||
|
||||
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 (nItem == 12)
|
||||
{
|
||||
pPickupActor->spr.hitag = 0;
|
||||
pPickupActor->spr.picnum++;
|
||||
ChangeActorStat(pPickupActor, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nItem == 14)
|
||||
{
|
||||
tintRed = tintGreen;
|
||||
tintGreen = 0;
|
||||
}
|
||||
|
||||
doPickupDestroy(pPickupActor, nItem);
|
||||
}
|
||||
|
||||
doPickupNotification(pPlayer, nItem, nSound, tintRed, tintGreen);
|
||||
}
|
||||
};
|
||||
|
||||
switch (nItem)
|
||||
{
|
||||
case 6: // Speed Loader
|
||||
|
@ -275,7 +281,7 @@ void doPlayerItemPickups(Player* const pPlayer)
|
|||
case 13: // Blood Bowl
|
||||
case 14: // Cobra Venom Bowl
|
||||
if (pPickupActor->spr.hitag != 0)
|
||||
doPickupHealth(healArray[nItem - 12], nItem + 8);
|
||||
doPickupHealth(pPlayer, pPickupActor, nItem, healArray[nItem - 12], nItem + 8);
|
||||
break;
|
||||
|
||||
case 17: // Bubble Nest
|
||||
|
|
Loading…
Reference in a new issue