Fade level music back in after Invincibility and Grow

Cvars are invincibilitymusicfade and growmusicfade. Both measure milliseconds.
This commit is contained in:
James R 2019-11-28 22:05:49 -08:00
parent e9c0e65e0e
commit 8524c3749d
6 changed files with 38 additions and 1 deletions

View file

@ -985,6 +985,9 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_soundtest);
CV_RegisterVar(&cv_invincmusicfade);
CV_RegisterVar(&cv_growmusicfade);
// ingame object placing
COM_AddCommand("objectplace", Command_ObjectPlace_f);
COM_AddCommand("writethings", Command_Writethings_f);

View file

@ -529,6 +529,9 @@ consvar_t cv_fireaxis4 = {"joyaxis4_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NU
consvar_t cv_driftaxis4 = {"joyaxis4_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
#if MAXPLAYERS > 16
#error "please update player_name table using the new value for MAXPLAYERS"

View file

@ -118,6 +118,9 @@ extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis
extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_deadzone4;
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
extern consvar_t cv_invincmusicfade;
extern consvar_t cv_growmusicfade;
typedef enum
{
AXISNONE = 0,

View file

@ -1244,10 +1244,16 @@ void P_RestoreMusic(player_t *player)
// Item - Grow
if (wantedmus == 2)
{
S_ChangeMusicInternal("kgrow", true);
S_SetRestoreMusicFadeInCvar(&cv_growmusicfade);
}
// Item - Invincibility
else if (wantedmus == 1)
{
S_ChangeMusicInternal("kinvnc", true);
S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade);
}
else
{
#if 0
@ -1256,7 +1262,8 @@ void P_RestoreMusic(player_t *player)
if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value))
S_SpeedMusic(1.2f);
#endif
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0,
S_GetRestoreMusicFadeIn());
}
}
}

View file

@ -1563,6 +1563,7 @@ static char music_name[7]; // up to 6-character name
static void *music_data;
static UINT16 music_flags;
static boolean music_looping;
static consvar_t *music_refade_cv;
static char queue_name[7];
static UINT16 queue_flags;
@ -1946,6 +1947,8 @@ static void S_UnloadMusic(void)
music_name[0] = 0;
music_flags = 0;
music_looping = false;
music_refade_cv = 0;
}
static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
@ -2167,6 +2170,21 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
}
}
void
S_SetRestoreMusicFadeInCvar (consvar_t *cv)
{
music_refade_cv = cv;
}
int
S_GetRestoreMusicFadeIn (void)
{
if (music_refade_cv)
return music_refade_cv->value;
else
return 0;
}
/// ------------------------
/// Music Fading
/// ------------------------

View file

@ -186,6 +186,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
#define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0)
#define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0)
void S_SetRestoreMusicFadeInCvar (consvar_t *cvar);
int S_GetRestoreMusicFadeIn (void);
// Stops the music.
void S_StopMusic(void);