1 .float wantswelcomemessage;
2 .string netname_previous;
4 void spawnfunc_info_player_survivor (void)
6 spawnfunc_info_player_deathmatch();
9 void spawnfunc_info_player_start (void)
11 spawnfunc_info_player_deathmatch();
14 void spawnfunc_info_player_deathmatch (void)
16 self.classname = "info_player_deathmatch";
17 relocate_spawnpoint();
20 void() spawnpoint_use =
25 self.team = activator.team;
26 some_spawn_has_been_used = 1;
32 entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck)
34 local entity spot, player, nextspot, previousspot, newfirstspot;
43 nextspot = spot.chain;
44 // count team mismatches as bad spots
46 local float spotactive;
49 // filter out spots for assault
50 if(spot.target != "") {
52 ent = find(world, targetname, spot.target);
54 if(ent.classname == "target_objective")
55 if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
57 ent = find(ent, targetname, spot.target);
61 if ((!teamcheck || spot.team == teamcheck) && spotactive > 0)
68 if (vlen(player.origin - spot.origin) < mindist)
70 player = player.chain;
76 previousspot.chain = spot;
83 spawn_allgood = FALSE;
87 // if we couldn't find ANY good points, return world
91 entity Spawn_RandomPoint(entity firstspot)
95 // count number of spots
100 numspots = numspots + 1;
104 numspots = numspots * random();
106 while (spot.chain && numspots >= 1)
108 numspots = numspots - 1;
114 entity Spawn_FurthestPoint(entity firstspot, entity playerlist)
116 local entity best, spot, player;
117 local float bestrating, rating;
119 bestrating = -1000000;
128 rating = min(rating, vlen(player.origin - spot.origin));
129 player = player.chain;
131 rating = rating + random() * 16;
132 if (bestrating < rating)
146 Finds a point to respawn
149 entity SelectSpawnPoint (float anypoint)
151 local float teamcheck;
152 local entity firstspot_new;
153 local entity spot, firstspot, playerlist;
155 spot = find (world, classname, "testplayerstart");
161 if(!anypoint && have_team_spawns)
162 teamcheck = self.team;
164 // get the list of players
165 playerlist = findchain(classname, "player");
166 // get the entire list of spots
167 firstspot = findchain(classname, "info_player_deathmatch");
168 // filter out the bad ones
169 // (note this returns the original list if none survived)
170 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 100, teamcheck);
172 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, -1, teamcheck);
173 firstspot = firstspot_new;
175 // there is 50/50 chance of choosing a random spot or the furthest spot
176 // (this means that roughly every other spawn will be furthest, so you
177 // usually won't get fragged at spawn twice in a row)
178 if (arena_roundbased)
180 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 800, teamcheck);
182 firstspot = firstspot_new;
183 spot = Spawn_RandomPoint(firstspot);
185 else if (random() > 0.5 || spawn_allbad || spawn_allgood)
186 spot = Spawn_RandomPoint(firstspot);
188 spot = Spawn_FurthestPoint(firstspot, playerlist);
192 if(cvar("spawn_debug"))
196 if(some_spawn_has_been_used)
197 return world; // team can't spawn any more, because of actions of other team
199 error("Cannot find a spawn point - please fix the map!");
210 Checks if the argument string can be a valid playermodel.
211 Returns a valid one in doubt.
214 string FallbackPlayerModel = "models/player/marine.zym";
215 string CheckPlayerModel(string plyermodel) {
216 if(strlen(plyermodel) < 4)
217 return FallbackPlayerModel;
218 if( substring(plyermodel,0,14) != "models/player/")
219 return FallbackPlayerModel;
220 else if(cvar("sv_servermodelsonly"))
222 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".zym")
223 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".dpm")
224 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".md3")
225 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".psk")
226 return FallbackPlayerModel;
227 if(!fexists(plyermodel))
228 return FallbackPlayerModel;
235 Client_customizeentityforclient
240 float Client_customizeentityforclient()
242 #ifdef ALLOW_VARIABLE_LOD
244 // other: the player viewing me
248 if(self.flags & FL_NOTARGET) // we don't need LOD for spectators
251 if(other.cvar_cl_playerdetailreduction <= 0)
253 if(other.cvar_cl_playerdetailreduction <= -2)
254 self.modelindex = self.modelindex_lod2;
255 else if(other.cvar_cl_playerdetailreduction <= -1)
256 self.modelindex = self.modelindex_lod1;
258 self.modelindex = self.modelindex_lod0;
262 distance = vlen(self.origin - other.origin);
263 f = (distance + 100.0) * other.cvar_cl_playerdetailreduction;
265 self.modelindex = self.modelindex_lod2;
267 self.modelindex = self.modelindex_lod1;
269 self.modelindex = self.modelindex_lod0;
276 void UpdatePlayerSounds();
277 void setmodel_lod(entity e, string modelname)
279 #ifdef ALLOW_VARIABLE_LOD
282 // FIXME: this only supports 3-letter extensions
283 s = strcat(substring(modelname, 0, strlen(modelname) - 4), "_1", substring(modelname, 0, strlen(modelname) - 4));
287 setmodel(e, s); // players have high precision
288 self.modelindex_lod1 = self.modelindex;
291 self.modelindex_lod1 = -1;
293 s = strcat(substring(modelname, 0, strlen(modelname) - 4), "_2", substring(modelname, 0, strlen(modelname) - 4));
297 setmodel(e, s); // players have high precision
298 self.modelindex_lod2 = self.modelindex;
301 self.modelindex_lod2 = -1;
303 precache_model(modelname);
304 setmodel(e, modelname); // players have high precision
305 self.modelindex_lod0 = self.modelindex;
307 if(self.modelindex_lod1 < 0)
308 self.modelindex_lod1 = self.modelindex;
310 if(self.modelindex_lod2 < 0)
311 self.modelindex_lod2 = self.modelindex;
313 precache_model(modelname);
314 setmodel(e, modelname); // players have high precision
316 player_setupanimsformodel();
317 UpdatePlayerSounds();
324 putting a client as observer in the server
327 void PutObserverInServer (void)
330 spot = SelectSpawnPoint (TRUE);
332 error("No spawnpoints for observers?!?\n");
333 RemoveGrapplingHook(self); // Wazat's Grappling Hook
335 if(clienttype(self) == CLIENTTYPE_REAL)
338 WriteByte(MSG_ONE, SVC_SETVIEW);
339 WriteEntity(MSG_ONE, self);
343 kh_Key_DropAll(self, TRUE);
346 DropFlag(self.flagcarried);
348 WaypointSprite_PlayerDead();
350 DistributeFragsAmongTeam(self, self.team, 1);
352 if(self.frags <= 0 && self.frags > -666 && g_lms && self.killcount != -666)
353 bprint ("^4", self.netname, "^4 has no more lives left\n");
354 else if(self.killcount != -666)
355 bprint ("^4", self.netname, "^4 is spectating now\n");
357 self.spectatortime = time;
359 self.classname = "observer";
361 self.takedamage = DAMAGE_NO;
362 self.solid = SOLID_NOT;
363 self.movetype = MOVETYPE_NOCLIP;
364 self.flags = FL_CLIENT | FL_NOTARGET;
365 self.armorvalue = 666;
367 self.armorvalue = cvar("g_balance_armor_start");
368 self.pauserotarmor_finished = 0;
369 self.pauserothealth_finished = 0;
370 self.pauseregen_finished = 0;
371 self.damageforcescale = 0;
379 self.pain_finished = 0;
380 self.strength_finished = 0;
381 self.invincible_finished = 0;
383 self.think = SUB_Null;
387 self.deadflag = DEAD_NO;
388 self.angles = spot.angles;
390 self.fixangle = TRUE;
393 self.view_ofs = PL_VIEW_OFS;
394 setorigin (self, spot.origin);
395 setsize (self, '0 0 0', '0 0 0');
396 self.oldorigin = self.origin;
401 self.weaponmodel = "";
402 self.weaponentity = world;
403 self.killcount = -666;
404 self.velocity = '0 0 0';
405 self.avelocity = '0 0 0';
406 self.punchangle = '0 0 0';
407 self.punchvector = '0 0 0';
408 self.oldvelocity = self.velocity;
409 self.customizeentityforclient = Client_customizeentityforclient;
411 self.wantswelcomemessage = 1;
417 Spawnqueue_Insert(self);
421 Spawnqueue_Unmark(self);
422 Spawnqueue_Remove(self);
429 float RestrictSkin(float s)
438 void FixPlayermodel()
440 local string defaultmodel;
441 local float defaultskin;
446 if(cvar("sv_defaultcharacter") == 1) {
451 defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", Team_ColorNameLowerCase(self.team)));
452 defaultskin = cvar(strcat("sv_defaultplayerskin_", Team_ColorNameLowerCase(self.team)));
455 if(defaultmodel == "")
457 defaultmodel = cvar_string("sv_defaultplayermodel");
458 defaultskin = cvar("sv_defaultplayerskin");
462 if(defaultmodel != "")
464 if (defaultmodel != self.model)
468 setmodel_lod (self, defaultmodel);
469 setsize (self, m1, m2);
472 self.skin = defaultskin;
474 if (self.playermodel != self.model)
476 self.playermodel = CheckPlayerModel(self.playermodel);
479 setmodel_lod (self, self.playermodel);
480 setsize (self, m1, m2);
483 self.skin = RestrictSkin(stof(self.playerskin));
487 if(strlen(cvar_string("sv_defaultplayercolors")))
488 if(self.clientcolors != cvar("sv_defaultplayercolors"))
489 setcolor(self, cvar("sv_defaultplayercolors"));
496 Called when a client spawns in the server
499 void PutClientInServer (void)
501 if(clienttype(self) == CLIENTTYPE_BOT)
503 self.classname = "player";
505 else if(clienttype(self) == CLIENTTYPE_REAL)
508 WriteByte(MSG_ONE, SVC_SETVIEW);
509 WriteEntity(MSG_ONE, self);
512 // player is dead and becomes observer
513 if(g_lms && self.frags < 1)
514 self.classname = "observer";
518 self.classname = "observer";
520 if(self.classname == "player") {
523 spot = SelectSpawnPoint (FALSE);
526 centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
527 return; // spawn failed
530 RemoveGrapplingHook(self); // Wazat's Grappling Hook
532 self.classname = "player";
533 self.iscreature = TRUE;
534 self.movetype = MOVETYPE_WALK;
535 self.solid = SOLID_SLIDEBOX;
536 self.flags = FL_CLIENT;
537 self.takedamage = DAMAGE_AIM;
539 self.effects = EF_FULLBRIGHT;
542 self.air_finished = time + 12;
545 self.ammo_shells = start_ammo_shells;
546 self.ammo_nails = start_ammo_nails;
547 self.ammo_rockets = start_ammo_rockets;
548 self.ammo_cells = start_ammo_cells;
549 self.health = start_health;
550 self.armorvalue = start_armorvalue;
551 self.items = start_items;
552 self.switchweapon = start_switchweapon;
553 self.cnt = start_switchweapon;
555 self.jump_interval = time;
557 self.spawnshieldtime = time + cvar("g_spawnshieldtime");
558 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
559 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
560 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
561 //extend the pause of rotting if client was reset at the beginning of the countdown
562 if(!cvar("sv_ready_restart_after_countdown") && time < restart_countdown) {
563 self.spawnshieldtime += RESTART_COUNTDOWN;
564 self.pauserotarmor_finished += RESTART_COUNTDOWN;
565 self.pauserothealth_finished += RESTART_COUNTDOWN;
566 self.pauseregen_finished += RESTART_COUNTDOWN;
568 self.damageforcescale = 2;
575 self.pain_finished = 0;
576 self.strength_finished = 0;
577 self.invincible_finished = 0;
579 //self.speed_finished = 0;
580 //self.slowmo_finished = 0;
581 // players have no think function
582 self.think = SUB_Null;
588 self.deadflag = DEAD_NO;
590 self.angles = spot.angles;
592 self.angles_z = 0; // never spawn tilted even if the spot says to
593 self.fixangle = TRUE; // turn this way immediately
594 self.velocity = '0 0 0';
595 self.avelocity = '0 0 0';
596 self.punchangle = '0 0 0';
597 self.punchvector = '0 0 0';
598 self.oldvelocity = self.velocity;
603 self.customizeentityforclient = Client_customizeentityforclient;
609 self.view_ofs = PL_VIEW_OFS;
610 setsize (self, PL_MIN, PL_MAX);
611 self.spawnorigin = spot.origin;
612 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
613 // don't reset back to last position, even if new position is stuck in solid
614 self.oldorigin = self.origin;
618 Spawnqueue_Remove(self);
619 Spawnqueue_Mark(self);
622 self.event_damage = PlayerDamage;
624 self.bot_attack = TRUE;
626 self.statdraintime = time + 5;
627 self.button0 = self.button1 = self.button2 = self.button3 = 0;
629 if(self.killcount == -666) {
636 self.cnt = WEP_LASER;
637 self.nixnex_lastchange_id = -1;
639 CL_SpawnWeaponentity();
640 self.alpha = default_player_alpha;
641 self.colormod = '1 1 1' * cvar("g_player_brightness");
642 self.exteriorweaponentity.alpha = default_weapon_alpha;
644 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
645 self.lms_traveled_distance = 0;
646 self.speedrunning = FALSE;
648 if(cvar("spawn_debug"))
650 sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n"));
651 remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
654 //stuffcmd(self, "chase_active 0");
655 //stuffcmd(self, "set viewsize $tmpviewsize \n");
657 if (cvar("g_spawnsound"))
658 sound (self, CHAN_AUTO, "misc/spawn.wav", 1, ATTN_NORM);
661 if(self.team == assault_attacker_team)
662 centerprint(self, "You are attacking!\n");
664 centerprint(self, "You are defending!\n");
667 } else if(self.classname == "observer") {
668 PutObserverInServer ();
677 void SetNewParms (void)
687 void SetChangeParms (void)
696 Called when a client types 'kill' in the console
700 void ClientKill_Now_TeamChange()
702 if(self.killindicator_teamchange == -1)
705 JoinBestTeam( self, FALSE, FALSE );
709 SV_ChangeTeam(self.killindicator_teamchange - 1);
713 void ClientKill_Now()
715 if(self.killindicator_teamchange)
716 ClientKill_Now_TeamChange();
719 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
721 void KillIndicator_Think()
723 if (!self.owner.modelindex)
725 self.owner.killindicator = world;
733 ClientKill_Now(); // no oldself needed
739 setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
740 if(clienttype(self.owner) == CLIENTTYPE_REAL)
743 play2(self.owner, strcat("announcer/robotic/", ftos(self.cnt), ".ogg"));
744 if(self.owner.killindicator_teamchange)
746 if(self.owner.killindicator_teamchange == -1)
747 centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
749 centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
752 centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
754 self.nextthink = time + 1;
759 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
763 killtime = cvar("g_balance_kill_delay");
765 self.killindicator_teamchange = targetteam;
767 if(!self.killindicator)
769 if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
775 self.killindicator = spawn();
776 self.killindicator.owner = self;
777 self.killindicator.scale = 0.5;
778 setattachment(self.killindicator, self, "");
779 setorigin(self.killindicator, '0 0 52');
780 self.killindicator.think = KillIndicator_Think;
781 self.killindicator.nextthink = time + (self.lip) * 0.05;
782 self.killindicator.cnt = ceil(killtime);
783 self.killindicator.count = bound(0, ceil(killtime), 10);
784 sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
786 for(e = world; (e = find(e, classname, "body")) != world; )
790 e.killindicator = spawn();
791 e.killindicator.owner = e;
792 e.killindicator.scale = 0.5;
793 setattachment(e.killindicator, e, "");
794 setorigin(e.killindicator, '0 0 52');
795 e.killindicator.think = KillIndicator_Think;
796 e.killindicator.nextthink = time + (e.lip) * 0.05;
797 e.killindicator.cnt = ceil(killtime);
802 if(self.killindicator)
805 self.killindicator.colormod = TeamColor(targetteam);
807 self.killindicator.colormod = '0 0 0';
811 void ClientKill (void)
813 ClientKill_TeamChange(0);
816 void DoTeamChange(float destteam)
819 if(!cvar("teamplay"))
822 SetPlayerColors(self, destteam);
825 if(self.classname == "player")
828 CheckAllowedTeams(self);
829 t = FindSmallestTeam(self, TRUE);
832 case COLOR_TEAM1: c0 = c1; break;
833 case COLOR_TEAM2: c0 = c2; break;
834 case COLOR_TEAM3: c0 = c3; break;
835 case COLOR_TEAM4: c0 = c4; break;
842 destteam = COLOR_TEAM1;
846 destteam = COLOR_TEAM2;
850 destteam = COLOR_TEAM3;
854 destteam = COLOR_TEAM4;
860 if(destteam == self.team && !self.killindicator)
862 ClientKill_TeamChange(destteam);
865 void FixClientCvars(entity e)
867 // send prediction settings to the client
868 stuffcmd(e, "\nin_bindmap 0 0\n");
870 * we no longer need to stuff this. Remove this comment block if you feel
871 * 2.3 and higher (or was it 2.2.3?) don't need these any more
872 stuffcmd(e, strcat("cl_gravity ", ftos(cvar("sv_gravity")), "\n"));
873 stuffcmd(e, strcat("cl_movement_accelerate ", ftos(cvar("sv_accelerate")), "\n"));
874 stuffcmd(e, strcat("cl_movement_friction ", ftos(cvar("sv_friction")), "\n"));
875 stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(cvar("sv_maxspeed")), "\n"));
876 stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(cvar("sv_airaccelerate")), "\n"));
877 stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(cvar("sv_maxairspeed")), "\n"));
878 stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(cvar("sv_stopspeed")), "\n"));
879 stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(cvar("sv_jumpvelocity")), "\n"));
880 stuffcmd(e, strcat("cl_movement_stepheight ", ftos(cvar("sv_stepheight")), "\n"));
881 stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(cvar("sv_friction_on_land")), "\n"));
882 stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(cvar("sv_airaccel_qw")), "\n"));
883 stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(cvar("sv_airaccel_sideways_friction")), "\n"));
884 stuffcmd(e, "cl_movement_edgefriction 1\n");
892 Called when a client connects to the server
895 string ColoredTeamName(float t);
896 //void dom_player_join_team(entity pl);
897 void ClientConnect (void)
902 if(Ban_IsClientBanned(self))
904 s = strcat("^1NOTE:^7 banned client ", self.netaddress, " just tried to enter\n");
910 self.classname = "player_joining";
911 self.flags = self.flags | FL_CLIENT;
912 self.version_nagtime = time + 10 + random() * 10;
916 dprint("BUG player count is lower than zero, this cannot happen!\n");
923 // dom_player_join_team(self);
925 //JoinBestTeam(self, FALSE, FALSE);
927 if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign")) {
928 self.classname = "observer";
930 self.classname = "player";
931 campaign_bots_may_start = 1;
934 self.playerid = (playerid_last = playerid_last + 1);
935 if(cvar("sv_eventlog"))
937 if(clienttype(self) == CLIENTTYPE_REAL)
941 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", s, ":", self.netname), TRUE);
942 s = strcat(":team:", ftos(self.playerid), ":");
943 s = strcat(s, ftos(self.team));
944 GameLogEcho(s, FALSE);
946 self.netname_previous = strzone(self.netname);
948 //stuffcmd(self, "set tmpviewsize $viewsize \n");
950 bprint ("^4",self.netname);
951 bprint ("^4 connected");
953 if(g_domination || g_ctf)
955 bprint(" and joined the ");
956 bprint(ColoredTeamName(self.team));
961 self.welcomemessage_time = 0;
963 stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n"));
964 // TODO: is this being used for anything else than cd tracks?
965 // Remember: SVC_CDTRACK exists. Maybe it should be used.
967 stuffcmd(self, "cl_particles_reloadeffects\n");
969 FixClientCvars(self);
971 // spawnfunc_waypoint sprites
972 WaypointSprite_InitClient(self);
974 // Wazat's grappling hook
975 SetGrappleHookBindings();
977 // get autoswitch state from player when he toggles it
978 stuffcmd(self, "alias autoswitch \"set cl_autoswitch $1 ; cmd autoswitch $1\"\n"); // default.cfg-ed in 2.4.1
980 // get version info from player
981 stuffcmd(self, "cmd clientversion $gameversion\n");
983 // send all weapon info strings
984 stuffcmd(self, "register_bestweapon clear\n"); // clear the Quake stuff
986 while (wep <= WEP_LAST)
988 weapon_action(wep, WR_REGISTER);
992 // get other cvars from player
995 // set cvar for team scoreboard
999 t = cvar("teamplay");
1000 // we have to stuff the correct teamplay value because if this is a listen server, this changes the teamplay mode of the server itself, which is bad
1001 stuffcmd(self, strcat("set teamplay ", ftos(t), "\n"));
1004 stuffcmd(self, "set teamplay 0\n");
1006 // notify about available teams
1009 CheckAllowedTeams(self);
1010 t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
1011 stuffcmd(self, strcat("set _teams_available ", ftos(t), "\n"));
1014 stuffcmd(self, "set _teams_available 0\n");
1016 stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
1020 self.frags = LMS_NewPlayerLives();
1026 self.classname = "observer";
1027 Spawnqueue_Insert(self);
1030 bot_relinkplayerlist();
1032 self.spectatortime = time;
1035 sprint(self, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
1038 self.jointime = time;
1039 self.allowedTimeouts = cvar("sv_timeout_number");
1046 Called when a client disconnects from the server
1049 void(entity e) DropFlag;
1050 .entity chatbubbleentity;
1051 .entity teambubbleentity;
1052 void ClientDisconnect (void)
1055 if(cvar("sv_eventlog"))
1056 GameLogEcho(strcat(":part:", ftos(self.playerid)), FALSE);
1057 bprint ("^4",self.netname);
1058 bprint ("^4 disconnected\n");
1060 if (self.chatbubbleentity)
1062 remove (self.chatbubbleentity);
1063 self.chatbubbleentity = world;
1066 if (self.teambubbleentity)
1068 remove (self.teambubbleentity);
1069 self.teambubbleentity = world;
1072 if (self.killindicator)
1074 remove (self.killindicator);
1075 self.killindicator = world;
1078 WaypointSprite_PlayerGone();
1081 kh_Key_DropAll(self, TRUE);
1083 if(self.flagcarried)
1084 DropFlag(self.flagcarried);
1086 DistributeFragsAmongTeam(self, self.team, 1);
1089 self.flags = self.flags - (self.flags & FL_CLIENT);
1090 bot_relinkplayerlist();
1094 if(self.weaponentity)
1095 if(self.weaponentity.lasertarget)
1096 remove(self.weaponentity.lasertarget);
1100 Spawnqueue_Unmark(self);
1101 Spawnqueue_Remove(self);
1104 if(self.netname_previous)
1105 strunzone(self.netname_previous);
1112 void() ChatBubbleThink =
1114 self.nextthink = time;
1115 if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
1117 self.owner.chatbubbleentity = world;
1121 setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1');
1122 if (self.owner.buttonchat && !self.owner.deadflag)
1123 self.model = self.mdl;
1128 void() UpdateChatBubble =
1130 if (!self.modelindex)
1132 // spawn a chatbubble entity if needed
1133 if (!self.chatbubbleentity)
1135 self.chatbubbleentity = spawn();
1136 self.chatbubbleentity.owner = self;
1137 self.chatbubbleentity.exteriormodeltoclient = self;
1138 self.chatbubbleentity.think = ChatBubbleThink;
1139 self.chatbubbleentity.nextthink = time;
1140 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
1141 setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1142 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
1143 self.chatbubbleentity.model = "";
1144 self.chatbubbleentity.effects = EF_LOWPRECISION;
1149 void() TeamBubbleThink =
1151 self.nextthink = time;
1152 if (!self.owner.modelindex || self.owner.teambubbleentity != self)
1154 self.owner.teambubbleentity = world;
1158 // setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1'); // bandwidth hog. setattachment does this now
1159 if (self.owner.buttonchat || self.owner.deadflag || self.owner.killindicator)
1162 self.model = self.mdl;
1166 float() TeamBubble_customizeentityforclient
1168 return (self.owner != other && self.owner.team == other.team && other.killcount > -666);
1171 void() UpdateTeamBubble =
1173 if (!self.modelindex || !cvar("teamplay"))
1175 // spawn a teambubble entity if needed
1176 if (!self.teambubbleentity && cvar("teamplay"))
1178 self.teambubbleentity = spawn();
1179 self.teambubbleentity.owner = self;
1180 self.teambubbleentity.exteriormodeltoclient = self;
1181 self.teambubbleentity.think = TeamBubbleThink;
1182 self.teambubbleentity.nextthink = time;
1183 setmodel(self.teambubbleentity, "models/misc/teambubble.spr"); // precision set below
1184 // setorigin(self.teambubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1185 setorigin(self.teambubbleentity, self.teambubbleentity.origin + '0 0 15' + self.maxs_z * '0 0 1');
1186 setattachment(self.teambubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
1187 self.teambubbleentity.mdl = self.teambubbleentity.model;
1188 self.teambubbleentity.model = self.teambubbleentity.mdl;
1189 self.teambubbleentity.customizeentityforclient = TeamBubble_customizeentityforclient;
1190 self.teambubbleentity.effects = EF_LOWPRECISION;
1194 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
1195 // added to the model skins
1196 /*void() UpdateColorModHack =
1199 c = self.clientcolors & 15;
1200 // LordHavoc: only bothering to support white, green, red, yellow, blue
1201 if (teamplay == 0) self.colormod = '0 0 0';
1202 else if (c == 0) self.colormod = '1.00 1.00 1.00';
1203 else if (c == 3) self.colormod = '0.10 1.73 0.10';
1204 else if (c == 4) self.colormod = '1.73 0.10 0.10';
1205 else if (c == 12) self.colormod = '1.22 1.22 0.10';
1206 else if (c == 13) self.colormod = '0.10 0.10 1.73';
1207 else self.colormod = '1 1 1';
1213 self.effects |= EF_NODRAW; // prevent another CopyBody
1214 PutClientInServer();
1218 * When sv_timeout is used this function returs strings like
1219 * "Timeout begins in 2 seconds!\n" or "Timeout ends in 23 seconds!\n".
1220 * Called by centerprint functions
1221 * @param addOneSecond boolean, set to 1 if the welcome-message centerprint asks for the text
1223 string getTimeoutText(float addOneSecond) {
1224 if (!cvar("sv_timeout") || !timeoutStatus)
1227 local string retStr;
1228 if (timeoutStatus == 1) {
1229 if (addOneSecond == 1) {
1230 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime + 1), " seconds!\n");
1233 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
1237 else if (timeoutStatus == 2) {
1239 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
1240 //don't show messages like "Timeout ends in 0 seconds"...
1241 if ((remainingTimeoutTime + 1) > 0)
1247 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
1248 //don't show messages like "Timeout ends in 0 seconds"...
1249 if (remainingTimeoutTime > 0)
1258 void player_powerups (void)
1262 if (self.items & IT_STRENGTH)
1264 if (time > self.strength_finished)
1266 if (g_minstagib_invis_alpha > 0)
1268 self.alpha = default_player_alpha;
1269 self.exteriorweaponentity.alpha = default_weapon_alpha;
1270 self.effects = self.effects | EF_FULLBRIGHT;
1274 self.effects -= self.effects & EF_NODRAW;
1276 self.items = self.items - (self.items & IT_STRENGTH);
1277 sprint(self, "^3Invisibility has worn off\n");
1282 if (time < self.strength_finished)
1284 if (g_minstagib_invis_alpha > 0)
1286 self.alpha = g_minstagib_invis_alpha;
1287 self.exteriorweaponentity.alpha = g_minstagib_invis_alpha;
1288 self.effects -= self.effects & EF_FULLBRIGHT;
1292 self.effects = self.effects | EF_NODRAW;
1294 self.items = self.items | IT_STRENGTH;
1295 sprint(self, "^3You are invisible\n");
1299 if (self.items & IT_INVINCIBLE)
1301 if (time > self.invincible_finished)
1303 self.items = self.items - (self.items & IT_INVINCIBLE);
1304 sprint(self, "^3Speed has worn off\n");
1309 if (time < self.invincible_finished)
1311 self.items = self.items | IT_INVINCIBLE;
1312 sprint(self, "^3You are on speed\n");
1318 self.effects = self.effects - (self.effects & (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT));
1319 if (self.items & IT_STRENGTH)
1321 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
1322 if (time > self.strength_finished)
1324 self.items = self.items - (self.items & IT_STRENGTH);
1325 sprint(self, "^3Strength has worn off\n");
1330 if (time < self.strength_finished)
1332 self.items = self.items | IT_STRENGTH;
1333 sprint(self, "^3Strength infuses your weapons with devastating power\n");
1336 if (self.items & IT_INVINCIBLE)
1338 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
1339 if (time > self.invincible_finished)
1341 self.items = self.items - (self.items & IT_INVINCIBLE);
1342 sprint(self, "^3Shield has worn off\n");
1347 if (time < self.invincible_finished)
1349 self.items = self.items | IT_INVINCIBLE;
1350 sprint(self, "^3Shield surrounds you\n");
1354 if (cvar("g_fullbrightplayers"))
1355 self.effects = self.effects | EF_FULLBRIGHT;
1357 // midair gamemode: damage only while in the air
1358 // if in midair mode, being on ground grants temporary invulnerability
1359 // (this is so that multishot weapon don't clear the ground flag on the
1360 // first damage in the frame, leaving the player vulnerable to the
1361 // remaining hits in the same frame)
1362 if (self.flags & FL_ONGROUND)
1364 self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
1366 if (time < self.spawnshieldtime)
1367 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
1370 float CalcRegen(float current, float stable, float regenfactor)
1372 if(current > stable)
1374 else if(current > stable - 0.25) // when close enough, "snap"
1377 return min(stable, current + (stable - current) * regenfactor * frametime);
1380 void player_regen (void)
1382 float maxh, maxa, limith, limita, max_mod, regen_mod, rot_mod, limit_mod;
1383 maxh = cvar("g_balance_health_stable");
1384 maxa = cvar("g_balance_armor_stable");
1385 limith = cvar("g_balance_health_limit");
1386 limita = cvar("g_balance_armor_limit");
1388 if (g_minstagib || (g_lms && !cvar("g_lms_regenerate")))
1391 max_mod = regen_mod = rot_mod = limit_mod = 1;
1393 if (self.runes & RUNE_REGEN)
1395 if (self.runes & CURSE_VENOM) // do we have both rune/curse?
1397 regen_mod = cvar("g_balance_rune_regen_combo_regenrate");
1398 max_mod = cvar("g_balance_rune_regen_combo_hpmod");
1399 limit_mod = cvar("g_balance_rune_regen_combo_limitmod");
1403 regen_mod = cvar("g_balance_rune_regen_regenrate");
1404 max_mod = cvar("g_balance_rune_regen_hpmod");
1405 limit_mod = cvar("g_balance_rune_regen_limitmod");
1408 else if (self.runes & CURSE_VENOM)
1410 max_mod = cvar("g_balance_curse_venom_hpmod");
1411 if (self.runes & RUNE_REGEN) // do we have both rune/curse?
1412 rot_mod = cvar("g_balance_rune_regen_combo_rotrate");
1414 rot_mod = cvar("g_balance_curse_venom_rotrate");
1415 limit_mod = cvar("g_balance_curse_venom_limitmod");
1416 //if (!self.runes & RUNE_REGEN)
1417 // rot_mod = cvar("g_balance_curse_venom_rotrate");
1419 maxh = maxh * max_mod;
1420 //maxa = maxa * max_mod;
1421 limith = limith * limit_mod;
1422 limita = limita * limit_mod;
1424 if (self.armorvalue > maxa)
1426 if (time > self.pauserotarmor_finished)
1428 self.armorvalue = max(maxa, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_rot") * frametime);
1429 self.armorvalue = max(maxa, self.armorvalue - cvar("g_balance_armor_rotlinear") * frametime);
1432 else if (self.armorvalue < maxa)
1434 if (time > self.pauseregen_finished)
1436 self.armorvalue = CalcRegen(self.armorvalue, maxa, cvar("g_balance_armor_regen"));
1437 self.armorvalue = min(maxa, self.armorvalue + cvar("g_balance_armor_regenlinear") * frametime);
1440 if (self.health > maxh)
1442 if (time > self.pauserothealth_finished)
1444 self.health = max(maxh, self.health + (maxh - self.health) * rot_mod*cvar("g_balance_health_rot") * frametime);
1445 self.health = max(maxh, self.health - rot_mod*cvar("g_balance_health_rotlinear") * frametime);
1448 else if (self.health < maxh)
1450 if (time > self.pauseregen_finished)
1452 self.health = CalcRegen(self.health, maxh, regen_mod * cvar("g_balance_health_regen"));
1453 self.health = min(maxh, self.health + regen_mod*cvar("g_balance_health_regenlinear") * frametime);
1457 if (self.health > limith)
1458 self.health = limith;
1459 if (self.armorvalue > limita)
1460 self.armorvalue = limita;
1462 // if player rotted to death... die!
1464 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
1468 ======================
1469 spectate mode routines
1470 ======================
1472 void SpectateCopy(entity spectatee) {
1473 self.armortype = spectatee.armortype;
1474 self.armorvalue = spectatee.armorvalue;
1475 self.currentammo = spectatee.currentammo;
1476 self.effects = spectatee.effects;
1477 self.health = spectatee.health;
1479 self.items = spectatee.items;
1480 self.punchangle = spectatee.punchangle;
1481 self.view_ofs = spectatee.view_ofs;
1482 self.v_angle = spectatee.v_angle;
1483 self.viewzoom = spectatee.viewzoom;
1484 self.velocity = spectatee.velocity;
1485 self.dmg_take = spectatee.dmg_take;
1486 self.dmg_save = spectatee.dmg_save;
1487 self.dmg_inflictor = spectatee.dmg_inflictor;
1488 self.angles = spectatee.v_angle;
1489 self.fixangle = TRUE;
1490 setorigin(self, spectatee.origin);
1491 setsize(self, spectatee.mins, spectatee.maxs);
1494 float SpectateUpdate() {
1498 if (self == self.enemy)
1501 if(self.enemy.flags & FL_NOTARGET)
1504 SpectateCopy(self.enemy);
1509 float SpectateNext() {
1510 other = find(self.enemy, classname, "player");
1512 other = find(other, classname, "player");
1517 if(self.enemy.classname == "player") {
1519 WriteByte(MSG_ONE, SVC_SETVIEW);
1520 WriteEntity(MSG_ONE, self.enemy);
1521 self.wantswelcomemessage = 1;
1522 //stuffcmd(self, "set viewsize $tmpviewsize \n");
1523 if(!SpectateUpdate())
1524 PutObserverInServer();
1533 ShowRespawnCountdown()
1535 Update a respawn countdown display.
1538 void ShowRespawnCountdown()
1541 if(self.deadflag == DEAD_NO) // just respawned?
1545 number = ceil(self.death_time - time);
1548 if(number <= self.respawn_countdown)
1550 self.respawn_countdown = number - 1;
1551 if(ceil(self.death_time - (time + 0.5)) == number) // only say it if it is the same number even in 0.5s; to prevent overlapping sounds
1552 play2(self, strcat("announcer/robotic/", ftos(number), ".ogg"));
1557 void LeaveSpectatorMode()
1559 if(isJoinAllowed()) {
1560 if(!cvar("teamplay") || cvar("g_campaign") || cvar("g_balance_teams")) {
1561 self.classname = "player";
1562 if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force"))
1563 JoinBestTeam(self, FALSE, TRUE);
1564 if(cvar("g_campaign"))
1565 campaign_bots_may_start = 1;
1566 PutClientInServer();
1567 if(!(self.flags & FL_NOTARGET))
1568 bprint ("^4", self.netname, "^4 is playing now\n");
1569 centerprint(self,"");
1572 stuffcmd(self,"menu_showteamselect\n");
1577 //player may not join because of g_maxplayers is set
1578 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
1583 * Determines whether the player is allowed to join. This depends on cvar
1584 * g_maxplayers, if it isn't used this function always return TRUE, otherwise
1585 * it checks whether the number of currently playing players exceeds g_maxplayers.
1586 * @return bool TRUE if the player is allowed to join, false otherwise
1588 float isJoinAllowed() {
1589 if (!cvar("g_maxplayers"))
1593 local float currentlyPlaying;
1594 FOR_EACH_REALPLAYER(e) {
1595 if(e.classname == "player")
1596 currentlyPlaying += 1;
1598 if(currentlyPlaying < cvar("g_maxplayers"))
1605 * Checks whether the client is an observer or spectator, if so, he will get kicked after
1606 * g_maxplayers_spectator_blocktime seconds
1608 void checkSpectatorBlock() {
1609 if(self.classname == "spectator" || self.classname == "observer") {
1610 if( time > (self.spectatortime + cvar("g_maxplayers_spectator_blocktime")) ) {
1611 sprint(self, "^7You were kicked from the server because you are spectator and spectators aren't allowed at the moment.\n");
1617 float vercmp_recursive(string v1, string v2)
1623 dot1 = strstrofs(v1, ".", 0);
1624 dot2 = strstrofs(v2, ".", 0);
1628 s1 = substring(v1, 0, dot1);
1632 s2 = substring(v2, 0, dot2);
1634 r = stof(s1) - stof(s2);
1638 r = strcasecmp(s1, s2);
1651 return vercmp_recursive(substring(v1, dot1 + 1, 999), substring(v2, dot2 + 1, 999));
1654 float vercmp(string v1, string v2)
1656 if(strcasecmp(v1, v2) == 0) // early out check
1658 return vercmp_recursive(v1, v2);
1661 void ObserverThink()
1663 if (self.flags & FL_JUMPRELEASED) {
1664 if (self.button2 && self.version == cvar("gameversion")) {
1665 self.welcomemessage_time = 0;
1666 self.flags = self.flags - FL_JUMPRELEASED;
1667 LeaveSpectatorMode();
1669 } else if(self.button0 && self.version == cvar("gameversion")) {
1670 self.welcomemessage_time = 0;
1671 self.flags = self.flags - FL_JUMPRELEASED;
1672 if(SpectateNext() == 1) {
1673 self.classname = "spectator";
1677 if (!(self.button0 || self.button2)) {
1678 self.flags = self.flags | FL_JUMPRELEASED;
1682 self.wantswelcomemessage = 0;
1683 if(self.wantswelcomemessage)
1684 PrintWelcomeMessage(self);
1687 void SpectatorThink()
1689 if (self.flags & FL_JUMPRELEASED) {
1690 if (self.button2 && self.version == cvar("gameversion")) {
1691 self.welcomemessage_time = 0;
1692 self.flags = self.flags - FL_JUMPRELEASED;
1693 LeaveSpectatorMode();
1695 } else if(self.button0) {
1696 self.welcomemessage_time = 0;
1697 self.flags = self.flags - FL_JUMPRELEASED;
1698 if(SpectateNext() == 1) {
1699 self.classname = "spectator";
1701 self.classname = "observer";
1702 PutClientInServer();
1704 } else if (self.button3) {
1705 self.welcomemessage_time = 0;
1706 self.flags = self.flags - FL_JUMPRELEASED;
1707 self.classname = "observer";
1708 PutClientInServer();
1710 if(!SpectateUpdate())
1711 PutObserverInServer();
1714 if (!(self.button0 || self.button3)) {
1715 self.flags = self.flags | FL_JUMPRELEASED;
1719 self.wantswelcomemessage = 0;
1720 if(self.wantswelcomemessage)
1721 PrintWelcomeMessage(self);
1722 self.flags = self.flags | FL_CLIENT | FL_NOTARGET;
1729 Called every frame for each client before the physics are run
1732 void() ctf_setstatus;
1733 .float vote_nagtime;
1734 void PlayerPreThink (void)
1737 checkSpectatorBlock();
1739 if(self.netname_previous != self.netname)
1741 if(cvar("sv_eventlog"))
1742 GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname), TRUE);
1743 if(self.netname_previous)
1744 strunzone(self.netname_previous);
1745 self.netname_previous = strzone(self.netname);
1749 if(self.version_nagtime)
1750 if(self.cvar_g_nexuizversion)
1751 if(time > self.version_nagtime)
1753 if(strstr(self.cvar_g_nexuizversion, "svn", 0) < 0)
1755 if(strstr(cvar_string("g_nexuizversion"), "svn", 0) >= 0)
1757 dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), " (beta)^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n");
1758 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), " (beta)^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
1763 r = vercmp(self.cvar_g_nexuizversion, cvar_string("g_nexuizversion"));
1766 dprint("^1NOTE^7 to ", self.netname, "^7 - ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7 is out, and you still have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1 - get the update from ^4http://www.nexuiz.com/^1!\n");
1767 sprint(self, strcat("\{1}^1NOTE: ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7 is out, and you still have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1 - get the update from ^4http://www.nexuiz.com/^1!\n"));
1771 dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n");
1772 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
1776 self.version_nagtime = 0;
1780 if(self.cvar_scr_centertime)
1781 if(time > self.vote_nagtime)
1784 self.vote_nagtime = time + self.cvar_scr_centertime * 0.6;
1788 if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue)
1790 sprint(self, strcat("godmode saved you ", ftos(self.max_armorvalue), " units of damage, cheater!\n"));
1791 self.max_armorvalue = 0;
1795 antilag_record(self);
1797 if(self.classname == "player") {
1798 // if(self.netname == "Wazat")
1799 // bprint(self.classname, "\n");
1801 CheckRules_Player();
1804 PrintWelcomeMessage(self);
1806 if(g_lms || !cvar("sv_spectate"))
1807 if((time - self.jointime) <= cvar("welcome_message_time"))
1808 PrintWelcomeMessage(self);
1810 if (intermission_running)
1812 IntermissionThink (); // otherwise a button could be missed between
1813 return; // the think tics
1816 if(self.teleport_time)
1817 if(time > self.teleport_time)
1819 self.teleport_time = 0;
1820 self.effects = self.effects - (self.effects & EF_NODRAW);
1821 if(self.weaponentity)
1822 self.weaponentity.flags = self.weaponentity.flags - (self.weaponentity.flags & EF_NODRAW);
1825 Nixnex_GiveCurrentWeapon();
1827 if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
1828 UpdateSelectedPlayer();
1830 //don't allow the player to turn around while game is paused!
1831 if(timeoutStatus == 2) {
1832 self.v_angle = self.lastV_angle;
1833 self.angles = self.lastV_angle;
1834 self.fixangle = TRUE;
1837 if (self.deadflag != DEAD_NO)
1839 float button_pressed, force_respawn;
1841 button_pressed = (self.button0 || self.button2 || self.button3 || self.button6 || self.buttonuse);
1842 force_respawn = (g_lms || cvar("g_forced_respawn"));
1843 if (self.deadflag == DEAD_DYING)
1846 self.deadflag = DEAD_RESPAWNING;
1847 else if(!button_pressed)
1848 self.deadflag = DEAD_DEAD;
1850 else if (self.deadflag == DEAD_DEAD)
1853 self.deadflag = DEAD_RESPAWNABLE;
1855 else if (self.deadflag == DEAD_RESPAWNABLE)
1858 self.deadflag = DEAD_RESPAWNING;
1860 else if (self.deadflag == DEAD_RESPAWNING)
1862 if(time > self.death_time)
1864 self.death_time = time + 1; // only retry once a second
1868 ShowRespawnCountdown();
1872 if(g_lms && !self.deadflag && cvar("g_lms_campcheck_interval"))
1876 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
1877 dist = self.oldorigin - self.origin;
1879 self.lms_traveled_distance += fabs(vlen(dist));
1881 if((cvar("g_campaign") && !campaign_bots_may_start) || (time < restart_countdown))
1883 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
1884 self.lms_traveled_distance = 0;
1887 if(time > self.lms_nextcheck)
1889 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
1890 if(self.lms_traveled_distance < cvar("g_lms_campcheck_distance"))
1892 centerprint(self, cvar_string("g_lms_campcheck_message"));
1893 // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
1894 // I wasn't able to find out WHY that happens, so I put a workaround in place that shall prevent players from being gibbed :(
1895 Damage(self, self, self, bound(0, cvar("g_lms_campcheck_damage"), self.health + self.armorvalue * cvar("g_balance_armor_blockpercent") + 5), DEATH_CAMP, self.origin, '0 0 0');
1897 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
1898 self.lms_traveled_distance = 0;
1902 if (self.button5 && !self.hook.state)
1907 self.view_ofs = PL_CROUCH_VIEW_OFS;
1908 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
1909 player_setanim(self.anim_duck, FALSE, TRUE, TRUE);
1916 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
1917 if (!trace_startsolid)
1919 self.crouch = FALSE;
1920 self.view_ofs = PL_VIEW_OFS;
1921 setsize (self, PL_MIN, PL_MAX);
1928 GrapplingHookFrame();
1933 float zoomfactor, zoomspeed, zoomdir;
1934 zoomfactor = self.cvar_cl_zoomfactor;
1935 if(zoomfactor < 1 || zoomfactor > 16)
1937 zoomspeed = self.cvar_cl_zoomspeed;
1938 if(zoomspeed >= 0) // < 0 is instant zoom
1939 if(zoomspeed < 0.5 || zoomspeed > 16)
1942 zoomdir = self.button4;
1944 if(self.weapon == WEP_NEX)
1949 self.has_zoomed = 1;
1953 if(zoomspeed <= 0) // instant zoom
1956 self.viewzoom = 1 / zoomfactor;
1962 // geometric zoom would be:
1963 // self.viewzoom = bound(1 / zoomfactor, self.viewzoom * pow(zoomfactor, (zoomdir ? -1 : 1) * frametime * zoomspeed), 1);
1964 // however, testing showed that arithmetic/harmonic zoom works better
1966 // self.viewzoom = 1 / bound(1, 1 / self.viewzoom + (zoomdir ? 1 : -1) * frametime * zoomspeed * (zoomfactor - 1), zoomfactor);
1967 // zoom in = arithmetic: 1x, 2x, 3x, 4x, ..., 8x
1968 self.viewzoom = 1 / bound(1, 1 / self.viewzoom + frametime * zoomspeed * (zoomfactor - 1), zoomfactor);
1970 // self.viewzoom = bound(1 / zoomfactor, self.viewzoom + (zoomdir ? -1 : 1) * frametime * zoomspeed * (1 - 1 / zoomfactor), 1);
1971 // zoom out = harmonic: 8/1x, 8/2x, 8/3x, 8/4x, ..., 8/8x
1972 self.viewzoom = bound(1 / zoomfactor, self.viewzoom + frametime * zoomspeed * (1 - 1 / zoomfactor), 1);
1976 self.viewzoom = min(1, self.viewzoom + frametime); // spawn zoom-in
1984 minstagib_ammocheck();
1989 //self.angles_y=self.v_angle_y + 90; // temp
1991 //if (TetrisPreFrame()) return;
1992 } else if(gameover) {
1993 if (intermission_running)
1994 IntermissionThink (); // otherwise a button could be missed between
1996 } else if(self.classname == "observer") {
1998 } else if(self.classname == "spectator") {
2008 Called every frame for each client after the physics are run
2011 void PlayerPostThink (void)
2013 // Savage: Check for nameless players
2014 if (strlen(self.netname) < 1) {
2015 self.netname = "Player";
2016 stuffcmd(self, "seta _cl_name Player\n");
2019 if(self.classname == "player") {
2020 CheckRules_Player();
2025 if (intermission_running)
2026 return; // intermission or finale
2028 //PrintWelcomeMessage(self);
2029 //if (TetrisPostFrame()) return;
2031 // restart countdown
2032 if (restart_countdown) {
2033 if(time < restart_countdown) {
2034 if (!cvar("sv_ready_restart_after_countdown"))
2036 self.movetype = MOVETYPE_NONE;
2037 self.velocity = '0 0 0';
2038 self.avelocity = '0 0 0';
2039 self.movement = '0 0 0';
2044 //allow the player to move again if sv_ready_restart_after_countdown is not used and countdown is over
2045 if (!cvar("sv_ready_restart_after_countdown"))
2047 if(self.movetype == MOVETYPE_NONE)
2049 self.movetype = MOVETYPE_WALK;
2055 } else if (self.classname == "observer") {
2057 } else if (self.classname == "spectator") {