Skip to content

Commit

Permalink
- Exhumed: Merge all player counter code into one function.
Browse files Browse the repository at this point in the history
* Probably a bit too much to break these down as much as I did.
  • Loading branch information
mjr4077au committed Mar 24, 2023
1 parent 72af290 commit 07dda89
Showing 1 changed file with 56 additions and 100 deletions.
156 changes: 56 additions & 100 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -752,87 +752,81 @@ void AIPlayer::Damage(RunListEvent* ev)
//
//---------------------------------------------------------------------------

static void doPlayerCurrentItem(Player* const pPlayer)
static void doPlayerCounters(Player* const pPlayer)
{
UseItem(pPlayer->nPlayer, pPlayer->nCurrentItem);
pPlayer->nCurrentItem = -1;
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

static void doPlayerTorch(Player* const pPlayer)
{
pPlayer->nTorch--;

if (pPlayer->nTorch == 0)
if (pPlayer->nCurrentItem > -1)
{
SetTorch(pPlayer->nPlayer, 0);
UseItem(pPlayer->nPlayer, pPlayer->nCurrentItem);
pPlayer->nCurrentItem = -1;
}
else if (pPlayer->nPlayer != nLocalPlayer)

if (pPlayer->nTorch > 0)
{
nFlashDepth = 5;
AddFlash(pPlayer->pActor->sector(), pPlayer->pActor->spr.pos, 0);
pPlayer->nTorch--;

if (pPlayer->nTorch == 0)
{
SetTorch(pPlayer->nPlayer, 0);
}
else if (pPlayer->nPlayer != nLocalPlayer)
{
nFlashDepth = 5;
AddFlash(pPlayer->pActor->sector(), pPlayer->pActor->spr.pos, 0);
}
}
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
if (pPlayer->nDouble > 0)
{
pPlayer->nDouble--;

static void doPlayerDouble(Player* const pPlayer)
{
pPlayer->nDouble--;
if (pPlayer->nDouble == 150 && pPlayer->nPlayer == nLocalPlayer)
{
PlayAlert(GStrings("TXT_EX_WEAPONEX"));
}
}

if (pPlayer->nDouble == 150 && pPlayer->nPlayer == nLocalPlayer)
if (pPlayer->nInvisible > 0)
{
PlayAlert(GStrings("TXT_EX_WEAPONEX"));
}
}
pPlayer->nInvisible--;

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
if (pPlayer->nInvisible == 0)
{
pPlayer->pActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible

static void doPlayerInvisibility(Player* const pPlayer)
{
pPlayer->nInvisible--;
if (pPlayer->pPlayerFloorSprite)
{
pPlayer->pPlayerFloorSprite->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible
}
}
else if (pPlayer->nInvisible == 150 && pPlayer->nPlayer == nLocalPlayer)
{
PlayAlert(GStrings("TXT_EX_INVISEX"));
}
}

if (pPlayer->nInvisible == 0)
if (pPlayer->invincibility > 0)
{
pPlayer->pActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible
pPlayer->invincibility--;

if (pPlayer->pPlayerFloorSprite)
if (pPlayer->invincibility == 150 && pPlayer->nPlayer == nLocalPlayer)
{
pPlayer->pPlayerFloorSprite->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible
PlayAlert(GStrings("TXT_EX_INVINCEX"));
}
}
else if (pPlayer->nInvisible == 150 && pPlayer->nPlayer == nLocalPlayer)
{
PlayAlert(GStrings("TXT_EX_INVISEX"));
}
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
if (pPlayer->nQuake != 0)
{
pPlayer->nQuake = -pPlayer->nQuake;

static void doPlayerInvincibility(Player* const pPlayer)
{
pPlayer->invincibility--;
if (pPlayer->nQuake > 0)
{
pPlayer->nQuake -= 2.;

if (pPlayer->invincibility == 150 && pPlayer->nPlayer == nLocalPlayer)
{
PlayAlert(GStrings("TXT_EX_INVINCEX"));
if (pPlayer->nQuake < 0)
{
pPlayer->nQuake = 0;
}
}
}
}

Expand Down Expand Up @@ -925,27 +919,6 @@ static void doPlayerBreath(Player* const pPlayer)
//
//---------------------------------------------------------------------------

static void doPlayerQuake(Player* const pPlayer)
{
pPlayer->nQuake = -pPlayer->nQuake;

if (pPlayer->nQuake > 0)
{
pPlayer->nQuake -= 2.;

if (pPlayer->nQuake < 0)
{
pPlayer->nQuake = 0;
}
}
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

static void doPlayerRamses(Player* const pPlayer)
{
setForcedSyncInput(pPlayer->nPlayer);
Expand Down Expand Up @@ -1564,24 +1537,7 @@ void AIPlayer::Tick(RunListEvent* ev)
pPlayerActor->spr.picnum = seq_GetSeqPicnum(pPlayer->nSeq, PlayerSeq[nHeightTemplate[pPlayer->nAction]].a, pPlayer->nSeqSize);
pPlayerActor->vel.XY() = pPlayer->vel;

if (pPlayer->nCurrentItem > -1)
doPlayerCurrentItem(pPlayer);

if (pPlayer->nTorch > 0)
doPlayerTorch(pPlayer);

if (pPlayer->nDouble > 0)
doPlayerDouble(pPlayer);

if (pPlayer->nInvisible > 0)
doPlayerInvisibility(pPlayer);

if (pPlayer->invincibility > 0)
doPlayerInvincibility(pPlayer);

if (pPlayer->nQuake != 0)
doPlayerQuake(pPlayer);

doPlayerCounters(pPlayer);
doPlayerYaw(pPlayer);
doPlayerGravity(pPlayerActor);

Expand Down

0 comments on commit 07dda89

Please sign in to comment.