Challenge unlock explosions (from character select screen)

* Generalised the existing system to work here, no need to copypaste
* Spawned on unlock AND on debug button, so you can watch how they propogate
* Currently unsure on how large tile does it - right now it just spawns two sets of explosions on topleft and bottomright corners.

Also fixed an issue where a large tile could fail to show its highlight border if it looped between the two ends of the challenge grid
This commit is contained in:
toaster 2022-12-02 21:31:13 +00:00
parent 3c915d8f68
commit 5e76896ac4
3 changed files with 88 additions and 25 deletions

View file

@ -653,9 +653,9 @@ extern UINT8 setup_maxpage;
#define CSEXPLOSIONS 48
extern struct setup_explosions_s {
UINT8 x, y;
UINT16 x, y;
UINT8 tics;
UINT8 color;
UINT16 color;
} setup_explosions[CSEXPLOSIONS];
typedef enum

View file

@ -1481,13 +1481,13 @@ static void M_DrawCharSelectPreview(UINT8 num)
}
}
static void M_DrawCharSelectExplosions(void)
static void M_DrawCharSelectExplosions(boolean charsel, UINT16 basex, UINT16 basey)
{
UINT8 i;
INT16 quadx = 0, quady = 0;
for (i = 0; i < CSEXPLOSIONS; i++)
{
INT16 quadx, quady;
UINT8 *colormap;
UINT8 frame;
@ -1496,14 +1496,17 @@ static void M_DrawCharSelectExplosions(void)
frame = 6 - setup_explosions[i].tics;
quadx = 4 * (setup_explosions[i].x / 3);
quady = 4 * (setup_explosions[i].y / 3);
if (charsel)
{
quadx = 4 * (setup_explosions[i].x / 3);
quady = 4 * (setup_explosions[i].y / 3);
}
colormap = R_GetTranslationColormap(TC_DEFAULT, setup_explosions[i].color, GTC_MENUCACHE);
V_DrawMappedPatch(
82 + (setup_explosions[i].x*16) + quadx - 6,
22 + (setup_explosions[i].y*16) + quady - 6,
basex + (setup_explosions[i].x*16) + quadx - 6,
basey + (setup_explosions[i].y*16) + quady - 6,
0, W_CachePatchName(va("CHCNFRM%d", frame), PU_CACHE),
colormap
);
@ -1742,7 +1745,7 @@ void M_DrawCharacterSelect(void)
}
// Explosions when you've made your final selection
M_DrawCharSelectExplosions();
M_DrawCharSelectExplosions(true, 82, 22);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
@ -4523,7 +4526,7 @@ void M_DrawChallenges(void)
// ...unless we simply aren't unlocked yet.
if ((gamedata->unlocked[num] == false)
|| (num == challengesmenu.currentunlock && challengesmenu.unlockanim < UNLOCKTIME/2))
|| (num == challengesmenu.currentunlock && challengesmenu.unlockanim < 2))
{
work = (ref->majorunlock) ? 2 : 1;
V_DrawFill(x, y, 16*work, 16*work,
@ -4570,4 +4573,6 @@ drawborder:
}
x += 16;
}
M_DrawCharSelectExplosions(false, currentMenu->x, currentMenu->y);
}

View file

