2016-12-01 17:50:48 +00:00
|
|
|
/*
|
2018-06-14 10:05:23 +00:00
|
|
|
Copyright 2016-2018 Marco "eukara" Hladik
|
|
|
|
|
|
|
|
MIT LICENSE
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2018-06-14 10:05:23 +00:00
|
|
|
Permission is hereby granted, free of charge, to any person
|
|
|
|
obtaining a copy of this software and associated documentation
|
|
|
|
files (the "Software"), to deal in the Software without
|
|
|
|
restriction, including without limitation the rights to use,
|
|
|
|
copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
sell copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2018-06-14 10:05:23 +00:00
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2018-06-14 10:05:23 +00:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
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
|
|
|
=================
|
|
|
|
*/
|
2017-05-01 15:52:01 +00:00
|
|
|
void SpectatorThink( void ) {
|
|
|
|
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
|
|
|
=================
|
|
|
|
*/
|
2017-11-11 07:25:59 +00:00
|
|
|
void ClientKill( void ) {
|
2017-11-11 21:46:04 +00:00
|
|
|
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
|
|
|
=================
|
|
|
|
*/
|
2017-05-01 15:52:01 +00:00
|
|
|
void 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
|
|
|
=================
|
|
|
|
*/
|
2017-05-01 15:52:01 +00:00
|
|
|
void SpectatorConnect( void ) {
|
|
|
|
//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
|
|
|
=================
|
|
|
|
*/
|
2017-05-01 15:52:01 +00:00
|
|
|
void SpectatorDisconnect( void ) {
|
2017-11-22 21:34:09 +00:00
|
|
|
Effect_RemoveSpray( 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
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-01 17:50:48 +00:00
|
|
|
void ClientDisconnect( void ) {
|
|
|
|
// We were part of the session
|
2016-12-04 14:04:30 +00:00
|
|
|
if( self.iInGame == TRUE ) {
|
|
|
|
if ( self.team == TEAM_T ) {
|
2016-12-05 18:06:24 +00:00
|
|
|
if ( self.health > 0 ) {
|
|
|
|
iAlivePlayers_T--;
|
|
|
|
}
|
2016-12-04 14:04:30 +00:00
|
|
|
} else if ( self.team == TEAM_CT ) {
|
2016-12-05 18:06:24 +00:00
|
|
|
if ( self.health > 0 ) {
|
|
|
|
iAlivePlayers_CT--;
|
|
|
|
}
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
2017-11-22 21:34:09 +00:00
|
|
|
|
|
|
|
Effect_RemoveSpray( self );
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
PutClientInServer
|
|
|
|
|
|
|
|
Puts a client into the world.
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-01 17:50:48 +00:00
|
|
|
void PutClientInServer( void ) {
|
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;
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
// Because we don't want to reset these when we die
|
2016-12-18 09:09:01 +00:00
|
|
|
Money_AddMoney( self, autocvar_mp_startmoney );
|
|
|
|
|
2017-11-20 02:03:30 +00:00
|
|
|
if ( cvar( "mp_timelimit" ) > 0 ) {
|
|
|
|
if ( autocvar_sv_voxannounce == TRUE ) {
|
|
|
|
float fTimeLeft = cvar( "mp_timelimit" ) - ( time / 60 );
|
|
|
|
Vox_Singlecast( self, sprintf( "we have %s minutes remaining", Vox_TimeToString( fTimeLeft ) ) );
|
|
|
|
}
|
2017-11-18 21:21:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 09:09:01 +00:00
|
|
|
self.team = 0;
|
2016-12-09 23:03:13 +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
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-01 17:50:48 +00:00
|
|
|
void SV_RunClientCommand( void ) {
|
2016-12-03 15:17:55 +00:00
|
|
|
// The individual zones will just override this behavior
|
2016-12-01 17:50:48 +00:00
|
|
|
self.fInBombZone = FALSE;
|
|
|
|
self.fInBuyZone = FALSE;
|
|
|
|
self.fInHostageZone = FALSE;
|
|
|
|
|
2018-06-09 16:37:42 +00:00
|
|
|
if (clienttype(self) == CLIENTTYPE_BOT) {
|
|
|
|
((CBot)self).RunAI();
|
|
|
|
}
|
|
|
|
|
2017-04-19 17:19:02 +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
|
|
|
|
|
|
|
Input_Handle();
|
2018-09-20 20:38:01 +00:00
|
|
|
QPhysics_Run( self );
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Client_SendEvent
|
|
|
|
|
|
|
|
Send a game event
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-01 17:50:48 +00:00
|
|
|
void Client_SendEvent( entity eClient, float fEVType ) {
|
|
|
|
Weapon_UpdateCurrents();
|
|
|
|
|
|
|
|
WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET );
|
|
|
|
WriteByte( MSG_MULTICAST, fEVType );
|
2017-06-24 12:36:36 +00:00
|
|
|
WriteByte( MSG_MULTICAST, num_for_edict( eClient ) );
|
2016-12-01 17:50:48 +00:00
|
|
|
msg_entity = eClient;
|
2017-06-24 12:36:36 +00:00
|
|
|
multicast( self.origin, MULTICAST_PVS );
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
2016-12-07 00:05:06 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Client_TriggerCamera
|
|
|
|
|
|
|
|
Switches the player camera to a different position for a specific time
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-07 00:05:06 +00:00
|
|
|
void Client_TriggerCamera( entity eTarget, vector vPos, vector vEndPos, float fResetTime ) {
|
|
|
|
WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET );
|
|
|
|
WriteByte( MSG_MULTICAST, EV_CAMERATRIGGER );
|
|
|
|
WriteCoord( MSG_MULTICAST, vPos_x );
|
|
|
|
WriteCoord( MSG_MULTICAST, vPos_y );
|
|
|
|
WriteCoord( MSG_MULTICAST, vPos_z );
|
|
|
|
WriteCoord( MSG_MULTICAST, vEndPos_x );
|
|
|
|
WriteCoord( MSG_MULTICAST, vEndPos_y );
|
|
|
|
WriteCoord( MSG_MULTICAST, vEndPos_z );
|
|
|
|
WriteFloat( MSG_MULTICAST, fResetTime );
|
|
|
|
msg_entity = eTarget;
|
2017-04-19 21:06:41 +00:00
|
|
|
multicast( '0 0 0', MULTICAST_ONE );
|
2016-12-07 00:05:06 +00:00
|
|
|
}
|