Merge branch 'tutorial-shorten' into 'master'

Tutorial shortening

See merge request KartKrew/Kart!2306
This commit is contained in:
Sal 2024-04-26 18:58:24 +00:00
commit b39f69c403
10 changed files with 80 additions and 53 deletions

View file

@ -1928,14 +1928,6 @@ bool CallFunc_CheckTutorialChallenge(ACSVM::Thread *thread, const ACSVM::Word *a
thread->dataStk.push(~env->getString( "Failed" )->idx); thread->dataStk.push(~env->getString( "Failed" )->idx);
return false; return false;
} }
if (gamedata != nullptr
&& gamedata->enteredtutorialchallenge == true
&& M_GameTrulyStarted() == false)
{
thread->dataStk.push(~env->getString( "Locked" )->idx);
return false;
}
} }
thread->dataStk.push(0); thread->dataStk.push(0);

View file

@ -2952,7 +2952,8 @@ static void readcondition(UINT16 set, UINT32 id, char *word2)
|| (++offset && fastcmp(params[0], "CREDITS")) || (++offset && fastcmp(params[0], "CREDITS"))
|| (++offset && fastcmp(params[0], "REPLAY")) || (++offset && fastcmp(params[0], "REPLAY"))
|| (++offset && fastcmp(params[0], "CRASH")) || (++offset && fastcmp(params[0], "CRASH"))
|| (++offset && fastcmp(params[0], "TUTORIALSKIP"))) || (++offset && fastcmp(params[0], "TUTORIALSKIP"))
|| (++offset && fastcmp(params[0], "TUTORIALDONE")))
{ {
//PARAMCHECK(1); //PARAMCHECK(1);
ty = UC_ADDON + offset; ty = UC_ADDON + offset;

View file

@ -4137,11 +4137,6 @@ void G_GetNextMap(void)
netgame == false netgame == false
&& gametype == GT_TUTORIAL && gametype == GT_TUTORIAL
&& nextmap == NEXTMAP_TUTORIALCHALLENGE && nextmap == NEXTMAP_TUTORIALCHALLENGE
&& (
!gamedata
|| gamedata->enteredtutorialchallenge == false
|| M_GameTrulyStarted() == true
)
) )
{ {
nextmap = G_MapNumber(tutorialchallengemap); nextmap = G_MapNumber(tutorialchallengemap);
@ -4152,7 +4147,7 @@ void G_GetNextMap(void)
// A gamedata save will happen on successful level enter // A gamedata save will happen on successful level enter
// Also set character, color, and follower from profile // Also set character, color, and follower from profile
D_SendPlayerConfig(0);
} }
} }
@ -4853,27 +4848,39 @@ void G_EndGame(void)
} }
// Only do evaluation and credits in singleplayer contexts // Only do evaluation and credits in singleplayer contexts
if (!netgame && grandprixinfo.gp == true) if (!netgame)
{ {
G_HandleSaveLevel(true); if (gametype == GT_TUTORIAL)
if (nextmap == NEXTMAP_CEREMONY) // end game with ceremony
{ {
if (K_StartCeremony() == true) // Tutorial was finished
gamedata->tutorialdone = true;
M_UpdateUnlockablesAndExtraEmblems(true, true);
gamedata->deferredsave = true;
}
if (grandprixinfo.gp == true)
{
G_HandleSaveLevel(true);
if (nextmap == NEXTMAP_CEREMONY) // end game with ceremony
{ {
if (K_StartCeremony() == true)
{
return;
}
}
if (nextmap == NEXTMAP_CREDITS) // end game with credits
{
F_StartCredits();
return;
}
if (nextmap == NEXTMAP_EVALUATION) // end game with evaluation
{
F_InitGameEvaluation();
F_StartGameEvaluation();
return; return;
} }
}
if (nextmap == NEXTMAP_CREDITS) // end game with credits
{
F_StartCredits();
return;
}
if (nextmap == NEXTMAP_EVALUATION) // end game with evaluation
{
F_InitGameEvaluation();
F_StartGameEvaluation();
return;
} }
} }

View file

