2019-01-16 16:43:50 +00:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
|
|
|
*
|
|
|
|
* See the file LICENSE attached with the sources for usage details.
|
|
|
|
*
|
|
|
|
****/
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
2017-05-01 15:52:01 +00:00
|
|
|
SpectatorThink
|
2017-01-10 18:24:45 +00:00
|
|
|
|
2017-05-01 15:52:01 +00:00
|
|
|
Run every frame on every spectator
|
2017-01-10 18:24:45 +00:00
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_SpectatorThink(void)
|
|
|
|
{
|
2017-05-01 15:52:01 +00:00
|
|
|
self.SendFlags = 1;
|
2016-12-09 23:03:13 +00:00
|
|
|
}
|
2017-05-01 15:52:01 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
2017-05-01 15:52:01 +00:00
|
|
|
ClientKill
|
2017-01-10 18:24:45 +00:00
|
|
|
|
2017-05-01 15:52:01 +00:00
|
|
|
Suicide command 'kill' executes this function.
|
2017-01-10 18:24:45 +00:00
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_ClientKill(void)
|
|
|
|
{
|
|
|
|
Damage_Apply(self, self, self.health, self.origin, TRUE);
|
2017-11-11 07:25:59 +00:00
|
|
|
}
|
2017-01-10 18:24:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
2017-05-01 15:52:01 +00:00
|
|
|
ClientConnect
|
2017-01-10 18:24:45 +00:00
|
|
|
|
2017-05-01 15:52:01 +00:00
|
|
|
Run whenever a new client joins
|
2017-01-10 18:24:45 +00:00
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_ClientConnect(void) {}
|
2016-12-09 23:03:13 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
2017-05-01 15:52:01 +00:00
|
|
|
SpectatorConnect
|
2017-01-10 18:24:45 +00:00
|
|
|
|
2017-05-01 15:52:01 +00:00
|
|
|
Called when a spectator joins the game
|
2017-01-10 18:24:45 +00:00
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_SpectatorConnect(void)
|
|
|
|
{
|
2017-05-01 15:52:01 +00:00
|
|
|
//Spawn_MakeSpectator();
|
|
|
|
//Spawn_ObserverCam();
|
|
|
|
ClientConnect();
|
|
|
|
PutClientInServer();
|
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
2017-05-01 15:52:01 +00:00
|
|
|
SpectatorDisconnect
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2017-05-01 15:52:01 +00:00
|
|
|
Called when a spectator leaves the game
|
2017-01-10 18:24:45 +00:00
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_SpectatorDisconnect(void)
|
|
|
|
{
|
|
|
|
Spray_RemoveAll(self);
|
2017-05-01 15:52:01 +00:00
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
ClientDisconnect
|
|
|
|
|
|
|
|
Run whenever a client quits
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_ClientDisconnect(void)
|
|
|
|
{
|
2016-12-01 17:50:48 +00:00
|
|
|
// We were part of the session
|
2018-12-05 14:05:56 +00:00
|
|
|
self.health = 0;
|
|
|
|
Rules_CountPlayers();
|
|
|
|
Rules_DeathCheck();
|
2019-02-20 13:30:16 +00:00
|
|
|
Spray_RemoveAll(self);
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_DecodeChangeParms(void)
|
2018-12-31 01:00:38 +00:00
|
|
|
{
|
|
|
|
g_landmarkpos[0] = parm1;
|
|
|
|
g_landmarkpos[1] = parm2;
|
|
|
|
g_landmarkpos[2] = parm3;
|
|
|
|
self.angles[0] = parm4;
|
|
|
|
self.angles[1] = parm5;
|
|
|
|
self.angles[2] = parm6;
|
|
|
|
}
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_SetChangeParms(void)
|
2018-12-31 01:00:38 +00:00
|
|
|
{
|
|
|
|
parm1 = g_landmarkpos[0];
|
|
|
|
parm2 = g_landmarkpos[1];
|
|
|
|
parm3 = g_landmarkpos[2];
|
|
|
|
parm4 = self.angles[0];
|
|
|
|
parm5 = self.angles[1];
|
|
|
|
parm6 = self.angles[2];
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
PutClientInServer
|
|
|
|
|
|
|
|
Puts a client into the world.
|
|
|
|
=================
|
|
|
|
*/
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_PutClientInServer(void)
|
|
|
|
{
|
2019-02-20 13:30:16 +00:00
|
|
|
if (cvar("sv_playerslots") == 1) {
|
2018-12-31 01:00:38 +00:00
|
|
|
entity spot;
|
|
|
|
self.SendEntity = Player_SendEntity;
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
Game_DecodeChangeParms();
|
2018-12-31 01:00:38 +00:00
|
|
|
|
|
|
|
if (startspot) {
|
|
|
|
self.origin = Landmark_GetSpot();
|
|
|
|
self.fixangle = TRUE;
|
|
|
|
} else {
|
2019-02-20 13:30:16 +00:00
|
|
|
spot = find(world, classname, "info_player_start");
|
2018-12-31 01:00:38 +00:00
|
|
|
self.origin = spot.origin;
|
|
|
|
self.angles = spot.angles;
|
|
|
|
self.fixangle = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.classname = "player";
|
|
|
|
self.health = self.max_health = 100;
|
2019-02-20 13:30:16 +00:00
|
|
|
forceinfokey(self, "*dead", "0");
|
2018-12-31 01:00:38 +00:00
|
|
|
self.takedamage = DAMAGE_YES;
|
|
|
|
self.solid = SOLID_SLIDEBOX;
|
|
|
|
self.movetype = MOVETYPE_WALK;
|
|
|
|
self.flags = FL_CLIENT;
|
|
|
|
self.vPain = Player_Pain;
|
|
|
|
self.vDeath = Player_Death;
|
|
|
|
self.iBleeds = TRUE;
|
|
|
|
self.fSlotGrenade = 0;
|
|
|
|
self.viewzoom = 1.0;
|
2019-02-20 13:30:16 +00:00
|
|
|
setmodel(self, "models/player/vip/vip.mdl");
|
|
|
|
setsize(self, VEC_HULL_MIN, VEC_HULL_MAX);
|
2018-12-31 01:00:38 +00:00
|
|
|
self.view_ofs = VEC_PLAYER_VIEWPOS;
|
|
|
|
self.velocity = '0 0 0';
|
|
|
|
self.frame = 1; // Idle frame
|
|
|
|
self.fBombProgress = 0;
|
|
|
|
self.team = TEAM_CT;
|
2019-02-20 13:30:16 +00:00
|
|
|
forceinfokey(self, "*spec", "0");
|
2018-12-31 01:00:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-05 22:25:47 +00:00
|
|
|
entity eTarget = world;
|
2016-12-07 00:05:06 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
Spawn_MakeSpectator();
|
2016-12-07 23:50:47 +00:00
|
|
|
Spawn_ObserverCam();
|
2017-03-04 20:08:59 +00:00
|
|
|
self.SendEntity = Player_SendEntity;
|
2019-03-21 19:14:51 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
// Because we don't want to reset these when we die
|
2019-02-20 13:30:16 +00:00
|
|
|
Money_AddMoney(self, autocvar_mp_startmoney);
|
2019-03-21 19:14:51 +00:00
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
if (cvar("mp_timelimit") > 0) {
|
|
|
|
if (autocvar_fcs_voxannounce == TRUE) {
|
|
|
|
float fTimeLeft = cvar("mp_timelimit") - (time / 60);
|
|
|
|
Vox_Singlecast(self, sprintf("we have %s minutes remaining", Vox_TimeToString(fTimeLeft)));
|
2017-11-20 02:03:30 +00:00
|
|
|
}
|
2017-11-18 21:21:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 09:09:01 +00:00
|
|
|
self.team = 0;
|
2019-02-20 13:30:16 +00:00
|
|
|
forceinfokey(self, "*team", "0");
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SV_RunClientCommand
|
|
|
|
|
|
|
|
Funtion that can interrupt client commands before physics are run
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_RunClientCommand(void)
|
|
|
|
{
|
2019-01-19 04:50:25 +00:00
|
|
|
/*if (clienttype(self) == CLIENTTYPE_BOT) {
|
2018-06-09 16:37:42 +00:00
|
|
|
((CBot)self).RunAI();
|
2019-01-19 04:50:25 +00:00
|
|
|
}*/
|
2018-06-09 16:37:42 +00:00
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
if (fGameState == GAME_FREEZE && self.health > 0) {
|
2016-12-01 17:50:48 +00:00
|
|
|
input_movevalues = '0 0 0';
|
2018-01-29 17:03:22 +00:00
|
|
|
//input_buttons = 0;
|
2016-12-01 17:50:48 +00:00
|
|
|
input_impulse = 0;
|
|
|
|
}
|
2018-06-09 16:37:42 +00:00
|
|
|
|
2018-12-05 14:05:56 +00:00
|
|
|
// The individual zones will just override this behavior
|
|
|
|
self.fInBombZone = FALSE;
|
|
|
|
self.fInBuyZone = FALSE;
|
|
|
|
self.fInHostageZone = FALSE;
|
2019-01-05 19:28:31 +00:00
|
|
|
self.fInEscapeZone = FALSE;
|
|
|
|
self.fInVIPZone = FALSE;
|
2018-12-05 14:05:56 +00:00
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
QPhysics_Run(self);
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_SetNewParms(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Client_SendEvent
|
|
|
|
|
|
|
|
Send a game event
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Client_SendEvent(entity eClient, float fEVType)
|
2019-01-21 02:00:14 +00:00
|
|
|
{
|
2016-12-01 17:50:48 +00:00
|
|
|
Weapon_UpdateCurrents();
|
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
|
|
|
WriteByte(MSG_MULTICAST, fEVType);
|
|
|
|
WriteByte(MSG_MULTICAST, num_for_edict(eClient));
|
2016-12-01 17:50:48 +00:00
|
|
|
msg_entity = eClient;
|
2019-02-20 13:30:16 +00:00
|
|
|
multicast(self.origin, MULTICAST_PVS);
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|