1 .float spectatee_status;
3 .float bloodloss_timer;
6 float ClientData_Send(entity to, float sf)
17 if(to.classname == "spectator")
23 sf |= 1; // forced scoreboard
24 if(to.spectatee_status)
25 sf |= 2; // spectator ent number follows
28 if(e.porto_v_angle_held)
29 sf |= 8; // angles held
31 WriteByte(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
32 WriteByte(MSG_ENTITY, sf);
35 WriteByte(MSG_ENTITY, to.spectatee_status);
39 WriteAngle(MSG_ENTITY, e.v_angle_x);
40 WriteAngle(MSG_ENTITY, e.v_angle_y);
46 void ClientData_Attach()
48 Net_LinkEntity(self.clientdata = spawn(), FALSE, 0, ClientData_Send);
49 self.clientdata.drawonlytoclient = self;
50 self.clientdata.owner = self;
53 void ClientData_Detach()
55 remove(self.clientdata);
56 self.clientdata = world;
59 void ClientData_Touch(entity e)
61 e.clientdata.SendFlags = 1;
63 // make it spectatable
65 FOR_EACH_REALCLIENT(e2)
68 if(e2.classname == "spectator")
70 e2.clientdata.SendFlags = 1;
75 #define SPAWNPOINT_SCORE frags
77 .string netname_previous;
79 void spawnfunc_info_player_survivor (void)
81 spawnfunc_info_player_deathmatch();
84 void spawnfunc_info_player_start (void)
86 spawnfunc_info_player_deathmatch();
89 void spawnfunc_info_player_deathmatch (void)
91 self.classname = "info_player_deathmatch";
92 relocate_spawnpoint();
100 self.team = activator.team;
101 some_spawn_has_been_used = 1;
106 // -1 if a spawn can't be used
107 // otherwise, a weight of the spawnpoint
108 float Spawn_Score(entity spot, entity playerlist, float teamcheck)
110 float shortest, thisdist;
113 // filter out spots for the wrong team
115 if(spot.team != teamcheck)
119 if(spot.target == "")
122 // filter out spots for assault
123 if(spot.target != "") {
126 ent = find(world, targetname, spot.target);
128 if(ent.classname == "target_objective")
131 if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
135 else if(ent.classname == "trigger_race_checkpoint")
138 if(self.classname == "player") // spectators may spawn everywhere
140 if(g_race_qualifying)
143 if(ent.race_checkpoint != 0)
145 if(spot.race_place != race_lowest_place_spawn)
150 if(ent.race_checkpoint != race_PreviousCheckpoint(self.race_checkpoint))
153 pl = self.race_place;
154 if(pl > race_highest_place_spawn)
156 if(spot.race_place != pl)
162 ent = find(ent, targetname, spot.target);
170 shortest = vlen(world.maxs - world.mins);
171 for(player = playerlist; player; player = player.chain)
174 thisdist = vlen(player.origin - spot.origin);
175 if (thisdist < shortest)
183 entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck)
185 local entity spot, spotlist, spotlistend;
186 spawn_allgood = TRUE;
192 for(spot = firstspot; spot; spot = spot.chain)
194 spot.SPAWNPOINT_SCORE = Spawn_Score(spot, playerlist, teamcheck);
196 if(cvar("spawn_debugview"))
198 setmodel(spot, "models/runematch/rune.mdl");
199 if(spot.SPAWNPOINT_SCORE < mindist)
201 spot.colormod = '1 0 0';
206 spot.colormod = '0 1 0';
207 spot.scale = spot.SPAWNPOINT_SCORE / mindist;
211 if(spot.SPAWNPOINT_SCORE >= 0) // spawning allowed here
213 if(spot.SPAWNPOINT_SCORE < mindist)
215 // too short distance
216 spawn_allgood = FALSE;
221 spawn_allbad = FALSE;
224 spotlistend.chain = spot;
231 if(spot.team != teamcheck)
232 error("invalid spawn added");
234 print("added ", etos(spot), "\n");
240 spotlistend.chain = world;
245 for(e = spotlist; e; e = e.chain)
247 print("seen ", etos(e), "\n");
248 if(e.team != teamcheck)
249 error("invalid spawn found");
256 entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
258 // weight of a point: bound(lower, mindisttoplayer, upper)^exponent
259 // multiplied by spot.cnt (useful if you distribute many spawnpoints in a small area)
262 RandomSelection_Init();
263 for(spot = firstspot; spot; spot = spot.chain)
264 RandomSelection_Add(spot, 0, pow(bound(lower, spot.SPAWNPOINT_SCORE, upper), exponent) * spot.cnt, spot.SPAWNPOINT_SCORE >= lower);
266 return RandomSelection_chosen_ent;
273 Finds a point to respawn
276 entity SelectSpawnPoint (float anypoint)
278 local float teamcheck;
279 local entity firstspot_new;
280 local entity spot, firstspot, playerlist;
282 spot = find (world, classname, "testplayerstart");
288 if(!anypoint && have_team_spawns)
289 teamcheck = self.team;
291 // get the list of players
292 playerlist = findchain(classname, "player");
293 // get the entire list of spots
294 firstspot = findchain(classname, "info_player_deathmatch");
295 // filter out the bad ones
296 // (note this returns the original list if none survived)
297 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 100, teamcheck);
299 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, -1, teamcheck);
300 firstspot = firstspot_new;
302 // there is 50/50 chance of choosing a random spot or the furthest spot
303 // (this means that roughly every other spawn will be furthest, so you
304 // usually won't get fragged at spawn twice in a row)
305 if (arena_roundbased)
307 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 800, teamcheck);
309 firstspot = firstspot_new;
310 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
312 else if (random() > cvar("g_spawn_furthest"))
313 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
315 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
317 if(cvar("spawn_debugview"))
319 print("spot mindistance: ", ftos(spot.SPAWNPOINT_SCORE), "\n");
323 for(e = firstspot; e; e = e.chain)
324 if(e.team != teamcheck)
325 error("invalid spawn found");
330 if(cvar("spawn_debug"))
334 if(some_spawn_has_been_used)
335 return world; // team can't spawn any more, because of actions of other team
337 error("Cannot find a spawn point - please fix the map!");
348 Checks if the argument string can be a valid playermodel.
349 Returns a valid one in doubt.
352 string FallbackPlayerModel = "models/player/marine.zym";
353 string CheckPlayerModel(string plyermodel) {
354 if(strlen(plyermodel) < 4)
355 return FallbackPlayerModel;
356 if( substring(plyermodel,0,14) != "models/player/")
357 return FallbackPlayerModel;
358 else if(cvar("sv_servermodelsonly"))
360 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".zym")
361 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".dpm")
362 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".md3")
363 if(substring(plyermodel,strlen(plyermodel)-4,4) != ".psk")
364 return FallbackPlayerModel;
365 if(plyermodel != strtolower(plyermodel))
366 return FallbackPlayerModel;
367 if(!fexists(plyermodel))
368 return FallbackPlayerModel;
375 Client_customizeentityforclient
380 float Client_customizeentityforclient()
382 #ifdef ALLOW_VARIABLE_LOD
384 // other: the player viewing me
388 if(self.classname != "player")
391 if(other.cvar_cl_playerdetailreduction <= 0)
393 if(other.cvar_cl_playerdetailreduction <= -2)
394 self.modelindex = self.modelindex_lod2;
395 else if(other.cvar_cl_playerdetailreduction <= -1)
396 self.modelindex = self.modelindex_lod1;
398 self.modelindex = self.modelindex_lod0;
402 distance = vlen(self.origin - other.origin);
403 f = (distance + 100.0) * other.cvar_cl_playerdetailreduction;
405 self.modelindex = self.modelindex_lod2;
407 self.modelindex = self.modelindex_lod1;
409 self.modelindex = self.modelindex_lod0;
416 void UpdatePlayerSounds();
417 void setmodel_lod(entity e, string modelname)
419 #ifdef ALLOW_VARIABLE_LOD
422 // FIXME: this only supports 3-letter extensions
423 s = strcat(substring(modelname, 0, strlen(modelname) - 4), "_1", substring(modelname, 0, strlen(modelname) - 4));
427 setmodel(e, s); // players have high precision
428 self.modelindex_lod1 = self.modelindex;
431 self.modelindex_lod1 = -1;
433 s = strcat(substring(modelname, 0, strlen(modelname) - 4), "_2", substring(modelname, 0, strlen(modelname) - 4));
437 setmodel(e, s); // players have high precision
438 self.modelindex_lod2 = self.modelindex;
441 self.modelindex_lod2 = -1;
443 precache_model(modelname);
444 setmodel(e, modelname); // players have high precision
445 self.modelindex_lod0 = self.modelindex;
447 if(self.modelindex_lod1 < 0)
448 self.modelindex_lod1 = self.modelindex;
450 if(self.modelindex_lod2 < 0)
451 self.modelindex_lod2 = self.modelindex;
453 precache_model(modelname);
454 setmodel(e, modelname); // players have high precision
456 player_setupanimsformodel();
457 UpdatePlayerSounds();
464 putting a client as observer in the server
467 void PutObserverInServer (void)
471 race_PreSpawnObserver();
473 spot = SelectSpawnPoint (TRUE);
475 error("No spawnpoints for observers?!?\n");
476 RemoveGrapplingHook(self); // Wazat's Grappling Hook
478 if(clienttype(self) == CLIENTTYPE_REAL)
481 WriteByte(MSG_ONE, SVC_SETVIEW);
482 WriteEntity(MSG_ONE, self);
486 kh_Key_DropAll(self, TRUE);
488 Portal_ClearAll(self);
491 DropFlag(self.flagcarried, world, world);
493 DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
495 WaypointSprite_PlayerDead();
497 if(self.killcount != -666)
501 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
502 bprint ("^4", self.netname, "^4 has no more lives left\n");
504 bprint ("^4", self.netname, "^4 is spectating now\n"); // TODO turn this into a proper forfeit?
507 bprint ("^4", self.netname, "^4 is spectating now\n");
510 PlayerScore_Clear(self); // clear scores when needed
512 self.spectatortime = time;
514 self.classname = "observer";
515 self.iscreature = FALSE;
517 self.takedamage = DAMAGE_NO;
518 self.solid = SOLID_NOT;
519 self.movetype = MOVETYPE_NOCLIP;
520 self.flags = FL_CLIENT | FL_NOTARGET;
521 self.armorvalue = 666;
523 self.armorvalue = cvar("g_balance_armor_start");
524 self.pauserotarmor_finished = 0;
525 self.pauserothealth_finished = 0;
526 self.pauseregen_finished = 0;
527 self.damageforcescale = 0;
534 self.pain_finished = 0;
535 self.strength_finished = 0;
536 self.invincible_finished = 0;
538 self.think = SUB_Null;
542 self.deadflag = DEAD_NO;
543 self.angles = spot.angles;
545 self.fixangle = TRUE;
548 self.view_ofs = PL_VIEW_OFS;
549 setorigin (self, spot.origin);
550 setsize (self, '0 0 0', '0 0 0');
551 self.prevorigin = self.origin;
557 self.weaponmodel = "";
558 self.weaponentity = world;
559 self.exteriorweaponentity = world;
560 self.killcount = -666;
561 self.velocity = '0 0 0';
562 self.avelocity = '0 0 0';
563 self.punchangle = '0 0 0';
564 self.punchvector = '0 0 0';
565 self.oldvelocity = self.velocity;
566 self.customizeentityforclient = Client_customizeentityforclient;
572 if(self.version_mismatch)
574 Spawnqueue_Unmark(self);
575 Spawnqueue_Remove(self);
579 Spawnqueue_Insert(self);
584 // Only if the player cannot play at all
585 if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666)
586 self.frags = FRAGS_SPECTATOR;
588 self.frags = FRAGS_LMS_LOSER;
591 self.frags = FRAGS_SPECTATOR;
594 float RestrictSkin(float s)
603 void FixPlayermodel()
605 local string defaultmodel;
606 local float defaultskin;
611 if(cvar("sv_defaultcharacter") == 1) {
616 defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", Team_ColorNameLowerCase(self.team)));
617 defaultskin = cvar(strcat("sv_defaultplayerskin_", Team_ColorNameLowerCase(self.team)));
620 if(defaultmodel == "")
622 defaultmodel = cvar_string("sv_defaultplayermodel");
623 defaultskin = cvar("sv_defaultplayerskin");
627 if(self.modelindex == 0 && self.deadflag == DEAD_NO)
630 bprint("\{1}^1Player ", self.netname, "^1 has a zero modelindex, trying to fix...\n");
631 self.model = ""; // force the != checks to return true
634 if(defaultmodel != "")
636 if (defaultmodel != self.model)
640 setmodel_lod (self, defaultmodel);
641 setsize (self, m1, m2);
644 self.skin = defaultskin;
646 if (self.playermodel != self.model)
648 self.playermodel = CheckPlayerModel(self.playermodel);
651 setmodel_lod (self, self.playermodel);
652 setsize (self, m1, m2);
655 self.skin = RestrictSkin(stof(self.playerskin));
659 if(strlen(cvar_string("sv_defaultplayercolors")))
660 if(self.clientcolors != cvar("sv_defaultplayercolors"))
661 setcolor(self, cvar("sv_defaultplayercolors"));
664 void PlayerTouchExplode(entity p1, entity p2)
667 org = (p1.origin + p2.origin) * 0.5;
668 org_z += (p1.mins_z + p2.mins_z) * 0.5;
675 RadiusDamage(e, world, g_touchexplode_damage, g_touchexplode_edgedamage, g_touchexplode_radius, world, g_touchexplode_force, DEATH_TOUCHEXPLODE, world);
683 Called when a client spawns in the server
686 //void() ctf_playerchanged;
687 void PutClientInServer (void)
689 if(clienttype(self) == CLIENTTYPE_BOT)
691 self.classname = "player";
693 else if(clienttype(self) == CLIENTTYPE_REAL)
696 WriteByte(MSG_ONE, SVC_SETVIEW);
697 WriteEntity(MSG_ONE, self);
700 // player is dead and becomes observer
701 // FIXME fix LMS scoring for new system
704 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
705 self.classname = "observer";
710 self.classname = "observer";
712 if(self.classname == "player") {
713 entity spot, oldself;
716 JoinBestTeam(self, FALSE, TRUE);
720 spot = SelectSpawnPoint (FALSE);
723 centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
724 return; // spawn failed
727 RemoveGrapplingHook(self); // Wazat's Grappling Hook
728 self.campingrifle_bulletcounter = 0;
730 self.classname = "player";
731 self.wasplayer = TRUE;
732 self.iscreature = TRUE;
733 self.movetype = MOVETYPE_WALK;
734 self.solid = SOLID_SLIDEBOX;
735 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
736 self.frags = FRAGS_PLAYER;
737 if(independent_players)
738 MAKE_INDEPENDENT_PLAYER(self);
739 self.flags = FL_CLIENT;
740 self.takedamage = DAMAGE_AIM;
742 self.effects = EF_FULLBRIGHT;
745 self.air_finished = time + 12;
750 self.ammo_shells = warmup_start_ammo_shells;
751 self.ammo_nails = warmup_start_ammo_nails;
752 self.ammo_rockets = warmup_start_ammo_rockets;
753 self.ammo_cells = warmup_start_ammo_cells;
754 self.ammo_fuel = warmup_start_ammo_fuel;
755 self.health = warmup_start_health;
756 self.armorvalue = warmup_start_armorvalue;
757 self.weapons = warmup_start_weapons;
761 self.ammo_shells = start_ammo_shells;
762 self.ammo_nails = start_ammo_nails;
763 self.ammo_rockets = start_ammo_rockets;
764 self.ammo_cells = start_ammo_cells;
765 self.ammo_fuel = start_ammo_fuel;
766 self.health = start_health;
767 self.armorvalue = start_armorvalue;
768 self.weapons = start_weapons;
770 self.items = start_items;
771 self.switchweapon = w_getbestweapon(self);
772 self.cnt = self.switchweapon;
774 self.jump_interval = time;
776 self.spawnshieldtime = time + cvar("g_spawnshieldtime");
777 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
778 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
779 self.pauserotfuel_finished = time + cvar("g_balance_pause_fuel_rot_spawn");
780 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
781 //extend the pause of rotting if client was reset at the beginning of the countdown
782 if(!cvar("sv_ready_restart_after_countdown") && time < game_starttime) { // TODO why is this cvar NOTted?
783 self.spawnshieldtime += game_starttime - time;
784 self.pauserotarmor_finished += game_starttime - time;
785 self.pauserothealth_finished += game_starttime - time;
786 self.pauseregen_finished += game_starttime - time;
788 self.damageforcescale = 2;
795 self.pain_finished = 0;
796 self.strength_finished = 0;
797 self.invincible_finished = 0;
799 //self.speed_finished = 0;
800 //self.slowmo_finished = 0;
801 // players have no think function
802 self.think = SUB_Null;
811 self.deadflag = DEAD_NO;
813 self.angles = spot.angles;
815 self.angles_z = 0; // never spawn tilted even if the spot says to
816 self.fixangle = TRUE; // turn this way immediately
817 self.velocity = '0 0 0';
818 self.avelocity = '0 0 0';
819 self.punchangle = '0 0 0';
820 self.punchvector = '0 0 0';
821 self.oldvelocity = self.velocity;
824 WRITESPECTATABLE_MSG_ONE({
825 WriteByte(MSG_ONE, SVC_TEMPENTITY);
826 WriteByte(MSG_ONE, TE_CSQC_SPAWN);
829 self.customizeentityforclient = Client_customizeentityforclient;
835 self.view_ofs = PL_VIEW_OFS;
836 setsize (self, PL_MIN, PL_MAX);
837 self.spawnorigin = spot.origin;
838 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
839 // don't reset back to last position, even if new position is stuck in solid
840 self.oldorigin = self.origin;
841 self.prevorigin = self.origin;
845 Spawnqueue_Remove(self);
846 Spawnqueue_Mark(self);
849 self.event_damage = PlayerDamage;
851 self.bot_attack = TRUE;
853 self.statdraintime = time + 5;
854 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
856 if(self.killcount == -666) {
857 PlayerScore_Clear(self);
861 self.cnt = WEP_LASER;
862 self.nixnex_lastchange_id = -1;
864 CL_SpawnWeaponentity();
865 self.alpha = default_player_alpha;
866 self.colormod = '1 1 1' * cvar("g_player_brightness");
867 self.exteriorweaponentity.alpha = default_weapon_alpha;
869 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
870 self.lms_traveled_distance = 0;
871 self.speedrunning = FALSE;
873 race_PostSpawn(spot);
875 if(cvar("spawn_debug"))
877 sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n"));
878 remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
881 //stuffcmd(self, "chase_active 0");
882 //stuffcmd(self, "set viewsize $tmpviewsize \n");
884 if (cvar("g_spawnsound"))
885 sound (self, CHAN_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
888 if(self.team == assault_attacker_team)
889 centerprint(self, "You are attacking!");
891 centerprint(self, "You are defending!");
894 target_voicescript_clear(self);
903 } else if(self.classname == "observer") {
904 PutObserverInServer ();
908 // ctf_playerchanged();
911 float ClientInit_SendEntity(entity to, float sf)
914 WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
915 WriteByte(MSG_ENTITY, g_nexball_meter_period * 32);
916 for(i = 1; i <= 24; ++i)
917 WriteByte(MSG_ENTITY, (get_weaponinfo(i)).impulse + 1);
918 WriteCoord(MSG_ENTITY, hook_shotorigin_x);
919 WriteCoord(MSG_ENTITY, hook_shotorigin_y);
920 WriteCoord(MSG_ENTITY, hook_shotorigin_z);
922 if(sv_foginterval && world.fog != "")
923 WriteString(MSG_ENTITY, world.fog);
925 WriteString(MSG_ENTITY, "");
930 void ClientInit_Spawn()
932 Net_LinkEntity(spawn(), FALSE, 0, ClientInit_SendEntity);
940 void SetNewParms (void)
942 // initialize parms for a new player
943 parm1 = -(86400 * 366);
951 void SetChangeParms (void)
953 // save parms for level change
954 parm1 = self.parm_idlesince - time;
962 void DecodeLevelParms (void)
965 self.parm_idlesince = parm1;
966 if(self.parm_idlesince == -(86400 * 366))
967 self.parm_idlesince = time;
969 // whatever happens, allow 60 seconds of idling directly after connect for map loading
970 self.parm_idlesince = max(self.parm_idlesince, time - sv_maxidle + 60);
977 Called when a client types 'kill' in the console
981 void ClientKill_Now_TeamChange()
983 if(self.killindicator_teamchange == -1)
986 JoinBestTeam( self, FALSE, FALSE );
989 SV_ChangeTeam(self.killindicator_teamchange - 1);
992 void ClientKill_Now()
994 if(self.killindicator_teamchange)
995 ClientKill_Now_TeamChange();
998 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
1000 if(self.killindicator)
1002 dprint("Cleaned up after a leaked kill indicator.\n");
1003 remove(self.killindicator);
1004 self.killindicator = world;
1007 void KillIndicator_Think()
1009 if (!self.owner.modelindex)
1011 self.owner.killindicator = world;
1019 ClientKill_Now(); // no oldself needed
1025 setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
1026 if(clienttype(self.owner) == CLIENTTYPE_REAL)
1029 announce(self.owner, strcat("announcer/robotic/", ftos(self.cnt), ".wav"));
1030 if(self.owner.killindicator_teamchange)
1032 if(self.owner.killindicator_teamchange == -1)
1033 centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
1035 centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
1038 centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
1040 self.nextthink = time + 1;
1045 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
1049 killtime = cvar("g_balance_kill_delay");
1051 self.killindicator_teamchange = targetteam;
1053 if(!self.killindicator)
1055 if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
1061 self.killindicator = spawn();
1062 self.killindicator.owner = self;
1063 self.killindicator.scale = 0.5;
1064 setattachment(self.killindicator, self, "");
1065 setorigin(self.killindicator, '0 0 52');
1066 self.killindicator.think = KillIndicator_Think;
1067 self.killindicator.nextthink = time + (self.lip) * 0.05;
1068 self.killindicator.cnt = ceil(killtime);
1069 self.killindicator.count = bound(0, ceil(killtime), 10);
1070 sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
1072 for(e = world; (e = find(e, classname, "body")) != world; )
1076 e.killindicator = spawn();
1077 e.killindicator.owner = e;
1078 e.killindicator.scale = 0.5;
1079 setattachment(e.killindicator, e, "");
1080 setorigin(e.killindicator, '0 0 52');
1081 e.killindicator.think = KillIndicator_Think;
1082 e.killindicator.nextthink = time + (e.lip) * 0.05;
1083 e.killindicator.cnt = ceil(killtime);
1088 if(self.killindicator)
1091 self.killindicator.colormod = TeamColor(targetteam);
1093 self.killindicator.colormod = '0 0 0';
1097 void ClientKill (void)
1099 ClientKill_TeamChange(0);
1102 void DoTeamChange(float destteam)
1108 SetPlayerColors(self, destteam);
1111 if(self.classname == "player")
1114 CheckAllowedTeams(self);
1115 t = FindSmallestTeam(self, TRUE);
1118 case COLOR_TEAM1: c0 = c1; break;
1119 case COLOR_TEAM2: c0 = c2; break;
1120 case COLOR_TEAM3: c0 = c3; break;
1121 case COLOR_TEAM4: c0 = c4; break;
1128 destteam = COLOR_TEAM1;
1132 destteam = COLOR_TEAM2;
1136 destteam = COLOR_TEAM3;
1140 destteam = COLOR_TEAM4;
1146 if(destteam == self.team && destteam >= 0 && !self.killindicator)
1148 ClientKill_TeamChange(destteam);
1151 void FixClientCvars(entity e)
1153 // send prediction settings to the client
1154 stuffcmd(e, "\nin_bindmap 0 0\n");
1156 * we no longer need to stuff this. Remove this comment block if you feel
1157 * 2.3 and higher (or was it 2.2.3?) don't need these any more
1158 stuffcmd(e, strcat("cl_gravity ", ftos(cvar("sv_gravity")), "\n"));
1159 stuffcmd(e, strcat("cl_movement_accelerate ", ftos(cvar("sv_accelerate")), "\n"));
1160 stuffcmd(e, strcat("cl_movement_friction ", ftos(cvar("sv_friction")), "\n"));
1161 stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(cvar("sv_maxspeed")), "\n"));
1162 stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(cvar("sv_airaccelerate")), "\n"));
1163 stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(cvar("sv_maxairspeed")), "\n"));
1164 stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(cvar("sv_stopspeed")), "\n"));
1165 stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(cvar("sv_jumpvelocity")), "\n"));
1166 stuffcmd(e, strcat("cl_movement_stepheight ", ftos(cvar("sv_stepheight")), "\n"));
1167 stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(cvar("sv_friction_on_land")), "\n"));
1168 stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(cvar("sv_airaccel_qw")), "\n"));
1169 stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(cvar("sv_airaccel_sideways_friction")), "\n"));
1170 stuffcmd(e, "cl_movement_edgefriction 1\n");
1178 Called when a client connects to the server
1181 //void ctf_clientconnect();
1182 string ColoredTeamName(float t);
1183 void DecodeLevelParms (void);
1184 //void dom_player_join_team(entity pl);
1185 void ClientConnect (void)
1190 if(self.flags & FL_CLIENT)
1192 print("Warning: ClientConnect, but already connected!\n");
1196 if(Ban_MaybeEnforceBan(self))
1201 self.classname = "player_joining";
1203 self.flags = FL_CLIENT;
1204 self.version_nagtime = time + 10 + random() * 10;
1208 dprint("BUG player count is lower than zero, this cannot happen!\n");
1212 PlayerScore_Attach(self);
1213 ClientData_Attach();
1215 bot_clientconnect();
1217 race_PreSpawnObserver();
1220 // dom_player_join_team(self);
1222 JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it
1224 if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign")) {
1225 self.classname = "observer";
1229 if(cvar("g_balance_teams") || cvar("g_balance_teams_force"))
1231 self.classname = "player";
1232 campaign_bots_may_start = 1;
1236 self.classname = "observer"; // do it anyway
1241 self.classname = "player";
1242 campaign_bots_may_start = 1;
1246 self.playerid = (playerid_last = playerid_last + 1);
1247 if(cvar("sv_eventlog"))
1249 if(clienttype(self) == CLIENTTYPE_REAL)
1250 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", self.netaddress, ":", self.netname));
1252 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":bot:", self.netname));
1253 s = strcat(":team:", ftos(self.playerid), ":");
1254 s = strcat(s, ftos(self.team));
1257 self.netname_previous = strzone(self.netname);
1259 //stuffcmd(self, "set tmpviewsize $viewsize \n");
1261 bprint ("^4",self.netname);
1262 bprint ("^4 connected");
1264 if(g_domination || g_ctf)
1266 bprint(" and joined the ");
1267 bprint(ColoredTeamName(self.team));
1272 self.welcomemessage_time = 0;
1274 stuffcmd(self, strcat(clientstuff, "\n"));
1275 stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n"));
1276 stuffcmd(self, "cl_particles_reloadeffects\n");
1278 FixClientCvars(self);
1280 // spawnfunc_waypoint sprites
1281 WaypointSprite_InitClient(self);
1283 // Wazat's grappling hook
1284 SetGrappleHookBindings();
1286 // get autoswitch state from player when he toggles it
1287 stuffcmd(self, "alias autoswitch \"set cl_autoswitch $1 ; cmd autoswitch $1\"\n"); // default.cfg-ed in 2.4.1
1289 // get version info from player
1290 stuffcmd(self, "cmd clientversion $gameversion\n");
1292 // get other cvars from player
1295 // set cvar for team scoreboard
1296 stuffcmd(self, strcat("set teamplay ", ftos(teamplay), "\n"));
1298 // notify about available teams
1301 CheckAllowedTeams(self);
1302 t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
1303 stuffcmd(self, strcat("set _teams_available ", ftos(t), "\n"));
1306 stuffcmd(self, "set _teams_available 0\n");
1308 stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
1312 self.classname = "observer";
1313 Spawnqueue_Insert(self);
1317 ctf_clientconnect();
1320 if(teams_matter || sv_cheats)
1323 bot_relinkplayerlist();
1325 self.spectatortime = time;
1328 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"));
1331 self.jointime = time;
1332 self.allowedTimeouts = cvar("sv_timeout_number");
1334 if(clienttype(self) == CLIENTTYPE_REAL)
1336 if(cvar("g_bugrigs"))
1337 stuffcmd(self, "cl_cmd settemp chase_active 1\n");
1342 if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
1344 PlayerScore_Add(self, SP_LMS_RANK, 666);
1345 self.frags = FRAGS_SPECTATOR;
1349 if(!sv_foginterval && world.fog != "")
1350 stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
1352 SoundEntity_Attach(self);
1359 Called when a client disconnects from the server
1362 .entity chatbubbleentity;
1363 .entity teambubbleentity;
1365 void ClientDisconnect (void)
1367 if not(self.flags & FL_CLIENT)
1369 print("Warning: ClientDisconnect without ClientConnect\n");
1373 bot_clientdisconnect();
1378 if(cvar("sv_eventlog"))
1379 GameLogEcho(strcat(":part:", ftos(self.playerid)));
1380 bprint ("^4",self.netname);
1381 bprint ("^4 disconnected\n");
1383 SoundEntity_Detach(self);
1386 kh_Key_DropAll(self, TRUE);
1388 Portal_ClearAll(self);
1390 if(self.flagcarried)
1391 DropFlag(self.flagcarried, world, world);
1392 if(self.ballcarried)
1393 DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
1395 // Here, everything has been done that requires this player to be a client.
1397 self.flags &~= FL_CLIENT;
1399 if (self.chatbubbleentity)
1400 remove (self.chatbubbleentity);
1402 if (self.teambubbleentity)
1403 remove (self.teambubbleentity);
1405 if (self.killindicator)
1406 remove (self.killindicator);
1408 WaypointSprite_PlayerGone();
1410 bot_relinkplayerlist();
1413 if(self.weaponentity)
1414 if(self.weaponentity.lasertarget)
1415 remove(self.weaponentity.lasertarget);
1419 Spawnqueue_Unmark(self);
1420 Spawnqueue_Remove(self);
1423 ClientData_Detach();
1424 PlayerScore_Detach(self);
1426 if(self.netname_previous)
1427 strunzone(self.netname_previous);
1429 ClearPlayerSounds();
1439 void ChatBubbleThink()
1441 self.nextthink = time;
1442 if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
1444 if(self.owner) // but why can that ever be world?
1445 self.owner.chatbubbleentity = world;
1449 if (self.owner.BUTTON_CHAT && !self.owner.deadflag)
1450 self.model = self.mdl;
1455 void UpdateChatBubble()
1457 if (!self.modelindex)
1459 // spawn a chatbubble entity if needed
1460 if (!self.chatbubbleentity)
1462 self.chatbubbleentity = spawn();
1463 self.chatbubbleentity.owner = self;
1464 self.chatbubbleentity.exteriormodeltoclient = self;
1465 self.chatbubbleentity.think = ChatBubbleThink;
1466 self.chatbubbleentity.nextthink = time;
1467 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
1468 //setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1469 setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
1470 setattachment(self.chatbubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
1471 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
1472 self.chatbubbleentity.model = "";
1473 self.chatbubbleentity.effects = EF_LOWPRECISION;
1478 void TeamBubbleThink()
1480 self.nextthink = time;
1481 if (!self.owner.modelindex || self.owner.teambubbleentity != self)
1483 if(self.owner) // but why can that ever be world?
1484 self.owner.teambubbleentity = world;
1488 // setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1'); // bandwidth hog. setattachment does this now
1489 if (self.owner.BUTTON_CHAT || self.owner.deadflag || self.owner.killindicator)
1492 self.model = self.mdl;
1496 float TeamBubble_customizeentityforclient()
1498 return (self.owner != other && self.owner.team == other.team && other.killcount > -666);
1501 void UpdateTeamBubble()
1503 if (!self.modelindex || !teams_matter)
1505 // spawn a teambubble entity if needed
1506 if (!self.teambubbleentity && teams_matter)
1508 self.teambubbleentity = spawn();
1509 self.teambubbleentity.owner = self;
1510 self.teambubbleentity.exteriormodeltoclient = self;
1511 self.teambubbleentity.think = TeamBubbleThink;
1512 self.teambubbleentity.nextthink = time;
1513 setmodel(self.teambubbleentity, "models/misc/teambubble.spr"); // precision set below
1514 // setorigin(self.teambubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
1515 setorigin(self.teambubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
1516 setattachment(self.teambubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
1517 self.teambubbleentity.mdl = self.teambubbleentity.model;
1518 self.teambubbleentity.model = self.teambubbleentity.mdl;
1519 self.teambubbleentity.customizeentityforclient = TeamBubble_customizeentityforclient;
1520 self.teambubbleentity.effects = EF_LOWPRECISION;
1524 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
1525 // added to the model skins
1526 /*void UpdateColorModHack()
1529 c = self.clientcolors & 15;
1530 // LordHavoc: only bothering to support white, green, red, yellow, blue
1531 if (!teams_matter) self.colormod = '0 0 0';
1532 else if (c == 0) self.colormod = '1.00 1.00 1.00';
1533 else if (c == 3) self.colormod = '0.10 1.73 0.10';
1534 else if (c == 4) self.colormod = '1.73 0.10 0.10';
1535 else if (c == 12) self.colormod = '1.22 1.22 0.10';
1536 else if (c == 13) self.colormod = '0.10 0.10 1.73';
1537 else self.colormod = '1 1 1';
1543 self.effects |= EF_NODRAW; // prevent another CopyBody
1544 PutClientInServer();
1547 void play_countdown(float finished, string samp)
1549 if(clienttype(self) == CLIENTTYPE_REAL)
1550 if(floor(finished - time - frametime) != floor(finished - time))
1551 if(finished - time < 6)
1552 sound (self, CHAN_AUTO, samp, VOL_BASE, ATTN_NORM);
1556 * When sv_timeout is used this function returs strings like
1557 * "Timeout begins in 2 seconds!\n" or "Timeout ends in 23 seconds!\n".
1558 * Called by centerprint functions
1559 * @param addOneSecond boolean, set to 1 if the welcome-message centerprint asks for the text
1561 string getTimeoutText(float addOneSecond) {
1562 if (!cvar("sv_timeout") || !timeoutStatus)
1565 local string retStr;
1566 if (timeoutStatus == 1) {
1567 if (addOneSecond == 1) {
1568 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime + 1), " seconds!\n");
1571 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
1575 else if (timeoutStatus == 2) {
1577 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
1578 //don't show messages like "Timeout ends in 0 seconds"...
1579 if ((remainingTimeoutTime + 1) > 0)
1585 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
1586 //don't show messages like "Timeout ends in 0 seconds"...
1587 if (remainingTimeoutTime > 0)
1596 void player_powerups (void)
1598 if((self.items & IT_USING_JETPACK) && !self.deadflag)
1600 SoundEntity_StartSound(self, CHAN_PLAYER, "misc/jetpack_fly.wav", VOL_BASE, ATTN_IDLE);
1601 self.modelflags |= MF_ROCKET;
1605 SoundEntity_StopSound(self, CHAN_PLAYER);
1606 self.modelflags &~= MF_ROCKET;
1609 self.effects &~= (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
1611 if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
1616 if (self.items & IT_STRENGTH)
1618 play_countdown(self.strength_finished, "misc/poweroff.wav");
1619 if (time > self.strength_finished)
1621 self.alpha = default_player_alpha;
1622 self.exteriorweaponentity.alpha = default_weapon_alpha;
1623 self.items &~= IT_STRENGTH;
1624 sprint(self, "^3Invisibility has worn off\n");
1629 if (time < self.strength_finished)
1631 self.alpha = g_minstagib_invis_alpha;
1632 self.exteriorweaponentity.alpha = g_minstagib_invis_alpha;
1633 self.items |= IT_STRENGTH;
1634 sprint(self, "^3You are invisible\n");
1638 if (self.items & IT_INVINCIBLE)
1640 play_countdown(self.invincible_finished, "misc/poweroff.wav");
1641 if (time > self.invincible_finished)
1643 self.items = self.items - (self.items & IT_INVINCIBLE);
1644 sprint(self, "^3Speed has worn off\n");
1649 if (time < self.invincible_finished)
1651 self.items = self.items | IT_INVINCIBLE;
1652 sprint(self, "^3You are on speed\n");
1658 if (self.items & IT_STRENGTH)
1660 play_countdown(self.strength_finished, "misc/poweroff.wav");
1661 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
1662 if (time > self.strength_finished)
1664 self.items = self.items - (self.items & IT_STRENGTH);
1665 sprint(self, "^3Strength has worn off\n");
1670 if (time < self.strength_finished)
1672 self.items = self.items | IT_STRENGTH;
1673 sprint(self, "^3Strength infuses your weapons with devastating power\n");
1676 if (self.items & IT_INVINCIBLE)
1678 play_countdown(self.invincible_finished, "misc/poweroff.wav");
1679 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
1680 if (time > self.invincible_finished)
1682 self.items = self.items - (self.items & IT_INVINCIBLE);
1683 sprint(self, "^3Shield has worn off\n");
1688 if (time < self.invincible_finished)
1690 self.items = self.items | IT_INVINCIBLE;
1691 sprint(self, "^3Shield surrounds you\n");
1695 if (cvar("g_fullbrightplayers"))
1696 self.effects = self.effects | EF_FULLBRIGHT;
1698 // midair gamemode: damage only while in the air
1699 // if in midair mode, being on ground grants temporary invulnerability
1700 // (this is so that multishot weapon don't clear the ground flag on the
1701 // first damage in the frame, leaving the player vulnerable to the
1702 // remaining hits in the same frame)
1703 if (self.flags & FL_ONGROUND)
1705 self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
1707 if (time >= game_starttime)
1708 if (time < self.spawnshieldtime)
1709 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
1712 float CalcRegen(float current, float stable, float regenfactor)
1714 if(current > stable)
1716 else if(current > stable - 0.25) // when close enough, "snap"
1719 return min(stable, current + (stable - current) * regenfactor * frametime);
1722 void player_regen (void)
1724 float maxh, maxa, maxf, limith, limita, limitf, max_mod, regen_mod, rot_mod, limit_mod;
1725 maxh = cvar("g_balance_health_stable");
1726 maxa = cvar("g_balance_armor_stable");
1727 maxf = cvar("g_balance_fuel_stable");
1728 limith = cvar("g_balance_health_limit");
1729 limita = cvar("g_balance_armor_limit");
1730 limitf = cvar("g_balance_fuel_limit");
1732 if (g_minstagib || (g_lms && !cvar("g_lms_regenerate")))
1735 max_mod = regen_mod = rot_mod = limit_mod = 1;
1737 if (self.runes & RUNE_REGEN)
1739 if (self.runes & CURSE_VENOM) // do we have both rune/curse?
1741 regen_mod = cvar("g_balance_rune_regen_combo_regenrate");
1742 max_mod = cvar("g_balance_rune_regen_combo_hpmod");
1743 limit_mod = cvar("g_balance_rune_regen_combo_limitmod");
1747 regen_mod = cvar("g_balance_rune_regen_regenrate");
1748 max_mod = cvar("g_balance_rune_regen_hpmod");
1749 limit_mod = cvar("g_balance_rune_regen_limitmod");
1752 else if (self.runes & CURSE_VENOM)
1754 max_mod = cvar("g_balance_curse_venom_hpmod");
1755 if (self.runes & RUNE_REGEN) // do we have both rune/curse?
1756 rot_mod = cvar("g_balance_rune_regen_combo_rotrate");
1758 rot_mod = cvar("g_balance_curse_venom_rotrate");
1759 limit_mod = cvar("g_balance_curse_venom_limitmod");
1760 //if (!self.runes & RUNE_REGEN)
1761 // rot_mod = cvar("g_balance_curse_venom_rotrate");
1763 maxh = maxh * max_mod;
1764 //maxa = maxa * max_mod;
1765 //maxf = maxf * max_mod;
1766 limith = limith * limit_mod;
1767 limita = limita * limit_mod;
1768 //limitf = limitf * limit_mod;
1770 if (self.armorvalue > maxa)
1772 if (time > self.pauserotarmor_finished)
1774 self.armorvalue = max(maxa, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_rot") * frametime);
1775 self.armorvalue = max(maxa, self.armorvalue - cvar("g_balance_armor_rotlinear") * frametime);
1778 else if (self.armorvalue < maxa)
1780 if (time > self.pauseregen_finished)
1782 self.armorvalue = CalcRegen(self.armorvalue, maxa, cvar("g_balance_armor_regen"));
1783 self.armorvalue = min(maxa, self.armorvalue + cvar("g_balance_armor_regenlinear") * frametime);
1786 if (self.health > maxh)
1788 if (time > self.pauserothealth_finished)
1790 self.health = max(maxh, self.health + (maxh - self.health) * rot_mod*cvar("g_balance_health_rot") * frametime);
1791 self.health = max(maxh, self.health - rot_mod*cvar("g_balance_health_rotlinear") * frametime);
1794 else if (self.health < maxh)
1796 if (time > self.pauseregen_finished)
1798 self.health = CalcRegen(self.health, maxh, regen_mod * cvar("g_balance_health_regen"));
1799 self.health = min(maxh, self.health + regen_mod*cvar("g_balance_health_regenlinear") * frametime);
1802 if (self.ammo_fuel > maxf)
1804 if (time > self.pauserotfuel_finished)
1806 self.ammo_fuel = max(maxf, self.ammo_fuel + (maxf - self.ammo_fuel) * rot_mod*cvar("g_balance_fuel_rot") * frametime);
1807 self.ammo_fuel = max(maxf, self.ammo_fuel - rot_mod*cvar("g_balance_fuel_rotlinear") * frametime);
1810 else if (self.ammo_fuel < maxf)
1812 if(self.items & IT_FUEL_REGEN)
1814 if (time > self.pauseregen_finished)
1816 self.ammo_fuel = CalcRegen(self.ammo_fuel, maxf, regen_mod * cvar("g_balance_fuel_regen"));
1817 self.ammo_fuel = min(maxf, self.ammo_fuel + regen_mod*cvar("g_balance_fuel_regenlinear") * frametime);
1822 if (self.health > limith)
1823 self.health = limith;
1824 if (self.armorvalue > limita)
1825 self.armorvalue = limita;
1826 if (self.ammo_fuel > limitf)
1827 self.ammo_fuel = limitf;
1829 // if player rotted to death... die!
1831 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
1834 float zoomstate_set;
1835 void SetZoomState(float z)
1837 if(z != self.zoomstate)
1838 ClientData_Touch(self);
1842 void GetPressedKeys(void) {
1843 if (self.movement_x > 0) // get if movement keys are pressed
1844 { // forward key pressed
1845 self.pressedkeys |= KEY_FORWARD;
1846 self.pressedkeys &~= KEY_BACKWARD;
1848 else if (self.movement_x < 0)
1849 { // backward key pressed
1850 self.pressedkeys |= KEY_BACKWARD;
1851 self.pressedkeys &~= KEY_FORWARD;
1855 self.pressedkeys &~= KEY_FORWARD;
1856 self.pressedkeys &~= KEY_BACKWARD;
1859 if (self.movement_y > 0)
1860 { // right key pressed
1861 self.pressedkeys |= KEY_RIGHT;
1862 self.pressedkeys &~= KEY_LEFT;
1864 else if (self.movement_y < 0)
1865 { // left key pressed
1866 self.pressedkeys |= KEY_LEFT;
1867 self.pressedkeys &~= KEY_RIGHT;
1871 self.pressedkeys &~= KEY_RIGHT;
1872 self.pressedkeys &~= KEY_LEFT;
1875 if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed
1876 self.pressedkeys |= KEY_JUMP;
1878 self.pressedkeys &~= KEY_JUMP;
1879 if (self.BUTTON_CROUCH)
1880 self.pressedkeys |= KEY_CROUCH;
1882 self.pressedkeys &~= KEY_CROUCH;
1886 ======================
1887 spectate mode routines
1888 ======================
1890 void SpectateCopy(entity spectatee) {
1891 self.armortype = spectatee.armortype;
1892 self.armorvalue = spectatee.armorvalue;
1893 self.ammo_cells = spectatee.ammo_cells;
1894 self.ammo_shells = spectatee.ammo_shells;
1895 self.ammo_nails = spectatee.ammo_nails;
1896 self.ammo_rockets = spectatee.ammo_rockets;
1897 self.ammo_fuel = spectatee.ammo_fuel;
1898 self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
1899 self.health = spectatee.health;
1901 self.items = spectatee.items;
1902 self.metertime = spectatee.metertime;
1903 self.strength_finished = spectatee.strength_finished;
1904 self.invincible_finished = spectatee.invincible_finished;
1905 self.pressedkeys = spectatee.pressedkeys;
1906 self.weapons = spectatee.weapons;
1907 self.switchweapon = spectatee.switchweapon;
1908 self.weapon = spectatee.weapon;
1909 self.punchangle = spectatee.punchangle;
1910 self.view_ofs = spectatee.view_ofs;
1911 self.v_angle = spectatee.v_angle;
1912 self.velocity = spectatee.velocity;
1913 self.dmg_take = spectatee.dmg_take;
1914 self.dmg_save = spectatee.dmg_save;
1915 self.dmg_inflictor = spectatee.dmg_inflictor;
1916 self.angles = spectatee.v_angle;
1917 self.fixangle = TRUE;
1918 setorigin(self, spectatee.origin);
1919 setsize(self, spectatee.mins, spectatee.maxs);
1920 SetZoomState(spectatee.zoomstate);
1923 float SpectateUpdate() {
1927 if (self == self.enemy)
1930 if(self.enemy.classname != "player")
1933 SpectateCopy(self.enemy);
1938 float SpectateNext() {
1939 other = find(self.enemy, classname, "player");
1941 other = find(other, classname, "player");
1946 if(self.enemy.classname == "player") {
1948 WriteByte(MSG_ONE, SVC_SETVIEW);
1949 WriteEntity(MSG_ONE, self.enemy);
1950 //stuffcmd(self, "set viewsize $tmpviewsize \n");
1951 if(!SpectateUpdate())
1952 PutObserverInServer();
1961 ShowRespawnCountdown()
1963 Update a respawn countdown display.
1966 void ShowRespawnCountdown()
1969 if(self.deadflag == DEAD_NO) // just respawned?
1973 number = ceil(self.death_time - time);
1976 if(number <= self.respawn_countdown)
1978 self.respawn_countdown = number - 1;
1979 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
1980 announce(self, strcat("announcer/robotic/", ftos(number), ".wav"));
1985 void LeaveSpectatorMode()
1987 if(isJoinAllowed()) {
1988 if(!teams_matter || cvar("g_campaign") || cvar("g_balance_teams") || (self.wasplayer && cvar("g_changeteam_banned"))) {
1989 self.classname = "player";
1990 if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force"))
1991 JoinBestTeam(self, FALSE, TRUE);
1992 if(cvar("g_campaign"))
1993 campaign_bots_may_start = 1;
1994 PutClientInServer();
1995 if(self.classname == "player")
1996 bprint ("^4", self.netname, "^4 is playing now\n");
1997 if(!cvar("g_campaign"))
1998 centerprint(self,""); // clear MOTD
2001 stuffcmd(self,"menu_showteamselect\n");
2006 //player may not join because of g_maxplayers is set
2007 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
2012 * Determines whether the player is allowed to join. This depends on cvar
2013 * g_maxplayers, if it isn't used this function always return TRUE, otherwise
2014 * it checks whether the number of currently playing players exceeds g_maxplayers.
2015 * @return bool TRUE if the player is allowed to join, false otherwise
2017 float isJoinAllowed() {
2018 if (!cvar("g_maxplayers"))
2022 local float currentlyPlaying;
2023 FOR_EACH_REALPLAYER(e) {
2024 if(e.classname == "player")
2025 currentlyPlaying += 1;
2027 if(currentlyPlaying < cvar("g_maxplayers"))
2034 * Checks whether the client is an observer or spectator, if so, he will get kicked after
2035 * g_maxplayers_spectator_blocktime seconds
2037 void checkSpectatorBlock() {
2038 if(self.classname == "spectator" || self.classname == "observer") {
2039 if( time > (self.spectatortime + cvar("g_maxplayers_spectator_blocktime")) ) {
2040 sprint(self, "^7You were kicked from the server because you are spectator and spectators aren't allowed at the moment.\n");
2046 float vercmp_recursive(string v1, string v2)
2052 dot1 = strstrofs(v1, ".", 0);
2053 dot2 = strstrofs(v2, ".", 0);
2057 s1 = substring(v1, 0, dot1);
2061 s2 = substring(v2, 0, dot2);
2063 r = stof(s1) - stof(s2);
2067 r = strcasecmp(s1, s2);
2081 s1 = substring(v1, dot1 + 1, -1);
2082 s2 = substring(v2, dot2 + 1, -1);
2083 return vercmp_recursive(s1, s2); // fteqcc sucks
2087 float vercmp(string v1, string v2)
2089 if(strcasecmp(v1, v2) == 0) // early out check
2091 return vercmp_recursive(v1, v2);
2094 void ObserverThink()
2096 if (self.flags & FL_JUMPRELEASED) {
2097 if (self.BUTTON_JUMP && !self.version_mismatch) {
2098 self.welcomemessage_time = 0;
2099 self.flags &~= FL_JUMPRELEASED;
2100 self.flags |= FL_SPAWNING;
2101 } else if(self.BUTTON_ATCK && !self.version_mismatch) {
2102 self.welcomemessage_time = 0;
2103 self.flags &~= FL_JUMPRELEASED;
2104 if(SpectateNext() == 1) {
2105 self.classname = "spectator";
2109 if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) {
2110 self.flags |= FL_JUMPRELEASED;
2111 if(self.flags & FL_SPAWNING)
2113 self.flags &~= FL_SPAWNING;
2114 LeaveSpectatorMode();
2119 PrintWelcomeMessage(self);
2122 void SpectatorThink()
2124 if (self.flags & FL_JUMPRELEASED) {
2125 if (self.BUTTON_JUMP && !self.version_mismatch) {
2126 self.welcomemessage_time = 0;
2127 self.flags &~= FL_JUMPRELEASED;
2128 self.flags |= FL_SPAWNING;
2129 } else if(self.BUTTON_ATCK) {
2130 self.welcomemessage_time = 0;
2131 self.flags &~= FL_JUMPRELEASED;
2132 if(SpectateNext() == 1) {
2133 self.classname = "spectator";
2135 self.classname = "observer";
2136 PutClientInServer();
2138 } else if (self.BUTTON_ATCK2) {
2139 self.welcomemessage_time = 0;
2140 self.flags &~= FL_JUMPRELEASED;
2141 self.classname = "observer";
2142 PutClientInServer();
2144 if(!SpectateUpdate())
2145 PutObserverInServer();
2148 if (!(self.BUTTON_ATCK || self.BUTTON_ATCK2)) {
2149 self.flags |= FL_JUMPRELEASED;
2150 if(self.flags & FL_SPAWNING)
2152 self.flags &~= FL_SPAWNING;
2153 LeaveSpectatorMode();
2158 PrintWelcomeMessage(self);
2159 self.flags |= FL_CLIENT | FL_NOTARGET;
2162 .float touchexplode_time;
2168 Called every frame for each client before the physics are run
2171 void() ctf_setstatus;
2172 void() nexball_setstatus;
2173 void PlayerPreThink (void)
2175 self.stat_sys_ticrate = cvar("sys_ticrate");
2176 self.stat_game_starttime = game_starttime;
2177 self.stat_allow_oldnexbeam = cvar("g_allow_oldnexbeam");
2179 if(blockSpectators && frametime)
2180 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
2181 checkSpectatorBlock();
2185 if(self.netname_previous != self.netname)
2187 if(cvar("sv_eventlog"))
2188 GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname));
2189 if(self.netname_previous)
2190 strunzone(self.netname_previous);
2191 self.netname_previous = strzone(self.netname);
2195 if(self.version_nagtime)
2196 if(self.cvar_g_nexuizversion)
2197 if(time > self.version_nagtime)
2199 if(strstr(self.cvar_g_nexuizversion, "svn", 0) < 0)
2201 if(strstr(cvar_string("g_nexuizversion"), "svn", 0) >= 0)
2203 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");
2204 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"));
2209 r = vercmp(self.cvar_g_nexuizversion, cvar_string("g_nexuizversion"));
2212 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");
2213 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"));
2217 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");
2218 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
2222 self.version_nagtime = 0;
2226 if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue)
2228 sprint(self, strcat("godmode saved you ", ftos(self.max_armorvalue), " units of damage, cheater!\n"));
2229 self.max_armorvalue = 0;
2233 antilag_record(self);
2235 if(self.classname == "player") {
2236 // if(self.netname == "Wazat")
2237 // bprint(self.classname, "\n");
2239 CheckRules_Player();
2241 PrintWelcomeMessage(self);
2243 if (intermission_running)
2245 IntermissionThink (); // otherwise a button could be missed between
2246 return; // the think tics
2249 if(self.teleport_time)
2250 if(time > self.teleport_time)
2252 self.teleport_time = 0;
2253 self.effects = self.effects - (self.effects & EF_NODRAW);
2256 Nixnex_GiveCurrentWeapon();
2258 if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
2259 UpdateSelectedPlayer();
2261 //don't allow the player to turn around while game is paused!
2262 if(timeoutStatus == 2) {
2263 self.v_angle = self.lastV_angle;
2264 self.angles = self.lastV_angle;
2265 self.fixangle = TRUE;
2271 if (self.deadflag != DEAD_NO)
2273 float button_pressed, force_respawn;
2276 button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE);
2277 force_respawn = (g_lms || cvar("g_forced_respawn"));
2278 if (self.deadflag == DEAD_DYING)
2281 self.deadflag = DEAD_RESPAWNING;
2282 else if(!button_pressed)
2283 self.deadflag = DEAD_DEAD;
2285 else if (self.deadflag == DEAD_DEAD)
2288 self.deadflag = DEAD_RESPAWNABLE;
2290 else if (self.deadflag == DEAD_RESPAWNABLE)
2293 self.deadflag = DEAD_RESPAWNING;
2295 else if (self.deadflag == DEAD_RESPAWNING)
2297 if(time > self.death_time)
2299 self.death_time = time + 1; // only retry once a second
2303 ShowRespawnCountdown();
2308 if(time > self.touchexplode_time)
2309 if(self.classname == "player")
2310 if(self.deadflag == DEAD_NO)
2311 if not(IS_INDEPENDENT_PLAYER(self))
2312 FOR_EACH_PLAYER(other) if(self != other)
2314 if(time > other.touchexplode_time)
2315 if(other.classname == "player")
2316 if(other.deadflag == DEAD_NO)
2317 if not(IS_INDEPENDENT_PLAYER(other))
2318 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
2320 PlayerTouchExplode(self, other);
2321 self.touchexplode_time = other.touchexplode_time = time + 0.2;
2325 if(g_lms && !self.deadflag && cvar("g_lms_campcheck_interval"))
2329 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
2330 dist = self.prevorigin - self.origin;
2332 self.lms_traveled_distance += fabs(vlen(dist));
2334 if((cvar("g_campaign") && !campaign_bots_may_start) || (time < game_starttime))
2336 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
2337 self.lms_traveled_distance = 0;
2340 if(time > self.lms_nextcheck)
2342 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
2343 if(self.lms_traveled_distance < cvar("g_lms_campcheck_distance"))
2345 centerprint(self, cvar_string("g_lms_campcheck_message"));
2346 // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
2347 // I wasn't able to find out WHY that happens, so I put a workaround in place that shall prevent players from being gibbed :(
2348 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');
2350 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
2351 self.lms_traveled_distance = 0;
2355 self.prevorigin = self.origin;
2357 if ((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss)
2362 self.view_ofs = PL_CROUCH_VIEW_OFS;
2363 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
2364 setanim(self, self.anim_duck, FALSE, TRUE, TRUE);
2371 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
2372 if (!trace_startsolid)
2374 self.crouch = FALSE;
2375 self.view_ofs = PL_VIEW_OFS;
2376 setsize (self, PL_MIN, PL_MAX);
2381 if(self.health <= g_bloodloss && self.deadflag == DEAD_NO)
2383 if(self.bloodloss_timer < time)
2385 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
2386 self.bloodloss_timer = time + 0.5 + random() * 0.5;
2392 GrapplingHookFrame();
2398 self.items &~= IT_FUEL; // TODO don't do this if the current weapon actually USES fuel...
2399 if(self.items & IT_JETPACK)
2400 if(self.items & IT_FUEL_REGEN || self.ammo_fuel >= 0.01)
2401 self.items |= IT_FUEL;
2409 minstagib_ammocheck();
2413 nexball_setstatus();
2415 self.dmg_team = max(0, self.dmg_team - cvar("g_teamdamage_resetspeed") * frametime);
2417 //self.angles_y=self.v_angle_y + 90; // temp
2419 //if (TetrisPreFrame()) return;
2420 } else if(gameover) {
2421 if (intermission_running)
2422 IntermissionThink (); // otherwise a button could be missed between
2424 } else if(self.classname == "observer") {
2426 } else if(self.classname == "spectator") {
2431 SetZoomState(self.BUTTON_ZOOM || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX));
2433 float oldspectatee_status;
2434 oldspectatee_status = self.spectatee_status;
2435 if(self.classname == "spectator")
2436 self.spectatee_status = num_for_edict(self.enemy);
2437 else if(self.classname == "observer")
2438 self.spectatee_status = num_for_edict(self);
2440 self.spectatee_status = 0;
2441 if(self.spectatee_status != oldspectatee_status)
2443 ClientData_Touch(self);
2445 race_InitSpectator();
2448 if(self.teamkill_soundtime)
2449 if(time > self.teamkill_soundtime)
2451 self.teamkill_soundtime = 0;
2453 entity oldpusher, oldself;
2455 oldself = self; self = self.teamkill_soundsource;
2456 oldpusher = self.pusher; self.pusher = oldself;
2458 PlayerSound(playersound_teamshoot, CHAN_VOICE, VOICETYPE_LASTATTACKER_ONLY);
2460 self.pusher = oldpusher;
2464 if(self.taunt_soundtime)
2465 if(time > self.taunt_soundtime)
2467 self.taunt_soundtime = 0;
2468 PlayerSound(playersound_taunt, CHAN_VOICE, VOICETYPE_AUTOTAUNT);
2471 target_voicescript_next(self);
2477 .float dragspeed; // speed of mouse wheel action
2478 .float dragdistance; // distance of dragentity's draglocalvector from view_ofs
2479 .vector draglocalvector; // local attachment vector of the dragentity
2480 .float draglocalangle;
2483 .float dragmovetype;
2484 void Drag_Begin(entity dragger, entity draggee, vector touchpoint)
2488 draggee.dragmovetype = draggee.movetype;
2489 draggee.draggravity = draggee.gravity;
2490 draggee.movetype = MOVETYPE_WALK;
2491 draggee.gravity = 0.00001;
2492 draggee.flags &~= FL_ONGROUND;
2493 draggee.draggedby = dragger;
2495 dragger.dragentity = draggee;
2497 dragger.dragdistance = vlen(touchpoint - dragger.origin - dragger.view_ofs);
2498 dragger.draglocalangle = draggee.angles_y - dragger.v_angle_y;
2499 touchpoint = touchpoint - gettaginfo(draggee, 0);
2500 tagscale = pow(vlen(v_forward), -2);
2501 dragger.draglocalvector_x = touchpoint * v_forward * tagscale;
2502 dragger.draglocalvector_y = touchpoint * v_right * tagscale;
2503 dragger.draglocalvector_z = touchpoint * v_up * tagscale;
2505 dragger.dragspeed = 64;
2508 void Drag_Finish(entity dragger)
2511 draggee = dragger.dragentity;
2513 dragger.dragentity = world;
2514 draggee.draggedby = world;
2515 draggee.movetype = draggee.dragmovetype;
2516 draggee.gravity = draggee.draggravity;
2518 switch(draggee.movetype)
2523 case MOVETYPE_FLYMISSILE:
2524 case MOVETYPE_BOUNCE:
2525 case MOVETYPE_BOUNCEMISSILE:
2528 draggee.velocity = '0 0 0';
2532 if((draggee.flags & FL_ITEM) && (vlen(draggee.velocity) < 32))
2534 draggee.velocity = '0 0 0';
2535 draggee.flags |= FL_ONGROUND; // floating items are FUN
2539 float Drag_IsDraggable(entity draggee)
2541 // TODO add more checks for bad stuff here
2542 if(draggee.classname == "func_bobbing")
2544 if(draggee.classname == "door") // FIXME find out why these must be excluded, or work around the problem (trying to drag these causes like 4 fps)
2546 if(draggee.classname == "plat")
2548 if(draggee.classname == "func_button")
2550 if(draggee.model == "")
2552 if(draggee.classname == "spectator")
2554 if(draggee.classname == "observer")
2556 if(draggee.classname == "exteriorweaponentity")
2562 float Drag_MayChangeAngles(entity draggee)
2564 // TODO add more checks for bad stuff here
2565 if(substring(draggee.model, 0, 1) == "*")
2570 void Drag_MoveForward(entity dragger)
2572 dragger.dragdistance += dragger.dragspeed;
2575 void Drag_SetSpeed(entity dragger, float s)
2577 dragger.dragspeed = pow(2, s);
2580 void Drag_MoveBackward(entity dragger)
2582 dragger.dragdistance = max(0, dragger.dragdistance - dragger.dragspeed);
2585 void Drag_Update(entity dragger)
2587 vector curorigin, neworigin, goodvelocity;
2591 draggee = dragger.dragentity;
2592 draggee.flags &~= FL_ONGROUND;
2594 curorigin = gettaginfo(draggee, 0);
2595 curorigin = curorigin + v_forward * dragger.draglocalvector_x + v_right * dragger.draglocalvector_y + v_up * dragger.draglocalvector_z;
2596 makevectors(dragger.v_angle);
2597 neworigin = dragger.origin + dragger.view_ofs + v_forward * dragger.dragdistance;
2598 goodvelocity = (neworigin - curorigin) * (1 / frametime);
2600 while(draggee.angles_y - dragger.v_angle_y - dragger.draglocalangle > 180)
2601 dragger.draglocalangle += 360;
2602 while(draggee.angles_y - dragger.v_angle_y - dragger.draglocalangle <= -180)
2603 dragger.draglocalangle -= 360;
2605 f = min(frametime * 10, 1);
2606 draggee.velocity = draggee.velocity * (1 - f) + goodvelocity * f;
2608 if(Drag_MayChangeAngles(draggee))
2609 draggee.angles_y = draggee.angles_y * (1 - f) + (dragger.v_angle_y + dragger.draglocalangle) * f;
2611 draggee.ltime = max(servertime + serverframetime, draggee.ltime); // fixes func_train breakage
2613 te_lightning1(dragger, dragger.origin + dragger.view_ofs, curorigin);
2616 float Drag_CanDrag(entity dragger)
2618 return (dragger.deadflag == DEAD_NO) || (dragger.classname == "player");
2621 float Drag_IsDragging(entity dragger)
2623 if(!dragger.dragentity)
2625 if(wasfreed(dragger.dragentity) || dragger.dragentity.draggedby != dragger)
2627 dragger.dragentity = world;
2630 if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity))
2632 Drag_Finish(dragger);
2638 void Drag_MoveDrag(entity from, entity to)
2642 to.draggedby = from.draggedby;
2643 to.draggedby.dragentity = to;
2644 from.draggedby = world;
2652 Called every frame for each client after the physics are run
2655 .float idlekick_lasttimeleft;
2656 .float race_penalty;
2657 .float race_penalty_nagged;
2658 .float race_penalty_nagtime;
2659 void PlayerPostThink (void)
2661 // Savage: Check for nameless players
2662 if (strlen(self.netname) < 1) {
2663 self.netname = "Player";
2664 stuffcmd(self, "seta _cl_name Player\n");
2667 if(sv_maxidle && frametime)
2669 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
2671 timeleft = ceil(sv_maxidle - (time - self.parm_idlesince));
2674 bprint("^3", self.netname, "^3 was kicked for idling.\n");
2675 announce(self, "announcer/robotic/terminated.wav");
2679 else if(timeleft <= 10)
2681 if(timeleft != self.idlekick_lasttimeleft)
2683 centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
2684 announce(self, strcat("announcer/robotic/", ftos(timeleft), ".wav"));
2689 centerprint_expire(self, CENTERPRIO_IDLEKICK);
2691 self.idlekick_lasttimeleft = timeleft;
2695 if(Drag_CanDrag(self))
2696 if(self.BUTTON_DRAG)
2697 if(!self.dragentity)
2698 if(self.cursor_trace_ent)
2699 if(Drag_IsDraggable(self.cursor_trace_ent))
2701 if(self.cursor_trace_ent.draggedby)
2702 Drag_Finish(self.cursor_trace_ent.draggedby);
2703 if(self.cursor_trace_ent.tag_entity)
2704 detach_sameorigin(self.cursor_trace_ent);
2705 Drag_Begin(self, self.cursor_trace_ent, self.cursor_trace_endpos);
2708 if(Drag_IsDragging(self))
2710 if(self.BUTTON_DRAG)
2712 if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
2714 Drag_MoveForward(self);
2717 else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19)
2719 Drag_MoveBackward(self);
2722 else if(self.impulse >= 1 && self.impulse <= 9)
2724 Drag_SetSpeed(self, self.impulse - 1);
2726 else if(self.impulse == 14)
2728 Drag_SetSpeed(self, 9);
2740 if(self.classname == "player") {
2741 CheckRules_Player();
2746 if (intermission_running)
2747 return; // intermission or finale
2749 //if (TetrisPostFrame()) return;
2751 // restart countdown
2752 if(time < game_starttime) {
2753 if (!cvar("sv_ready_restart_after_countdown"))
2755 if(self.movement != '0 0 0' && g_race && !g_race_qualifying)
2757 if(time < game_starttime - 2)
2759 if(!self.race_penalty_nagged)
2761 // TODO better notification for this!
2762 self.race_penalty_nagtime = 0;
2763 self.race_penalty_nagged = 1;
2766 else if(!self.race_penalty)
2768 self.race_penalty_nagtime = 0;
2769 self.race_penalty = time + 5;
2772 if(time > self.race_penalty_nagtime)
2774 if(self.race_penalty > time)
2776 centerprint_atprio(self, CENTERPRIO_IDLEKICK, "^1FIVE SECONDS PENALTY.");
2778 else if(self.race_penalty_nagged && time < game_starttime - 2)
2780 centerprint_atprio(self, CENTERPRIO_IDLEKICK, "^1DO NOT MOVE DURING THE COUNTDOWN.");
2782 self.race_penalty_nagtime = time + self.cvar_scr_centertime * 0.6;
2784 self.movetype = MOVETYPE_NONE;
2785 self.velocity = '0 0 0';
2786 self.avelocity = '0 0 0';
2787 self.movement = '0 0 0';
2790 else if (time < self.race_penalty)
2792 self.movetype = MOVETYPE_NONE;
2793 self.velocity = '0 0 0';
2794 self.avelocity = '0 0 0';
2795 self.movement = '0 0 0';
2799 //allow the player to move again if sv_ready_restart_after_countdown is not used and countdown is over
2800 if (!cvar("sv_ready_restart_after_countdown"))
2802 if(self.movetype == MOVETYPE_NONE)
2804 self.movetype = MOVETYPE_WALK;
2806 self.race_penalty = 0;
2807 self.race_penalty_nagged = 0;
2811 } else if (self.classname == "observer") {
2813 } else if (self.classname == "spectator") {
2819 for(i = 0; i < 1000; ++i)
2822 end = self.origin + '0 0 1024' + 512 * randomvec();
2823 tracebox(self.origin, self.mins, self.maxs, end, MOVE_NORMAL, self);
2824 if(trace_fraction < 1)
2825 if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
2827 print("I HIT SOLID: ", vtos(self.origin), " -> ", vtos(end), "\n");
2835 //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);