@ -76,6 +76,7 @@ void srb2::save_ng_gamedata()
ng.milestones.finishedtutorialchallenge = gamedata->finishedtutorialchallenge; ng.milestones.finishedtutorialchallenge = gamedata->finishedtutorialchallenge;
ng.milestones.enteredtutorialchallenge = gamedata->enteredtutorialchallenge; ng.milestones.enteredtutorialchallenge = gamedata->enteredtutorialchallenge;
ng.milestones.sealedswapalerted = gamedata->sealedswapalerted; ng.milestones.sealedswapalerted = gamedata->sealedswapalerted;
ng.milestones.tutorialdone = gamedata->tutorialdone;
ng.milestones.gonerlevel = gamedata->gonerlevel; ng.milestones.gonerlevel = gamedata->gonerlevel;
ng.prisons.thisprisoneggpickup = gamedata->thisprisoneggpickup; ng.prisons.thisprisoneggpickup = gamedata->thisprisoneggpickup;
ng.prisons.prisoneggstothispickup = gamedata->prisoneggstothispickup; ng.prisons.prisoneggstothispickup = gamedata->prisoneggstothispickup;
@ -480,6 +481,7 @@ void srb2::load_ng_gamedata()
gamedata->finishedtutorialchallenge = js.milestones.finishedtutorialchallenge; gamedata->finishedtutorialchallenge = js.milestones.finishedtutorialchallenge;
gamedata->enteredtutorialchallenge = js.milestones.enteredtutorialchallenge; gamedata->enteredtutorialchallenge = js.milestones.enteredtutorialchallenge;
gamedata->sealedswapalerted = js.milestones.sealedswapalerted; gamedata->sealedswapalerted = js.milestones.sealedswapalerted;
gamedata->tutorialdone = js.milestones.tutorialdone;
gamedata->gonerlevel = js.milestones.gonerlevel; gamedata->gonerlevel = js.milestones.gonerlevel;
gamedata->thisprisoneggpickup = js.prisons.thisprisoneggpickup; gamedata->thisprisoneggpickup = js.prisons.thisprisoneggpickup;
gamedata->prisoneggstothispickup = js.prisons.prisoneggstothispickup; gamedata->prisoneggstothispickup = js.prisons.prisoneggstothispickup;

View file

@ -96,6 +96,7 @@ struct GamedataMilestonesJson final
bool finishedtutorialchallenge; bool finishedtutorialchallenge;
bool enteredtutorialchallenge; bool enteredtutorialchallenge;
bool sealedswapalerted; bool sealedswapalerted;
bool tutorialdone;
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT( NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(
GamedataMilestonesJson, GamedataMilestonesJson,
@ -108,7 +109,8 @@ struct GamedataMilestonesJson final
majorkeyskipattempted, majorkeyskipattempted,
finishedtutorialchallenge, finishedtutorialchallenge,
enteredtutorialchallenge, enteredtutorialchallenge,
sealedswapalerted sealedswapalerted,
tutorialdone
) )
}; };

View file

@ -259,7 +259,7 @@ void K_UpdateMatchRaceBots(void)
else if (tutorialchallenge == TUTORIALSKIP_INPROGRESS) else if (tutorialchallenge == TUTORIALSKIP_INPROGRESS)
{ {
pmax = 8; // can you believe this is a nerf pmax = 8; // can you believe this is a nerf
difficulty = MAXBOTDIFFICULTY; difficulty = 4;
} }
else if (K_CanChangeRules(true) == false) else if (K_CanChangeRules(true) == false)
{ {
@ -321,6 +321,27 @@ void K_UpdateMatchRaceBots(void)
} }
} }
auto clear_bots = [&numbots](UINT8 max)
{
UINT8 i = MAXPLAYERS;
while (numbots > max && i > 0)
{
i--;
if (playeringame[i] && players[i].bot)
{
CL_RemovePlayer(i, KR_LEAVE);
numbots--;
}
}
};
if (tutorialchallenge == TUTORIALSKIP_INPROGRESS)
{
// Prevent Eggman bot carrying over from Tutorial
clear_bots(0);
}
if (numbots < wantedbots) if (numbots < wantedbots)
{ {
// We require MORE bots! // We require MORE bots!
@ -374,17 +395,7 @@ void K_UpdateMatchRaceBots(void)
} }
else if (numbots > wantedbots) else if (numbots > wantedbots)
{ {
i = MAXPLAYERS; clear_bots(wantedbots);
while (numbots > wantedbots && i > 0)
{
i--;
if (playeringame[i] && players[i].bot)
{
CL_RemovePlayer(i, KR_LEAVE);
numbots--;
}
}
} }
// We should have enough bots now :) // We should have enough bots now :)

View file

