NSGameRules: send a newly joined player to the intermission screen gently

This commit is contained in:
Marco Cawthorne 2024-02-21 13:41:18 -08:00
parent 08259f5652
commit 9847f3828e
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
4 changed files with 55 additions and 43 deletions

View File

@ -23,11 +23,6 @@
/** This class represents active gamerules. */
class NSGameRules:NSIO
{
private:
int m_iIntermission;
float m_flIntermissionTime;
float m_flIntermissionCycle;
public:
void NSGameRules(void);
@ -94,12 +89,14 @@ public:
virtual void DamageRadius(vector,entity,float,float,bool,int);
/* end of a game */
/** Called when intermission starts. */
/** Called when intermission starts. Will send all current players to the intermission screen. */
virtual void IntermissionStart(void);
/** Called when intermission calls a new map. */
/** Called when the intermission system calls a new map. */
virtual void IntermissionCycle(void);
/** Called when intermission ents. */
/** Called when intermission ends. */
virtual void IntermissionEnd(void);
/** Run to send a specific player to an intermission. Like when joining late. */
virtual void IntermissionToPlayer(NSClientPlayer);
/** Returns if the gamerules find themselves in an intermission. */
virtual bool InIntermission(void);
@ -126,7 +123,11 @@ public:
virtual void SpectatorDisconnect(NSClientPlayer);
virtual void SpectatorThink(NSClientPlayer);
*/
private:
int m_iIntermission;
float m_flIntermissionTime;
float m_flIntermissionCycle;
entity m_eIntermissionPoint;
};
/* our currently running mode */

View File

@ -192,7 +192,6 @@ NSGameRules::IntermissionStart(void)
void
NSGameRules::IntermissionCycle(void)
{
static NSEntity cam;
NSEntity targ;
if (!m_iIntermission)
@ -205,34 +204,28 @@ NSGameRules::IntermissionCycle(void)
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_INTERMISSION);
cam = (NSEntity)find(cam, ::classname, "info_intermission");
m_eIntermissionPoint = (NSEntity)find(m_eIntermissionPoint, ::classname, "info_intermission");
if (cam) {
targ = (NSEntity)find(world, ::targetname, cam.target);
/* if we have an intermission point, send it to all players. */
if (m_eIntermissionPoint) {
targ = (NSEntity)find(world, ::targetname, m_eIntermissionPoint.target);
if (targ) {
vector foo;
foo = vectoangles(targ.origin - cam.origin);
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, foo[0]);
WriteFloat(MSG_MULTICAST, foo[1]);
WriteFloat(MSG_MULTICAST, foo[2]);
WriteCoord(MSG_MULTICAST, cam.origin[0]);
WriteCoord(MSG_MULTICAST, cam.origin[1]);
WriteCoord(MSG_MULTICAST, cam.origin[2]);
} else {
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, cam.angles[0]);
WriteFloat(MSG_MULTICAST, cam.angles[1]);
WriteFloat(MSG_MULTICAST, cam.angles[2]);
WriteCoord(MSG_MULTICAST, cam.origin[0]);
WriteCoord(MSG_MULTICAST, cam.origin[1]);
WriteCoord(MSG_MULTICAST, cam.origin[2]);
foo = vectoangles(targ.origin - m_eIntermissionPoint.origin);
m_eIntermissionPoint.angles = foo;
}
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, m_eIntermissionPoint.angles[0]);
WriteFloat(MSG_MULTICAST, m_eIntermissionPoint.angles[1]);
WriteFloat(MSG_MULTICAST, m_eIntermissionPoint.angles[2]);
WriteCoord(MSG_MULTICAST, m_eIntermissionPoint.origin[0]);
WriteCoord(MSG_MULTICAST, m_eIntermissionPoint.origin[1]);
WriteCoord(MSG_MULTICAST, m_eIntermissionPoint.origin[2]);
for (entity pl = world; (pl = find(pl, ::classname, "player"));) {
setorigin(pl, cam.origin);
setorigin(pl, m_eIntermissionPoint.origin);
}
} else {
WriteByte(MSG_MULTICAST, 0);
@ -241,11 +234,33 @@ NSGameRules::IntermissionCycle(void)
msg_entity = world;
multicast([0,0,0], MULTICAST_ALL);
if (!cam)
if (!m_eIntermissionPoint)
m_flIntermissionCycle = 0.0f;
else
m_flIntermissionCycle = time + 5.0f;
}
void
NSGameRules::IntermissionToPlayer(NSClientPlayer targetPlayer)
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_INTERMISSION);
/* we're in an intermission already, so this should be set. */
if (g_grMode.m_eIntermissionPoint) {
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.angles[0]);
WriteFloat(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.angles[1]);
WriteFloat(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.angles[2]);
WriteCoord(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.origin[0]);
WriteCoord(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.origin[1]);
WriteCoord(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.origin[2]);
} else {
WriteByte(MSG_MULTICAST, 0);
}
msg_entity = targetPlayer;
multicast([0,0,0], MULTICAST_ONE_R);
}
bool

View File

@ -162,6 +162,10 @@ PutClientInServer(void)
/* the game and its triggers start when the player is ready to see it */
trigger_auto_trigger();
if (g_grMode.InIntermission() == true) {
g_grMode.IntermissionToPlayer((NSClientPlayer)self);
}
}
/** Run before game physics have taken place.

View File

@ -361,6 +361,8 @@ NSRenderableEntity::RenderFXPass(void)
break;
case RM_GLOW:
colormod = [1,1,1];
alpha = m_flRenderAmt == 0.0 ? 0.0f : 1.0f;
case RM_WORLDGLOW: /* TODO: Figure out what this does differently */
if (checkpvs(vecPlayer, this) == FALSE)
alpha -= clframetime;
@ -900,22 +902,12 @@ NSRenderableEntity::GetRenderFX(void)
float
NSRenderableEntity::GetRenderAmt(void)
{
if (m_iRenderMode == RM_NORMAL)
return 1.0f;
else if (m_iRenderMode == RM_GLOW && m_flRenderAmt == 0.0)
return 1.0f;
return m_flRenderAmt;
}
vector
NSRenderableEntity::GetRenderColor(void)
{
if (m_iRenderMode == RM_NORMAL)
return [1.0, 1.0, 1.0];
else if (m_iRenderMode == RM_GLOW)
return [1.0, 1.0, 1.0];
return m_vecRenderColor;
}