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
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
entity eLastTSpawn;
|
|
|
|
entity eLastCTSpawn;
|
2017-01-10 18:24:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Spawn_FindSpawnPoint
|
|
|
|
|
|
|
|
Recursive function that gets the next spawnpoint
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-05 00:22:52 +00:00
|
|
|
entity Spawn_FindSpawnPoint( float fTeam ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
entity eSpot, eLastSpawn;
|
|
|
|
entity eThing;
|
|
|
|
int iCount;
|
|
|
|
string sClassname;
|
|
|
|
|
2016-12-05 00:22:52 +00:00
|
|
|
if ( fTeam == TEAM_T ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
sClassname = "info_player_deathmatch";
|
|
|
|
eSpot = eLastSpawn = eLastTSpawn;
|
2016-12-08 20:24:09 +00:00
|
|
|
} else if ( fTeam == TEAM_CT ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
sClassname = "info_player_start";
|
|
|
|
eSpot = eLastSpawn = eLastCTSpawn;
|
2016-12-08 20:24:09 +00:00
|
|
|
} else if ( fTeam == TEAM_VIP ) {
|
|
|
|
return find( world, classname, "info_vip_start" );
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
while ( 1 ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
eSpot = find(eSpot, classname, sClassname);
|
|
|
|
|
2017-11-16 22:53:02 +00:00
|
|
|
if (eSpot == eLastSpawn)
|
|
|
|
{ //fall back on lame cycling/spawnfragging
|
|
|
|
eLastSpawn = find(eLastSpawn, classname, sClassname);
|
|
|
|
if (!eLastSpawn)
|
|
|
|
eLastSpawn = find(eLastSpawn, classname, sClassname);
|
|
|
|
return eLastSpawn;
|
|
|
|
}
|
2016-12-04 14:04:30 +00:00
|
|
|
if (eSpot != world) {
|
|
|
|
iCount = 0;
|
|
|
|
eThing = findradius(eSpot.origin, 32);
|
|
|
|
while(eThing) {
|
|
|
|
if (eThing.classname == "player")
|
|
|
|
iCount++;
|
|
|
|
eThing = eThing.chain;
|
|
|
|
}
|
|
|
|
if (iCount == 0) {
|
|
|
|
eLastSpawn = eSpot;
|
|
|
|
return eSpot;
|
|
|
|
}
|
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
2016-12-04 14:04:30 +00:00
|
|
|
|
|
|
|
return eSpot;
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Spawn_ObserverCam
|
|
|
|
|
|
|
|
Look for the next spawnpoint
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-07 23:50:47 +00:00
|
|
|
void Spawn_ObserverCam( void ) {
|
2017-05-01 00:12:13 +00:00
|
|
|
entity eTarget;
|
2019-01-06 21:00:17 +00:00
|
|
|
|
2016-12-07 23:50:47 +00:00
|
|
|
// Go find a camera if we aren't dead
|
|
|
|
entity eCamera = find ( world, classname, "trigger_camera" );
|
2019-01-06 21:00:17 +00:00
|
|
|
|
2016-12-07 23:50:47 +00:00
|
|
|
if ( eCamera ) {
|
|
|
|
self.origin = eCamera.origin;
|
|
|
|
|
|
|
|
if ( eCamera.target ) {
|
2017-05-01 00:12:13 +00:00
|
|
|
eTarget = find( world, targetname, eCamera.target );
|
2016-12-07 23:50:47 +00:00
|
|
|
if ( eTarget ) {
|
|
|
|
self.angles = vectoangles( eTarget.origin - eCamera.origin );
|
|
|
|
self.angles_x *= -1;
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 18:24:45 +00:00
|
|
|
} else {
|
|
|
|
// Can't find a camera? Just do this lazy thing, CS seems to do the same
|
|
|
|
eCamera = find ( world, classname, "info_player_start" );
|
2017-05-01 00:12:13 +00:00
|
|
|
|
|
|
|
if ( eCamera ) {
|
|
|
|
self.origin = eCamera.origin;
|
|
|
|
|
|
|
|
if ( eCamera.target ) {
|
|
|
|
eTarget = find( world, targetname, eCamera.target );
|
|
|
|
if ( eTarget ) {
|
|
|
|
self.angles = vectoangles( eTarget.origin - eCamera.origin );
|
|
|
|
self.angles_x *= -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-07 23:50:47 +00:00
|
|
|
}
|
2019-01-06 21:00:17 +00:00
|
|
|
|
2016-12-07 23:50:47 +00:00
|
|
|
self.fixangle = TRUE;
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Spawn_RespawnClient
|
|
|
|
|
|
|
|
Called whenever a player just needs his basic properties to be reset
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-05 00:22:52 +00:00
|
|
|
void Spawn_RespawnClient( float fTeam ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
entity eSpawn;
|
2018-12-05 16:02:49 +00:00
|
|
|
forceinfokey( self, "*spec", "0" );
|
2016-12-04 14:04:30 +00:00
|
|
|
eSpawn = Spawn_FindSpawnPoint( self.team );
|
2016-12-01 17:50:48 +00:00
|
|
|
|
|
|
|
self.classname = "player";
|
|
|
|
self.health = self.max_health = 100;
|
2016-12-09 23:03:13 +00:00
|
|
|
forceinfokey( self, "*dead", "0" );
|
2018-12-05 14:05:56 +00:00
|
|
|
Rules_CountPlayers();
|
2019-01-06 21:00:17 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
self.takedamage = DAMAGE_YES;
|
2016-12-01 17:50:48 +00:00
|
|
|
self.solid = SOLID_SLIDEBOX;
|
|
|
|
self.movetype = MOVETYPE_WALK;
|
|
|
|
self.flags = FL_CLIENT;
|
2016-12-04 14:04:30 +00:00
|
|
|
self.vPain = Player_Pain;
|
|
|
|
self.vDeath = Player_Death;
|
2017-01-03 18:31:24 +00:00
|
|
|
self.iBleeds = TRUE;
|
2019-01-06 21:00:17 +00:00
|
|
|
self.fSlotC4Bomb = 0; // Clear the C4
|
2018-12-06 04:34:40 +00:00
|
|
|
self.viewzoom = 1.0; // Clear scopes
|
2016-12-01 17:50:48 +00:00
|
|
|
|
|
|
|
self.origin = eSpawn.origin;
|
|
|
|
self.angles = eSpawn.angles;
|
|
|
|
self.fixangle = TRUE;
|
|
|
|
|
|
|
|
// Get the player-model from Defs.h's list
|
2016-12-08 20:24:09 +00:00
|
|
|
if ( self.team != TEAM_VIP ) {
|
|
|
|
setmodel( self, sCSPlayers[ self.fCharModel ] );
|
|
|
|
} else {
|
|
|
|
setmodel( self, "models/player/vip/vip.mdl" );
|
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
setsize( self, VEC_HULL_MIN, VEC_HULL_MAX );
|
|
|
|
|
2016-12-05 00:22:52 +00:00
|
|
|
self.view_ofs = VEC_PLAYER_VIEWPOS;
|
2016-12-01 17:50:48 +00:00
|
|
|
self.velocity = '0 0 0';
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-01 17:50:48 +00:00
|
|
|
self.frame = 1; // Idle frame
|
2016-12-05 18:06:24 +00:00
|
|
|
self.fBombProgress = 0;
|
2018-12-05 16:02:49 +00:00
|
|
|
|
|
|
|
Ammo_AutoFill(self.fSlotPrimary);
|
|
|
|
Ammo_AutoFill(self.fSlotSecondary);
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Spawn_CreateClient
|
|
|
|
|
|
|
|
Called whenever a player becomes a completely new type of player
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-05 00:22:52 +00:00
|
|
|
void Spawn_CreateClient( float fCharModel ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
// What team are we on - 0= Spectator, < 5 Terrorists, CT rest
|
2016-12-05 00:22:52 +00:00
|
|
|
if( fCharModel == 0 ) {
|
2016-12-04 14:04:30 +00:00
|
|
|
PutClientInServer();
|
2016-12-07 23:50:47 +00:00
|
|
|
Spawn_ObserverCam();
|
2016-12-04 14:04:30 +00:00
|
|
|
return;
|
2016-12-05 00:22:52 +00:00
|
|
|
} else if( fCharModel < 5 ) {
|
2016-12-09 23:03:13 +00:00
|
|
|
forceinfokey( self, "*team", "0" );
|
2016-12-04 14:04:30 +00:00
|
|
|
self.team = TEAM_T;
|
|
|
|
|
2016-12-07 00:05:06 +00:00
|
|
|
Weapon_AddItem( WEAPON_KNIFE );
|
2017-12-01 19:02:58 +00:00
|
|
|
if ( autocvar_fcs_knifeonly == FALSE ) {
|
|
|
|
Weapon_AddItem( WEAPON_GLOCK18 );
|
|
|
|
Weapon_GiveAmmo( WEAPON_GLOCK18, 40 );
|
|
|
|
Weapon_Draw( WEAPON_GLOCK18 );
|
|
|
|
} else {
|
|
|
|
Weapon_Draw( WEAPON_KNIFE );
|
|
|
|
}
|
2016-12-04 14:04:30 +00:00
|
|
|
} else {
|
|
|
|
self.team = TEAM_CT;
|
|
|
|
|
2016-12-07 00:05:06 +00:00
|
|
|
Weapon_AddItem( WEAPON_KNIFE );
|
2017-12-01 19:02:58 +00:00
|
|
|
if ( autocvar_fcs_knifeonly == FALSE ) {
|
|
|
|
Weapon_AddItem( WEAPON_USP45 );
|
|
|
|
Weapon_GiveAmmo( WEAPON_USP45, 24 );
|
|
|
|
Weapon_Draw( WEAPON_USP45 );
|
|
|
|
} else {
|
|
|
|
Weapon_Draw( WEAPON_KNIFE );
|
|
|
|
}
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
if( self.iInGame == FALSE ) {
|
|
|
|
self.iInGame = TRUE;
|
|
|
|
}
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-09 23:03:13 +00:00
|
|
|
forceinfokey( self, "*team", ftos( self.team ) );
|
2016-12-04 14:04:30 +00:00
|
|
|
Spawn_RespawnClient( self.team );
|
2016-12-01 17:50:48 +00:00
|
|
|
self.fAttackFinished = time + 1;
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Spawn_MakeSpectator
|
|
|
|
|
|
|
|
Called on connect and whenever a player dies
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-04 14:04:30 +00:00
|
|
|
void Spawn_MakeSpectator( void ) {
|
2016-12-07 00:05:06 +00:00
|
|
|
self.classname = "spectator";
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
self.health = 0;
|
2017-11-18 06:30:20 +00:00
|
|
|
self.armor = 0;
|
2016-12-04 14:04:30 +00:00
|
|
|
self.takedamage = DAMAGE_NO;
|
|
|
|
self.solid = SOLID_NOT;
|
|
|
|
self.movetype = MOVETYPE_NOCLIP;
|
|
|
|
self.flags = FL_CLIENT;
|
|
|
|
self.weapon = 0;
|
2017-07-01 00:39:15 +00:00
|
|
|
self.viewzoom = 1.0f;
|
2016-12-04 14:04:30 +00:00
|
|
|
|
|
|
|
self.model = 0;
|
|
|
|
setsize (self, '-16 -16 -16', '16 16 16');
|
|
|
|
|
|
|
|
self.view_ofs = self.velocity = '0 0 0';
|
2017-06-24 12:36:36 +00:00
|
|
|
forceinfokey( self, "*spec", "2" ); // Make sure we are known as a spectator
|
2016-12-09 23:03:13 +00:00
|
|
|
|
2018-12-05 16:02:49 +00:00
|
|
|
Ammo_Clear();
|
|
|
|
|
2016-12-05 00:22:52 +00:00
|
|
|
// Clear the inventory
|
2017-11-18 06:30:20 +00:00
|
|
|
self.fSlotMelee = self.fSlotPrimary = self.fSlotSecondary = self.fSlotGrenade = self.iEquipment = 0;
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CSEv_GamePlayerSpawn_f
|
|
|
|
|
|
|
|
Event Handling, called by the Client codebase via 'sendevent'
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-05 00:22:52 +00:00
|
|
|
void CSEv_GamePlayerSpawn_f( float fChar ) {
|
2016-12-05 18:06:24 +00:00
|
|
|
|
2016-12-09 23:03:13 +00:00
|
|
|
if ( self.team == TEAM_VIP ) {
|
|
|
|
centerprint( self, "You are the VIP!\nYou cannot switch roles now.\n" );
|
|
|
|
self.fAttackFinished = time + 1.0;
|
|
|
|
return;
|
|
|
|
}
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-17 12:55:18 +00:00
|
|
|
// Hey, we are alive and are trying to switch teams, so subtract us from the Alive_Team counter.
|
|
|
|
if ( self.health > 0 ) {
|
2018-12-05 14:05:56 +00:00
|
|
|
self.health = 0;
|
|
|
|
Rules_CountPlayers();
|
|
|
|
Rules_DeathCheck();
|
2018-12-05 16:02:49 +00:00
|
|
|
Player_Death(0);
|
2016-12-17 12:55:18 +00:00
|
|
|
}
|
2018-12-05 16:02:49 +00:00
|
|
|
|
|
|
|
Ammo_Clear();
|
|
|
|
|
2016-12-17 12:55:18 +00:00
|
|
|
// Spawn the players immediately when its in the freeze state
|
2016-12-05 18:06:24 +00:00
|
|
|
switch ( fGameState ) {
|
2016-12-17 12:55:18 +00:00
|
|
|
case GAME_FREEZE:
|
|
|
|
self.fCharModel = fChar;
|
|
|
|
Spawn_CreateClient( fChar );
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2017-11-18 06:30:20 +00:00
|
|
|
if ( ( self.team == TEAM_T ) && ( iAlivePlayers_T == 1 ) ) {
|
|
|
|
if ( iBombZones > 0 ) {
|
|
|
|
Rules_MakeBomber();
|
|
|
|
}
|
|
|
|
} else if ( ( self.team == TEAM_CT ) && ( iAlivePlayers_CT == 1 ) ) {
|
|
|
|
if ( iVIPZones > 0 ) {
|
|
|
|
Rules_MakeVIP();
|
|
|
|
}
|
|
|
|
}
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-17 12:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-11-11 10:34:08 +00:00
|
|
|
if ( fChar == 0 ) {
|
2016-12-05 18:06:24 +00:00
|
|
|
PutClientInServer();
|
|
|
|
return;
|
|
|
|
} else if( fChar < 5 ) {
|
|
|
|
self.team = TEAM_T;
|
|
|
|
} else {
|
|
|
|
self.team = TEAM_CT;
|
|
|
|
}
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2016-12-07 00:05:06 +00:00
|
|
|
Spawn_MakeSpectator();
|
2016-12-05 18:06:24 +00:00
|
|
|
self.classname = "player";
|
|
|
|
self.fCharModel = fChar;
|
|
|
|
self.health = 0;
|
2016-12-09 23:03:13 +00:00
|
|
|
forceinfokey( self, "*dead", "1" );
|
|
|
|
forceinfokey( self, "*team", ftos( self.team ) );
|
2016-12-05 18:06:24 +00:00
|
|
|
break;
|
2016-12-05 00:22:52 +00:00
|
|
|
}
|
2018-12-05 14:05:56 +00:00
|
|
|
|
2016-12-10 14:25:16 +00:00
|
|
|
self.frags = 0;
|
2016-12-09 23:03:13 +00:00
|
|
|
self.fDeaths = 0;
|
|
|
|
forceinfokey( self, "*deaths", "0" );
|
2018-12-05 16:02:49 +00:00
|
|
|
|
2017-11-18 06:30:20 +00:00
|
|
|
// Split up for readability and expandability?
|
|
|
|
if ( ( self.team == TEAM_T ) && ( iAlivePlayers_T == 0 ) ) {
|
|
|
|
Rules_RoundOver( FALSE, 0, FALSE );
|
|
|
|
} else if ( ( self.team == TEAM_CT ) && ( iAlivePlayers_CT == 0 ) ) {
|
|
|
|
Rules_RoundOver( FALSE, 0, FALSE );
|
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
info_player_start
|
|
|
|
|
|
|
|
Counter-Terrorist Spawnpoints
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-01 17:50:48 +00:00
|
|
|
void info_player_start( void ) {
|
2017-12-01 19:02:58 +00:00
|
|
|
if ( autocvar_fcs_swapteams == TRUE ) {
|
|
|
|
self.classname = "info_player_deathmatch";
|
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
info_player_deathmatch
|
|
|
|
|
|
|
|
Terrorist Spawnpoints
|
|
|
|
=================
|
|
|
|
*/
|
2016-12-01 17:50:48 +00:00
|
|
|
void info_player_deathmatch( void ) {
|
2017-12-01 19:02:58 +00:00
|
|
|
if ( autocvar_fcs_swapteams == TRUE ) {
|
|
|
|
self.classname = "info_player_start";
|
|
|
|
}
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-09 04:58:28 +00:00
|
|
|
/* Counter-Strike: Source compat */
|
|
|
|
void info_player_counterterrorist(void)
|
|
|
|
{
|
|
|
|
setorigin(self, self.origin + [0,0,32]);
|
|
|
|
self.classname = "info_player_start";
|
|
|
|
info_player_start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void info_player_terrorist(void)
|
|
|
|
{
|
|
|
|
setorigin(self, self.origin + [0,0,32]);
|
|
|
|
self.classname = "info_player_deathmatch";
|
|
|
|
info_player_deathmatch();
|
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
info_vip_start
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void info_vip_start( void ) {
|
|
|
|
}
|