}
void Announce(string snd) {
- WriteByte(MSG_ALL, SVC_TEMPENTITY);
- WriteByte(MSG_ALL, TE_CSQC_ANNOUNCE);
- WriteString(MSG_ALL, snd);
+ WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
+ WriteByte(MSG_BROADCAST, TE_CSQC_ANNOUNCE);
+ WriteString(MSG_BROADCAST, snd);
}
void AnnounceTo(entity e, string snd) {
}
}
-
-.vector spawnpoint_score;
.string netname_previous;
-void spawnfunc_info_player_survivor (void)
-{
- spawnfunc_info_player_deathmatch();
-}
-
-void spawnfunc_info_player_start (void)
-{
- spawnfunc_info_player_deathmatch();
-}
-
-void spawnfunc_info_player_deathmatch (void)
-{
- self.classname = "info_player_deathmatch";
- relocate_spawnpoint();
-}
-
-void spawnpoint_use()
-{
- if(teamplay)
- if(have_team_spawns > 0)
- {
- self.team = activator.team;
- some_spawn_has_been_used = 1;
- }
-}
-
-// Returns:
-// _x: prio (-1 if unusable)
-// _y: weight
-vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{
- float shortest, thisdist;
- float prio;
- entity player;
-
- prio = 0;
-
- // filter out spots for the wrong team
- if(teamcheck >= 0)
- if(spot.team != teamcheck)
- return '-1 0 0';
-
- if(race_spawns)
- if(spot.target == "")
- return '-1 0 0';
-
- if(clienttype(self) == CLIENTTYPE_REAL)
- {
- if(spot.restriction == 1)
- return '-1 0 0';
- }
- else
- {
- if(spot.restriction == 2)
- return '-1 0 0';
- }
-
- shortest = vlen(world.maxs - world.mins);
- FOR_EACH_PLAYER(player) if (player != self)
- {
- thisdist = vlen(player.origin - spot.origin);
- if (thisdist < shortest)
- shortest = thisdist;
- }
- if(shortest > mindist)
- prio += SPAWN_PRIO_GOOD_DISTANCE;
-
- spawn_score = prio * '1 0 0' + shortest * '0 1 0';
- spawn_spot = spot;
-
- // filter out spots for assault
- if(spot.target != "") {
- entity ent;
- float found;
-
- found = 0;
- for(ent = world; (ent = find(ent, targetname, spot.target)); )
- {
- ++found;
- if(ent.spawn_evalfunc)
- {
- entity oldself = self;
- self = ent;
- spawn_score = ent.spawn_evalfunc(oldself, spot, spawn_score);
- self = oldself;
- if(spawn_score_x < 0)
- return spawn_score;
- }
- }
-
- if(!found)
- {
- dprint("WARNING: spawnpoint at ", vtos(spot.origin), " could not find its target ", spot.target, "\n");
- return '-1 0 0';
- }
- }
-
- MUTATOR_CALLHOOK(Spawn_Score);
- return spawn_score;
-}
-
-void Spawn_ScoreAll(entity firstspot, float mindist, float teamcheck)
-{
- entity spot;
- for(spot = firstspot; spot; spot = spot.chain)
- spot.spawnpoint_score = Spawn_Score(spot, mindist, teamcheck);
-}
-
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck)
-{
- entity spot, spotlist, spotlistend;
-
- spotlist = world;
- spotlistend = world;
-
- Spawn_ScoreAll(firstspot, mindist, teamcheck);
-
- for(spot = firstspot; spot; spot = spot.chain)
- {
- if(spot.spawnpoint_score_x >= 0) // spawning allowed here
- {
- if(spotlistend)
- spotlistend.chain = spot;
- spotlistend = spot;
- if(!spotlist)
- spotlist = spot;
- }
- }
- if(spotlistend)
- spotlistend.chain = world;
-
- return spotlist;
-}
-
-entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
-{
- // weight of a point: bound(lower, mindisttoplayer, upper)^exponent
- // multiplied by spot.cnt (useful if you distribute many spawnpoints in a small area)
- entity spot;
-
- RandomSelection_Init();
- for(spot = firstspot; spot; spot = spot.chain)
- RandomSelection_Add(spot, 0, string_null, pow(bound(lower, spot.spawnpoint_score_y, upper), exponent) * spot.cnt, (spot.spawnpoint_score_y >= lower) * 0.5 + spot.spawnpoint_score_x);
-
- return RandomSelection_chosen_ent;
-}
-
-/*
-=============
-SelectSpawnPoint
-
-Finds a point to respawn
-=============
-*/
-entity SelectSpawnPoint (float anypoint)
-{
- float teamcheck;
- entity spot, firstspot;
-
- spot = find (world, classname, "testplayerstart");
- if (spot)
- return spot;
-
- if(anypoint || autocvar_g_spawn_useallspawns)
- 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_forteam[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_forteam[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
-
-
- // get the entire list of spots
- firstspot = findchain(classname, "info_player_deathmatch");
- // filter out the bad ones
- // (note this returns the original list if none survived)
- if(anypoint)
- {
- spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
- }
- else
- {
- float mindist;
- if (arena_roundbased && !g_ca)
- mindist = 800;
- else
- mindist = 100;
- firstspot = Spawn_FilterOutBadSpots(firstspot, mindist, teamcheck);
-
- // there is 50/50 chance of choosing a random spot or the furthest spot
- // (this means that roughly every other spawn will be furthest, so you
- // usually won't get fragged at spawn twice in a row)
- if (random() > autocvar_g_spawn_furthest)
- spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
- else
- spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
- }
-
- if (!spot)
- {
- if(autocvar_spawn_debug)
- GotoNextMap(0);
- else
- {
- if(some_spawn_has_been_used)
- return world; // team can't spawn any more, because of actions of other team
- else
- error("Cannot find a spawn point - please fix the map!");
- }
- }
-
- return spot;
-}
-
/*
=============
CheckPlayerModel
minstagib_stop_countdown(self);
Portal_ClearAll(self);
-
+
if(self.alivetime)
{
- PlayerStats_Event(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
+ if(!inWarmupStage)
+ PlayerStats_Event(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
self.alivetime = 0;
}
if(self.vehicle)
- vehicles_exit(VHEF_RELESE);
-
- if(self.flagcarried)
- DropFlag(self.flagcarried, world, world);
+ vehicles_exit(VHEF_RELESE);
WaypointSprite_PlayerDead();
self.classname = "observer";
self.iscreature = FALSE;
+ self.teleportable = TELEPORT_SIMPLE;
self.damagedbycontents = FALSE;
self.health = -666;
self.takedamage = DAMAGE_NO;
self.invincible_finished = 0;
self.superweapons_finished = 0;
self.pushltime = 0;
- self.think = SUB_Null;
+ self.istypefrag = 0;
+ self.think = func_null;
self.nextthink = 0;
self.hook_time = 0;
self.runes = 0;
{
if(self.version_mismatch)
{
+ self.frags = FRAGS_SPECTATOR;
Spawnqueue_Unmark(self);
Spawnqueue_Remove(self);
}
else
{
+ self.frags = FRAGS_LMS_LOSER;
Spawnqueue_Insert(self);
}
}
else
self.frags = FRAGS_SPECTATOR;
}
+ else if((g_race && g_race_qualifying) || g_cts)
+ {
+ if(PlayerScore_Add(self, SP_RACE_FASTEST, 0))
+ self.frags = FRAGS_LMS_LOSER;
+ else
+ self.frags = FRAGS_SPECTATOR;
+ }
else
self.frags = FRAGS_SPECTATOR;
}
Called when a client spawns in the server
=============
*/
-//void() ctf_playerchanged;
void PutClientInServer (void)
{
self.classname = "player";
self.wasplayer = TRUE;
self.iscreature = TRUE;
+ self.teleportable = TELEPORT_NORMAL;
self.damagedbycontents = TRUE;
self.movetype = MOVETYPE_WALK;
self.solid = SOLID_SLIDEBOX;
self.invincible_finished = 0;
self.pushltime = 0;
// players have no think function
- self.think = SUB_Null;
+ self.think = func_null;
self.nextthink = 0;
self.hook_time = 0;
self.dmg_team = 0;
self.weaponname = "";
self.switchingweapon = 0;
- if(!self.alivetime)
- self.alivetime = time;
+ if(!inWarmupStage)
+ if(!self.alivetime)
+ self.alivetime = time;
antilag_clear(self);
} else if(self.classname == "observer") {
PutObserverInServer ();
}
-
- //if(g_ctf)
- // ctf_playerchanged();
}
.float ebouncefactor, ebouncestop; // electro's values
return;
}
- if (self.owner.alpha < 0)
+ if (self.owner.alpha < 0 && !self.owner.vehicle)
{
self.owner.killindicator = world;
remove(self);
Called when a client connects to the server
=============
*/
-//void ctf_clientconnect();
string ColoredTeamName(float t);
void DecodeLevelParms (void);
//void dom_player_join_team(entity pl);
DecodeLevelParms();
#ifdef WATERMARK
- sprint(self, strcat("^4SVQC Build information: ^1", WATERMARK(), "\n"));
+ sprint(self, strcat("^4SVQC Build information: ^1", WATERMARK, "\n"));
#endif
self.classname = "player_joining";
race_PreSpawnObserver();
- //if(g_domination)
- // dom_player_join_team(self);
-
// identify the right forced team
if(autocvar_g_campaign)
{
if(g_arena)
Spawnqueue_Insert(self);
}
- /*else if(g_ctf)
- {
- ctf_clientconnect();
- }*/
attach_entcs();
if(!sv_foginterval && world.fog != "")
stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
- SoundEntity_Attach(self);
-
if(autocvar_g_hitplots || strstrofs(strcat(" ", autocvar_g_hitplots_individuals, " "), strcat(" ", self.netaddress, " "), 0) >= 0)
{
self.hitplotfh = fopen(strcat("hits-", matchid, "-", self.netaddress, "-", ftos(self.playerid), ".plot"), FILE_WRITE);
else if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
send_CSQC_teamnagger();
- if (g_domination)
- set_dom_state(self);
-
CheatInitClient();
if(!autocvar_g_campaign)
return;
sv_notice_join();
+
+ MUTATOR_CALLHOOK(ClientConnect);
}
/*
=============
bprint ("^4",self.netname);
bprint ("^4 disconnected\n");
- SoundEntity_Detach(self);
-
DropAllRunes(self);
MUTATOR_CALLHOOK(ClientDisconnect);
Portal_ClearAll(self);
RemoveGrapplingHook(self);
- if(self.flagcarried)
- DropFlag(self.flagcarried, world, world);
// Here, everything has been done that requires this player to be a client.
olditems = self.items;
if((self.items & IT_USING_JETPACK) && !self.deadflag)
- {
- SoundEntity_StartSound(self, CH_TRIGGER_SINGLE, "misc/jetpack_fly.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
self.modelflags |= MF_ROCKET;
- }
else
- {
- SoundEntity_StopSound(self, CH_TRIGGER_SINGLE);
self.modelflags &~= MF_ROCKET;
- }
self.effects &~= (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
self.dmg_inflictor = spectatee.dmg_inflictor;
self.v_angle = spectatee.v_angle;
self.angles = spectatee.v_angle;
+ self.stat_respawn_time = spectatee.stat_respawn_time;
if(!self.BUTTON_USE)
self.fixangle = TRUE;
setorigin(self, spectatee.origin);
return other;
}
-float SpectateNext() {
- other = find(self.enemy, classname, "player");
+float SpectateNext(entity _prefer) {
+
+ if(_prefer)
+ other = _prefer;
+ else
+ other = find(self.enemy, classname, "player");
+
if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) {
// CA and ca players when spectating enemies is forbidden
other = CA_SpectateNext(other);
self.flags |= FL_SPAWNING;
} else if(self.BUTTON_ATCK && !self.version_mismatch) {
self.flags &~= FL_JUMPRELEASED;
- if(SpectateNext() == 1) {
+ if(SpectateNext(world) == 1) {
self.classname = "spectator";
}
} else {
self.flags |= FL_SPAWNING;
} else if(self.BUTTON_ATCK) {
self.flags &~= FL_JUMPRELEASED;
- if(SpectateNext() == 1) {
+ if(SpectateNext(world) == 1) {
self.classname = "spectator";
} else {
self.classname = "observer";
self.flags |= FL_CLIENT | FL_NOTARGET;
}
-float ctf_usekey();
void PlayerUseKey()
{
if(self.classname != "player")
}
// a use key was pressed; call handlers
- if(ctf_usekey())
- return;
-
MUTATOR_CALLHOOK(PlayerUseKey);
}
=============
*/
.float usekeypressed;
-void() ctf_setstatus;
void() nexball_setstatus;
.float items_added;
void PlayerPreThink (void)
self.stat_allow_oldnexbeam = autocvar_g_allow_oldnexbeam;
self.stat_leadlimit = autocvar_leadlimit;
+ if(g_arena || (g_ca && !allowed_to_spawn))
+ self.stat_respawn_time = 0;
+ else
+ self.stat_respawn_time = self.respawn_time;
+
if(frametime)
{
// physics frames: update anticheat stuff
}
ShowRespawnCountdown();
}
+
+ // if respawning, invert stat_respawn_time to indicate this, the client translates it
+ if(self.deadflag == DEAD_RESPAWNING && self.stat_respawn_time > 0)
+ self.stat_respawn_time *= -1;
+
return;
}
// FIXME from now on self.deadflag is always 0 (and self.health is never < 1)
self.prevorigin = self.origin;
- if (((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss) && self.animstate_startframe != self.anim_melee_x) // prevent crouching if using melee attack
+ if (!self.vehicle)
+ if (((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss) && self.animstate_startframe != self.anim_melee_x && !self.freezetag_frozen) // prevent crouching if using melee attack
{
if (!self.crouch)
{
if(frametime)
player_anim();
- if(g_ctf)
- ctf_setstatus();
-
if(g_nexball)
nexball_setstatus();
if (intermission_running)
return; // intermission or finale
GetPressedKeys();
- } else if (self.classname == "observer") {
- //do nothing
- } else if (self.classname == "spectator") {
- //do nothing
}
#ifdef TETRIS
if((g_cts || g_race) && self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
{
- if(!self.stored_netname)
+ if not(self.stored_netname)
self.stored_netname = strzone(uid2name(self.crypto_idfp));
if(self.stored_netname != self.netname)
{