void race_SendRankings(float pos, float prevpos, float del, float msg);
void send_CSQC_teamnagger() {
- WriteByte(0, SVC_TEMPENTITY);
- WriteByte(0, TE_CSQC_TEAMNAGGER);
-}
-
-void send_CSQC_cr_maxbullets(entity e) {
- msg_entity = e;
- WriteByte(MSG_ONE, SVC_TEMPENTITY);
- WriteByte(MSG_ONE, TE_CSQC_CR_MAXBULLETS);
- WriteByte(MSG_ONE, autocvar_g_balance_campingrifle_magazinecapacity);
+ WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
+ WriteByte(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
}
void Announce(string snd) {
prio = 0;
// filter out spots for the wrong team
- if(teamcheck)
- if(spot.team != teamcheck)
- return '-1 0 0';
+ if(teamcheck >= 0)
+ if(spot.team != teamcheck)
+ return '-1 0 0';
if(race_spawns)
if(spot.target == "")
spotlist = spot;
/*
- if(teamcheck)
+ if(teamcheck >= 0)
if(spot.team != teamcheck)
error("invalid spawn added");
/*
entity e;
- if(teamcheck)
+ if(teamcheck >= 0)
for(e = spotlist; e; e = e.chain)
{
print("seen ", etos(e), "\n");
if (spot)
return spot;
- teamcheck = 0;
+ if(anypoint)
+ teamcheck = -1;
+ else if(have_team_spawns > 0)
+ {
+ if(have_team_spawns_forteam[self.team] == 0)
+ {
+ // we request a spawn for a team, and we have team
+ // spawns, but that team has no spawns?
+ if(have_team_spawns[0])
+ // try noteam spawns
+ teamcheck = 0;
+ else
+ // if not, any spawn has to do
+ teamcheck = -1;
+ }
+ else
+ teamcheck = self.team; // MUST be team
+ }
+ else if(have_team_spawns == 0 && have_team_spawns[0])
+ teamcheck = 0; // MUST be noteam
+ else
+ teamcheck = -1;
+ // if we get here, we either require team spawns but have none, or we require non-team spawns and have none; use any spawn then
- if(!anypoint && have_team_spawns > 0)
- teamcheck = self.team;
// get the list of players
playerlist = findchain(classname, "player");
print("spot mindistance: ", vtos(spot.spawnpoint_score), "\n");
entity e;
- if(teamcheck)
+ if(teamcheck >= 0)
for(e = firstspot; e; e = e.chain)
if(e.team != teamcheck)
error("invalid spawn found");
}
if(self.flagcarried)
- DropFlag(self.flagcarried, world, world);
+ ctf_Handle_Drop(self); // FIXCTF
if(self.ballcarried && g_nexball)
DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
self.frags = FRAGS_SPECTATOR;
}
-float RestrictSkin(float s)
-{
- if(!teams_matter)
- return s;
- if(s == 6)
- return 6;
- return mod(s, 3);
-}
-
void FixPlayermodel()
{
local string defaultmodel;
}
oldskin = self.skinindex;
- self.skinindex = RestrictSkin(stof(self.playerskin));
+ self.skinindex = stof(self.playerskin);
}
if(chmdl || oldskin != self.skinindex)
// reset fields the weapons may use
for (j = WEP_FIRST; j <= WEP_LAST; ++j)
+ {
weapon_action(j, WR_RESETPLAYER);
+ // all weapons must be fully loaded when we spawn
+ entity e;
+ e = get_weaponinfo(j);
+ if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
+ self.weapon_load[j] = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
+ }
+
oldself = self;
self = spot;
activator = oldself;
WriteCoord(MSG_ENTITY, self.ebouncefactor); // g_balance_grenadelauncher_bouncefactor
WriteCoord(MSG_ENTITY, self.ebouncestop); // g_balance_grenadelauncher_bouncestop
WriteByte(MSG_ENTITY, autocvar_g_balance_nex_secondary); // client has to know if it should zoom or not
- WriteByte(MSG_ENTITY, autocvar_g_balance_campingrifle_secondary); // client has to know if it should zoom or not
+ WriteByte(MSG_ENTITY, autocvar_g_balance_sniperrifle_secondary); // client has to know if it should zoom or not
WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not
+ WriteByte(MSG_ENTITY, autocvar_g_balance_minelayer_limit); // minelayer max mines
+ WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange);
return TRUE;
}
=============
*/
+.float clientkill_nexttime;
void ClientKill_Now_TeamChange()
{
if(self.killindicator_teamchange == -1)
self.team = -1;
JoinBestTeam( self, FALSE, FALSE );
}
+ else if(self.killindicator_teamchange == -2)
+ {
+ if(g_ca)
+ self.caplayer = 0;
+ if(blockSpectators)
+ sprint(self, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
+ PutObserverInServer();
+ }
else
SV_ChangeTeam(self.killindicator_teamchange - 1);
}
void ClientKill_Now()
{
+ remove(self.killindicator);
+ self.killindicator = world;
+
if(self.killindicator_teamchange)
ClientKill_Now_TeamChange();
// in any case:
Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
- if(self.killindicator)
- {
- dprint("Cleaned up after a leaked kill indicator.\n");
- remove(self.killindicator);
- self.killindicator = world;
- }
+ // now I am sure the player IS dead
}
void KillIndicator_Think()
{
ClientKill_Now(); // no oldself needed
return;
}
- else if(g_cts)
+ else if(g_cts && self.health == 1) // health == 1 means that it's silent
{
self.nextthink = time + 1;
self.cnt -= 1;
{
if(self.owner.killindicator_teamchange == -1)
centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
+ else if(self.owner.killindicator_teamchange == -2)
+ centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
else
centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
}
}
}
-void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
+void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
{
float killtime;
entity e;
killtime = autocvar_g_balance_kill_delay;
- if(g_race_qualifying)
+ if(g_race_qualifying || g_cts)
killtime = 0;
- self.killindicator_teamchange = targetteam;
-
- if(g_cts) // allow an instant kill in CTS
+ if(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill
{
- ClientKill_Now();
+ remove(self.killindicator);
+ self.killindicator = world;
+
+ ClientKill_Now(); // allow instant kill in this case
return;
}
- else if(!self.killindicator)
+ self.killindicator_teamchange = targetteam;
+
+ if(!self.killindicator)
{
+ if(self.modelindex && self.deadflag == DEAD_NO)
+ {
+ killtime = max(killtime, self.clientkill_nexttime - time);
+ self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
+ }
+
if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
{
ClientKill_Now();
self.killindicator.nextthink = time + (self.lip) * 0.05;
self.killindicator.cnt = ceil(killtime);
self.killindicator.count = bound(0, ceil(killtime), 10);
- sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
+ //sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
for(e = world; (e = find(e, classname, "body")) != world; )
{
}
if(self.killindicator)
{
- if(targetteam)
- self.killindicator.colormod = TeamColor(targetteam);
- else
+ if(targetteam == 0) // just die
self.killindicator.colormod = '0 0 0';
+ else if(targetteam == -1) // auto
+ self.killindicator.colormod = '0 1 0';
+ else if(targetteam == -2) // spectate
+ self.killindicator.colormod = '0.5 0.5 0.5';
+ else
+ self.killindicator.colormod = TeamColor(targetteam);
}
}
{
// do nothing
}
- else if(g_freezetag && self.freezetag_frozen == 1)
+ else if(self.freezetag_frozen)
{
// do nothing
}
ClientKill_TeamChange(0);
}
-void CTS_ClientKill (entity e) // silent version of ClientKill
+void CTS_ClientKill (entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
{
e.killindicator = spawn();
e.killindicator.owner = e;
e.killindicator.think = KillIndicator_Think;
e.killindicator.nextthink = time + (e.lip) * 0.05;
e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay);
+ e.killindicator.health = 1; // this is used to indicate that it should be silent
e.lip = 0;
}
else if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
send_CSQC_teamnagger();
- send_CSQC_cr_maxbullets(self);
-
CheatInitClient();
PlayerStats_AddPlayer(self);
Portal_ClearAll(self);
if(self.flagcarried)
- DropFlag(self.flagcarried, world, world);
+ ctf_Handle_Drop(self); // FIXCTF
if(self.ballcarried && g_nexball)
DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
self.modelflags &~= MF_ROCKET;
}
- self.effects &~= (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
+ self.effects &~= (EF_DIMLIGHT | EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
return;
self.ammo_nails = spectatee.ammo_nails;
self.ammo_rockets = spectatee.ammo_rockets;
self.ammo_fuel = spectatee.ammo_fuel;
+ self.clip_load = spectatee.clip_load;
+ self.clip_size = spectatee.clip_size;
self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
self.health = spectatee.health;
self.impulse = 0;
self.items = spectatee.items;
self.last_pickup = spectatee.last_pickup;
+ self.hit_time = spectatee.hit_time;
self.metertime = spectatee.metertime;
self.strength_finished = spectatee.strength_finished;
self.invincible_finished = spectatee.invincible_finished;
self.weapons = spectatee.weapons;
self.switchweapon = spectatee.switchweapon;
self.weapon = spectatee.weapon;
+ self.nex_charge = spectatee.nex_charge;
+ self.nex_chargepool_ammo = spectatee.nex_chargepool_ammo;
+ self.minelayer_mines = spectatee.minelayer_mines;
self.punchangle = spectatee.punchangle;
self.view_ofs = spectatee.view_ofs;
self.v_angle = spectatee.v_angle;
void LeaveSpectatorMode()
{
- if(isJoinAllowed()) {
+ if(nJoinAllowed(1)) {
if(!teams_matter || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) {
self.classname = "player";
* Determines whether the player is allowed to join. This depends on cvar
* g_maxplayers, if it isn't used this function always return TRUE, otherwise
* it checks whether the number of currently playing players exceeds g_maxplayers.
- * @return bool TRUE if the player is allowed to join, false otherwise
+ * @return int number of free slots for players, 0 if none
*/
-float isJoinAllowed() {
+float nJoinAllowed(float includeMe) {
if(self.team_forced < 0)
return FALSE; // forced spectators can never join
+ // TODO simplify this
+ local entity e;
+
+ local float totalClients;
+ FOR_EACH_CLIENT(e)
+ totalClients += 1;
+
if (!autocvar_g_maxplayers)
- return TRUE;
+ return maxclients - totalClients + includeMe;
- local entity e;
local float currentlyPlaying;
- FOR_EACH_REALPLAYER(e) {
- if(e.classname == "player")
- currentlyPlaying += 1;
- }
+ FOR_EACH_REALPLAYER(e)
+ currentlyPlaying += 1;
+
if(currentlyPlaying < autocvar_g_maxplayers)
- return TRUE;
+ return min(maxclients - totalClients + includeMe, autocvar_g_maxplayers - currentlyPlaying);
- return FALSE;
+ return 0;
}
/**
Called every frame for each client before the physics are run
=============
*/
-void() ctf_setstatus;
+//void() ctf_setstatus;
void() nexball_setstatus;
.float items_added;
void PlayerPreThink (void)
return; // the think tics
}
- if(self.teleport_time)
- if(time > self.teleport_time)
- {
- self.teleport_time = 0;
- self.effects = self.effects - (self.effects & EF_NODRAW);
- }
-
if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
UpdateSelectedPlayer();
if(frametime)
player_anim();
button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE);
- force_respawn = (g_lms || (g_ca) || autocvar_g_forced_respawn);
+ force_respawn = (g_lms || g_ca || g_cts || autocvar_g_forced_respawn);
if (self.deadflag == DEAD_DYING)
{
if(force_respawn)
if (g_minstagib)
minstagib_ammocheck();
- if(g_ctf)
- ctf_setstatus();
+ //if(g_ctf)
+ // ctf_setstatus();
if(g_nexball)
nexball_setstatus();
}
if(!zoomstate_set)
- SetZoomState(self.BUTTON_ZOOM || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_CAMPINGRIFLE && autocvar_g_balance_campingrifle_secondary == 0));
+ SetZoomState(self.BUTTON_ZOOM || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_SNIPERRIFLE && autocvar_g_balance_sniperrifle_secondary == 0));
float oldspectatee_status;
oldspectatee_status = self.spectatee_status;
}
target_voicescript_next(self);
+
+ // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
+ if(!self.weapon)
+ self.clip_load = self.clip_size = 0;
}
float isInvisibleString(string s)
playerdemo_write();
- if((g_cts || g_race) && self.cvar_cl_allow_uid2name == 1)
+ if((g_cts || g_race) && self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
{
if(!self.stored_netname)
self.stored_netname = strzone(uid2name(self.crypto_idfp));