@ -2229,10 +2229,12 @@ void M_CharacterSelect(INT32 choice)
M_SetupNextMenu(&PLAY_CharSelectDef, false);
}
static void M_SetupReadyExplosions(setup_player_t *p)
static void M_SetupReadyExplosions(boolean charsel, UINT16 basex, UINT16 basey, UINT16 color)
{
UINT8 i, j;
UINT8 e = 0;
UINT16 maxx = (charsel ? 9 : gamedata->challengegridwidth);
UINT16 maxy = (charsel ? 9 : CHALLENGEGRIDHEIGHT);
while (setup_explosions[e].tics)
{
@ -2248,7 +2250,7 @@ static void M_SetupReadyExplosions(setup_player_t *p)
for (j = 0; j < 4; j++)
{
SINT8 x = p->gridx, y = p->gridy;
INT16 x = basex, y = basey;
switch (j)
{
@ -2258,11 +2260,27 @@ static void M_SetupReadyExplosions(setup_player_t *p)
case 3: y -= offset; break;
}
if ((x < 0 || x > 8) || (y < 0 || y > 8))
if ((y < 0 || y >= maxy))
continue;
if (/*charsel &&*/ (x < 0 || x >= maxx))
continue;
/*if (!charsel)
{
while (x < 0)
{
x += maxx;
}
while (x >= maxx)
{
x -= maxx;
}
}*/
setup_explosions[e].tics = t;
setup_explosions[e].color = p->color;
setup_explosions[e].color = color;
setup_explosions[e].x = x;
setup_explosions[e].y = y;
@ -2550,7 +2568,7 @@ static void M_HandleCharAskChange(setup_player_t *p, UINT8 num)
p->delay = TICRATE;
S_StartSound(NULL, sfx_s3k4e);
M_SetupReadyExplosions(p);
M_SetupReadyExplosions(true, p->gridx, p->gridy, p->color);
}
else
{
@ -2850,7 +2868,7 @@ static void M_HandleFollowerCategoryRotate(setup_player_t *p, UINT8 num)
p->followern = -1;
p->mdepth = CSSTEP_READY;
p->delay = TICRATE;
M_SetupReadyExplosions(p);
M_SetupReadyExplosions(true, p->gridx, p->gridy, p->color);
S_StartSound(NULL, sfx_s3k4e);
}
else
@ -2951,7 +2969,7 @@ static void M_HandleFollowerRotate(setup_player_t *p, UINT8 num)
{
p->mdepth = CSSTEP_READY;
p->delay = TICRATE;
M_SetupReadyExplosions(p);
M_SetupReadyExplosions(true, p->gridx, p->gridy, p->color);
S_StartSound(NULL, sfx_s3k4e);
}
@ -3000,7 +3018,7 @@ static void M_HandleFollowerColorRotate(setup_player_t *p, UINT8 num)
{
p->mdepth = CSSTEP_READY;
p->delay = TICRATE;
M_SetupReadyExplosions(p);
M_SetupReadyExplosions(true, p->gridx, p->gridy, p->color);
S_StartSound(NULL, sfx_s3k4e);
M_SetMenuDelay(num);
}
@ -6822,6 +6840,7 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
if (challengesmenu.pending || desiredmenu == NULL)
{
memset(setup_explosions, 0, sizeof(setup_explosions));
challengesmenu.currentunlock = MAXUNLOCKABLES;
M_PopulateChallengeGrid();
return &MISC_ChallengesDef;
@ -6843,6 +6862,8 @@ void M_Challenges(INT32 choice)
UINT8 selection[MAXUNLOCKABLES];
UINT8 numunlocks = 0;
challengesmenu.extradata = M_ChallengeGridExtraData();
// Get a random available unlockable.
for (i = 0; i < MAXUNLOCKABLES; i++)
{
@ -6882,6 +6903,11 @@ void M_Challenges(INT32 choice)
continue;
}
if (challengesmenu.extradata[i] & CHE_CONNECTEDLEFT) // no need to check for CHE_CONNECTEDUP in linear iteration
{
continue;
}
challengesmenu.col = challengesmenu.hilix = i/CHALLENGEGRIDHEIGHT;
challengesmenu.row = challengesmenu.hiliy = i%CHALLENGEGRIDHEIGHT;
break;
@ -6897,6 +6923,12 @@ void M_ChallengesTick(void)
challengesmenu.ticker++;
for (i = 0; i < CSEXPLOSIONS; i++)
{
if (setup_explosions[i].tics > 0)
setup_explosions[i].tics--;
}
if (challengesmenu.pending && challengesmenu.currentunlock >= MAXUNLOCKABLES)
{
if ((newunlock = M_GetNextAchievedUnlock(true)) < MAXUNLOCKABLES)
@ -6906,6 +6938,9 @@ void M_ChallengesTick(void)
if (gamedata->challengegrid)
{
Z_Free(challengesmenu.extradata);
challengesmenu.extradata = M_ChallengeGridExtraData();
for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++)
{
if (gamedata->challengegrid[i] != challengesmenu.currentunlock)
@ -6913,10 +6948,25 @@ void M_ChallengesTick(void)
continue;
}
if (challengesmenu.extradata[i] & CHE_CONNECTEDLEFT) // no need to check for CHE_CONNECTEDUP in linear iteration
{
continue;
}
challengesmenu.col = challengesmenu.hilix = i/CHALLENGEGRIDHEIGHT;
challengesmenu.row = challengesmenu.hiliy = i%CHALLENGEGRIDHEIGHT;
break;
}
S_StartSound(NULL, sfx_s3k4e);
M_SetupReadyExplosions(false, challengesmenu.col, challengesmenu.row, SKINCOLOR_KETCHUP);
if (unlockables[challengesmenu.currentunlock].majorunlock)
{
UINT8 temp = challengesmenu.col+1;
if (temp == gamedata->challengegridwidth)
temp = 0;
M_SetupReadyExplosions(false, temp, challengesmenu.row+1, SKINCOLOR_KETCHUP);
}
}
}
else
@ -6924,8 +6974,6 @@ void M_ChallengesTick(void)
challengesmenu.pending = false;
G_SaveGameData();
}
Z_Free(challengesmenu.extradata);
challengesmenu.extradata = NULL;
}
else if (challengesmenu.unlockanim >= UNLOCKTIME)
{
@ -6935,11 +6983,6 @@ void M_ChallengesTick(void)
{
challengesmenu.unlockanim++;
}
if (challengesmenu.extradata == NULL)
{
challengesmenu.extradata = M_ChallengeGridExtraData();
}
}
boolean M_ChallengesInputs(INT32 ch)
@ -6978,10 +7021,25 @@ boolean M_ChallengesInputs(INT32 ch)
continue;
}
if (challengesmenu.extradata[i] & CHE_CONNECTEDLEFT) // no need to check for CHE_CONNECTEDUP in linear iteration
{
continue;
}
challengesmenu.col = challengesmenu.hilix = i/CHALLENGEGRIDHEIGHT;
challengesmenu.row = challengesmenu.hiliy = i%CHALLENGEGRIDHEIGHT;
break;
}
S_StartSound(NULL, sfx_s3k4e);
M_SetupReadyExplosions(false, challengesmenu.col, challengesmenu.row, SKINCOLOR_KETCHUP);
if (unlockables[challengesmenu.currentunlock].majorunlock)
{
UINT8 temp = challengesmenu.col+1;
if (temp == gamedata->challengegridwidth)
temp = 0;
M_SetupReadyExplosions(false, temp, challengesmenu.row+1, SKINCOLOR_KETCHUP);
}
}
return true;
}