@ -676,6 +676,7 @@ void M_ClearStats(void)
gamedata->enteredtutorialchallenge = false; gamedata->enteredtutorialchallenge = false;
gamedata->finishedtutorialchallenge = false; gamedata->finishedtutorialchallenge = false;
gamedata->sealedswapalerted = false; gamedata->sealedswapalerted = false;
gamedata->tutorialdone = false;
gamedata->musicstate = GDMUSIC_NONE; gamedata->musicstate = GDMUSIC_NONE;
gamedata->importprofilewins = false; gamedata->importprofilewins = false;
@ -1726,6 +1727,8 @@ boolean M_CheckCondition(condition_t *cn, player_t *player)
return false; return false;
case UC_TUTORIALSKIP: case UC_TUTORIALSKIP:
return (gamedata->finishedtutorialchallenge == true); return (gamedata->finishedtutorialchallenge == true);
case UC_TUTORIALDONE:
return (gamedata->tutorialdone == true);
case UC_PASSWORD: case UC_PASSWORD:
return (cn->stringvar == NULL); return (cn->stringvar == NULL);
@ -2605,6 +2608,8 @@ static const char *M_GetConditionString(condition_t *cn)
return NULL; return NULL;
case UC_TUTORIALSKIP: case UC_TUTORIALSKIP:
return "successfully skip the Tutorial"; return "successfully skip the Tutorial";
case UC_TUTORIALDONE:
return "complete the Tutorial";
case UC_PASSWORD: case UC_PASSWORD:
return "enter a secret password"; return "enter a secret password";

View file

@ -67,6 +67,7 @@ typedef enum
UC_REPLAY, // Save a replay UC_REPLAY, // Save a replay
UC_CRASH, // Hee ho ! UC_CRASH, // Hee ho !
UC_TUTORIALSKIP, // Complete the Tutorial Challenge UC_TUTORIALSKIP, // Complete the Tutorial Challenge
UC_TUTORIALDONE, // Complete the Tutorial at all
UC_PASSWORD, // Type in something funny UC_PASSWORD, // Type in something funny
@ -393,6 +394,7 @@ struct gamedata_t
boolean enteredtutorialchallenge; boolean enteredtutorialchallenge;
boolean finishedtutorialchallenge; boolean finishedtutorialchallenge;
boolean sealedswapalerted; boolean sealedswapalerted;
boolean tutorialdone;
gdmusic_t musicstate; gdmusic_t musicstate;
UINT8 gonerlevel; UINT8 gonerlevel;

View file

@ -103,11 +103,15 @@ boolean M_CanShowLevelInList(INT16 mapnum, levelsearch_t *levelsearch)
// Finally, the most complex check: does the map have lock conditions? // Finally, the most complex check: does the map have lock conditions?
if (levelsearch->checklocked) if (levelsearch->checklocked)
{ {
// Check for visitation // All tutorial courses can be visited for the first time once the game has truly started.
if (!(mapheaderinfo[mapnum]->menuflags & LF2_NOVISITNEEDED) if (levelsearch->tutorial == false || M_GameTrulyStarted() == false)
&& !(mapheaderinfo[mapnum]->records.mapvisited & MV_VISITED) {
&& !(cup && cup->cachedlevels[0] == mapnum)) // Check for visitation
return false; if (!(mapheaderinfo[mapnum]->menuflags & LF2_NOVISITNEEDED)
&& !(mapheaderinfo[mapnum]->records.mapvisited & MV_VISITED)
&& !(cup && cup->cachedlevels[0] == mapnum))
return false;
}
// Check for completion // Check for completion
if ((mapheaderinfo[mapnum]->menuflags & LF2_FINISHNEEDED) if ((mapheaderinfo[mapnum]->menuflags & LF2_FINISHNEEDED)

View file

@ -7696,6 +7696,10 @@ static void P_InitLevelSettings(void)
// We don't touch the gamespeed, though! // We don't touch the gamespeed, though!
} }
else if (tutorialchallenge == TUTORIALSKIP_INPROGRESS)
{
gamespeed = KARTSPEED_NORMAL;
}
else if (grandprixinfo.gp == true) else if (grandprixinfo.gp == true)
{ {
if (multi_speed) if (multi_speed)
@ -7703,10 +7707,7 @@ static void P_InitLevelSettings(void)
gamespeed = grandprixinfo.gamespeed; gamespeed = grandprixinfo.gamespeed;
} }
} }
else if ( else if (modeattacking != ATTACKING_NONE)
modeattacking != ATTACKING_NONE
|| tutorialchallenge == TUTORIALSKIP_INPROGRESS
)
{ {
if (multi_speed) if (multi_speed)
{ {