Skip to content

Commit

Permalink
- Exhumed: Same for main pickup process.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Mar 24, 2023
1 parent 77e262c commit 239ee20
Showing 1 changed file with 40 additions and 41 deletions.
81 changes: 40 additions & 41 deletions source/games/exhumed/src/playerpickups.cpp
Expand Up @@ -83,8 +83,6 @@ static DExhumedActor* feebtag(const DVector3& pos, sectortype* pSector, int nVal

enum
{
kPickupProcess = 1,
kPickupDefaults = kPickupProcess,
kPickupHealth = 4,
kPickupWeapon = 8,
};
Expand Down Expand Up @@ -124,22 +122,43 @@ void doPlayerItemPickups(Player* const pPlayer)
TintPalette(tintRed * 4, tintGreen * 4, 0);
}
};
const auto doProcessPickup = [&]()
{
if (!mplevel || (statBase >= 25 && (statBase <= 25 || statBase == 50)))
{
// If this is an anim we need to properly destroy it so we need to do some proper detection and not wild guesses.
if (pPickupActor->nRun == pPickupActor->nDamage && pPickupActor->nRun != 0 && pPickupActor->nPhase == ITEM_MAGIC)
{
DestroyAnim(pPickupActor);
}
else
{
DeleteActor(pPickupActor);
}
}
else
{
StartRegenerate(pPickupActor);
}

doConsoleMessage();
};

switch (itemtype)
{
case 0: // Speed Loader
if (AddAmmo(pPlayer->nPlayer, 1, pPickupActor->spr.hitag))
{
nSound = StaticSound[kSoundAmmoPickup];
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 1: // Fuel Canister
if (AddAmmo(pPlayer->nPlayer, 3, pPickupActor->spr.hitag))
{
nSound = StaticSound[kSoundAmmoPickup];
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

Expand All @@ -148,7 +167,7 @@ void doPlayerItemPickups(Player* const pPlayer)
{
nSound = StaticSound[kSoundAmmoPickup];
CheckClip(pPlayer->nPlayer);
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

Expand All @@ -173,7 +192,7 @@ void doPlayerItemPickups(Player* const pPlayer)
}
else
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
}
break;
Expand All @@ -194,12 +213,12 @@ void doPlayerItemPickups(Player* const pPlayer)
case 38:
case 45:
case 52:
pickFlag |= kPickupDefaults;
doProcessPickup();
break;

case 5: // Map
GrabMap();
pickFlag |= kPickupDefaults;
doProcessPickup();
break;

case 6: // Berry Twig
Expand Down Expand Up @@ -242,42 +261,42 @@ void doPlayerItemPickups(Player* const pPlayer)
case 12: // Still Beating Heart
if (GrabItem(pPlayer->nPlayer, kItemHeart))
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 13: // Scarab amulet(Invicibility)
if (GrabItem(pPlayer->nPlayer, kItemInvincibility))
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 14: // Severed Slave Hand(double damage)
if (GrabItem(pPlayer->nPlayer, kItemDoubleDamage))
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 15: // Unseen eye(Invisibility)
if (GrabItem(pPlayer->nPlayer, kItemInvisibility))
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 16: // Torch
if (GrabItem(pPlayer->nPlayer, kItemTorch))
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 17: // Sobek Mask
if (GrabItem(pPlayer->nPlayer, kItemMask))
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

Expand All @@ -287,7 +306,7 @@ void doPlayerItemPickups(Player* const pPlayer)
pPlayer->nLives++;
tintGreen = 32;
tintRed = 32;
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

Expand Down Expand Up @@ -336,15 +355,15 @@ void doPlayerItemPickups(Player* const pPlayer)
if (AddAmmo(pPlayer->nPlayer, 5, 1))
{
nSound = StaticSound[kSoundAmmoPickup];
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

case 32: // Raw Energy
if (AddAmmo(pPlayer->nPlayer, 6, pPickupActor->spr.hitag))
{
nSound = StaticSound[kSoundAmmoPickup];
pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

Expand All @@ -366,7 +385,7 @@ void doPlayerItemPickups(Player* const pPlayer)
}
else
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
}
break;
Expand All @@ -385,7 +404,7 @@ void doPlayerItemPickups(Player* const pPlayer)
pPlayer->nMagic = 1000;
}

pickFlag |= kPickupDefaults;
doProcessPickup();
}
break;

Expand Down Expand Up @@ -452,7 +471,7 @@ void doPlayerItemPickups(Player* const pPlayer)
tintGreen = 0;
}

pickFlag |= kPickupDefaults;
doProcessPickup();
}
}
}
Expand Down Expand Up @@ -481,7 +500,7 @@ void doPlayerItemPickups(Player* const pPlayer)

if (statBase <= 50)
{
pickFlag |= kPickupDefaults;
doProcessPickup();
}
else
{
Expand All @@ -490,26 +509,6 @@ void doPlayerItemPickups(Player* const pPlayer)
doConsoleMessage();
}
}

if (pickFlag & kPickupProcess)
{
if (!mplevel || (statBase >= 25 && (statBase <= 25 || statBase == 50)))
{
// If this is an anim we need to properly destroy it so we need to do some proper detection and not wild guesses.
if (pPickupActor->nRun == pPickupActor->nDamage && pPickupActor->nRun != 0 && pPickupActor->nPhase == ITEM_MAGIC)
{
DestroyAnim(pPickupActor);
}
else
{
DeleteActor(pPickupActor);
}
}
else
{
StartRegenerate(pPickupActor);
}
}
}
}
}
Expand Down

0 comments on commit 239ee20

Please sign in to comment.