Merge branch 'nights-score-lap' into 'master'

NiGHTS: Intermission Bonuses

See merge request STJr/SRB2Internal!159
This commit is contained in:
Digiku 2018-09-19 11:03:14 -04:00
commit 106afd48af
2 changed files with 38 additions and 4 deletions

View file

@ -1196,8 +1196,10 @@ static void readlevelheader(MYFILE *f, INT32 num)
else if (fastcmp(word2, "NORMAL")) i = 0;
else if (fastcmp(word2, "BOSS")) i = 1;
else if (fastcmp(word2, "ERZ3")) i = 2;
else if (fastcmp(word2, "NIGHTS")) i = 3;
else if (fastcmp(word2, "NIGHTSLINK")) i = 4;
if (i >= -1 && i <= 2) // -1 for no bonus. Max is 2.
if (i >= -1 && i <= 4) // -1 for no bonus. Max is 4.
mapheaderinfo[num-1]->bonustype = (SINT8)i;
else
deh_warning("Level header %d: invalid bonus type number %d", num, i);

View file

@ -1750,6 +1750,26 @@ static void Y_SetRingBonus(player_t *player, y_bonus_t *bstruct)
bstruct->points = max(0, (player->rings) * 100);
}
//
// Y_SetNightsBonus
//
static void Y_SetNightsBonus(player_t *player, y_bonus_t *bstruct)
{
strncpy(bstruct->patch, "YB_NIGHT", sizeof(bstruct->patch));
bstruct->display = true;
bstruct->points = player->totalmarescore;
}
//
// Y_SetLapBonus
//
static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct)
{
strncpy(bstruct->patch, "YB_LAP", sizeof(bstruct->patch));
bstruct->display = true;
bstruct->points = max(0, player->totalmarebonuslap * 1000);
}
//
// Y_SetLinkBonus
//
@ -1811,7 +1831,7 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct)
// This list can be extended in the future with SOC/Lua, perhaps.
typedef void (*bonus_f)(player_t *, y_bonus_t *);
bonus_f bonuses_list[4][4] = {
bonus_f bonuses_list[6][4] = {
{
Y_SetNullBonus,
Y_SetNullBonus,
@ -1836,6 +1856,18 @@ bonus_f bonuses_list[4][4] = {
Y_SetRingBonus,
Y_SetPerfectBonus,
},
{
Y_SetNullBonus,
Y_SetNightsBonus,
Y_SetLapBonus,
Y_SetNullBonus,
},
{
Y_SetNullBonus,
Y_SetLinkBonus,
Y_SetLapBonus,
Y_SetNullBonus,
},
};
@ -1911,8 +1943,8 @@ static void Y_AwardSpecialStageBonus(void)
if (!playeringame[i] || players[i].lives < 1) // not active or game over
Y_SetNullBonus(&players[i], &localbonus);
else if (maptol & TOL_NIGHTS) // Link instead of Rings
Y_SetLinkBonus(&players[i], &localbonus);
else if (maptol & TOL_NIGHTS) // Mare score instead of Rings
Y_SetNightsBonus(&players[i], &localbonus);
else
Y_SetRingBonus(&players[i], &localbonus);
players[i].score += localbonus.points;