mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Automatically toggle director depending on number of players
- Upon becoming a spectator: if there are any players who can be spectated, e.g. haven't finished the level, then turn on director cam. - Removes director cvar.
This commit is contained in:
parent
7a67aa2f35
commit
2d063445a6
5 changed files with 35 additions and 11 deletions
|
|
@ -545,8 +545,6 @@ static CV_PossibleValue_t perfstats_cons_t[] = {
|
|||
};
|
||||
consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", 0, perfstats_cons_t, NULL);
|
||||
|
||||
consvar_t cv_director = CVAR_INIT ("director", "Off", 0, CV_OnOff, NULL);
|
||||
|
||||
consvar_t cv_schedule = CVAR_INIT ("schedule", "On", CV_NETVAR|CV_CALL, CV_OnOff, Schedule_OnChange);
|
||||
|
||||
consvar_t cv_automate = CVAR_INIT ("automate", "On", CV_NETVAR, CV_OnOff, NULL);
|
||||
|
|
@ -1053,8 +1051,6 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_scr_width);
|
||||
CV_RegisterVar(&cv_scr_height);
|
||||
|
||||
CV_RegisterVar(&cv_director);
|
||||
|
||||
CV_RegisterVar(&cv_soundtest);
|
||||
|
||||
CV_RegisterVar(&cv_invincmusicfade);
|
||||
|
|
|
|||
|
|
@ -128,8 +128,6 @@ extern consvar_t cv_sleep;
|
|||
|
||||
extern consvar_t cv_perfstats;
|
||||
|
||||
extern consvar_t cv_director;
|
||||
|
||||
extern consvar_t cv_schedule;
|
||||
|
||||
extern consvar_t cv_livestudioaudience;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ void K_InitDirector(void)
|
|||
{
|
||||
INT32 playernum;
|
||||
|
||||
directorinfo.active = false;
|
||||
directorinfo.cooldown = SWITCHTIME;
|
||||
directorinfo.freeze = 0;
|
||||
directorinfo.attacker = 0;
|
||||
|
|
@ -109,6 +110,11 @@ static boolean K_CanSwitchDirector(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!directorinfo.active)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -218,11 +224,6 @@ void K_UpdateDirector(void)
|
|||
INT32 *displayplayerp = &displayplayers[0];
|
||||
INT32 targetposition;
|
||||
|
||||
if (!cv_director.value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
K_UpdateDirectorPositions();
|
||||
|
||||
if (directorinfo.cooldown > 0) {
|
||||
|
|
@ -299,3 +300,13 @@ void K_UpdateDirector(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void K_ToggleDirector(boolean active)
|
||||
{
|
||||
if (directorinfo.active != active)
|
||||
{
|
||||
directorinfo.cooldown = 0; // switch immediately
|
||||
}
|
||||
|
||||
directorinfo.active = active;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ extern "C" {
|
|||
|
||||
extern struct directorinfo
|
||||
{
|
||||
boolean active; // is view point switching enabled?
|
||||
tic_t cooldown; // how long has it been since we last switched?
|
||||
tic_t freeze; // when nonzero, fixed switch pending, freeze logic!
|
||||
INT32 attacker; // who to switch to when freeze delay elapses
|
||||
|
|
@ -26,6 +27,7 @@ void K_InitDirector(void);
|
|||
void K_UpdateDirector(void);
|
||||
void K_DrawDirectorDebugger(void);
|
||||
void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source);
|
||||
void K_ToggleDirector(boolean active);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
17
src/p_mobj.c
17
src/p_mobj.c
|
|
@ -46,6 +46,7 @@
|
|||
#include "k_collide.h"
|
||||
#include "k_objects.h"
|
||||
#include "k_grandprix.h"
|
||||
#include "k_director.h"
|
||||
|
||||
static CV_PossibleValue_t CV_BobSpeed[] = {{0, "MIN"}, {4*FRACUNIT, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_movebob = CVAR_INIT ("movebob", "1.0", CV_FLOAT|CV_SAVE, CV_BobSpeed, NULL);
|
||||
|
|
@ -11827,6 +11828,22 @@ void P_SpawnPlayer(INT32 playernum)
|
|||
K_SpawnPlayerBattleBumpers(p);
|
||||
}
|
||||
}
|
||||
|
||||
// I'm not refactoring the loop at the top of this file.
|
||||
pcount = 0;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (G_CouldView(i))
|
||||
{
|
||||
pcount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Spectating when there is literally any other player in
|
||||
// the level enables director cam.
|
||||
// TODO: how do we support splitscreen?
|
||||
K_ToggleDirector(players[consoleplayer].spectator && pcount > 0);
|
||||
}
|
||||
|
||||
void P_AfterPlayerSpawn(INT32 playernum)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue