Merge branch 'finish-jingles-return' into 'master'

Finish Jingles Return

See merge request KartKrew/Kart!1214
This commit is contained in:
Oni 2023-05-01 03:17:26 +00:00
commit b5fbb84395
9 changed files with 221 additions and 267 deletions

View file

@ -6455,18 +6455,9 @@ struct int_const_s const INT_CONST[] = {
{"JT_NONE",JT_NONE},
{"JT_OTHER",JT_OTHER},
{"JT_MASTER",JT_MASTER},
{"JT_1UP",JT_1UP},
{"JT_SHOES",JT_SHOES},
{"JT_INV",JT_INV},
{"JT_MINV",JT_MINV},
{"JT_DROWN",JT_DROWN},
{"JT_SUPER",JT_SUPER},
{"JT_GOVER",JT_GOVER},
{"JT_NIGHTSTIMEOUT",JT_NIGHTSTIMEOUT},
{"JT_SSTIMEOUT",JT_SSTIMEOUT},
// {"JT_LCLEAR",JT_LCLEAR},
// {"JT_RACENT",JT_RACENT},
// {"JT_CONTSC",JT_CONTSC},
{"JT_INVINCIBILITY",JT_INVINCIBILITY},
{"JT_GROW",JT_GROW},
// Overlay exception settings
{"OV_DONTSCREENOFFSET", OV_DONTSCREENOFFSET},

View file

@ -669,7 +669,7 @@ extern const tic_t bulbtime;
extern UINT8 numbulbs;
extern tic_t raceexittime;
extern tic_t battleexittime;
#define MUSICCOUNTDOWNMAX (raceexittime - (TICRATE/2))
extern INT32 hyudorotime;
extern INT32 stealtime;
@ -694,7 +694,7 @@ extern UINT8 maxXtraLife; // Max extra lives from rings
extern mobj_t *hunt1, *hunt2, *hunt3; // Emerald hunt locations
// For racing
extern tic_t racecountdown, exitcountdown;
extern tic_t racecountdown, exitcountdown, musiccountdown;
#define DEFAULT_GRAVITY (4*FRACUNIT/5)
extern fixed_t gravity;

View file

@ -249,8 +249,7 @@ tic_t starttime = 3;
const tic_t bulbtime = TICRATE/2;
UINT8 numbulbs = 1;
tic_t raceexittime = 5*TICRATE + (2*TICRATE/3);
tic_t battleexittime = 8*TICRATE;
tic_t raceexittime = 7*TICRATE + (TICRATE/2);
INT32 hyudorotime = 7*TICRATE;
INT32 stealtime = TICRATE/2;
@ -277,7 +276,7 @@ mobj_t *hunt1;
mobj_t *hunt2;
mobj_t *hunt3;
tic_t racecountdown, exitcountdown; // for racing
tic_t racecountdown, exitcountdown, musiccountdown; // for racing
fixed_t gravity;
fixed_t mapobjectscale;
@ -2392,6 +2391,19 @@ void G_Ticker(boolean run)
if (Playing() == true)
{
if (musiccountdown > 1)
{
musiccountdown--;
if (musiccountdown == 1)
{
S_ChangeMusicInternal("racent", true);
}
else if (musiccountdown == (MUSICCOUNTDOWNMAX - (3*TICRATE)/2))
{
P_EndingMusic();
}
}
K_TickMidVote();
}
}
@ -4447,11 +4459,6 @@ static void G_DoCompleted(void)
}
}
// See Y_StartIntermission timer handling
if ((gametyperules & GTR_CIRCUIT) && ((multiplayer && demo.playback) || j == r_splitscreen+1) && (!K_CanChangeRules(false) || cv_inttime.value > 0))
// play some generic music if there's no win/cool/lose music going on (for exitlevel commands)
S_ChangeMusicInternal("racent", true);
if (automapactive)
AM_Stop();
@ -5542,7 +5549,7 @@ void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skippr
// Clear a bunch of variables
redscore = bluescore = lastmap = 0;
racecountdown = exitcountdown = mapreset = exitfadestarted = 0;
racecountdown = exitcountdown = musiccountdown = mapreset = exitfadestarted = 0;
for (i = 0; i < MAXPLAYERS; i++)
{

View file

@ -1771,21 +1771,6 @@ static int lib_pPlayVictorySound(lua_State *L)
return 0;
}
static int lib_pPlayLivesJingle(lua_State *L)
{
player_t *player = NULL;
//NOHUD
//INLEVEL
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
P_PlayLivesJingle(player);
return 0;
}
static int lib_pCanPickupItem(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -4051,7 +4036,6 @@ static luaL_Reg lib[] = {
{"P_PlayRinglossSound",lib_pPlayRinglossSound},
{"P_PlayDeathSound",lib_pPlayDeathSound},
{"P_PlayVictorySound",lib_pPlayVictorySound},
{"P_PlayLivesJingle",lib_pPlayLivesJingle},
{"P_CanPickupItem",lib_pCanPickupItem},
// p_spec

View file

@ -188,7 +188,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean fromAir, angle_t oldPitch, an
void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative);
void P_RestoreMusic(player_t *player);
boolean P_EndingMusic(player_t *player);
void P_EndingMusic(void);
mobj_t *P_SpawnGhostMobj(mobj_t *mobj);
INT32 P_GivePlayerRings(player_t *player, INT32 num_rings);
INT32 P_GivePlayerSpheres(player_t *player, INT32 num_spheres);
@ -228,7 +228,6 @@ UINT8 P_FindHighestLap(void);
boolean P_PlayerMoving(INT32 pnum);
void P_PlayLivesJingle(player_t *player);
void P_PlayRinglossSound(mobj_t *source);
void P_PlayDeathSound(mobj_t *source);
void P_PlayVictorySound(mobj_t *source);
@ -246,20 +245,9 @@ typedef enum
JT_NONE, // Null state
JT_OTHER, // Other state
JT_MASTER, // Main level music
JT_1UP, // Extra life
JT_SHOES, // Speed shoes
JT_INV, // Invincibility
JT_MINV, // Mario Invincibility
JT_DROWN, // Drowning
JT_SUPER, // Super Sonic
JT_GOVER, // Game Over
JT_NIGHTSTIMEOUT, // NiGHTS Time Out (10 seconds)
JT_SSTIMEOUT, // NiGHTS Special Stage Time Out (10 seconds)
// these are not jingles
// JT_LCLEAR, // Level Clear
// JT_RACENT, // Multiplayer Intermission
// JT_CONTSC, // Continue
JT_INVINCIBILITY, // Invincibility
JT_GROW, // Grow
NUMJINGLES
} jingletype_t;

