1 void race_send_recordtime(float msg);
\r
2 void race_SendRankings(float pos, float prevpos, float del, float msg);
\r
4 void send_CSQC_teamnagger() {
\r
5 WriteByte(0, SVC_TEMPENTITY);
\r
6 WriteByte(0, TE_CSQC_TEAMNAGGER);
\r
9 void Announce(string snd) {
\r
10 WriteByte(MSG_ALL, SVC_TEMPENTITY);
\r
11 WriteByte(MSG_ALL, TE_CSQC_ANNOUNCE);
\r
12 WriteString(MSG_ALL, snd);
\r
15 void AnnounceTo(entity e, string snd) {
\r
16 if (clienttype(e) == CLIENTTYPE_REAL)
\r
19 WriteByte(MSG_ONE, SVC_TEMPENTITY);
\r
20 WriteByte(MSG_ONE, TE_CSQC_ANNOUNCE);
\r
21 WriteString(MSG_ONE, snd);
\r
25 float ClientData_Send(entity to, float sf)
\r
27 if(to != self.owner)
\r
36 if(to.classname == "spectator")
\r
41 if(e.race_completed)
\r
42 sf |= 1; // forced scoreboard
\r
43 if(to.spectatee_status)
\r
44 sf |= 2; // spectator ent number follows
\r
48 WriteByte(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
\r
49 WriteByte(MSG_ENTITY, sf);
\r
52 WriteByte(MSG_ENTITY, to.spectatee_status);
\r
56 WriteAngle(MSG_ENTITY, e.v_angle_x);
\r
57 WriteAngle(MSG_ENTITY, e.v_angle_y);
\r
63 void ClientData_Attach()
\r
65 Net_LinkEntity(self.clientdata = spawn(), FALSE, 0, ClientData_Send);
\r
66 self.clientdata.drawonlytoclient = self;
\r
67 self.clientdata.owner = self;
\r
70 void ClientData_Detach()
\r
72 remove(self.clientdata);
\r
73 self.clientdata = world;
\r
76 void ClientData_Touch(entity e)
\r
78 e.clientdata.SendFlags = 1;
\r
80 // make it spectatable
\r
82 FOR_EACH_REALCLIENT(e2)
\r
85 if(e2.classname == "spectator")
\r
87 e2.clientdata.SendFlags = 1;
\r
92 .vector spawnpoint_score;
\r
93 .string netname_previous;
\r
95 void spawnfunc_info_player_survivor (void)
\r
97 spawnfunc_info_player_deathmatch();
\r
100 void spawnfunc_info_player_start (void)
\r
102 spawnfunc_info_player_deathmatch();
\r
105 void spawnfunc_info_player_deathmatch (void)
\r
107 self.classname = "info_player_deathmatch";
\r
108 relocate_spawnpoint();
\r
111 void spawnpoint_use()
\r
114 if(have_team_spawns > 0)
\r
116 self.team = activator.team;
\r
117 some_spawn_has_been_used = 1;
\r
122 // _x: prio (-1 if unusable)
\r
124 vector Spawn_Score(entity spot, entity playerlist, float teamcheck, float anypoint)
\r
126 float shortest, thisdist;
\r
132 // filter out spots for the wrong team
\r
134 if(spot.team != teamcheck)
\r
138 if(spot.target == "")
\r
141 if(clienttype(self) == CLIENTTYPE_REAL)
\r
143 if(spot.restriction == 1)
\r
148 if(spot.restriction == 2)
\r
152 // filter out spots for assault
\r
153 if(spot.target != "") {
\r
156 ent = find(world, targetname, spot.target);
\r
159 if(ent.classname == "target_objective")
\r
162 if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
\r
166 else if(ent.classname == "trigger_race_checkpoint")
\r
169 if(!anypoint) // spectators may spawn everywhere
\r
172 if(g_race_qualifying)
\r
175 if(ent.race_checkpoint != 0)
\r
177 if(spot.race_place != race_lowest_place_spawn)
\r
182 if(ent.race_checkpoint != self.race_respawn_checkpoint)
\r
184 // try reusing the previous spawn
\r
185 if(ent == self.race_respawn_spotref || spot == self.race_respawn_spotref)
\r
187 if(ent.race_checkpoint == 0)
\r
190 pl = self.race_place;
\r
191 if(pl > race_highest_place_spawn)
\r
193 if(pl == 0 && !self.race_started)
\r
194 pl = race_highest_place_spawn; // use last place if he has not even touched finish yet
\r
195 if(spot.race_place != pl)
\r
202 ent = find(ent, targetname, spot.target);
\r
209 player = playerlist;
\r
210 shortest = vlen(world.maxs - world.mins);
\r
211 for(player = playerlist; player; player = player.chain)
\r
212 if (player != self)
\r
214 thisdist = vlen(player.origin - spot.origin);
\r
215 if (thisdist < shortest)
\r
216 shortest = thisdist;
\r
218 return prio * '1 0 0' + shortest * '0 1 0';
\r
221 float spawn_allbad;
\r
222 float spawn_allgood;
\r
223 entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck, float anypoint)
\r
225 local entity spot, spotlist, spotlistend;
\r
226 spawn_allgood = TRUE;
\r
227 spawn_allbad = TRUE;
\r
230 spotlistend = world;
\r
232 for(spot = firstspot; spot; spot = spot.chain)
\r
234 spot.spawnpoint_score = Spawn_Score(spot, playerlist, teamcheck, anypoint);
\r
236 if(cvar("spawn_debugview"))
\r
238 setmodel(spot, "models/rune.mdl");
\r
239 if(spot.spawnpoint_score_y < mindist)
\r
241 spot.colormod = '1 0 0';
\r
246 spot.colormod = '0 1 0';
\r
247 spot.scale = spot.spawnpoint_score_y / mindist;
\r
251 if(spot.spawnpoint_score_x >= 0) // spawning allowed here
\r
253 if(spot.spawnpoint_score_y < mindist)
\r
255 // too short distance
\r
256 spawn_allgood = FALSE;
\r
261 spawn_allbad = FALSE;
\r
264 spotlistend.chain = spot;
\r
265 spotlistend = spot;
\r
271 if(spot.team != teamcheck)
\r
272 error("invalid spawn added");
\r
274 print("added ", etos(spot), "\n");
\r
280 spotlistend.chain = world;
\r
285 for(e = spotlist; e; e = e.chain)
\r
287 print("seen ", etos(e), "\n");
\r
288 if(e.team != teamcheck)
\r
289 error("invalid spawn found");
\r
296 entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
\r
298 // weight of a point: bound(lower, mindisttoplayer, upper)^exponent
\r
299 // multiplied by spot.cnt (useful if you distribute many spawnpoints in a small area)
\r
302 RandomSelection_Init();
\r
303 for(spot = firstspot; spot; spot = spot.chain)
\r
304 RandomSelection_Add(spot, 0, string_null, pow(bound(lower, spot.spawnpoint_score_y, upper), exponent) * spot.cnt, (spot.spawnpoint_score_y >= lower) * 0.5 + spot.spawnpoint_score_x);
\r
306 return RandomSelection_chosen_ent;
\r
313 Finds a point to respawn
\r
316 entity SelectSpawnPoint (float anypoint)
\r
318 local float teamcheck;
\r
319 local entity firstspot_new;
\r
320 local entity spot, firstspot, playerlist;
\r
322 spot = find (world, classname, "testplayerstart");
\r
328 if(!anypoint && have_team_spawns > 0)
\r
329 teamcheck = self.team;
\r
331 // get the list of players
\r
332 playerlist = findchain(classname, "player");
\r
333 // get the entire list of spots
\r
334 firstspot = findchain(classname, "info_player_deathmatch");
\r
335 // filter out the bad ones
\r
336 // (note this returns the original list if none survived)
\r
339 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
\r
343 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 100, teamcheck, anypoint);
\r
345 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, -1, teamcheck, anypoint);
\r
346 firstspot = firstspot_new;
\r
348 // there is 50/50 chance of choosing a random spot or the furthest spot
\r
349 // (this means that roughly every other spawn will be furthest, so you
\r
350 // usually won't get fragged at spawn twice in a row)
\r
351 if (arena_roundbased && !g_ca)
\r
353 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 800, teamcheck, anypoint);
\r
355 firstspot = firstspot_new;
\r
356 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
\r
358 else if (random() > cvar("g_spawn_furthest"))
\r
359 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
\r
361 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
\r
364 if(cvar("spawn_debugview"))
\r
366 print("spot mindistance: ", vtos(spot.spawnpoint_score), "\n");
\r
370 for(e = firstspot; e; e = e.chain)
\r
371 if(e.team != teamcheck)
\r
372 error("invalid spawn found");
\r
377 if(cvar("spawn_debug"))
\r
381 if(some_spawn_has_been_used)
\r
382 return world; // team can't spawn any more, because of actions of other team
\r
384 error("Cannot find a spawn point - please fix the map!");
\r
395 Checks if the argument string can be a valid playermodel.
\r
396 Returns a valid one in doubt.
\r
399 string FallbackPlayerModel = "models/player/vixen.iqm";
\r
400 string CheckPlayerModel(string plyermodel) {
\r
401 if(strlen(plyermodel) < 4)
\r
402 return FallbackPlayerModel;
\r
403 if( substring(plyermodel,0,14) != "models/player/")
\r
404 return FallbackPlayerModel;
\r
405 else if(cvar("sv_servermodelsonly"))
\r
407 if(substring(plyermodel,-4,4) != ".zym")
\r
408 if(substring(plyermodel,-4,4) != ".dpm")
\r
409 if(substring(plyermodel,-4,4) != ".iqm")
\r
410 if(substring(plyermodel,-4,4) != ".md3")
\r
411 if(substring(plyermodel,-4,4) != ".psk")
\r
412 return FallbackPlayerModel;
\r
413 if(plyermodel != strtolower(plyermodel))
\r
414 return FallbackPlayerModel;
\r
415 if(!fexists(plyermodel))
\r
416 return FallbackPlayerModel;
\r
421 void setmodel_apply(string modelname, float reset_anims)
\r
423 precache_model(modelname);
\r
424 setmodel(self, modelname); // players have high precision
\r
426 player_setupanimsformodel();
\r
429 string setmodel_state()
\r
431 // set the proper belly model depending on how full we are
\r
432 string newmodel_name, newmodel_extension, applymodel;
\r
434 // 4 is the extension length
\r
435 newmodel_name = substring(self.playermodel, 0, strlen(self.playermodel) - 4);
\r
436 newmodel_extension = substring(self.playermodel, strlen(self.playermodel) - 4, 4);
\r
439 if(self.stomach_load > self.stomach_maxload * 0.75)
\r
441 else if(self.stomach_load > self.stomach_maxload * 0.5)
\r
443 else if(self.stomach_load > self.stomach_maxload * 0.25)
\r
447 applymodel = strcat(newmodel_name, "_state", ftos(vore_state), newmodel_extension);
\r
449 applymodel = self.playermodel;
\r
456 Client_customizeentityforclient
\r
459 void Client_setmodel(string applymodel)
\r
461 local vector m1, m2;
\r
462 if(self.classname != "player") // prevent some bugs
\r
464 if(applymodel == self.model || self.spectatee_status) // no change to apply
\r
467 applymodel = CheckPlayerModel(applymodel); // this is never "", so no endless loop
\r
470 setmodel_apply(applymodel, FALSE);
\r
471 setsize (self, m1, m2);
\r
474 void Client_uncustomizeentityforclient()
\r
476 self.skin = self.skinindex;
\r
479 float Client_customizeentityforclient()
\r
481 entity modelsource;
\r
482 string stomachmodel;
\r
484 if(self.modelindex == 0)
\r
487 // forcemodel stuff
\r
491 t0 = gettime(GETTIME_HIRES); // reference
\r
494 modelsource = self;
\r
496 #ifdef ALLOW_FORCEMODELS
\r
497 if(other.cvar_cl_forceplayermodelsfromvoretournament)
\r
498 modelsource = other;
\r
499 if(other.cvar_cl_forceplayermodels && sv_clforceplayermodels)
\r
500 modelsource = other;
\r
503 self.skin = modelsource.skinindex;
\r
506 if(modelsource == self)
\r
507 self.skin = modelsource.skinindex;
\r
509 self.skin = mod(modelsource.skinindex, 3); // forbid the fbskins as forced skins
\r
513 // other: the player viewing me
\r
517 t1 = gettime(GETTIME_HIRES); // reference
\r
518 client_cefc_accumulator += (t1 - t0);
\r
521 // now change the predator's player model into a stomach model for the prey
\r
522 // in other words, when a player is swallowed by another player, the predator becomes an inward stomach model so the prey can see theirself in the stomach
\r
523 // this is only visible to the prey however, otherwise players would appear as a floating stomach to everyone (ewww)
\r
524 stomachmodel = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_stomach.md3"); // 4 is the extension length
\r
527 chase = other.cvar_chase_active;
\r
529 if(other.spectatee_status && other.spectatee_status == num_for_edict(other.enemy))
\r
530 other = other.enemy; // also do this for the player we are spectating
\r
532 // don't do this if we have chase_active enabled, as we'd be seeing a floating stomach from third person view
\r
533 if not(chase || other.classname == "observer") // the observer check prevents a bug
\r
534 if(other.predator == self)
\r
536 Client_setmodel(stomachmodel);
\r
537 self.effects |= EF_NODEPTHTEST; // don't hide behind walls
\r
538 self.alpha = other.cvar_cl_vore_stomachmodel;
\r
542 Client_setmodel(setmodel_state());
\r
543 self.effects &~= EF_NODEPTHTEST;
\r
544 if not(self.stat_eaten)
\r
545 self.alpha = default_player_alpha;
\r
546 else if(cvar("g_vore_neighborprey_distance") && self.predator == other.predator && !(chase || other.classname == "observer"))
\r
548 self.alpha = default_player_alpha; // allow seeing neighboring prey
\r
549 self.effects |= EF_NODEPTHTEST; // don't hide behind the stomach's own EF_NODEPTHTEST
\r
552 self.alpha = -1; // hide prey
\r
558 PutObserverInServer
\r
560 putting a client as observer in the server
\r
563 void FixPlayermodel();
\r
564 void PutObserverInServer (void)
\r
568 race_PreSpawnObserver();
\r
570 spot = SelectSpawnPoint (TRUE);
\r
572 error("No spawnpoints for observers?!?\n");
\r
573 RemoveGrabber(self); // Wazat's Grabber
\r
575 if(clienttype(self) == CLIENTTYPE_REAL)
\r
578 WriteByte(MSG_ONE, SVC_SETVIEW);
\r
579 WriteEntity(MSG_ONE, self);
\r
584 kh_Key_DropAll(self, TRUE);
\r
586 if(self.flagcarried)
\r
587 DropFlag(self.flagcarried, world, world);
\r
589 WaypointSprite_PlayerDead();
\r
591 if not(g_ca) // don't reset teams when moving a ca player to the spectators
\r
592 self.team = -1; // move this as it is needed to log the player spectating in eventlog
\r
594 if(self.killcount != -666) {
\r
596 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
\r
597 bprint ("^4", self.netname, "^4 has no more lives left\n");
\r
599 bprint ("^4", self.netname, "^4 is spectating now\n"); // TODO turn this into a proper forfeit?
\r
601 bprint ("^4", self.netname, "^4 is spectating now\n");
\r
603 if(self.just_joined == FALSE) {
\r
604 LogTeamchange(self.playerid, -1, 4);
\r
606 self.just_joined = FALSE;
\r
609 PlayerScore_Clear(self); // clear scores when needed
\r
611 self.spectatortime = time;
\r
613 self.classname = "observer";
\r
614 self.iscreature = FALSE;
\r
615 self.health = -666;
\r
616 self.takedamage = DAMAGE_NO;
\r
617 self.solid = SOLID_NOT;
\r
618 self.movetype = MOVETYPE_NOCLIP;
\r
619 self.flags = FL_CLIENT | FL_NOTARGET;
\r
620 self.armorvalue = 666;
\r
622 self.armorvalue = cvar("g_balance_armor_start");
\r
623 self.pauserotarmor_finished = 0;
\r
624 self.pauserothealth_finished = 0;
\r
625 self.pauseregenhealth_finished = 0;
\r
626 self.pauseregenarmor_finished = 0;
\r
627 self.damageforcescale = 0;
\r
628 self.death_time = 0;
\r
629 self.dead_frame = 0;
\r
632 self.fade_time = 0;
\r
633 self.pain_frame = 0;
\r
634 self.pain_finished = 0;
\r
635 self.strength_finished = 0;
\r
636 self.invincible_finished = 0;
\r
637 self.pushltime = 0;
\r
638 self.think = SUB_Null;
\r
639 self.nextthink = 0;
\r
640 self.grabber_time = 0;
\r
641 self.deadflag = DEAD_NO;
\r
642 self.angles = spot.angles;
\r
644 self.fixangle = TRUE;
\r
645 self.crouch = FALSE;
\r
647 self.view_ofs = PL_VIEW_OFS;
\r
648 setorigin (self, spot.origin);
\r
649 setsize (self, '0 0 0', '0 0 0');
\r
650 self.prevorigin = self.origin;
\r
656 self.modelindex = 0;
\r
658 self.weaponmodel = "";
\r
659 self.weaponentity = world;
\r
660 self.exteriorweaponentity = world;
\r
661 self.killcount = -666;
\r
662 self.velocity = '0 0 0';
\r
663 self.avelocity = '0 0 0';
\r
664 self.punchangle = '0 0 0';
\r
665 self.punchvector = '0 0 0';
\r
666 self.oldvelocity = self.velocity;
\r
667 self.fire_endtime = -1;
\r
669 SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
\r
673 if(self.version_mismatch)
\r
675 Spawnqueue_Unmark(self);
\r
676 Spawnqueue_Remove(self);
\r
680 Spawnqueue_Insert(self);
\r
685 // Only if the player cannot play at all
\r
686 if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666)
\r
687 self.frags = FRAGS_SPECTATOR;
\r
689 self.frags = FRAGS_LMS_LOSER;
\r
692 self.frags = FRAGS_SPECTATOR;
\r
695 float RestrictSkin(float s)
\r
704 void FixPlayermodel()
\r
706 local string defaultmodel;
\r
707 local float defaultskin, chmdl, oldskin;
\r
708 local vector m1, m2;
\r
712 if(cvar("sv_defaultcharacter") == 1) {
\r
718 s = Team_ColorNameLowerCase(self.team);
\r
721 defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
\r
722 defaultskin = cvar(strcat("sv_defaultplayerskin_", s));
\r
726 if(defaultmodel == "")
\r
728 defaultmodel = cvar_string("sv_defaultplayermodel");
\r
729 defaultskin = cvar("sv_defaultplayerskin");
\r
733 if(self.modelindex == 0 && self.deadflag == DEAD_NO)
\r
735 if(self.model != "")
\r
736 bprint("\{1}^1Player ", self.netname, "^1 has a zero modelindex, trying to fix...\n");
\r
737 self.model = ""; // force the != checks to return true
\r
740 if(defaultmodel != "")
\r
742 if (defaultmodel != self.model)
\r
746 setmodel_apply (defaultmodel, TRUE);
\r
747 setsize (self, m1, m2);
\r
751 oldskin = self.skinindex;
\r
752 self.skinindex = defaultskin;
\r
754 if (self.model == "")
\r
756 self.playermodel = CheckPlayerModel(self.playermodel); // this is never "", so no endless loop
\r
759 setmodel_apply (self.playermodel, TRUE);
\r
760 setsize (self, m1, m2);
\r
763 // update player sounds if we changed model
\r
764 if(self.model == self.playermodel) // don't apply sounds for other models (like the player stomach state models)
\r
765 UpdatePlayerSounds();
\r
767 oldskin = self.skinindex;
\r
768 self.skinindex = RestrictSkin(stof(self.playerskin));
\r
771 if(chmdl || oldskin != self.skinindex)
\r
772 self.species = player_getspecies(); // model or skin has changed
\r
775 if(strlen(cvar_string("sv_defaultplayercolors")))
\r
776 if(self.clientcolors != cvar("sv_defaultplayercolors"))
\r
777 setcolor(self, cvar("sv_defaultplayercolors"));
\r
780 void PlayerTouchExplode(entity p1, entity p2)
\r
783 org = (p1.origin + p2.origin) * 0.5;
\r
784 org_z += (p1.mins_z + p2.mins_z) * 0.5;
\r
791 RadiusDamage(e, world, g_touchexplode_damage, g_touchexplode_edgedamage, g_touchexplode_radius, world, g_touchexplode_force, DEATH_TOUCHEXPLODE, world);
\r
799 Called when a client spawns in the server
\r
802 //void() ctf_playerchanged;
\r
803 void PutClientInServer (void)
\r
805 if(clienttype(self) == CLIENTTYPE_BOT)
\r
807 self.classname = "player";
\r
809 else if(clienttype(self) == CLIENTTYPE_REAL)
\r
812 WriteByte(MSG_ONE, SVC_SETVIEW);
\r
813 WriteEntity(MSG_ONE, self);
\r
816 // player is dead and becomes observer
\r
817 // FIXME fix LMS scoring for new system
\r
820 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
\r
821 self.classname = "observer";
\r
824 if(g_arena || (g_ca && !allowed_to_spawn))
\r
826 self.classname = "observer";
\r
829 self.classname = "observer";
\r
831 if(self.classname == "player" && (!g_ca || (g_ca && allowed_to_spawn))) {
\r
832 entity spot, oldself;
\r
836 JoinBestTeam(self, FALSE, TRUE);
\r
840 spot = SelectSpawnPoint (FALSE);
\r
843 centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
\r
844 return; // spawn failed
\r
847 RemoveGrabber(self); // Wazat's Grabber
\r
850 self.swallow_progress_pred = self.swallow_progress_prey = 0;
\r
852 self.classname = "player";
\r
853 self.wasplayer = TRUE;
\r
854 self.iscreature = TRUE;
\r
855 self.movetype = MOVETYPE_WALK;
\r
856 if(cvar("g_player_colisions"))
\r
857 self.solid = SOLID_SLIDEBOX;
\r
859 self.solid = SOLID_CORPSE;
\r
860 self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
\r
861 if(cvar("g_playerclip_collisions"))
\r
862 self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
\r
863 if(clienttype(self) == CLIENTTYPE_BOT && cvar("g_botclip_collisions"))
\r
864 self.dphitcontentsmask |= DPCONTENTS_BOTCLIP;
\r
865 self.frags = FRAGS_PLAYER;
\r
866 if(independent_players)
\r
867 MAKE_INDEPENDENT_PLAYER(self);
\r
868 self.flags = FL_CLIENT;
\r
869 self.takedamage = DAMAGE_AIM;
\r
871 self.air_finished = time + 12;
\r
876 self.ammo_fuel = warmup_start_ammo_fuel;
\r
877 self.health = warmup_start_health;
\r
878 self.armorvalue = warmup_start_armorvalue;
\r
879 self.weapons = warmup_start_weapons;
\r
883 self.ammo_fuel = start_ammo_fuel;
\r
884 self.health = start_health;
\r
885 self.armorvalue = start_armorvalue;
\r
886 self.weapons = start_weapons;
\r
889 self.items = start_items;
\r
890 self.switchweapon = w_getbestweapon(self);
\r
891 self.cnt = self.switchweapon;
\r
894 self.spawnshieldtime = time + cvar("g_spawnshieldtime");
\r
895 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
\r
896 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
\r
897 self.pauserotfuel_finished = time + cvar("g_balance_pause_fuel_rot_spawn");
\r
898 self.pauseregenhealth_finished = time + cvar("g_balance_pause_health_regen_spawn");
\r
899 self.pauseregenarmor_finished = time + cvar("g_balance_pause_armor_regen_spawn");
\r
900 //extend the pause of rotting if client was reset at the beginning of the countdown
\r
901 if(!cvar("sv_ready_restart_after_countdown") && time < game_starttime) { // TODO why is this cvar NOTted?
\r
902 self.spawnshieldtime += game_starttime - time;
\r
903 self.pauserotarmor_finished += game_starttime - time;
\r
904 self.pauserothealth_finished += game_starttime - time;
\r
905 self.pauseregenhealth_finished += game_starttime - time;
\r
906 self.pauseregenarmor_finished += game_starttime - time;
\r
908 self.damageforcescale = 2;
\r
909 self.death_time = 0;
\r
910 self.dead_frame = 0;
\r
913 self.fade_time = 0;
\r
914 self.pain_frame = 0;
\r
915 self.pain_finished = 0;
\r
916 self.strength_finished = 0;
\r
917 self.invincible_finished = 0;
\r
918 self.pushltime = 0;
\r
919 // players have no think function
\r
920 self.think = SUB_Null;
\r
921 self.nextthink = 0;
\r
922 self.grabber_time = 0;
\r
925 self.deadflag = DEAD_NO;
\r
926 self.stomach_load = 0;
\r
927 self.angles = spot.angles;
\r
929 self.angles_z = 0; // never spawn tilted even if the spot says to
\r
930 self.fixangle = TRUE; // turn this way immediately
\r
931 self.leanangle_damage_force = '0 0 0';
\r
932 self.velocity = '0 0 0';
\r
933 self.avelocity = '0 0 0';
\r
934 self.punchangle = '0 0 0';
\r
935 self.punchvector = '0 0 0';
\r
936 self.oldvelocity = self.velocity;
\r
937 self.fire_endtime = -1;
\r
940 WRITESPECTATABLE_MSG_ONE({
\r
941 WriteByte(MSG_ONE, SVC_TEMPENTITY);
\r
942 WriteByte(MSG_ONE, TE_CSQC_SPAWN);
\r
945 SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
\r
950 self.crouch = FALSE;
\r
951 self.view_ofs = PL_VIEW_OFS;
\r
952 setsize (self, PL_MIN, PL_MAX);
\r
953 self.spawnorigin = spot.origin;
\r
954 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
\r
955 // don't reset back to last position, even if new position is stuck in solid
\r
956 self.oldorigin = self.origin;
\r
957 self.prevorigin = self.origin;
\r
958 self.lastteleporttime = time; // prevent insane speeds due to changing origin
\r
962 Spawnqueue_Remove(self);
\r
963 Spawnqueue_Mark(self);
\r
969 self.event_damage = PlayerDamage;
\r
971 self.bot_attack = TRUE;
\r
973 self.statdraintime = time + 5;
\r
974 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
\r
976 if(self.killcount == -666) {
\r
977 PlayerScore_Clear(self);
\r
978 self.killcount = 0;
\r
981 CL_SpawnWeaponentity();
\r
982 self.alpha = default_player_alpha;
\r
983 self.colormod = '1 1 1' * cvar("g_player_brightness");
\r
984 self.exteriorweaponentity.alpha = default_weapon_alpha;
\r
986 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
\r
987 self.lms_traveled_distance = 0;
\r
988 self.speedrunning = FALSE;
\r
990 race_PostSpawn(spot);
\r
992 if(cvar("spawn_debug"))
\r
994 sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n"));
\r
995 remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
\r
998 //stuffcmd(self, "chase_active 0");
\r
999 //stuffcmd(self, "set viewsize $tmpviewsize \n");
\r
1001 if (cvar("g_spawnsound"))
\r
1002 sound (self, CHAN_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
\r
1003 pointparticles(particleeffectnum("player_respawn"), self.origin, '0 0 0', 1);
\r
1006 if(self.team == assault_attacker_team)
\r
1007 centerprint(self, "You are attacking!");
\r
1009 centerprint(self, "You are defending!");
\r
1012 target_voicescript_clear(self);
\r
1014 // reset fields the weapons may use
\r
1015 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
\r
1017 weapon_action(j, WR_RESETPLAYER);
\r
1019 // all weapons must be fully loaded when we spawn
\r
1021 e = get_weaponinfo(j);
\r
1022 if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
\r
1023 self.(weapon_load[j]) = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
\r
1028 activator = oldself;
\r
1030 activator = world;
\r
1032 } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
\r
1033 PutObserverInServer ();
\r
1037 // ctf_playerchanged();
\r
1040 float ClientInit_SendEntity(entity to, float sf)
\r
1042 WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
\r
1043 WriteCoord(MSG_ENTITY, grabber_shotorigin_x);
\r
1044 WriteCoord(MSG_ENTITY, grabber_shotorigin_y);
\r
1045 WriteCoord(MSG_ENTITY, grabber_shotorigin_z);
\r
1047 if(sv_foginterval && world.fog != "")
\r
1048 WriteString(MSG_ENTITY, world.fog);
\r
1050 WriteString(MSG_ENTITY, "");
\r
1051 WriteShort(MSG_ENTITY, cvar("g_campaign"));
\r
1052 WriteByte(MSG_ENTITY, cvar("g_balance_armor_blockpercent") * 255.0);
\r
1053 WriteByte(MSG_ENTITY, cvar("g_balance_weaponswitchdelay") * 255.0);
\r
1055 WriteShort(MSG_ENTITY, cvar("g_vore"));
\r
1056 if(cvar("g_healthsize"))
\r
1057 WriteShort(MSG_ENTITY, cvar("g_healthsize_center"));
\r
1059 WriteShort(MSG_ENTITY, -1); // healthsize is disabled
\r
1060 WriteShort(MSG_ENTITY, cvar("g_healthsize_min"));
\r
1061 WriteShort(MSG_ENTITY, cvar("g_healthsize_max"));
\r
1063 // tell the client if this server uses armor
\r
1065 if(cvar("g_balance_armor_start") || (cvar("g_lms") && cvar("g_lms_start_armor")) /*|| (inWarmupStage && cvar("g_warmup_start_armor"))*/ || cvar("g_balance_armor_regen") || cvar("g_balance_armor_regenlinear"))
\r
1066 armor_max = cvar("g_balance_armor_limit");
\r
1067 WriteCoord(MSG_ENTITY, armor_max);
\r
1069 float teamheal_max;
\r
1070 if(cvar("g_vore") && cvar("g_vore_teamvore") && cvar("g_balance_vore_teamheal"))
\r
1071 teamheal_max = cvar("g_balance_vore_teamheal_stable");
\r
1072 WriteCoord(MSG_ENTITY, teamheal_max);
\r
1074 WriteShort(MSG_ENTITY, cvar("g_power"));
\r
1075 WriteShort(MSG_ENTITY, cvar("g_power_reboot"));
\r
1076 WriteByte(MSG_ENTITY, cvar("g_power_reboot_spawn"));
\r
1081 void ClientInit_Spawn()
\r
1083 Net_LinkEntity(spawn(), FALSE, 0, ClientInit_SendEntity);
\r
1091 void SetNewParms (void)
\r
1093 // initialize parms for a new player
\r
1094 parm1 = -(86400 * 366);
\r
1102 void SetChangeParms (void)
\r
1104 // save parms for level change
\r
1105 parm1 = self.parm_idlesince - time;
\r
1113 void DecodeLevelParms (void)
\r
1116 self.parm_idlesince = parm1;
\r
1117 if(self.parm_idlesince == -(86400 * 366))
\r
1118 self.parm_idlesince = time;
\r
1120 // whatever happens, allow 60 seconds of idling directly after connect for map loading
\r
1121 self.parm_idlesince = max(self.parm_idlesince, time - sv_maxidle + 60);
\r
1128 Called when a client types 'kill' in the console
\r
1132 .float clientkill_nexttime;
\r
1133 void ClientKill_Now_TeamChange()
\r
1135 if(self.killindicator_teamchange == -1)
\r
1138 JoinBestTeam( self, FALSE, FALSE );
\r
1140 else if(self.killindicator_teamchange == -2)
\r
1143 self.caplayer = 0;
\r
1144 if(blockSpectators)
\r
1145 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"));
\r
1146 PutObserverInServer();
\r
1149 SV_ChangeTeam(self.killindicator_teamchange - 1);
\r
1152 void ClientKill_Now()
\r
1154 if(self.killindicator && !wasfreed(self.killindicator))
\r
1155 remove(self.killindicator);
\r
1157 self.killindicator = world;
\r
1159 if(self.killindicator_teamchange)
\r
1160 ClientKill_Now_TeamChange();
\r
1163 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
\r
1165 // now I am sure the player IS dead
\r
1167 void KillIndicator_Think()
\r
1169 if (!self.owner.modelindex)
\r
1171 self.owner.killindicator = world;
\r
1178 self = self.owner;
\r
1179 ClientKill_Now(); // no oldself needed
\r
1182 else if(g_cts && self.health == 1) // health == 1 means that it's silent
\r
1184 self.nextthink = time + 1;
\r
1189 if(self.cnt <= 10)
\r
1190 setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
\r
1191 if(clienttype(self.owner) == CLIENTTYPE_REAL)
\r
1193 if(self.cnt <= 10)
\r
1194 AnnounceTo(self.owner, strcat(ftos(self.cnt), ""));
\r
1195 if(self.owner.killindicator_teamchange)
\r
1197 if(self.owner.killindicator_teamchange == -1)
\r
1198 centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
\r
1199 else if(self.owner.killindicator_teamchange == -2)
\r
1200 centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
\r
1202 centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
\r
1205 centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
\r
1207 self.nextthink = time + 1;
\r
1212 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
\r
1216 killtime = cvar("g_balance_kill_delay");
\r
1218 if(g_race_qualifying || g_cts)
\r
1221 if(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill
\r
1223 remove(self.killindicator);
\r
1224 self.killindicator = world;
\r
1226 ClientKill_Now(); // allow instant kill in this case
\r
1230 self.killindicator_teamchange = targetteam;
\r
1232 if(!self.killindicator)
\r
1234 if(self.modelindex && self.deadflag == DEAD_NO)
\r
1236 killtime = max(killtime, self.clientkill_nexttime - time);
\r
1237 self.clientkill_nexttime = time + killtime + cvar("g_balance_kill_antispam");
\r
1240 if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
\r
1246 self.killindicator = spawn();
\r
1247 self.killindicator.owner = self;
\r
1248 self.killindicator.scale = 0.5;
\r
1249 setattachment(self.killindicator, self, "");
\r
1250 setorigin(self.killindicator, '0 0 52');
\r
1251 self.killindicator.think = KillIndicator_Think;
\r
1252 self.killindicator.nextthink = time + (self.lip) * 0.05;
\r
1253 self.killindicator.cnt = ceil(killtime);
\r
1254 self.killindicator.count = bound(0, ceil(killtime), 10);
\r
1255 //sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
\r
1257 for(e = world; (e = find(e, classname, "body")) != world; )
\r
1259 if(e.enemy != self)
\r
1261 e.killindicator = spawn();
\r
1262 e.killindicator.owner = e;
\r
1263 e.killindicator.scale = 0.5;
\r
1264 setattachment(e.killindicator, e, "");
\r
1265 setorigin(e.killindicator, '0 0 52');
\r
1266 e.killindicator.think = KillIndicator_Think;
\r
1267 e.killindicator.nextthink = time + (e.lip) * 0.05;
\r
1268 e.killindicator.cnt = ceil(killtime);
\r
1273 if(self.killindicator)
\r
1275 if(targetteam == 0) // just die
\r
1276 self.killindicator.colormod = '0 0 0';
\r
1277 else if(targetteam == -1) // auto
\r
1278 self.killindicator.colormod = '0 1 0';
\r
1279 else if(targetteam == -2) // spectate
\r
1280 self.killindicator.colormod = '0.5 0.5 0.5';
\r
1282 self.killindicator.colormod = TeamColor(targetteam);
\r
1286 void ClientKill (void)
\r
1288 if((g_arena || g_ca) && ((champion && champion.classname == "player" && player_count > 1) || player_count == 1)) // don't allow a kill in this case either
\r
1293 ClientKill_TeamChange(0);
\r
1296 void CTS_ClientKill (entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
\r
1298 e.killindicator = spawn();
\r
1299 e.killindicator.owner = e;
\r
1300 e.killindicator.think = KillIndicator_Think;
\r
1301 e.killindicator.nextthink = time + (e.lip) * 0.05;
\r
1302 e.killindicator.cnt = ceil(cvar("g_cts_finish_kill_delay"));
\r
1303 e.killindicator.health = 1; // this is used to indicate that it should be silent
\r
1307 void DoTeamChange(float destteam)
\r
1313 SetPlayerColors(self, destteam);
\r
1316 if(self.classname == "player")
\r
1317 if(destteam == -1)
\r
1319 CheckAllowedTeams(self);
\r
1320 t = FindSmallestTeam(self, TRUE);
\r
1323 case COLOR_TEAM1: c0 = c1; break;
\r
1324 case COLOR_TEAM2: c0 = c2; break;
\r
1325 case COLOR_TEAM3: c0 = c3; break;
\r
1326 case COLOR_TEAM4: c0 = c4; break;
\r
1327 default: c0 = 999;
\r
1333 destteam = COLOR_TEAM1;
\r
1337 destteam = COLOR_TEAM2;
\r
1341 destteam = COLOR_TEAM3;
\r
1345 destteam = COLOR_TEAM4;
\r
1348 if(destteam == -1)
\r
1351 if(destteam == self.team && destteam >= 0 && !self.killindicator)
\r
1353 ClientKill_TeamChange(destteam);
\r
1356 void FixClientCvars(entity e)
\r
1358 // send prediction settings to the client
\r
1359 stuffcmd(e, "\nin_bindmap 0 0\n");
\r
1360 if(g_race || g_cts)
\r
1361 stuffcmd(e, "cl_cmd settemp cl_movecliptokeyboard 2\n");
\r
1362 if(cvar("g_antilag") == 3) // client side hitscan
\r
1363 //stuffcmd(e, "cl_cmd settemp cl_prydoncursor -1\ncl_cmd settemp cl_prydoncursor_notrace 0\n");
\r
1364 stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
\r
1366 * we no longer need to stuff this. Remove this comment block if you feel
\r
1367 * 2.3 and higher (or was it 2.2.3?) don't need these any more
\r
1368 stuffcmd(e, strcat("cl_gravity ", ftos(cvar("sv_gravity")), "\n"));
\r
1369 stuffcmd(e, strcat("cl_movement_accelerate ", ftos(cvar("sv_accelerate")), "\n"));
\r
1370 stuffcmd(e, strcat("cl_movement_friction ", ftos(cvar("sv_friction")), "\n"));
\r
1371 stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(cvar("sv_maxspeed")), "\n"));
\r
1372 stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(cvar("sv_airaccelerate")), "\n"));
\r
1373 stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(cvar("sv_maxairspeed")), "\n"));
\r
1374 stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(cvar("sv_stopspeed")), "\n"));
\r
1375 stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(cvar("sv_jumpvelocity")), "\n"));
\r
1376 stuffcmd(e, strcat("cl_movement_stepheight ", ftos(cvar("sv_stepheight")), "\n"));
\r
1377 stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(cvar("sv_friction_on_land")), "\n"));
\r
1378 stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(cvar("sv_airaccel_qw")), "\n"));
\r
1379 stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(cvar("sv_airaccel_sideways_friction")), "\n"));
\r
1380 stuffcmd(e, "cl_movement_edgefriction 1\n");
\r
1388 Called when a client connects to the server
\r
1391 //void ctf_clientconnect();
\r
1392 string ColoredTeamName(float t);
\r
1393 void DecodeLevelParms (void);
\r
1394 //void dom_player_join_team(entity pl);
\r
1396 .float uid_kicktime;
\r
1399 void ClientConnect (void)
\r
1403 if(self.flags & FL_CLIENT)
\r
1405 print("Warning: ClientConnect, but already connected!\n");
\r
1409 if(Ban_MaybeEnforceBan(self))
\r
1412 DecodeLevelParms();
\r
1414 self.classname = "player_joining";
\r
1416 self.flags = FL_CLIENT;
\r
1417 self.version_nagtime = time + 10 + random() * 10;
\r
1419 if(player_count<0)
\r
1421 dprint("BUG player count is lower than zero, this cannot happen!\n");
\r
1425 PlayerScore_Attach(self);
\r
1426 ClientData_Attach();
\r
1428 bot_clientconnect();
\r
1430 playerdemo_init();
\r
1434 race_PreSpawnObserver();
\r
1436 //if(g_domination)
\r
1437 // dom_player_join_team(self);
\r
1439 JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it
\r
1441 if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign")) {
\r
1442 self.classname = "observer";
\r
1446 if(cvar("g_balance_teams") || cvar("g_balance_teams_force"))
\r
1448 self.classname = "player";
\r
1449 campaign_bots_may_start = 1;
\r
1453 self.classname = "observer"; // do it anyway
\r
1458 self.classname = "player";
\r
1459 campaign_bots_may_start = 1;
\r
1463 self.playerid = (playerid_last = playerid_last + 1);
\r
1465 if(cvar("sv_eventlog"))
\r
1466 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((clienttype(self) == CLIENTTYPE_REAL) ? self.netaddress : "bot"), ":", self.netname));
\r
1468 LogTeamchange(self.playerid, self.team, 1);
\r
1470 self.just_joined = TRUE; // stop spamming the eventlog with additional lines when the client connects
\r
1472 self.netname_previous = strzone(self.netname);
\r
1474 bprint("^4", self.netname, "^4 connected");
\r
1476 if(self.classname != "observer" && (g_domination || g_ctf))
\r
1477 bprint(" and joined the ", ColoredTeamName(self.team));
\r
1481 self.welcomemessage_time = 0;
\r
1483 stuffcmd(self, strcat(clientstuff, "\n"));
\r
1484 stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n"));
\r
1485 stuffcmd(self, "cl_particles_reloadeffects\n");
\r
1487 FixClientCvars(self);
\r
1489 // spawnfunc_waypoint sprites
\r
1490 WaypointSprite_InitClient(self);
\r
1492 // Wazat's grabber
\r
1493 SetGrabberBindings();
\r
1495 // get autoswitch state from player when he toggles it
\r
1496 stuffcmd(self, "alias autoswitch \"set cl_autoswitch $1 ; cmd autoswitch $1\"\n"); // default.cfg-ed in 2.4.1
\r
1498 // get version info from player
\r
1499 stuffcmd(self, "cmd clientversion $gameversion\n");
\r
1501 // get other cvars from player
\r
1504 // set cvar for team scoreboard
\r
1505 stuffcmd(self, strcat("set teamplay ", ftos(teamplay), "\n"));
\r
1507 // notify about available teams
\r
1510 CheckAllowedTeams(self);
\r
1511 t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
\r
1512 stuffcmd(self, strcat("set _teams_available ", ftos(t), "\n"));
\r
1515 stuffcmd(self, "set _teams_available 0\n");
\r
1517 stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
\r
1519 if(g_arena || g_ca)
\r
1521 self.classname = "observer";
\r
1523 Spawnqueue_Insert(self);
\r
1527 ctf_clientconnect();
\r
1532 bot_relinkplayerlist();
\r
1534 self.spectatortime = time;
\r
1535 if(blockSpectators)
\r
1537 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"));
\r
1540 self.jointime = time;
\r
1541 self.allowedTimeouts = cvar("sv_timeout_number");
\r
1543 if(clienttype(self) == CLIENTTYPE_REAL)
\r
1545 if(cvar("g_bugrigs"))
\r
1546 stuffcmd(self, "cl_cmd settemp chase_active 1\n");
\r
1551 if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
\r
1553 PlayerScore_Add(self, SP_LMS_RANK, 666);
\r
1554 self.frags = FRAGS_SPECTATOR;
\r
1558 if(!sv_foginterval && world.fog != "")
\r
1559 stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
\r
1561 SoundEntity_Attach(self);
\r
1563 if(cvar("g_hitplots") || strstrofs(strcat(" ", cvar_string("g_hitplots_individuals"), " "), strcat(" ", self.netaddress, " "), 0) >= 0)
\r
1565 self.hitplotfh = fopen(strcat("hits-", matchid, "-", self.netaddress, "-", ftos(self.playerid), ".plot"), FILE_WRITE);
\r
1566 fputs(self.hitplotfh, strcat("#name ", self.netname, "\n"));
\r
1569 self.hitplotfh = -1;
\r
1572 if(clienttype(self) == CLIENTTYPE_REAL)
\r
1574 self.uid_kicktime = time + 60;
\r
1577 if(g_race || g_cts) {
\r
1583 t = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time")));
\r
1585 race_send_recordtime(MSG_ONE);
\r
1586 race_send_speedaward(MSG_ONE);
\r
1588 speedaward_alltimebest = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed")));
\r
1589 speedaward_alltimebest_holder = db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/netname"));
\r
1590 race_send_speedaward_alltimebest(MSG_ONE);
\r
1593 for (i = 1; i <= RANKINGS_CNT; ++i) {
\r
1594 race_SendRankings(i, 0, 0, MSG_ONE);
\r
1597 else if(cvar("sv_teamnagger") && !g_ca) // teamnagger is currently bad for ca
\r
1598 send_CSQC_teamnagger();
\r
1600 CheatInitClient();
\r
1607 Called when a client disconnects from the server
\r
1610 .entity chatbubbleentity;
\r
1611 void ReadyCount();
\r
1612 void ClientDisconnect (void)
\r
1614 if not(self.flags & FL_CLIENT)
\r
1616 print("Warning: ClientDisconnect without ClientConnect\n");
\r
1620 Vore_Disconnect();
\r
1622 CheatShutdownClient();
\r
1624 if(self.hitplotfh >= 0)
\r
1626 fclose(self.hitplotfh);
\r
1627 self.hitplotfh = -1;
\r
1630 anticheat_report();
\r
1631 anticheat_shutdown();
\r
1633 playerdemo_shutdown();
\r
1635 bot_clientdisconnect();
\r
1640 if(cvar("sv_eventlog"))
\r
1641 GameLogEcho(strcat(":part:", ftos(self.playerid)));
\r
1642 bprint ("^4",self.netname);
\r
1643 bprint ("^4 disconnected\n");
\r
1645 SoundEntity_Detach(self);
\r
1647 kh_Key_DropAll(self, TRUE);
\r
1649 if(self.flagcarried)
\r
1650 DropFlag(self.flagcarried, world, world);
\r
1651 // Here, everything has been done that requires this player to be a client.
\r
1653 self.flags &~= FL_CLIENT;
\r
1655 if (self.chatbubbleentity)
\r
1656 remove (self.chatbubbleentity);
\r
1658 if (self.killindicator)
\r
1659 remove (self.killindicator);
\r
1661 WaypointSprite_PlayerGone();
\r
1663 bot_relinkplayerlist();
\r
1667 Spawnqueue_Unmark(self);
\r
1668 Spawnqueue_Remove(self);
\r
1671 ClientData_Detach();
\r
1672 PlayerScore_Detach(self);
\r
1674 if(self.netname_previous)
\r
1675 strunzone(self.netname_previous);
\r
1676 if(self.clientstatus)
\r
1677 strunzone(self.clientstatus);
\r
1679 ClearPlayerSounds();
\r
1682 remove(self.personal);
\r
1684 self.playerid = 0;
\r
1691 .float BUTTON_CHAT;
\r
1692 void ChatBubbleThink()
\r
1694 self.nextthink = time;
\r
1695 if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
\r
1697 if(self.owner) // but why can that ever be world?
\r
1698 self.owner.chatbubbleentity = world;
\r
1702 if ((self.owner.BUTTON_CHAT && !self.owner.deadflag && !self.owner.stat_eaten)
\r
1704 || self.owner.tetris_on
\r
1707 self.model = self.mdl;
\r
1712 void UpdateChatBubble()
\r
1714 if (!self.modelindex)
\r
1716 // spawn a chatbubble entity if needed
\r
1717 if (!self.chatbubbleentity)
\r
1719 self.chatbubbleentity = spawn();
\r
1720 self.chatbubbleentity.owner = self;
\r
1721 self.chatbubbleentity.exteriormodeltoclient = self;
\r
1722 self.chatbubbleentity.think = ChatBubbleThink;
\r
1723 self.chatbubbleentity.nextthink = time;
\r
1724 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
\r
1725 //setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
\r
1726 setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
\r
1727 setattachment(self.chatbubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
\r
1728 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
\r
1729 self.chatbubbleentity.model = "";
\r
1730 self.chatbubbleentity.effects = EF_LOWPRECISION;
\r
1734 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
\r
1735 // added to the model skins
\r
1736 /*void UpdateColorModHack()
\r
1739 c = self.clientcolors & 15;
\r
1740 // LordHavoc: only bothering to support white, green, red, yellow, blue
\r
1741 if (!teams_matter) self.colormod = '0 0 0';
\r
1742 else if (c == 0) self.colormod = '1.00 1.00 1.00';
\r
1743 else if (c == 3) self.colormod = '0.10 1.73 0.10';
\r
1744 else if (c == 4) self.colormod = '1.73 0.10 0.10';
\r
1745 else if (c == 12) self.colormod = '1.22 1.22 0.10';
\r
1746 else if (c == 13) self.colormod = '0.10 0.10 1.73';
\r
1747 else self.colormod = '1 1 1';
\r
1750 .float oldcolormap;
\r
1751 void respawn(void)
\r
1753 // don't allow respawing if the prey is still digesting
\r
1754 if(cvar("g_balance_vore_digestion_limit_blockrespawn"))
\r
1755 if(self.predator.digesting && self.health > cvar("g_balance_vore_digestion_limit"))
\r
1758 setmodel(self, self.playermodel); // prevents an issue with dead predators
\r
1759 if(self.alpha >= 0 && self.modelindex != 0 && cvar("g_respawn_ghosts"))
\r
1761 self.solid = SOLID_NOT;
\r
1762 self.takedamage = DAMAGE_NO;
\r
1763 self.movetype = MOVETYPE_FLY;
\r
1764 self.velocity = '0 0 1' * cvar("g_respawn_ghosts_speed");
\r
1765 self.avelocity = randomvec() * cvar("g_respawn_ghosts_speed") * 3 - randomvec() * cvar("g_respawn_ghosts_speed") * 3;
\r
1766 self.effects |= EF_ADDITIVE;
\r
1767 self.oldcolormap = self.colormap;
\r
1768 self.colormap = 512;
\r
1769 pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1);
\r
1770 if(cvar("g_respawn_ghosts_maxtime"))
\r
1771 SUB_SetFade (self, time + cvar("g_respawn_ghosts_maxtime") / 2 + random () * (cvar("g_respawn_ghosts_maxtime") - cvar("g_respawn_ghosts_maxtime") / 2), 1.5);
\r
1775 self.effects |= EF_NODRAW; // prevent another CopyBody
\r
1776 if(self.oldcolormap)
\r
1778 self.colormap = self.oldcolormap;
\r
1779 self.oldcolormap = 0;
\r
1781 PutClientInServer();
\r
1784 void play_countdown(float finished, string samp)
\r
1786 if(clienttype(self) == CLIENTTYPE_REAL)
\r
1787 if(floor(finished - time - frametime) != floor(finished - time))
\r
1788 if(finished - time < 6)
\r
1789 sound (self, CHAN_AUTO, samp, VOL_BASE, ATTN_NORM);
\r
1793 * When sv_timeout is used this function returs strings like
\r
1794 * "Timeout begins in 2 seconds!\n" or "Timeout ends in 23 seconds!\n".
\r
1795 * Called by centerprint functions
\r
1796 * @param addOneSecond boolean, set to 1 if the welcome-message centerprint asks for the text
\r
1798 string getTimeoutText(float addOneSecond) {
\r
1799 if (!cvar("sv_timeout") || !timeoutStatus)
\r
1802 local string retStr;
\r
1803 if (timeoutStatus == 1) {
\r
1804 if (addOneSecond == 1) {
\r
1805 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime + 1), " seconds!\n");
\r
1808 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
\r
1812 else if (timeoutStatus == 2) {
\r
1813 if (addOneSecond) {
\r
1814 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
\r
1815 //don't show messages like "Timeout ends in 0 seconds"...
\r
1816 if ((remainingTimeoutTime + 1) > 0)
\r
1822 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
\r
1823 //don't show messages like "Timeout ends in 0 seconds"...
\r
1824 if (remainingTimeoutTime > 0)
\r
1833 void player_powerups (void)
\r
1835 if((self.items & IT_USING_JETPACK) && !self.deadflag)
\r
1837 SoundEntity_StartSound(self, CHAN_PLAYER, "misc/jetpack_fly.wav", VOL_BASE, cvar("g_jetpack_attenuation"));
\r
1838 self.modelflags |= MF_ROCKET;
\r
1842 SoundEntity_StopSound(self, CHAN_PLAYER);
\r
1843 self.modelflags &~= MF_ROCKET;
\r
1846 self.effects &~= (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
\r
1848 if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
\r
1851 Fire_ApplyDamage(self);
\r
1852 Fire_ApplyEffect(self);
\r
1854 if (self.items & IT_STRENGTH)
\r
1856 play_countdown(self.strength_finished, "misc/poweroff.wav");
\r
1857 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
\r
1858 if (time > self.strength_finished && cvar("g_balance_powerup_timer"))
\r
1860 self.items = self.items - (self.items & IT_STRENGTH);
\r
1861 sprint(self, "^3Strength has worn off\n");
\r
1866 if (time < self.strength_finished)
\r
1868 self.items = self.items | IT_STRENGTH;
\r
1869 sprint(self, "^3Strength infuses your weapons with devastating power\n");
\r
1872 if (self.items & IT_INVINCIBLE)
\r
1874 play_countdown(self.invincible_finished, "misc/poweroff.wav");
\r
1875 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
\r
1876 if (time > self.invincible_finished && cvar("g_balance_powerup_timer"))
\r
1878 self.items = self.items - (self.items & IT_INVINCIBLE);
\r
1879 sprint(self, "^3Shield has worn off\n");
\r
1884 if (time < self.invincible_finished)
\r
1886 self.items = self.items | IT_INVINCIBLE;
\r
1887 sprint(self, "^3Shield surrounds you\n");
\r
1891 if(cvar("g_nodepthtestplayers"))
\r
1892 self.effects = self.effects | EF_NODEPTHTEST;
\r
1894 if(cvar("g_fullbrightplayers"))
\r
1895 self.effects = self.effects | EF_FULLBRIGHT;
\r
1897 // midair gamemode: damage only while in the air
\r
1898 // if in midair mode, being on ground grants temporary invulnerability
\r
1899 // (this is so that multishot weapon don't clear the ground flag on the
\r
1900 // first damage in the frame, leaving the player vulnerable to the
\r
1901 // remaining hits in the same frame)
\r
1902 if (self.flags & FL_ONGROUND)
\r
1904 self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
\r
1906 if (time >= game_starttime)
\r
1907 if (time < self.spawnshieldtime)
\r
1908 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
\r
1911 float CalcRegen(float current, float stable, float regenfactor, float regenframetime)
\r
1913 if(current > stable)
\r
1915 else if(current > stable - 0.25) // when close enough, "snap"
\r
1918 return min(stable, current + (stable - current) * regenfactor * regenframetime);
\r
1921 float CalcRot(float current, float stable, float rotfactor, float rotframetime)
\r
1923 if(current < stable)
\r
1925 else if(current < stable + 0.25) // when close enough, "snap"
\r
1928 return max(stable, current + (stable - current) * rotfactor * rotframetime);
\r
1931 .float regen_soundtime;
\r
1932 float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit, string regensound)
\r
1934 if(current > rotstable)
\r
1936 if(rotframetime > 0)
\r
1938 current = CalcRot(current, rotstable, rotfactor, rotframetime);
\r
1939 current = max(rotstable, current - rotlinear * rotframetime);
\r
1942 else if(current < regenstable)
\r
1944 if(regenframetime > 0)
\r
1946 current = CalcRegen(current, regenstable, regenfactor, regenframetime);
\r
1947 current = min(regenstable, current + regenlinear * regenframetime);
\r
1949 if(regensound != "")
\r
1950 if(regenfactor || regenlinear)
\r
1952 if(self.regen_soundtime < time)
\r
1954 msg_entity = self;
\r
1955 if(clienttype(msg_entity) == CLIENTTYPE_REAL)
\r
1956 soundto(MSG_ONE, self, CHAN_AUTO, regensound, VOL_BASE, ATTN_NONE);
\r
1958 self.regen_soundtime = time + 1; // only replay the sound if regen was paused for one second
\r
1963 if(current > limit)
\r
1969 void player_regen (void)
\r
1971 float minh, mina, minf, maxh, maxa, maxf, limith, limita, limitf, max_mod, regen_mod, rot_mod, limit_mod;
\r
1972 maxh = cvar("g_balance_health_rotstable");
\r
1973 maxa = cvar("g_balance_armor_rotstable");
\r
1974 maxf = cvar("g_balance_fuel_rotstable");
\r
1975 minh = cvar("g_balance_health_regenstable");
\r
1976 mina = cvar("g_balance_armor_regenstable");
\r
1977 minf = cvar("g_balance_fuel_regenstable");
\r
1978 limith = cvar("g_balance_health_limit");
\r
1979 limita = cvar("g_balance_armor_limit");
\r
1980 limitf = cvar("g_balance_fuel_limit");
\r
1982 max_mod = regen_mod = rot_mod = limit_mod = 1;
\r
1984 maxh = maxh * max_mod;
\r
1985 //maxa = maxa * max_mod;
\r
1986 //maxf = maxf * max_mod;
\r
1987 minh = minh * max_mod;
\r
1988 //mina = mina * max_mod;
\r
1989 //minf = minf * max_mod;
\r
1990 limith = limith * limit_mod;
\r
1991 limita = limita * limit_mod;
\r
1992 //limitf = limitf * limit_mod;
\r
1997 if (!g_ca && (!g_lms || cvar("g_lms_regenerate")))
\r
1999 self.armorvalue = CalcRotRegen(self.armorvalue, mina, cvar("g_balance_armor_regen"), cvar("g_balance_armor_regenlinear"), regen_mod * frametime * (time > self.pauseregenarmor_finished), maxa, cvar("g_balance_armor_rot"), cvar("g_balance_armor_rotlinear"), rot_mod * frametime * (time > self.pauserotarmor_finished), limita, "misc/armor_regen.wav");
\r
2000 self.health = CalcRotRegen(self.health, minh, cvar("g_balance_health_regen"), cvar("g_balance_health_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished), maxh, cvar("g_balance_health_rot"), cvar("g_balance_health_rotlinear"), rot_mod * frametime * (time > self.pauserothealth_finished), limith, "misc/health_regen.wav");
\r
2002 // if player rotted to death... die!
\r
2003 if(self.health < 1)
\r
2004 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
\r
2007 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
\r
2008 self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, cvar("g_balance_fuel_regen"), cvar("g_balance_fuel_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished) * (self.items & IT_FUEL_REGEN != 0), maxf, cvar("g_balance_fuel_rot"), cvar("g_balance_fuel_rotlinear"), rot_mod * frametime * (time > self.pauserotfuel_finished), limitf, "");
\r
2011 float zoomstate_set;
\r
2012 void SetZoomState(float z)
\r
2014 if(z != self.zoomstate)
\r
2016 self.zoomstate = z;
\r
2017 ClientData_Touch(self);
\r
2019 zoomstate_set = 1;
\r
2022 void GetPressedKeys(void) {
\r
2023 if (self.movement_x > 0) // get if movement keys are pressed
\r
2024 { // forward key pressed
\r
2025 self.pressedkeys |= KEY_FORWARD;
\r
2026 self.pressedkeys &~= KEY_BACKWARD;
\r
2028 else if (self.movement_x < 0)
\r
2029 { // backward key pressed
\r
2030 self.pressedkeys |= KEY_BACKWARD;
\r
2031 self.pressedkeys &~= KEY_FORWARD;
\r
2035 self.pressedkeys &~= KEY_FORWARD;
\r
2036 self.pressedkeys &~= KEY_BACKWARD;
\r
2039 if (self.movement_y > 0)
\r
2040 { // right key pressed
\r
2041 self.pressedkeys |= KEY_RIGHT;
\r
2042 self.pressedkeys &~= KEY_LEFT;
\r
2044 else if (self.movement_y < 0)
\r
2045 { // left key pressed
\r
2046 self.pressedkeys |= KEY_LEFT;
\r
2047 self.pressedkeys &~= KEY_RIGHT;
\r
2051 self.pressedkeys &~= KEY_RIGHT;
\r
2052 self.pressedkeys &~= KEY_LEFT;
\r
2055 if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed
\r
2056 self.pressedkeys |= KEY_JUMP;
\r
2058 self.pressedkeys &~= KEY_JUMP;
\r
2059 if (self.BUTTON_CROUCH)
\r
2060 self.pressedkeys |= KEY_CROUCH;
\r
2062 self.pressedkeys &~= KEY_CROUCH;
\r
2065 void update_stats (float number, float hit, float fired) {
\r
2066 // self.stat_hit = number + ((number==0) ? 1 : 64) * hit * sv_accuracy_data_share;
\r
2067 // self.stat_fired = number + ((number==0) ? 1 : 64) * fired * sv_accuracy_data_share;
\r
2070 self.stat_hit = number + 64 * hit * sv_accuracy_data_share;
\r
2071 self.stat_fired = number + 64 * fired * sv_accuracy_data_share;
\r
2073 self.stat_hit = hit * sv_accuracy_data_share;
\r
2074 self.stat_fired = fired * sv_accuracy_data_share;
\r
2079 ======================
\r
2080 spectate mode routines
\r
2081 ======================
\r
2084 .float weapon_count;
\r
2085 void SpectateCopy(entity spectatee) {
\r
2086 if(spectatee.weapon_count < WEP_LAST) {
\r
2087 update_stats (spectatee.weapon_count, spectatee.cvar_cl_accuracy_data_share * floor(spectatee.stats_hit[spectatee.weapon_count - 1]), spectatee.cvar_cl_accuracy_data_share * floor(spectatee.stats_fired[spectatee.weapon_count - 1]));
\r
2088 spectatee.weapon_count ++;
\r
2090 update_stats (0, spectatee.cvar_cl_accuracy_data_share * spectatee.stat_hit, spectatee.cvar_cl_accuracy_data_share * spectatee.stat_fired);
\r
2092 self.kh_state = spectatee.kh_state;
\r
2093 self.armortype = spectatee.armortype;
\r
2094 self.armorvalue = spectatee.armorvalue;
\r
2095 self.ammo_fuel = spectatee.ammo_fuel;
\r
2096 self.clip_load = spectatee.clip_load;
\r
2097 self.clip_size = spectatee.clip_size;
\r
2098 self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
\r
2099 self.health = spectatee.health;
\r
2101 self.items = spectatee.items;
\r
2102 self.last_pickup = spectatee.last_pickup;
\r
2103 self.strength_finished = spectatee.strength_finished;
\r
2104 self.invincible_finished = spectatee.invincible_finished;
\r
2105 self.pressedkeys = spectatee.pressedkeys;
\r
2106 self.weapons = spectatee.weapons;
\r
2107 self.switchweapon = spectatee.switchweapon;
\r
2108 self.weapon = spectatee.weapon;
\r
2109 self.punchangle = spectatee.punchangle;
\r
2110 self.view_ofs = spectatee.view_ofs;
\r
2111 self.v_angle = spectatee.v_angle;
\r
2112 self.velocity = spectatee.velocity;
\r
2113 self.dmg_take = spectatee.dmg_take;
\r
2114 self.dmg_save = spectatee.dmg_save;
\r
2115 self.dmg_inflictor = spectatee.dmg_inflictor;
\r
2116 self.angles = spectatee.v_angle;
\r
2117 self.scale = spectatee.scale;
\r
2118 self.fixangle = TRUE;
\r
2119 self.stomach_load = spectatee.stomach_load;
\r
2120 self.stat_eaten = spectatee.stat_eaten;
\r
2121 self.swallow_progress_prey = spectatee.swallow_progress_prey;
\r
2122 self.swallow_progress_pred = spectatee.swallow_progress_pred;
\r
2123 self.stat_stomachload = spectatee.stat_stomachload;
\r
2124 self.stat_stomachmaxload = spectatee.stomach_maxload;
\r
2125 self.stat_digesting = spectatee.stat_digesting;
\r
2126 self.stat_canleave = spectatee.stat_canleave;
\r
2127 self.stat_canswallow = spectatee.stat_canswallow;
\r
2128 self.stat_sbring1_type = spectatee.stat_sbring1_type;
\r
2129 self.stat_sbring1_clip = spectatee.stat_sbring1_clip;
\r
2130 self.stat_sbring2_type = spectatee.stat_sbring2_type;
\r
2131 self.stat_sbring2_clip = spectatee.stat_sbring2_clip;
\r
2132 setorigin(self, spectatee.origin);
\r
2133 setsize(self, spectatee.mins, spectatee.maxs);
\r
2134 SetZoomState(spectatee.zoomstate);
\r
2136 anticheat_spectatecopy(spectatee);
\r
2139 float SpectateUpdate() {
\r
2143 if (self == self.enemy)
\r
2146 if(self.enemy.classname != "player")
\r
2149 SpectateCopy(self.enemy);
\r
2154 float SpectateNext() {
\r
2155 other = find(self.enemy, classname, "player");
\r
2158 other = find(other, classname, "player");
\r
2161 self.enemy = other;
\r
2163 if(self.enemy.classname == "player") {
\r
2164 msg_entity = self;
\r
2165 WriteByte(MSG_ONE, SVC_SETVIEW);
\r
2166 WriteEntity(MSG_ONE, self.enemy);
\r
2167 //stuffcmd(self, "set viewsize $tmpviewsize \n");
\r
2168 self.movetype = MOVETYPE_NONE;
\r
2170 self.enemy.weapon_count = 0;
\r
2172 if(!SpectateUpdate())
\r
2173 PutObserverInServer();
\r
2183 ShowRespawnCountdown()
\r
2185 Update a respawn countdown display.
\r
2188 void ShowRespawnCountdown()
\r
2191 if(self.deadflag == DEAD_NO) // just respawned?
\r
2195 number = ceil(self.death_time - time);
\r
2198 if(number <= self.respawn_countdown)
\r
2200 self.respawn_countdown = number - 1;
\r
2201 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
\r
2202 AnnounceTo(self, strcat(ftos(number), ""));
\r
2207 void LeaveSpectatorMode()
\r
2209 if(isJoinAllowed()) {
\r
2210 if(!teams_matter || cvar("g_campaign") || cvar("g_balance_teams") || (self.wasplayer && cvar("g_changeteam_banned"))) {
\r
2211 self.classname = "player";
\r
2213 if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force"))
\r
2214 JoinBestTeam(self, FALSE, TRUE);
\r
2216 if(cvar("g_campaign"))
\r
2217 campaign_bots_may_start = 1;
\r
2219 self.stat_count = WEP_LAST;
\r
2221 PutClientInServer();
\r
2223 if(self.classname == "player")
\r
2224 bprint ("^4", self.netname, "^4 is playing now\n");
\r
2226 if(!cvar("g_campaign"))
\r
2227 centerprint(self,""); // clear MOTD
\r
2231 if (g_ca && self.caplayer) {
\r
2234 stuffcmd(self,"menu_showteamselect\n");
\r
2239 //player may not join because of g_maxplayers is set
\r
2240 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
\r
2245 * Determines whether the player is allowed to join. This depends on cvar
\r
2246 * g_maxplayers, if it isn't used this function always return TRUE, otherwise
\r
2247 * it checks whether the number of currently playing players exceeds g_maxplayers.
\r
2248 * @return bool TRUE if the player is allowed to join, false otherwise
\r
2250 float isJoinAllowed() {
\r
2251 if (!cvar("g_maxplayers"))
\r
2255 local float currentlyPlaying;
\r
2256 FOR_EACH_REALPLAYER(e) {
\r
2257 if(e.classname == "player")
\r
2258 currentlyPlaying += 1;
\r
2260 if(currentlyPlaying < cvar("g_maxplayers"))
\r
2267 * Checks whether the client is an observer or spectator, if so, he will get kicked after
\r
2268 * g_maxplayers_spectator_blocktime seconds
\r
2270 void checkSpectatorBlock() {
\r
2271 if(self.classname == "spectator" || self.classname == "observer") {
\r
2272 if( time > (self.spectatortime + cvar("g_maxplayers_spectator_blocktime")) ) {
\r
2273 sprint(self, "^7You were kicked from the server because you are spectator and spectators aren't allowed at the moment.\n");
\r
2279 float vercmp_recursive(string v1, string v2)
\r
2285 dot1 = strstrofs(v1, ".", 0);
\r
2286 dot2 = strstrofs(v2, ".", 0);
\r
2290 s1 = substring(v1, 0, dot1);
\r
2294 s2 = substring(v2, 0, dot2);
\r
2296 r = stof(s1) - stof(s2);
\r
2300 r = strcasecmp(s1, s2);
\r
2313 return vercmp_recursive(substring(v1, dot1 + 1, 999), substring(v2, dot2 + 1, 999));
\r
2316 float vercmp(string v1, string v2)
\r
2318 if(strcasecmp(v1, v2) == 0) // early out check
\r
2320 return vercmp_recursive(v1, v2);
\r
2323 .float last_alive_scale;
\r
2324 void SetPlayerSize()
\r
2326 if(!cvar("g_healthsize"))
\r
2329 if(self.deadflag == DEAD_NO)
\r
2331 // change player scale based on the amount of health we have
\r
2332 self.scale = pow(bound(cvar("g_healthsize_min"), self.health, cvar("g_healthsize_max")) / cvar("g_healthsize_center"), cvar("g_healthsize"));
\r
2334 // The following code sets the bounding box to match the player's size.
\r
2335 // It is currently disabled because of issues with engine movement prediction (cl_movement).
\r
2336 // The engine expects the bounding box to be default size, and changing it will cause glitches.
\r
2337 // This code may be enabled once the engine has the ability to use different bbox sizes for movement prediction.
\r
2340 //setsize (self, PL_CROUCH_MIN * self.scale, PL_CROUCH_MAX * self.scale);
\r
2341 if(!self.stat_eaten)
\r
2342 self.view_ofs = PL_CROUCH_VIEW_OFS * self.scale;
\r
2346 //setsize (self, PL_MIN * self.scale, PL_MAX * self.scale);
\r
2347 if(!self.stat_eaten)
\r
2348 self.view_ofs = PL_VIEW_OFS * self.scale;
\r
2351 self.last_alive_scale = self.scale;
\r
2353 else if(self.last_alive_scale)
\r
2355 // if the player is dead, use the last scale he had when he was alive
\r
2356 self.scale = self.last_alive_scale;
\r
2359 if(cvar("g_healthsize_death") && self.deadflag != DEAD_NO)
\r
2361 // dead players shrink to zero as they head toward the health limit
\r
2362 self.scale *= 1 - bound(0, (self.health / cvar("g_healthsize_death_min")) * cvar("g_healthsize_death"), 1);
\r
2365 if(self.scale < 0.1)
\r
2366 self.scale = 0.1; // stuff breaks if scale is smaller than this
\r
2369 void ObserverThink()
\r
2371 if (self.flags & FL_JUMPRELEASED) {
\r
2372 if (self.BUTTON_JUMP && !self.version_mismatch) {
\r
2373 self.welcomemessage_time = 0;
\r
2374 self.flags &~= FL_JUMPRELEASED;
\r
2375 self.flags |= FL_SPAWNING;
\r
2376 } else if(self.BUTTON_ATCK && !self.version_mismatch) {
\r
2377 self.welcomemessage_time = 0;
\r
2378 self.flags &~= FL_JUMPRELEASED;
\r
2379 if(SpectateNext() == 1) {
\r
2380 self.classname = "spectator";
\r
2384 if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) {
\r
2385 self.flags |= FL_JUMPRELEASED;
\r
2386 if(self.flags & FL_SPAWNING)
\r
2388 self.flags &~= FL_SPAWNING;
\r
2389 LeaveSpectatorMode();
\r
2394 PrintWelcomeMessage(self);
\r
2397 void SpectatorThink()
\r
2399 if (self.flags & FL_JUMPRELEASED) {
\r
2400 if (self.BUTTON_JUMP && !self.version_mismatch) {
\r
2401 self.welcomemessage_time = 0;
\r
2402 self.flags &~= FL_JUMPRELEASED;
\r
2403 self.flags |= FL_SPAWNING;
\r
2404 } else if(self.BUTTON_ATCK) {
\r
2405 self.welcomemessage_time = 0;
\r
2406 self.flags &~= FL_JUMPRELEASED;
\r
2407 if(SpectateNext() == 1) {
\r
2408 self.classname = "spectator";
\r
2410 self.classname = "observer";
\r
2411 self.stat_count = WEP_LAST;
\r
2412 PutClientInServer();
\r
2414 } else if (self.BUTTON_ATCK2) {
\r
2415 self.welcomemessage_time = 0;
\r
2416 self.flags &~= FL_JUMPRELEASED;
\r
2417 self.classname = "observer";
\r
2418 self.stat_count = WEP_LAST;
\r
2419 PutClientInServer();
\r
2421 if(!SpectateUpdate())
\r
2422 PutObserverInServer();
\r
2425 if (!(self.BUTTON_ATCK || self.BUTTON_ATCK2)) {
\r
2426 self.flags |= FL_JUMPRELEASED;
\r
2427 if(self.flags & FL_SPAWNING)
\r
2429 self.flags &~= FL_SPAWNING;
\r
2430 LeaveSpectatorMode();
\r
2436 PrintWelcomeMessage(self);
\r
2437 self.flags |= FL_CLIENT | FL_NOTARGET;
\r
2440 .float touchexplode_time;
\r
2446 Called every frame for each client before the physics are run
\r
2449 void() ctf_setstatus;
\r
2450 .float items_added;
\r
2452 .float power_sounded;
\r
2453 void PlayerPreThink (void)
\r
2455 self.stat_game_starttime = game_starttime;
\r
2456 self.stat_allow_oldnexbeam = cvar("g_allow_oldnexbeam");
\r
2457 self.stat_leadlimit = cvar("leadlimit");
\r
2461 // physics frames: update anticheat stuff
\r
2462 anticheat_prethink();
\r
2465 if(blockSpectators && frametime)
\r
2466 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
\r
2467 checkSpectatorBlock();
\r
2469 zoomstate_set = 0;
\r
2471 if(self.netname_previous != self.netname)
\r
2473 if(cvar("sv_eventlog"))
\r
2474 GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname));
\r
2475 if(self.netname_previous)
\r
2476 strunzone(self.netname_previous);
\r
2477 self.netname_previous = strzone(self.netname);
\r
2480 // core code for the vore system
\r
2483 // play power fail sound
\r
2484 if(self.armorvalue < cvar("g_power"))
\r
2486 if(!self.power_sounded)
\r
2488 sound(self, CHAN_TRIGGER, "misc/power_fail.ogg", VOL_BASE, ATTN_NORM);
\r
2489 self.power_sounded = TRUE;
\r
2493 self.power_sounded = FALSE;
\r
2495 // version nagging
\r
2496 if(self.version_nagtime)
\r
2497 if(self.cvar_g_voretournamentversion)
\r
2498 if(time > self.version_nagtime)
\r
2500 if(strstr(self.cvar_g_voretournamentversion, "svn", 0) < 0)
\r
2502 if(strstr(cvar_string("g_voretournamentversion"), "svn", 0) >= 0)
\r
2504 dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Voretournament ", cvar_string("g_voretournamentversion"), " (beta)^7, you have ^3Voretournament ", self.cvar_g_voretournamentversion, "^1\n");
\r
2505 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Voretournament ", cvar_string("g_voretournamentversion"), " (beta)^7, you have ^3Voretournament ", self.cvar_g_voretournamentversion, "^1\n"));
\r
2510 r = vercmp(self.cvar_g_voretournamentversion, cvar_string("g_voretournamentversion"));
\r
2513 dprint("^1NOTE^7 to ", self.netname, "^7 - ^3Voretournament ", cvar_string("g_voretournamentversion"), "^7 is out, and you still have ^3Voretournament ", self.cvar_g_voretournamentversion, "^1 - get the update from ^4http://www.alientrap.org/voretournament/^1!\n");
\r
2514 sprint(self, strcat("\{1}^1NOTE: ^3Voretournament ", cvar_string("g_voretournamentversion"), "^7 is out, and you still have ^3Voretournament ", self.cvar_g_voretournamentversion, "^1 - get the update from ^4http://www.alientrap.org/voretournament/^1!\n"));
\r
2518 dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Voretournament ", cvar_string("g_voretournamentversion"), "^7, you have ^3Voretournament ", self.cvar_g_voretournamentversion, "^1\n");
\r
2519 sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Voretournament ", cvar_string("g_voretournamentversion"), "^7, you have ^3Voretournament ", self.cvar_g_voretournamentversion, "^1\n"));
\r
2523 self.version_nagtime = 0;
\r
2527 if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue)
\r
2529 sprint(self, strcat("godmode saved you ", ftos(self.max_armorvalue), " units of damage, cheater!\n"));
\r
2530 self.max_armorvalue = 0;
\r
2534 if (TetrisPreFrame())
\r
2538 if(self.classname == "player") {
\r
2539 // if(self.netname == "Wazat")
\r
2540 // bprint(self.classname, "\n");
\r
2542 CheckRules_Player();
\r
2544 PrintWelcomeMessage(self);
\r
2546 if (intermission_running)
\r
2548 IntermissionThink (); // otherwise a button could be missed between
\r
2549 return; // the think tics
\r
2552 if(self.teleport_time)
\r
2553 if(time > self.teleport_time)
\r
2555 self.teleport_time = 0;
\r
2556 self.effects = self.effects - (self.effects & EF_NODRAW);
\r
2559 if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
\r
2560 UpdateSelectedPlayer();
\r
2562 //don't allow the player to turn around while game is paused!
\r
2563 if(timeoutStatus == 2) {
\r
2564 self.v_angle = self.lastV_angle;
\r
2565 self.angles = self.lastV_angle;
\r
2566 self.fixangle = TRUE;
\r
2569 if(self.deadflag == DEAD_NO && !self.stat_eaten) // prevents bugs
\r
2571 // lean the player with damage and acceleration
\r
2572 // credits go to divVerent for these maths :)
\r
2573 vector L0, L1, LF, LA;
\r
2575 LA = AnglesTransform_FromAngles(self.angles);
\r
2577 // acceleration leaning
\r
2578 if(cvar("g_leanplayer_acceleration"))
\r
2580 // average velocity to obtain a smooth acceleration
\r
2582 f = frametime * cvar("g_leanplayer_acceleration_fade");
\r
2583 self.avg_vel = self.avg_vel * (1 - f) + self.velocity * f;
\r
2587 accel = self.velocity - self.avg_vel * cvar("g_leanplayer_acceleration"); // acceleration
\r
2589 // bound angles to the specified limit
\r
2590 accel_x = bound(-cvar("g_leanplayer_acceleration_max"), accel_x, cvar("g_leanplayer_acceleration_max"));
\r
2591 accel_y = bound(-cvar("g_leanplayer_acceleration_max"), accel_y, cvar("g_leanplayer_acceleration_max"));
\r
2592 accel_z = bound(-cvar("g_leanplayer_acceleration_max"), accel_z, cvar("g_leanplayer_acceleration_max"));
\r
2594 L0_x = vlen(accel);
\r
2595 L0_y = L1_y = vectoyaw(accel);
\r
2597 L0 = AnglesTransform_FromAngles(L0);
\r
2598 L1 = AnglesTransform_FromAngles(L1);
\r
2599 LF = AnglesTransform_Multiply(AnglesTransform_Invert(L1), L0);
\r
2600 LA = AnglesTransform_Multiply(LA, LF);
\r
2601 // end of acceleration leaning
\r
2604 L0 = vectoangles(self.leanangle_damage_loc);
\r
2605 L1 = vectoangles(self.leanangle_damage_loc + self.leanangle_damage_force);
\r
2607 L0 = AnglesTransform_FromAngles(L0);
\r
2608 L1 = AnglesTransform_FromAngles(L1);
\r
2609 LF = AnglesTransform_Multiply(AnglesTransform_Invert(L1), L0);
\r
2611 LA = AnglesTransform_Multiply(LA, LF);
\r
2613 // fade the player back to normal rotation each frame
\r
2614 self.leanangle_damage_force = self.leanangle_damage_force * cvar("g_leanplayer_damage_fade");
\r
2615 // end of damage leaning
\r
2617 self.angles = AnglesTransform_Normalize(AnglesTransform_ToAngles(LA), TRUE);
\r
2624 if(self.health <= 0 && cvar("g_deathglow"))
\r
2626 if(self.glowmod_x > 0)
\r
2627 self.glowmod_x -= cvar("g_deathglow") * frametime;
\r
2629 self.glowmod_x = -1;
\r
2630 if(self.glowmod_y > 0)
\r
2631 self.glowmod_y -= cvar("g_deathglow") * frametime;
\r
2633 self.glowmod_y = -1;
\r
2634 if(self.glowmod_z > 0)
\r
2635 self.glowmod_z -= cvar("g_deathglow") * frametime;
\r
2637 self.glowmod_z = -1;
\r
2641 // set weapon and player glowmod
\r
2642 self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
\r
2643 if(self.armorvalue < cvar("g_power"))
\r
2644 self.glowmod = self.glowmod * random(); // make glow flicker when power is down
\r
2645 self.weaponentity_glowmod = self.glowmod;
\r
2648 player_powerups();
\r
2651 if (self.deadflag != DEAD_NO)
\r
2653 float button_pressed, force_respawn;
\r
2654 if(self.personal && g_race_qualifying)
\r
2656 if(time > self.death_time)
\r
2658 self.death_time = time + 1; // only retry once a second
\r
2660 self.impulse = 141;
\r
2667 button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_JETPACK || self.BUTTON_USE);
\r
2668 force_respawn = (g_lms || (g_ca) || cvar("g_forced_respawn"));
\r
2669 if (self.deadflag == DEAD_DYING)
\r
2672 self.deadflag = DEAD_RESPAWNING;
\r
2673 else if(!button_pressed)
\r
2674 self.deadflag = DEAD_DEAD;
\r
2676 else if (self.deadflag == DEAD_DEAD)
\r
2678 if(button_pressed)
\r
2679 self.deadflag = DEAD_RESPAWNABLE;
\r
2681 else if (self.deadflag == DEAD_RESPAWNABLE)
\r
2683 if(!button_pressed)
\r
2684 self.deadflag = DEAD_RESPAWNING;
\r
2686 else if (self.deadflag == DEAD_RESPAWNING)
\r
2688 if(time > self.death_time)
\r
2690 self.death_time = time + 1; // only retry once a second
\r
2694 ShowRespawnCountdown();
\r
2699 if(g_touchexplode)
\r
2700 if(time > self.touchexplode_time)
\r
2701 if(self.classname == "player")
\r
2702 if(self.deadflag == DEAD_NO)
\r
2703 if not(IS_INDEPENDENT_PLAYER(self))
\r
2704 FOR_EACH_PLAYER(other) if(self != other)
\r
2706 if(time > other.touchexplode_time)
\r
2707 if(other.classname == "player")
\r
2708 if(other.deadflag == DEAD_NO)
\r
2709 if not(IS_INDEPENDENT_PLAYER(other))
\r
2710 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
\r
2712 PlayerTouchExplode(self, other);
\r
2713 self.touchexplode_time = other.touchexplode_time = time + 0.2;
\r
2717 if(g_lms && !self.deadflag && cvar("g_lms_campcheck_interval"))
\r
2721 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
\r
2722 dist = self.prevorigin - self.origin;
\r
2724 self.lms_traveled_distance += fabs(vlen(dist));
\r
2726 if((cvar("g_campaign") && !campaign_bots_may_start) || (time < game_starttime))
\r
2728 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
\r
2729 self.lms_traveled_distance = 0;
\r
2732 if(time > self.lms_nextcheck)
\r
2734 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
\r
2735 if(self.lms_traveled_distance < cvar("g_lms_campcheck_distance"))
\r
2737 centerprint(self, cvar_string("g_lms_campcheck_message"));
\r
2738 // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
\r
2739 // I wasn't able to find out WHY that happens, so I put a workaround in place that shall prevent players from being gibbed :(
\r
2740 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');
\r
2742 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
\r
2743 self.lms_traveled_distance = 0;
\r
2747 self.prevorigin = self.origin;
\r
2749 if ((self.BUTTON_CROUCH && !self.grabber.state) || self.health <= g_bloodloss)
\r
2753 self.crouch = TRUE;
\r
2754 self.view_ofs = PL_CROUCH_VIEW_OFS;
\r
2755 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
\r
2756 setanim(self, self.anim_duck, FALSE, TRUE, TRUE);
\r
2763 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
\r
2764 if (!trace_startsolid)
\r
2766 self.crouch = FALSE;
\r
2767 self.view_ofs = PL_VIEW_OFS;
\r
2768 setsize (self, PL_MIN, PL_MAX);
\r
2773 if(self.health <= g_bloodloss && self.deadflag == DEAD_NO)
\r
2775 if(self.bloodloss_timer < time)
\r
2777 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
\r
2778 self.bloodloss_timer = time + 0.5 + random() * 0.5;
\r
2786 // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
\r
2789 self.items &~= self.items_added;
\r
2793 self.items_added = 0;
\r
2794 if(self.items & IT_JETPACK)
\r
2795 if(self.items & IT_FUEL_REGEN || self.ammo_fuel >= 0.01)
\r
2796 self.items_added |= IT_FUEL;
\r
2798 self.items |= self.items_added;
\r
2807 self.dmg_team = max(0, self.dmg_team - cvar("g_teamdamage_resetspeed") * frametime);
\r
2809 //self.angles_y=self.v_angle_y + 90; // temp
\r
2810 } else if(gameover) {
\r
2811 if (intermission_running)
\r
2812 IntermissionThink (); // otherwise a button could be missed between
\r
2814 } else if(self.classname == "observer") {
\r
2816 } else if(self.classname == "spectator") {
\r
2820 if(!zoomstate_set)
\r
2821 SetZoomState(self.BUTTON_ZOOM);
\r
2823 float oldspectatee_status;
\r
2824 oldspectatee_status = self.spectatee_status;
\r
2825 if(self.classname == "spectator")
\r
2826 self.spectatee_status = num_for_edict(self.enemy);
\r
2827 else if(self.classname == "observer")
\r
2828 self.spectatee_status = num_for_edict(self);
\r
2830 self.spectatee_status = 0;
\r
2831 if(self.spectatee_status != oldspectatee_status)
\r
2833 ClientData_Touch(self);
\r
2834 if(g_race || g_cts)
\r
2835 race_InitSpectator();
\r
2838 if(self.teamkill_soundtime)
\r
2839 if(time > self.teamkill_soundtime)
\r
2841 self.teamkill_soundtime = 0;
\r
2843 entity oldpusher, oldself;
\r
2845 oldself = self; self = self.teamkill_soundsource;
\r
2846 oldpusher = self.pusher; self.pusher = oldself;
\r
2848 PlayerSound(self, playersound_teamshoot, CHAN_VOICE, VOICETYPE_LASTATTACKER_ONLY);
\r
2850 self.pusher = oldpusher;
\r
2854 if(self.taunt_soundtime)
\r
2855 if(time > self.taunt_soundtime)
\r
2857 switch(self.taunt_soundtype)
\r
2859 case TAUNTTYPE_DEATH:
\r
2860 PlayerSound(self, playersound_taunt, CHAN_VOICE, VOICETYPE_AUTOTAUNT);
\r
2862 case TAUNTTYPE_VOREPRED:
\r
2863 PlayerSound(self, playersound_pred, CHAN_VOICE, VOICETYPE_AUTOTAUNT);
\r
2865 case TAUNTTYPE_VOREPREY:
\r
2866 PlayerSound(self, playersound_prey, CHAN_VOICE, VOICETYPE_AUTOTAUNT);
\r
2869 dprint("Incorrect autotaunt type\n");
\r
2873 self.taunt_soundtime = 0;
\r
2874 self.taunt_soundtype = 0;
\r
2877 target_voicescript_next(self);
\r
2879 // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
\r
2881 self.clip_load = self.clip_size = 0;
\r
2884 float isInvisibleString(string s)
\r
2887 s = strdecolorize(s);
\r
2888 for((i = 0), (n = strlen(s)); i < n; ++i)
\r
2890 c = str2chr(s, i);
\r
2896 case 192: // charmap space
\r
2897 if (!cvar("utf8_enable"))
\r
2900 case 160: // space in unicode fonts
\r
2901 case 0xE000 + 192: // utf8 charmap space
\r
2902 if (cvar("utf8_enable"))
\r
2915 Called every frame for each client after the physics are run
\r
2918 .float idlekick_lasttimeleft;
\r
2919 void PlayerPostThink (void)
\r
2921 // Savage: Check for nameless players
\r
2922 if (isInvisibleString(self.netname)) {
\r
2923 self.netname = "Player";
\r
2924 stuffcmd(self, strcat("name ", self.netname, substring(ftos(random()), 2, -1), "\n"));
\r
2927 // send the clients accuracy stats to the client
\r
2928 if(self.stat_count > 0)
\r
2931 self.stat_hit = self.stat_count + 64 * floor(self.(stats_hit[self.stat_count - 1]));
\r
2932 self.stat_fired = self.stat_count + 64 * floor(self.(stats_fired[self.stat_count - 1]));
\r
2933 self.stat_count -= 1;
\r
2937 if(self.uid_kicktime)
\r
2938 if(time > self.uid_kicktime)
\r
2940 bprint("^3", self.netname, "^3 was kicked for missing UID.\n");
\r
2946 if(sv_maxidle && frametime)
\r
2948 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
\r
2950 timeleft = ceil(sv_maxidle - (time - self.parm_idlesince));
\r
2953 bprint("^3", self.netname, "^3 was kicked for idling.\n");
\r
2954 AnnounceTo(self, "terminated");
\r
2958 else if(timeleft <= 10)
\r
2960 if(timeleft != self.idlekick_lasttimeleft)
\r
2962 centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
\r
2963 AnnounceTo(self, strcat(ftos(timeleft), ""));
\r
2968 centerprint_expire(self, CENTERPRIO_IDLEKICK);
\r
2970 self.idlekick_lasttimeleft = timeleft;
\r
2974 if(self.impulse == 100)
\r
2975 ImpulseCommands();
\r
2976 if (TetrisPostFrame())
\r
2982 if(self.classname == "player") {
\r
2983 CheckRules_Player();
\r
2984 UpdateChatBubble();
\r
2986 ImpulseCommands();
\r
2987 if (intermission_running)
\r
2988 return; // intermission or finale
\r
2991 } else if (self.classname == "observer") {
\r
2993 } else if (self.classname == "spectator") {
\r
2999 for(i = 0; i < 1000; ++i)
\r
3002 end = self.origin + '0 0 1024' + 512 * randomvec();
\r
3003 tracebox(self.origin, self.mins, self.maxs, end, MOVE_NORMAL, self);
\r
3004 if(trace_fraction < 1)
\r
3005 if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
\r
3007 print("I HIT SOLID: ", vtos(self.origin), " -> ", vtos(end), "\n");
\r
3015 //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
\r
3017 if(self.waypointsprite_attachedforcarrier)
\r
3018 WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, cvar("g_balance_armor_blockpercent")));
\r
3020 playerdemo_write();
\r
3024 dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));
\r