View file

@ -7165,7 +7165,7 @@ static void P_InitLevelSettings(void)
K_UpdateShrinkCheat(&players[i]);
}
racecountdown = exitcountdown = exitfadestarted = 0;
racecountdown = exitcountdown = musiccountdown = exitfadestarted = 0;
curlap = bestlap = 0; // SRB2Kart
// Gamespeed and frantic items

View file

@ -813,10 +813,14 @@ void P_Ticker(boolean run)
}
}
if (K_CheckBossIntro() == true)
if (musiccountdown > 0)
{
// Music is controlled by completion sequence
}
else if (K_CheckBossIntro() == true)
{
// Bosses have a punchy start, so no position.
if (leveltime == 3)
if (leveltime == 1)
{
S_ChangeMusic(mapmusname, mapmusflags, true);
S_ShowMusicCredit();
@ -849,7 +853,7 @@ void P_Ticker(boolean run)
if (encoremode)
{
// Encore humming starts immediately.
if (leveltime == 3)
if (leveltime == 1)
S_ChangeMusicInternal("encore", true);
}
else

View file

@ -36,6 +36,7 @@
#include "r_splats.h"
#include "z_zone.h"
#include "w_wad.h"
#include "y_inter.h" // Y_DetermineIntermissionType
#include "hu_stuff.h"
// We need to affect the NiGHTS hud
#include "st_stuff.h"
@ -86,18 +87,9 @@ jingle_t jingleinfo[NUMJINGLES] = {
{"" , false}, // JT_NONE
{"" , false}, // JT_OTHER
{"" , false}, // JT_MASTER
{"_1up" , false},
{"_shoes" , true},
{"_inv" , false},
{"_minv" , false},
{"_drown" , false},
{"_super" , true},
{"_gover" , false},
{"_ntime" , false}, // JT_NIGHTSTIMEOUT
{"_drown" , false} // JT_SSTIMEOUT
// {"_clear" , false},
// {"_inter" , true},
// {"_conti" , true}
{"kinvnc" , true}, // JT_INVINCIBILITY
{"kgrow" , true}, // JT_GROW
};
//
@ -606,24 +598,6 @@ void P_AddPlayerScore(player_t *player, UINT32 amount)
player->roundscore = MAXSCORE;
}
//
// P_PlayLivesJingle
//
void P_PlayLivesJingle(player_t *player)
{
if (player && !P_IsLocalPlayer(player))
return;
if (use1upSound)
S_StartSound(NULL, sfx_oneup);
else
{
P_PlayJingle(player, JT_1UP);
strlcpy(S_sfx[sfx_None].caption, "One-up", 7);
S_StartCaption(sfx_None, -1, extralifetics+1);
}
}
void P_PlayJingle(player_t *player, jingletype_t jingletype)
{
const char *musname = jingleinfo[jingletype].musname;
@ -651,7 +625,7 @@ void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, b
return;
S_RetainMusic(musname, musflags, looping, 0, status);
S_StopMusic();
//S_StopMusic();
S_ChangeMusicInternal(musname, looping);
}
@ -668,48 +642,30 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname)
switch(status)
{
case JT_1UP: // Extra life
result = false; //(players[i].powers[pw_extralife] > 1);
break;
case JT_SHOES: // Speed shoes
/*if (players[i].powers[pw_sneakers] > 1 && !players[i].powers[pw_super])
case JT_INVINCIBILITY: // Invincibility
if (players[i].invincibilitytimer > 1)
{
//strlcpy(S_sfx[sfx_None].caption, "Speed shoes", 12);
//S_StartCaption(sfx_None, -1, players[i].powers[pw_sneakers]);
strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14);
S_StartCaption(sfx_None, -1, players[i].invincibilitytimer);
result = true;
}
else*/
else
{
result = false;
}
break;
case JT_INV: // Invincibility
case JT_MINV: // Mario Invincibility
/*if (players[i].powers[pw_invulnerability] > 1)
case JT_GROW: // Grow
if (players[i].growshrinktimer > 1)
{
//strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14);
//S_StartCaption(sfx_None, -1, players[i].powers[pw_invulnerability]);
strlcpy(S_sfx[sfx_None].caption, "Grow", 14);
S_StartCaption(sfx_None, -1, players[i].growshrinktimer);
result = true;
}
else*/
else
{
result = false;
break;
case JT_DROWN: // Drowning
result = false; //(players[i].powers[pw_underwater] && players[i].powers[pw_underwater] <= 11*TICRATE + 1);
break;
case JT_SUPER: // Super Sonic
result = false; //(players[i].powers[pw_super]);
break;
case JT_GOVER: // Game Over
result = (players[i].lives <= 0);
break;
case JT_NIGHTSTIMEOUT: // NiGHTS Time Out (10 seconds)
case JT_SSTIMEOUT:
result = false; //(players[i].nightstime && players[i].nightstime <= 10*TICRATE);
}
break;
case JT_OTHER: // Other state
@ -755,91 +711,105 @@ void P_PlayVictorySound(mobj_t *source)
//
// Consistently sets ending music!
//
boolean P_EndingMusic(player_t *player)
void P_EndingMusic(void)
{
char buffer[9];
boolean looping = true;
boolean racetracks = !!(gametyperules & GTR_CIRCUIT);
INT32 bestlocalpos, test;
player_t *bestlocalplayer;
const char *jingle = NULL;
boolean nointer = false;
UINT8 bestPos = UINT8_MAX;
player_t *bestPlayer = NULL;
if (!P_IsLocalPlayer(player)) // Only applies to a local player
return false;
if (multiplayer && demo.playback) // Don't play this in multiplayer replays
return false;
SINT8 i;
// Event - Level Finish
// Check for if this is valid or not
#define getplayerpos(p) \
(((players[p].position < 1) || (players[p].pflags & PF_NOCONTEST)) \
? MAXPLAYERS+1 \
: players[p].position);
if (r_splitscreen)
for (i = 0; i <= r_splitscreen; i++)
{
const UINT8 *localplayertable = G_PartyArray(consoleplayer);
UINT8 pos = UINT8_MAX;
player_t *checkPlayer = NULL;
if (!((players[localplayertable[0]].exiting || (players[localplayertable[0]].pflags & PF_NOCONTEST))
|| (players[localplayertable[1]].exiting || (players[localplayertable[1]].pflags & PF_NOCONTEST))
|| ((r_splitscreen > 1) && (players[localplayertable[2]].exiting || (players[localplayertable[2]].pflags & PF_NOCONTEST)))
|| ((r_splitscreen > 2) && (players[localplayertable[3]].exiting || (players[localplayertable[3]].pflags & PF_NOCONTEST)))))
return false;
checkPlayer = &players[displayplayers[i]];
if (!checkPlayer || checkPlayer->spectator == true)
{
continue;
}
bestlocalplayer = &players[localplayertable[0]];
bestlocalpos = getplayerpos(localplayertable[0]);
#define setbests(p) \
test = getplayerpos(p); \
if (test < bestlocalpos) \
{ \
bestlocalplayer = &players[p]; \
bestlocalpos = test; \
}
setbests(localplayertable[1]);
if (r_splitscreen > 1)
setbests(localplayertable[2]);
if (r_splitscreen > 2)
setbests(localplayertable[3]);
#undef setbests
}
else
{
if (!(player->exiting || (player->pflags & PF_NOCONTEST)))
return false;
bestlocalplayer = player;
bestlocalpos = getplayerpos((player-players));
}
#undef getplayerpos
if (racetracks == true && bestlocalpos == MAXPLAYERS+1)
sprintf(buffer, "k*fail"); // F-Zero death results theme
else
{
if (K_IsPlayerLosing(bestlocalplayer))
sprintf(buffer, "k*lose");
else if (bestlocalpos == 1)
sprintf(buffer, "k*win");
if (checkPlayer->pflags & PF_NOCONTEST)
{
// No Contest, use special value
;
}
else if (checkPlayer->exiting)
{
// Standard exit, use their position
pos = checkPlayer->position;
}
else
sprintf(buffer, "k*ok");
{
// Not finished, ignore
continue;
}
if (pos <= bestPos)
{
bestPlayer = checkPlayer;
bestPos = pos;
}
}
// See G_DoCompleted and Y_DetermineIntermissionType
nointer = ((modeattacking && (players[consoleplayer].pflags & PF_NOCONTEST))
|| (grandprixinfo.gp == true && grandprixinfo.eventmode != GPEVENT_NONE));
if (bestPlayer == NULL)
{
// No jingle for you
return;
}
if (bestPos == UINT8_MAX)
{
jingle = "RETIRE";
if (G_GametypeUsesLives() == true)
{
// A retry will be happening
nointer = true;
}
}
else
{
if (bestPlayer->position == 1)
{
jingle = "_first";
}
else if (K_IsPlayerLosing(bestPlayer) == false)
{
jingle = "_win";
}
else
{
jingle = "_lose";
if (G_GametypeUsesLives() == true)
{
// A retry will be happening
nointer = true;
}
}
}
if (nointer == true)
{
// Do not set "racent" in G_Ticker
musiccountdown = 1;
}
if (jingle == NULL)
return;
S_SpeedMusic(1.0f);
if (racetracks == true)
{
buffer[1] = 'r';
}
else
{
buffer[1] = 'b';
looping = false;
}
S_ChangeMusicInternal(buffer, looping);
return true;
S_ChangeMusicInternal(jingle, false);
}
//
@ -849,96 +819,100 @@ boolean P_EndingMusic(player_t *player)
//
void P_RestoreMusic(player_t *player)
{
UINT32 position;
UINT8 overrideLevel = 0;
SINT8 i;
if (!P_IsLocalPlayer(player)) // Only applies to a local player
if (P_IsLocalPlayer(player) == false)
{
// Only applies to local players
return;
}
S_SpeedMusic(1.0f);
// TO-DO: Use jingle system for Kart's stuff
// Event - HERE COMES A NEW CHALLENGER
if (mapreset)
{
S_ChangeMusicInternal("chalng", false); //S_StopMusic();
S_ChangeMusicInternal("chalng", false);
return;
}
// Event - Level Ending
if (P_EndingMusic(player))
if (musiccountdown > 0)
{
return;
}
// Event - Level Start
if ((K_CheckBossIntro() == false)
&& (leveltime < (starttime + (TICRATE/2)))) // see also where time overs are handled
return;
{
INT32 wantedmus = 0; // 0 is level music, 1 is invincibility, 2 is grow
if (r_splitscreen)
{
INT32 bestlocaltimer = 1;
const UINT8 *localplayertable = G_PartyArray(consoleplayer);
#define setbests(p) \
if (players[p].playerstate == PST_LIVE) \
{ \
if (players[p].invincibilitytimer > bestlocaltimer) \
{ wantedmus = 1; bestlocaltimer = players[p].invincibilitytimer; } \
else if (players[p].growshrinktimer > bestlocaltimer) \
{ wantedmus = 2; bestlocaltimer = players[p].growshrinktimer; } \
return;
}
setbests(localplayertable[0]);
setbests(localplayertable[1]);
if (r_splitscreen > 1)
setbests(localplayertable[2]);
if (r_splitscreen > 2)
setbests(localplayertable[3]);
#undef setbests
}
else
for (i = 0; i <= r_splitscreen; i++)
{
player_t *checkPlayer = &players[displayplayers[i]];
if (!checkPlayer)
{
if (player->playerstate == PST_LIVE)
{
if (player->invincibilitytimer > 1)
wantedmus = 1;
else if (player->growshrinktimer > 1)
wantedmus = 2;
}
continue;
}
// Item - Grow
if (wantedmus == 2)
if (checkPlayer->exiting)
{
S_ChangeMusicInternal("kgrow", true);
S_SetRestoreMusicFadeInCvar(&cv_growmusicfade);
return;
}
// Item - Invincibility
else if (wantedmus == 1)
if (checkPlayer->invincibilitytimer > 1)
{
S_ChangeMusicInternal("kinvnc", true);
S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade);
overrideLevel = max(overrideLevel, 2);
}
else
else if (checkPlayer->growshrinktimer > 1)
{
overrideLevel = max(overrideLevel, 1);
}
}
if (overrideLevel != 0)
{
// Do a jingle override.
jingletype_t jt = JT_NONE;
switch (overrideLevel)
{
// Lowest priority to highest priority.
case 1:
jt = JT_GROW;
break;
case 2:
jt = JT_INVINCIBILITY;
break;
default:
break;
}
if (jt != JT_NONE)
{
//CONS_Printf("JINGLE: %d\n", jt);
//if (S_RecallMusic(jt, false) == false)
//{
P_PlayJingle(player, jt);
//}
return;
}
}
#if 0
// Event - Final Lap
// Still works for GME, but disabled for consistency
if ((gametyperules & GTR_CIRCUIT) && player->laps >= numlaps)
S_SpeedMusic(1.2f);
#endif
if (mapmusresume && cv_resume.value)
position = mapmusresume;
else
position = mapmusposition;
S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0,
S_GetRestoreMusicFadeIn());
S_ClearRestoreMusicFadeInCvar();
mapmusresume = 0;
}
if (S_RecallMusic(JT_NONE, false) == false) // go down the stack
{
CONS_Debug(DBG_BASIC, "Cannot find any music in resume stack!\n");
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
}
}
@ -1286,9 +1260,12 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
void P_DoPlayerExit(player_t *player)
{
const boolean losing = K_IsPlayerLosing(player);
const boolean specialout = (specialstageinfo.valid == true && losing == true);
if (player->exiting || mapreset)
{
return;
}
if (P_IsLocalPlayer(player) && (!player->spectator && !demo.playback))
{
@ -1303,13 +1280,19 @@ void P_DoPlayerExit(player_t *player)
K_PlayerLoseLife(player);
}
if (P_IsLocalPlayer(player) && !specialout)
{
S_StopMusic();
musiccountdown = MUSICCOUNTDOWNMAX;
}
player->exiting = 1;
if (!player->spectator)
{
ClearFakePlayerSkin(player);
if ((gametyperules & GTR_CIRCUIT)) // If in Race Mode, allow
if ((gametyperules & GTR_CIRCUIT)) // Special Race-like handling
{
K_UpdateAllPlayerPositions();
@ -1333,13 +1316,9 @@ void P_DoPlayerExit(player_t *player)
}
}
// See Y_StartIntermission timer handling
if (!K_CanChangeRules(false) || cv_inttime.value > 0)
P_EndingMusic(player);
if (P_CheckRacers() && !exitcountdown)
{
if (specialstageinfo.valid == true && losing == true)
if (specialout == true)
{
exitcountdown = TICRATE;
}
@ -1349,16 +1328,9 @@ void P_DoPlayerExit(player_t *player)
}
}
}
else if ((gametyperules & GTR_BUMPERS)) // Battle Mode exiting
else if (!exitcountdown) // All other gametypes
{
if (!exitcountdown)
exitcountdown = battleexittime+1;
P_EndingMusic(player);
}
else // Accidental death safeguard???
{
if (!exitcountdown)
exitcountdown = raceexittime+2;
exitcountdown = raceexittime+1;
}
if (grandprixinfo.gp == true && player->bot == false && losing == false)
@ -1377,7 +1349,9 @@ void P_DoPlayerExit(player_t *player)
}
if (modeattacking)
{
G_UpdateRecords();
}
profile_t *pr = PR_GetPlayerProfile(player);
if (pr != NULL && !losing)
@ -3844,10 +3818,16 @@ void P_DoTimeOver(player_t *player)
P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER);
}
P_EndingMusic(player);
if (P_IsLocalPlayer(player))
{
S_StopMusic();
musiccountdown = MUSICCOUNTDOWNMAX;
}
if (!exitcountdown)
exitcountdown = 5*TICRATE;
{
exitcountdown = raceexittime;
}
}
// SRB2Kart: These are useful functions, but we aren't using them yet.

View file

@ -805,7 +805,7 @@ void Y_StartIntermission(void)
if (prevmap >= nummapheaders || !mapheaderinfo[prevmap])
I_Error("Y_StartIntermission: Internal map ID %d not found (nummapheaders = %d)", prevmap, nummapheaders);
if (!(gametyperules & GTR_CIRCUIT) && (timer > 1))
if (timer > 1 && musiccountdown == 0)
S_ChangeMusicInternal("racent", true); // loop it
S_ShowMusicCredit(); // Always call