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
17 WriteByte(MSG_ONE, SVC_TEMPENTITY);
\r
18 WriteByte(MSG_ONE, TE_CSQC_ANNOUNCE);
\r
19 WriteString(MSG_ONE, snd);
\r
22 float ClientData_Send(entity to, float sf)
\r
24 if(to != self.owner)
\r
33 if(to.classname == "spectator")
\r
38 if(e.race_completed)
\r
39 sf |= 1; // forced scoreboard
\r
40 if(to.spectatee_status)
\r
41 sf |= 2; // spectator ent number follows
\r
45 WriteByte(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
\r
46 WriteByte(MSG_ENTITY, sf);
\r
49 WriteByte(MSG_ENTITY, to.spectatee_status);
\r
53 WriteAngle(MSG_ENTITY, e.v_angle_x);
\r
54 WriteAngle(MSG_ENTITY, e.v_angle_y);
\r
60 void ClientData_Attach()
\r
62 Net_LinkEntity(self.clientdata = spawn(), FALSE, 0, ClientData_Send);
\r
63 self.clientdata.drawonlytoclient = self;
\r
64 self.clientdata.owner = self;
\r
67 void ClientData_Detach()
\r
69 remove(self.clientdata);
\r
70 self.clientdata = world;
\r
73 void ClientData_Touch(entity e)
\r
75 e.clientdata.SendFlags = 1;
\r
77 // make it spectatable
\r
79 FOR_EACH_REALCLIENT(e2)
\r
82 if(e2.classname == "spectator")
\r
84 e2.clientdata.SendFlags = 1;
\r
89 .vector spawnpoint_score;
\r
90 .string netname_previous;
\r
92 void spawnfunc_info_player_survivor (void)
\r
94 spawnfunc_info_player_deathmatch();
\r
97 void spawnfunc_info_player_start (void)
\r
99 spawnfunc_info_player_deathmatch();
\r
102 void spawnfunc_info_player_deathmatch (void)
\r
104 self.classname = "info_player_deathmatch";
\r
105 relocate_spawnpoint();
\r
108 void spawnpoint_use()
\r
111 if(have_team_spawns > 0)
\r
113 self.team = activator.team;
\r
114 some_spawn_has_been_used = 1;
\r
119 // _x: prio (-1 if unusable)
\r
121 vector Spawn_Score(entity spot, entity playerlist, float teamcheck, float anypoint)
\r
123 float shortest, thisdist;
\r
129 // filter out spots for the wrong team
\r
131 if(spot.team != teamcheck)
\r
135 if(spot.target == "")
\r
138 if(clienttype(self) == CLIENTTYPE_REAL)
\r
140 if(spot.restriction == 1)
\r
145 if(spot.restriction == 2)
\r
149 // filter out spots for assault
\r
150 if(spot.target != "") {
\r
153 ent = find(world, targetname, spot.target);
\r
156 if(ent.classname == "target_objective")
\r
159 if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
\r
163 else if(ent.classname == "trigger_race_checkpoint")
\r
166 if(!anypoint) // spectators may spawn everywhere
\r
169 if(g_race_qualifying)
\r
172 if(ent.race_checkpoint != 0)
\r
174 if(spot.race_place != race_lowest_place_spawn)
\r
179 if(ent.race_checkpoint != self.race_respawn_checkpoint)
\r
181 // try reusing the previous spawn
\r
182 if(ent == self.race_respawn_spotref || spot == self.race_respawn_spotref)
\r
184 if(ent.race_checkpoint == 0)
\r
187 pl = self.race_place;
\r
188 if(pl > race_highest_place_spawn)
\r
190 if(pl == 0 && !self.race_started)
\r
191 pl = race_highest_place_spawn; // use last place if he has not even touched finish yet
\r
192 if(spot.race_place != pl)
\r
199 ent = find(ent, targetname, spot.target);
\r
206 player = playerlist;
\r
207 shortest = vlen(world.maxs - world.mins);
\r
208 for(player = playerlist; player; player = player.chain)
\r
209 if (player != self)
\r
211 thisdist = vlen(player.origin - spot.origin);
\r
212 if (thisdist < shortest)
\r
213 shortest = thisdist;
\r
215 return prio * '1 0 0' + shortest * '0 1 0';
\r
218 float spawn_allbad;
\r
219 float spawn_allgood;
\r
220 entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck, float anypoint)
\r
222 local entity spot, spotlist, spotlistend;
\r
223 spawn_allgood = TRUE;
\r
224 spawn_allbad = TRUE;
\r
227 spotlistend = world;
\r
229 for(spot = firstspot; spot; spot = spot.chain)
\r
231 spot.spawnpoint_score = Spawn_Score(spot, playerlist, teamcheck, anypoint);
\r
233 if(cvar("spawn_debugview"))
\r
235 setmodel(spot, "models/rune.mdl");
\r
236 if(spot.spawnpoint_score_y < mindist)
\r
238 spot.colormod = '1 0 0';
\r
243 spot.colormod = '0 1 0';
\r
244 spot.scale = spot.spawnpoint_score_y / mindist;
\r
248 if(spot.spawnpoint_score_x >= 0) // spawning allowed here
\r
250 if(spot.spawnpoint_score_y < mindist)
\r
252 // too short distance
\r
253 spawn_allgood = FALSE;
\r
258 spawn_allbad = FALSE;
\r
261 spotlistend.chain = spot;
\r
262 spotlistend = spot;
\r
268 if(spot.team != teamcheck)
\r
269 error("invalid spawn added");
\r
271 print("added ", etos(spot), "\n");
\r
277 spotlistend.chain = world;
\r
282 for(e = spotlist; e; e = e.chain)
\r
284 print("seen ", etos(e), "\n");
\r
285 if(e.team != teamcheck)
\r
286 error("invalid spawn found");
\r
293 entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
\r
295 // weight of a point: bound(lower, mindisttoplayer, upper)^exponent
\r
296 // multiplied by spot.cnt (useful if you distribute many spawnpoints in a small area)
\r
299 RandomSelection_Init();
\r
300 for(spot = firstspot; spot; spot = spot.chain)
\r
301 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
303 return RandomSelection_chosen_ent;
\r
310 Finds a point to respawn
\r
313 entity SelectSpawnPoint (float anypoint)
\r
315 local float teamcheck;
\r
316 local entity firstspot_new;
\r
317 local entity spot, firstspot, playerlist;
\r
319 spot = find (world, classname, "testplayerstart");
\r
325 if(!anypoint && have_team_spawns > 0)
\r
326 teamcheck = self.team;
\r
328 // get the list of players
\r
329 playerlist = findchain(classname, "player");
\r
330 // get the entire list of spots
\r
331 firstspot = findchain(classname, "info_player_deathmatch");
\r
332 // filter out the bad ones
\r
333 // (note this returns the original list if none survived)
\r
336 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
\r
340 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 100, teamcheck, anypoint);
\r
342 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, -1, teamcheck, anypoint);
\r
343 firstspot = firstspot_new;
\r
345 // there is 50/50 chance of choosing a random spot or the furthest spot
\r
346 // (this means that roughly every other spawn will be furthest, so you
\r
347 // usually won't get fragged at spawn twice in a row)
\r
348 if (arena_roundbased && !g_ca)
\r
350 firstspot_new = Spawn_FilterOutBadSpots(firstspot, playerlist, 800, teamcheck, anypoint);
\r
352 firstspot = firstspot_new;
\r
353 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
\r
355 else if (random() > cvar("g_spawn_furthest"))
\r
356 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
\r
358 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
\r
361 if(cvar("spawn_debugview"))
\r
363 print("spot mindistance: ", vtos(spot.spawnpoint_score), "\n");
\r
367 for(e = firstspot; e; e = e.chain)
\r
368 if(e.team != teamcheck)
\r
369 error("invalid spawn found");
\r
374 if(cvar("spawn_debug"))
\r
378 if(some_spawn_has_been_used)
\r
379 return world; // team can't spawn any more, because of actions of other team
\r
381 error("Cannot find a spawn point - please fix the map!");
\r
392 Checks if the argument string can be a valid playermodel.
\r
393 Returns a valid one in doubt.
\r
396 // string FallbackPlayerModel = "models/player/vixen.zym";
\r
397 string FallbackPlayerModel = "models/onslaught/generator.md3"; // TEMPORARY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\r
398 string CheckPlayerModel(string plyermodel) {
\r
399 if(strlen(plyermodel) < 4)
\r
400 return FallbackPlayerModel;
\r
401 if( substring(plyermodel,0,14) != "models/player/")
\r
402 return FallbackPlayerModel;
\r
403 else if(cvar("sv_servermodelsonly"))
\r
405 if(substring(plyermodel,-4,4) != ".zym")
\r
406 if(substring(plyermodel,-4,4) != ".dpm")
\r
407 if(substring(plyermodel,-4,4) != ".md3")
\r
408 if(substring(plyermodel,-4,4) != ".psk")
\r
409 return FallbackPlayerModel;
\r
410 if(plyermodel != strtolower(plyermodel))
\r
411 return FallbackPlayerModel;
\r
412 if(!fexists(plyermodel))
\r
413 return FallbackPlayerModel;
\r
418 void setmodel_apply(string modelname)
\r
420 precache_model(modelname);
\r
421 setmodel(self, modelname); // players have high precision
\r
422 player_setupanimsformodel();
\r
425 string setmodel_state()
\r
427 // set the proper belly model depending on how full we are
\r
428 string newmodel_name, newmodel_extension, applymodel;
\r
430 tokenizebyseparator(self.playermodel, ".");
\r
431 newmodel_name = argv(0);
\r
432 newmodel_extension = argv(1);
\r
434 if(self.stomach_load >= 3)
\r
435 applymodel = strcat(newmodel_name, "_state3.", newmodel_extension);
\r
436 else if(self.stomach_load >= 2)
\r
437 applymodel = strcat(newmodel_name, "_state2.", newmodel_extension);
\r
438 else if(self.stomach_load >= 1)
\r
439 applymodel = strcat(newmodel_name, "_state1.", newmodel_extension);
\r
441 applymodel = self.playermodel;
\r
448 Client_customizeentityforclient
\r
451 void Client_setmodel(string applymodel)
\r
453 local vector m1, m2;
\r
454 if(self.classname != "player" || self.deadflag != DEAD_NO) // prevent some bugs
\r
456 if(applymodel == self.model || self.spectatee_status) // no change to apply
\r
459 applymodel = CheckPlayerModel(applymodel); // this is never "", so no endless loop
\r
462 setmodel_apply(applymodel);
\r
463 setsize (self, m1, m2);
\r
466 void Client_uncustomizeentityforclient()
\r
468 self.skin = self.skinindex;
\r
471 float Client_customizeentityforclient()
\r
473 entity modelsource;
\r
475 if(self.modelindex == 0)
\r
478 // forcemodel stuff
\r
482 t0 = gettime(GETTIME_HIRES); // reference
\r
485 modelsource = self;
\r
487 #ifdef ALLOW_FORCEMODELS
\r
488 if(other.cvar_cl_forceplayermodelsfromvoretournament)
\r
489 modelsource = other;
\r
490 if(other.cvar_cl_forceplayermodels && sv_clforceplayermodels)
\r
491 modelsource = other;
\r
494 self.skin = modelsource.skinindex;
\r
497 if(modelsource == self)
\r
498 self.skin = modelsource.skinindex;
\r
500 self.skin = mod(modelsource.skinindex, 3); // forbid the fbskins as forced skins
\r
504 // other: the player viewing me
\r
508 t1 = gettime(GETTIME_HIRES); // reference
\r
509 client_cefc_accumulator += (t1 - t0);
\r
512 // now change the predator's player model into a stomach model for the prey
\r
513 // in other words, when a player is swallowed by another player, the eater becomes an inward stomach model so the prey can see theirself in the stomach
\r
514 // this is only visible to the prey however, otherwise players would appear as a floating stomach to everyone (ewww)
\r
516 // don't do this if we have chase_active enabled, as we'd be seeing a floating stomach from third person view
\r
517 if(other.cvar_chase_active > 0 || other.classname == "observer") // the classname check prevents a bug
\r
519 Client_setmodel(setmodel_state());
\r
522 if(other.spectatee_status)
\r
523 other = other.enemy; // also do this for the player we are spectating
\r
524 if(other.eater == self)
\r
526 tokenizebyseparator(self.playermodel, ".");
\r
527 Client_setmodel(strcat(argv(0), "_stomach.md3"));
\r
530 Client_setmodel(setmodel_state());
\r
536 PutObserverInServer
\r
538 putting a client as observer in the server
\r
541 void FixPlayermodel();
\r
542 void PutObserverInServer (void)
\r
546 race_PreSpawnObserver();
\r
548 spot = SelectSpawnPoint (TRUE);
\r
550 error("No spawnpoints for observers?!?\n");
\r
551 RemoveGrabber(self); // Wazat's Grabber
\r
553 if(clienttype(self) == CLIENTTYPE_REAL)
\r
556 WriteByte(MSG_ONE, SVC_SETVIEW);
\r
557 WriteEntity(MSG_ONE, self);
\r
560 kh_Key_DropAll(self, TRUE);
\r
562 if(self.flagcarried)
\r
563 DropFlag(self.flagcarried, world, world);
\r
565 WaypointSprite_PlayerDead();
\r
567 if not(g_ca) // don't reset teams when moving a ca player to the spectators
\r
568 self.team = -1; // move this as it is needed to log the player spectating in eventlog
\r
570 if(self.killcount != -666) {
\r
572 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
\r
573 bprint ("^4", self.netname, "^4 has no more lives left\n");
\r
575 bprint ("^4", self.netname, "^4 is spectating now\n"); // TODO turn this into a proper forfeit?
\r
577 bprint ("^4", self.netname, "^4 is spectating now\n");
\r
579 if(self.just_joined == FALSE) {
\r
580 LogTeamchange(self.playerid, -1, 4);
\r
582 self.just_joined = FALSE;
\r
585 PlayerScore_Clear(self); // clear scores when needed
\r
587 self.spectatortime = time;
\r
589 self.classname = "observer";
\r
590 self.iscreature = FALSE;
\r
591 self.health = -666;
\r
592 self.takedamage = DAMAGE_NO;
\r
593 self.solid = SOLID_NOT;
\r
594 self.movetype = MOVETYPE_NOCLIP;
\r
595 self.flags = FL_CLIENT | FL_NOTARGET;
\r
596 self.armorvalue = 666;
\r
598 self.armorvalue = cvar("g_balance_armor_start");
\r
599 self.pauserotarmor_finished = 0;
\r
600 self.pauserothealth_finished = 0;
\r
601 self.pauseregen_finished = 0;
\r
602 self.damageforcescale = 0;
\r
603 self.death_time = 0;
\r
604 self.dead_frame = 0;
\r
607 self.fade_time = 0;
\r
608 self.pain_frame = 0;
\r
609 self.pain_finished = 0;
\r
610 self.strength_finished = 0;
\r
611 self.invincible_finished = 0;
\r
612 self.pushltime = 0;
\r
613 self.think = SUB_Null;
\r
614 self.nextthink = 0;
\r
615 self.grabber_time = 0;
\r
616 self.deadflag = DEAD_NO;
\r
617 self.angles = spot.angles;
\r
619 self.fixangle = TRUE;
\r
620 self.crouch = FALSE;
\r
622 self.view_ofs = PL_VIEW_OFS;
\r
623 setorigin (self, spot.origin);
\r
624 setsize (self, '0 0 0', '0 0 0');
\r
625 self.prevorigin = self.origin;
\r
631 self.modelindex = 0;
\r
633 self.weaponmodel = "";
\r
634 self.weaponentity = world;
\r
635 self.exteriorweaponentity = world;
\r
636 self.killcount = -666;
\r
637 self.velocity = '0 0 0';
\r
638 self.avelocity = '0 0 0';
\r
639 self.punchangle = '0 0 0';
\r
640 self.punchvector = '0 0 0';
\r
641 self.oldvelocity = self.velocity;
\r
642 self.fire_endtime = -1;
\r
644 SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
\r
648 if(self.version_mismatch)
\r
650 Spawnqueue_Unmark(self);
\r
651 Spawnqueue_Remove(self);
\r
655 Spawnqueue_Insert(self);
\r
660 // Only if the player cannot play at all
\r
661 if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666)
\r
662 self.frags = FRAGS_SPECTATOR;
\r
664 self.frags = FRAGS_LMS_LOSER;
\r
667 self.frags = FRAGS_SPECTATOR;
\r
670 float RestrictSkin(float s)
\r
679 void FixPlayermodel()
\r
681 local string defaultmodel;
\r
682 local float defaultskin, chmdl, oldskin;
\r
683 local vector m1, m2;
\r
687 if(cvar("sv_defaultcharacter") == 1) {
\r
693 s = Team_ColorNameLowerCase(self.team);
\r
696 defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
\r
697 defaultskin = cvar(strcat("sv_defaultplayerskin_", s));
\r
701 if(defaultmodel == "")
\r
703 defaultmodel = cvar_string("sv_defaultplayermodel");
\r
704 defaultskin = cvar("sv_defaultplayerskin");
\r
708 if(self.modelindex == 0 && self.deadflag == DEAD_NO)
\r
710 if(self.model != "")
\r
711 bprint("\{1}^1Player ", self.netname, "^1 has a zero modelindex, trying to fix...\n");
\r
712 self.model = ""; // force the != checks to return true
\r
715 if(defaultmodel != "")
\r
717 if (defaultmodel != self.model)
\r
721 setmodel_apply (defaultmodel);
\r
722 setsize (self, m1, m2);
\r
726 oldskin = self.skinindex;
\r
727 self.skinindex = defaultskin;
\r
729 if (self.model == "")
\r
731 self.playermodel = CheckPlayerModel(self.playermodel); // this is never "", so no endless loop
\r
734 setmodel_apply (self.playermodel);
\r
735 setsize (self, m1, m2);
\r
738 // update player sounds if we changed model
\r
739 if(self.model == self.playermodel) // don't apply sounds for other models (like the player stomach state models)
\r
740 UpdatePlayerSounds();
\r
742 oldskin = self.skinindex;
\r
743 self.skinindex = RestrictSkin(stof(self.playerskin));
\r
746 if(chmdl || oldskin != self.skinindex)
\r
747 self.species = player_getspecies(); // model or skin has changed
\r
750 if(strlen(cvar_string("sv_defaultplayercolors")))
\r
751 if(self.clientcolors != cvar("sv_defaultplayercolors"))
\r
752 setcolor(self, cvar("sv_defaultplayercolors"));
\r
755 void PlayerTouchExplode(entity p1, entity p2)
\r
758 org = (p1.origin + p2.origin) * 0.5;
\r
759 org_z += (p1.mins_z + p2.mins_z) * 0.5;
\r
766 RadiusDamage(e, world, g_touchexplode_damage, g_touchexplode_edgedamage, g_touchexplode_radius, world, g_touchexplode_force, DEATH_TOUCHEXPLODE, world);
\r
774 Called when a client spawns in the server
\r
777 //void() ctf_playerchanged;
\r
778 void PutClientInServer (void)
\r
780 if(clienttype(self) == CLIENTTYPE_BOT)
\r
782 self.classname = "player";
\r
784 else if(clienttype(self) == CLIENTTYPE_REAL)
\r
787 WriteByte(MSG_ONE, SVC_SETVIEW);
\r
788 WriteEntity(MSG_ONE, self);
\r
791 // player is dead and becomes observer
\r
792 // FIXME fix LMS scoring for new system
\r
795 if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
\r
796 self.classname = "observer";
\r
799 if(g_arena || (g_ca && !allowed_to_spawn))
\r
801 self.classname = "observer";
\r
804 self.classname = "observer";
\r
806 if(self.classname == "player" && (!g_ca || (g_ca && allowed_to_spawn))) {
\r
807 entity spot, oldself;
\r
811 JoinBestTeam(self, FALSE, TRUE);
\r
815 spot = SelectSpawnPoint (FALSE);
\r
818 centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
\r
819 return; // spawn failed
\r
822 RemoveGrabber(self); // Wazat's Grabber
\r
824 self.classname = "player";
\r
825 self.wasplayer = TRUE;
\r
826 self.iscreature = TRUE;
\r
827 self.movetype = MOVETYPE_WALK;
\r
828 self.solid = SOLID_SLIDEBOX;
\r
829 if(cvar("g_playerclip_collisions"))
\r
830 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
832 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
\r
833 self.frags = FRAGS_PLAYER;
\r
834 if(independent_players)
\r
835 MAKE_INDEPENDENT_PLAYER(self);
\r
836 self.flags = FL_CLIENT;
\r
837 self.takedamage = DAMAGE_AIM;
\r
839 self.air_finished = time + 12;
\r
844 self.ammo_fuel = warmup_start_ammo_fuel;
\r
845 self.health = warmup_start_health;
\r
846 self.armorvalue = warmup_start_armorvalue;
\r
847 self.weapons = warmup_start_weapons;
\r
851 self.ammo_fuel = start_ammo_fuel;
\r
852 self.health = start_health;
\r
853 self.armorvalue = start_armorvalue;
\r
854 self.weapons = start_weapons;
\r
857 self.items = start_items;
\r
858 self.switchweapon = w_getbestweapon(self);
\r
859 self.cnt = self.switchweapon;
\r
862 self.spawnshieldtime = time + cvar("g_spawnshieldtime");
\r
863 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
\r
864 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
\r
865 self.pauserotfuel_finished = time + cvar("g_balance_pause_fuel_rot_spawn");
\r
866 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
\r
867 //extend the pause of rotting if client was reset at the beginning of the countdown
\r
868 if(!cvar("sv_ready_restart_after_countdown") && time < game_starttime) { // TODO why is this cvar NOTted?
\r
869 self.spawnshieldtime += game_starttime - time;
\r
870 self.pauserotarmor_finished += game_starttime - time;
\r
871 self.pauserothealth_finished += game_starttime - time;
\r
872 self.pauseregen_finished += game_starttime - time;
\r
874 self.damageforcescale = 2;
\r
875 self.death_time = 0;
\r
876 self.dead_frame = 0;
\r
879 self.fade_time = 0;
\r
880 self.pain_frame = 0;
\r
881 self.pain_finished = 0;
\r
882 self.strength_finished = 0;
\r
883 self.invincible_finished = 0;
\r
884 self.pushltime = 0;
\r
885 // players have no think function
\r
886 self.think = SUB_Null;
\r
887 self.nextthink = 0;
\r
888 self.grabber_time = 0;
\r
891 self.deadflag = DEAD_NO;
\r
892 self.stomach_load = 0;
\r
893 self.angles = spot.angles;
\r
895 self.angles_z = 0; // never spawn tilted even if the spot says to
\r
896 self.fixangle = TRUE; // turn this way immediately
\r
897 self.velocity = '0 0 0';
\r
898 self.avelocity = '0 0 0';
\r
899 self.punchangle = '0 0 0';
\r
900 self.punchvector = '0 0 0';
\r
901 self.oldvelocity = self.velocity;
\r
902 self.fire_endtime = -1;
\r
905 WRITESPECTATABLE_MSG_ONE({
\r
906 WriteByte(MSG_ONE, SVC_TEMPENTITY);
\r
907 WriteByte(MSG_ONE, TE_CSQC_SPAWN);
\r
910 SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
\r
915 self.crouch = FALSE;
\r
916 self.view_ofs = PL_VIEW_OFS;
\r
917 setsize (self, PL_MIN, PL_MAX);
\r
918 self.spawnorigin = spot.origin;
\r
919 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
\r
920 // don't reset back to last position, even if new position is stuck in solid
\r
921 self.oldorigin = self.origin;
\r
922 self.prevorigin = self.origin;
\r
923 self.lastrocket = world; // stop rocket guiding, no revenge from the grave!
\r
927 Spawnqueue_Remove(self);
\r
928 Spawnqueue_Mark(self);
\r
934 self.event_damage = PlayerDamage;
\r
936 self.bot_attack = TRUE;
\r
938 self.statdraintime = time + 5;
\r
939 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
\r
941 if(self.killcount == -666) {
\r
942 PlayerScore_Clear(self);
\r
943 self.killcount = 0;
\r
946 CL_SpawnWeaponentity();
\r
947 self.alpha = default_player_alpha;
\r
948 self.colormod = '1 1 1' * cvar("g_player_brightness");
\r
949 self.exteriorweaponentity.alpha = default_weapon_alpha;
\r
951 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
\r
952 self.lms_traveled_distance = 0;
\r
953 self.speedrunning = FALSE;
\r
955 race_PostSpawn(spot);
\r
957 if(cvar("spawn_debug"))
\r
959 sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n"));
\r
960 remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
\r
963 //stuffcmd(self, "chase_active 0");
\r
964 //stuffcmd(self, "set viewsize $tmpviewsize \n");
\r
966 if (cvar("g_spawnsound"))
\r
967 sound (self, CHAN_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
\r
970 if(self.team == assault_attacker_team)
\r
971 centerprint(self, "You are attacking!");
\r
973 centerprint(self, "You are defending!");
\r
976 target_voicescript_clear(self);
\r
978 // reset fields the weapons may use
\r
979 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
\r
980 weapon_action(j, WR_RESETPLAYER);
\r
984 activator = oldself;
\r
988 } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
\r
989 PutObserverInServer ();
\r
993 // ctf_playerchanged();
\r
996 float ClientInit_SendEntity(entity to, float sf)
\r
998 WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
\r
999 WriteCoord(MSG_ENTITY, grabber_shotorigin_x);
\r
1000 WriteCoord(MSG_ENTITY, grabber_shotorigin_y);
\r
1001 WriteCoord(MSG_ENTITY, grabber_shotorigin_z);
\r
1003 if(sv_foginterval && world.fog != "")
\r
1004 WriteString(MSG_ENTITY, world.fog);
\r
1006 WriteString(MSG_ENTITY, "");
\r
1007 WriteByte(MSG_ENTITY, cvar("g_balance_armor_blockpercent") * 255.0);
\r
1008 WriteByte(MSG_ENTITY, cvar("g_balance_weaponswitchdelay") * 255.0);
\r
1010 WriteCoord(MSG_ENTITY, cvar("g_balance_vore_swallow_limit"));
\r
1011 WriteCoord(MSG_ENTITY, cvar("g_vore_showpreyhealth"));
\r
1015 void ClientInit_Spawn()
\r
1017 Net_LinkEntity(spawn(), FALSE, 0, ClientInit_SendEntity);
\r
1025 void SetNewParms (void)
\r
1027 // initialize parms for a new player
\r
1028 parm1 = -(86400 * 366);
\r
1036 void SetChangeParms (void)
\r
1038 // save parms for level change
\r
1039 parm1 = self.parm_idlesince - time;
\r
1047 void DecodeLevelParms (void)
\r
1050 self.parm_idlesince = parm1;
\r
1051 if(self.parm_idlesince == -(86400 * 366))
\r
1052 self.parm_idlesince = time;
\r
1054 // whatever happens, allow 60 seconds of idling directly after connect for map loading
\r
1055 self.parm_idlesince = max(self.parm_idlesince, time - sv_maxidle + 60);
\r
1062 Called when a client types 'kill' in the console
\r
1066 void ClientKill_Now_TeamChange()
\r
1068 if(self.killindicator_teamchange == -1)
\r
1071 JoinBestTeam( self, FALSE, FALSE );
\r
1074 SV_ChangeTeam(self.killindicator_teamchange - 1);
\r
1077 void ClientKill_Now()
\r
1079 if(self.killindicator_teamchange)
\r
1080 ClientKill_Now_TeamChange();
\r
1083 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
\r
1085 if(self.killindicator)
\r
1087 dprint("Cleaned up after a leaked kill indicator.\n");
\r
1088 remove(self.killindicator);
\r
1089 self.killindicator = world;
\r
1092 void KillIndicator_Think()
\r
1094 if (!self.owner.modelindex)
\r
1096 self.owner.killindicator = world;
\r
1103 self = self.owner;
\r
1104 ClientKill_Now(); // no oldself needed
\r
1109 if(self.cnt <= 10)
\r
1110 setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
\r
1111 if(clienttype(self.owner) == CLIENTTYPE_REAL)
\r
1113 if(self.cnt <= 10)
\r
1114 AnnounceTo(self.owner, strcat(ftos(self.cnt), ""));
\r
1115 if(self.owner.killindicator_teamchange)
\r
1117 if(self.owner.killindicator_teamchange == -1)
\r
1118 centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
\r
1120 centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
\r
1123 centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
\r
1125 self.nextthink = time + 1;
\r
1130 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
\r
1134 killtime = cvar("g_balance_kill_delay");
\r
1136 if(g_race_qualifying)
\r
1139 self.killindicator_teamchange = targetteam;
\r
1141 if(!self.killindicator)
\r
1143 if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
\r
1149 self.killindicator = spawn();
\r
1150 self.killindicator.owner = self;
\r
1151 self.killindicator.scale = 0.5;
\r
1152 setattachment(self.killindicator, self, "");
\r
1153 setorigin(self.killindicator, '0 0 52');
\r
1154 self.killindicator.think = KillIndicator_Think;
\r
1155 self.killindicator.nextthink = time + (self.lip) * 0.05;
\r
1156 self.killindicator.cnt = ceil(killtime);
\r
1157 self.killindicator.count = bound(0, ceil(killtime), 10);
\r
1158 sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n"));
\r
1160 for(e = world; (e = find(e, classname, "body")) != world; )
\r
1162 if(e.enemy != self)
\r
1164 e.killindicator = spawn();
\r
1165 e.killindicator.owner = e;
\r
1166 e.killindicator.scale = 0.5;
\r
1167 setattachment(e.killindicator, e, "");
\r
1168 setorigin(e.killindicator, '0 0 52');
\r
1169 e.killindicator.think = KillIndicator_Think;
\r
1170 e.killindicator.nextthink = time + (e.lip) * 0.05;
\r
1171 e.killindicator.cnt = ceil(killtime);
\r
1176 if(self.killindicator)
\r
1179 self.killindicator.colormod = TeamColor(targetteam);
\r
1181 self.killindicator.colormod = '0 0 0';
\r
1185 void ClientKill (void)
\r
1187 ClientKill_TeamChange(0);
\r
1190 void DoTeamChange(float destteam)
\r
1196 SetPlayerColors(self, destteam);
\r
1199 if(self.classname == "player")
\r
1200 if(destteam == -1)
\r
1202 CheckAllowedTeams(self);
\r
1203 t = FindSmallestTeam(self, TRUE);
\r
1206 case COLOR_TEAM1: c0 = c1; break;
\r
1207 case COLOR_TEAM2: c0 = c2; break;
\r
1208 case COLOR_TEAM3: c0 = c3; break;
\r
1209 case COLOR_TEAM4: c0 = c4; break;
\r
1210 default: c0 = 999;
\r
1216 destteam = COLOR_TEAM1;
\r
1220 destteam = COLOR_TEAM2;
\r
1224 destteam = COLOR_TEAM3;
\r
1228 destteam = COLOR_TEAM4;
\r
1231 if(destteam == -1)
\r
1234 if(destteam == self.team && destteam >= 0 && !self.killindicator)
\r
1236 ClientKill_TeamChange(destteam);
\r
1239 void FixClientCvars(entity e)
\r
1241 // send prediction settings to the client
\r
1242 stuffcmd(e, "\nin_bindmap 0 0\n");
\r
1243 if(g_race || g_cts)
\r
1244 stuffcmd(e, "cl_cmd settemp cl_movecliptokeyboard 2\n");
\r
1245 if(cvar("g_antilag") == 3) // client side hitscan
\r
1246 //stuffcmd(e, "cl_cmd settemp cl_prydoncursor -1\ncl_cmd settemp cl_prydoncursor_notrace 0\n");
\r
1247 stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
\r
1249 * we no longer need to stuff this. Remove this comment block if you feel
\r
1250 * 2.3 and higher (or was it 2.2.3?) don't need these any more
\r
1251 stuffcmd(e, strcat("cl_gravity ", ftos(cvar("sv_gravity")), "\n"));
\r
1252 stuffcmd(e, strcat("cl_movement_accelerate ", ftos(cvar("sv_accelerate")), "\n"));
\r
1253 stuffcmd(e, strcat("cl_movement_friction ", ftos(cvar("sv_friction")), "\n"));
\r
1254 stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(cvar("sv_maxspeed")), "\n"));
\r
1255 stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(cvar("sv_airaccelerate")), "\n"));
\r
1256 stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(cvar("sv_maxairspeed")), "\n"));
\r
1257 stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(cvar("sv_stopspeed")), "\n"));
\r
1258 stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(cvar("sv_jumpvelocity")), "\n"));
\r
1259 stuffcmd(e, strcat("cl_movement_stepheight ", ftos(cvar("sv_stepheight")), "\n"));
\r
1260 stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(cvar("sv_friction_on_land")), "\n"));
\r
1261 stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(cvar("sv_airaccel_qw")), "\n"));
\r
1262 stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(cvar("sv_airaccel_sideways_friction")), "\n"));
\r
1263 stuffcmd(e, "cl_movement_edgefriction 1\n");
\r
1271 Called when a client connects to the server
\r
1274 //void ctf_clientconnect();
\r
1275 string ColoredTeamName(float t);
\r
1276 void DecodeLevelParms (void);
\r
1277 //void dom_player_join_team(entity pl);
\r
1279 .float uid_kicktime;
\r
1282 void ClientConnect (void)
\r
1286 if(self.flags & FL_CLIENT)
\r
1288 print("Warning: ClientConnect, but already connected!\n");
\r
1292 if(Ban_MaybeEnforceBan(self))
\r
1295 DecodeLevelParms();
\r
1297 self.classname = "player_joining";
\r
1299 self.flags = FL_CLIENT;
\r
1300 self.version_nagtime = time + 10 + random() * 10;
\r
1302 if(player_count<0)
\r
1304 dprint("BUG player count is lower than zero, this cannot happen!\n");
\r
1308 PlayerScore_Attach(self);
\r
1309 ClientData_Attach();
\r
1311 bot_clientconnect();
\r
1313 playerdemo_init();
\r
1317 race_PreSpawnObserver();
\r
1319 //if(g_domination)
\r
1320 // dom_player_join_team(self);
\r
1322 JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it
\r
1324 if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign")) {
\r
1325 self.classname = "observer";
\r
1329 if(cvar("g_balance_teams") || cvar("g_balance_teams_force"))
\r
1331 self.classname = "player";
\r
1332 campaign_bots_may_start = 1;
\r
1336 self.classname = "observer"; // do it anyway
\r
1341 self.classname = "player";
\r
1342 campaign_bots_may_start = 1;
\r
1346 self.playerid = (playerid_last = playerid_last + 1);
\r
1348 if(cvar("sv_eventlog"))
\r
1349 GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((clienttype(self) == CLIENTTYPE_REAL) ? self.netaddress : "bot"), ":", self.netname));
\r
1351 LogTeamchange(self.playerid, self.team, 1);
\r
1353 self.just_joined = TRUE; // stop spamming the eventlog with additional lines when the client connects
\r
1355 self.netname_previous = strzone(self.netname);
\r
1357 bprint("^4", self.netname, "^4 connected");
\r
1359 if(self.classname != "observer" && (g_domination || g_ctf))
\r
1360 bprint(" and joined the ", ColoredTeamName(self.team));
\r
1364 self.welcomemessage_time = 0;
\r
1366 stuffcmd(self, strcat(clientstuff, "\n"));
\r
1367 stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n"));
\r
1368 stuffcmd(self, "cl_particles_reloadeffects\n");
\r
1370 FixClientCvars(self);
\r
1372 // spawnfunc_waypoint sprites
\r
1373 WaypointSprite_InitClient(self);
\r
1375 // Wazat's grabber
\r
1376 SetGrabberBindings();
\r
1378 // get autoswitch state from player when he toggles it
\r
1379 stuffcmd(self, "alias autoswitch \"set cl_autoswitch $1 ; cmd autoswitch $1\"\n"); // default.cfg-ed in 2.4.1
\r
1381 // get version info from player
\r
1382 stuffcmd(self, "cmd clientversion $gameversion\n");
\r
1384 // get other cvars from player
\r
1387 // set cvar for team scoreboard
\r
1388 stuffcmd(self, strcat("set teamplay ", ftos(teamplay), "\n"));
\r
1390 // notify about available teams
\r
1393 CheckAllowedTeams(self);
\r
1394 t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
\r
1395 stuffcmd(self, strcat("set _teams_available ", ftos(t), "\n"));
\r
1398 stuffcmd(self, "set _teams_available 0\n");
\r
1400 stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
\r
1402 if(g_arena || g_ca)
\r
1404 self.classname = "observer";
\r
1406 Spawnqueue_Insert(self);
\r
1410 ctf_clientconnect();
\r
1413 if(teams_matter || radar_showennemies)
\r
1416 bot_relinkplayerlist();
\r
1418 self.spectatortime = time;
\r
1419 if(blockSpectators)
\r
1421 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
1424 self.jointime = time;
\r
1425 self.allowedTimeouts = cvar("sv_timeout_number");
\r
1427 if(clienttype(self) == CLIENTTYPE_REAL)
\r
1429 if(cvar("g_bugrigs"))
\r
1430 stuffcmd(self, "cl_cmd settemp chase_active 1\n");
\r
1435 if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
\r
1437 PlayerScore_Add(self, SP_LMS_RANK, 666);
\r
1438 self.frags = FRAGS_SPECTATOR;
\r
1442 if(!sv_foginterval && world.fog != "")
\r
1443 stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
\r
1445 SoundEntity_Attach(self);
\r
1447 if(cvar("g_hitplots") || strstrofs(strcat(" ", cvar_string("g_hitplots_individuals"), " "), strcat(" ", self.netaddress, " "), 0) >= 0)
\r
1449 self.hitplotfh = fopen(strcat("hits-", matchid, "-", self.netaddress, "-", ftos(self.playerid), ".plot"), FILE_WRITE);
\r
1450 fputs(self.hitplotfh, strcat("#name ", self.netname, "\n"));
\r
1453 self.hitplotfh = -1;
\r
1456 if(clienttype(self) == CLIENTTYPE_REAL)
\r
1458 self.uid_kicktime = time + 60;
\r
1461 if(g_race || g_cts) {
\r
1467 t = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time")));
\r
1469 race_send_recordtime(MSG_ONE);
\r
1470 race_send_speedaward(MSG_ONE);
\r
1472 speedaward_alltimebest = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed")));
\r
1473 speedaward_alltimebest_holder = db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/netname"));
\r
1474 race_send_speedaward_alltimebest(MSG_ONE);
\r
1477 for (i = 1; i <= RANKINGS_CNT; ++i) {
\r
1478 race_SendRankings(i, 0, 0, MSG_ONE);
\r
1481 else if(cvar("sv_teamnagger") && !g_ca) // teamnagger is currently bad for ca
\r
1482 send_CSQC_teamnagger();
\r
1484 CheatInitClient();
\r
1491 Called when a client disconnects from the server
\r
1494 .entity chatbubbleentity;
\r
1495 .entity teambubbleentity;
\r
1496 void ReadyCount();
\r
1497 void ClientDisconnect (void)
\r
1499 if not(self.flags & FL_CLIENT)
\r
1501 print("Warning: ClientDisconnect without ClientConnect\n");
\r
1505 Vore_Disconnect();
\r
1507 CheatShutdownClient();
\r
1509 if(self.hitplotfh >= 0)
\r
1511 fclose(self.hitplotfh);
\r
1512 self.hitplotfh = -1;
\r
1515 anticheat_report();
\r
1516 anticheat_shutdown();
\r
1518 playerdemo_shutdown();
\r
1520 bot_clientdisconnect();
\r
1525 if(cvar("sv_eventlog"))
\r
1526 GameLogEcho(strcat(":part:", ftos(self.playerid)));
\r
1527 bprint ("^4",self.netname);
\r
1528 bprint ("^4 disconnected\n");
\r
1530 SoundEntity_Detach(self);
\r
1532 kh_Key_DropAll(self, TRUE);
\r
1534 if(self.flagcarried)
\r
1535 DropFlag(self.flagcarried, world, world);
\r
1536 // Here, everything has been done that requires this player to be a client.
\r
1538 self.flags &~= FL_CLIENT;
\r
1540 if (self.chatbubbleentity)
\r
1541 remove (self.chatbubbleentity);
\r
1543 if (self.teambubbleentity)
\r
1544 remove (self.teambubbleentity);
\r
1546 if (self.killindicator)
\r
1547 remove (self.killindicator);
\r
1549 WaypointSprite_PlayerGone();
\r
1551 bot_relinkplayerlist();
\r
1555 Spawnqueue_Unmark(self);
\r
1556 Spawnqueue_Remove(self);
\r
1559 ClientData_Detach();
\r
1560 PlayerScore_Detach(self);
\r
1562 if(self.netname_previous)
\r
1563 strunzone(self.netname_previous);
\r
1564 if(self.clientstatus)
\r
1565 strunzone(self.clientstatus);
\r
1567 ClearPlayerSounds();
\r
1570 remove(self.personal);
\r
1572 self.playerid = 0;
\r
1579 .float BUTTON_CHAT;
\r
1580 void ChatBubbleThink()
\r
1582 self.nextthink = time;
\r
1583 if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
\r
1585 if(self.owner) // but why can that ever be world?
\r
1586 self.owner.chatbubbleentity = world;
\r
1590 if ((self.owner.BUTTON_CHAT && !self.owner.deadflag && self.owner.eater.classname != "player")
\r
1592 || self.owner.tetris_on
\r
1595 self.model = self.mdl;
\r
1600 void UpdateChatBubble()
\r
1602 if (!self.modelindex)
\r
1604 // spawn a chatbubble entity if needed
\r
1605 if (!self.chatbubbleentity)
\r
1607 self.chatbubbleentity = spawn();
\r
1608 self.chatbubbleentity.owner = self;
\r
1609 self.chatbubbleentity.exteriormodeltoclient = self;
\r
1610 self.chatbubbleentity.think = ChatBubbleThink;
\r
1611 self.chatbubbleentity.nextthink = time;
\r
1612 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
\r
1613 //setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
\r
1614 setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
\r
1615 setattachment(self.chatbubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
\r
1616 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
\r
1617 self.chatbubbleentity.model = "";
\r
1618 self.chatbubbleentity.effects = EF_LOWPRECISION;
\r
1623 void TeamBubbleThink()
\r
1625 self.nextthink = time;
\r
1626 if (!self.owner.modelindex || self.owner.teambubbleentity != self)
\r
1628 if(self.owner) // but why can that ever be world?
\r
1629 self.owner.teambubbleentity = world;
\r
1633 // setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1'); // bandwidth hog. setattachment does this now
\r
1634 if (self.owner.BUTTON_CHAT || self.owner.deadflag || self.owner.killindicator || self.owner.eater.classname == "player")
\r
1637 self.model = self.mdl;
\r
1641 float TeamBubble_customizeentityforclient()
\r
1643 return (self.owner != other && self.owner.team == other.team && other.killcount > -666);
\r
1646 void UpdateTeamBubble()
\r
1648 if (!self.modelindex || !teams_matter)
\r
1650 // spawn a teambubble entity if needed
\r
1651 if (!self.teambubbleentity && teams_matter)
\r
1653 self.teambubbleentity = spawn();
\r
1654 self.teambubbleentity.owner = self;
\r
1655 self.teambubbleentity.exteriormodeltoclient = self;
\r
1656 self.teambubbleentity.think = TeamBubbleThink;
\r
1657 self.teambubbleentity.nextthink = time;
\r
1658 setmodel(self.teambubbleentity, "models/misc/teambubble.spr"); // precision set below
\r
1659 // setorigin(self.teambubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
\r
1660 setorigin(self.teambubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
\r
1661 setattachment(self.teambubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
\r
1662 self.teambubbleentity.mdl = self.teambubbleentity.model;
\r
1663 self.teambubbleentity.model = self.teambubbleentity.mdl;
\r
1664 self.teambubbleentity.customizeentityforclient = TeamBubble_customizeentityforclient;
\r
1665 self.teambubbleentity.effects = EF_LOWPRECISION;
\r
1669 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
\r
1670 // added to the model skins
\r
1671 /*void UpdateColorModHack()
\r
1674 c = self.clientcolors & 15;
\r
1675 // LordHavoc: only bothering to support white, green, red, yellow, blue
\r
1676 if (!teams_matter) self.colormod = '0 0 0';
\r
1677 else if (c == 0) self.colormod = '1.00 1.00 1.00';
\r
1678 else if (c == 3) self.colormod = '0.10 1.73 0.10';
\r
1679 else if (c == 4) self.colormod = '1.73 0.10 0.10';
\r
1680 else if (c == 12) self.colormod = '1.22 1.22 0.10';
\r
1681 else if (c == 13) self.colormod = '0.10 0.10 1.73';
\r
1682 else self.colormod = '1 1 1';
\r
1685 void respawn(void)
\r
1688 self.effects |= EF_NODRAW; // prevent another CopyBody
\r
1689 PutClientInServer();
\r
1692 void play_countdown(float finished, string samp)
\r
1694 if(clienttype(self) == CLIENTTYPE_REAL)
\r
1695 if(floor(finished - time - frametime) != floor(finished - time))
\r
1696 if(finished - time < 6)
\r
1697 sound (self, CHAN_AUTO, samp, VOL_BASE, ATTN_NORM);
\r
1701 * When sv_timeout is used this function returs strings like
\r
1702 * "Timeout begins in 2 seconds!\n" or "Timeout ends in 23 seconds!\n".
\r
1703 * Called by centerprint functions
\r
1704 * @param addOneSecond boolean, set to 1 if the welcome-message centerprint asks for the text
\r
1706 string getTimeoutText(float addOneSecond) {
\r
1707 if (!cvar("sv_timeout") || !timeoutStatus)
\r
1710 local string retStr;
\r
1711 if (timeoutStatus == 1) {
\r
1712 if (addOneSecond == 1) {
\r
1713 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime + 1), " seconds!\n");
\r
1716 retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
\r
1720 else if (timeoutStatus == 2) {
\r
1721 if (addOneSecond) {
\r
1722 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
\r
1723 //don't show messages like "Timeout ends in 0 seconds"...
\r
1724 if ((remainingTimeoutTime + 1) > 0)
\r
1730 retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
\r
1731 //don't show messages like "Timeout ends in 0 seconds"...
\r
1732 if (remainingTimeoutTime > 0)
\r
1741 void player_powerups (void)
\r
1743 if((self.items & IT_USING_JETPACK) && !self.deadflag)
\r
1745 SoundEntity_StartSound(self, CHAN_PLAYER, "misc/jetpack_fly.wav", VOL_BASE, cvar("g_jetpack_attenuation"));
\r
1746 self.modelflags |= MF_ROCKET;
\r
1750 SoundEntity_StopSound(self, CHAN_PLAYER);
\r
1751 self.modelflags &~= MF_ROCKET;
\r
1754 self.effects &~= (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
\r
1756 if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
\r
1759 Fire_ApplyDamage(self);
\r
1760 Fire_ApplyEffect(self);
\r
1762 if (self.items & IT_STRENGTH)
\r
1764 play_countdown(self.strength_finished, "misc/poweroff.wav");
\r
1765 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
\r
1766 if (time > self.strength_finished && cvar("g_balance_powerup_timer"))
\r
1768 self.items = self.items - (self.items & IT_STRENGTH);
\r
1769 sprint(self, "^3Strength has worn off\n");
\r
1774 if (time < self.strength_finished)
\r
1776 self.items = self.items | IT_STRENGTH;
\r
1777 sprint(self, "^3Strength infuses your weapons with devastating power\n");
\r
1780 if (self.items & IT_INVINCIBLE)
\r
1782 play_countdown(self.invincible_finished, "misc/poweroff.wav");
\r
1783 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
\r
1784 if (time > self.invincible_finished && cvar("g_balance_powerup_timer"))
\r
1786 self.items = self.items - (self.items & IT_INVINCIBLE);
\r
1787 sprint(self, "^3Shield has worn off\n");
\r
1792 if (time < self.invincible_finished)
\r
1794 self.items = self.items | IT_INVINCIBLE;
\r
1795 sprint(self, "^3Shield surrounds you\n");
\r
1799 if(cvar("g_nodepthtestplayers"))
\r
1800 self.effects = self.effects | EF_NODEPTHTEST;
\r
1802 if(cvar("g_fullbrightplayers"))
\r
1803 self.effects = self.effects | EF_FULLBRIGHT;
\r
1805 // midair gamemode: damage only while in the air
\r
1806 // if in midair mode, being on ground grants temporary invulnerability
\r
1807 // (this is so that multishot weapon don't clear the ground flag on the
\r
1808 // first damage in the frame, leaving the player vulnerable to the
\r
1809 // remaining hits in the same frame)
\r
1810 if (self.flags & FL_ONGROUND)
\r
1812 self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
\r
1814 if (time >= game_starttime)
\r
1815 if (time < self.spawnshieldtime)
\r
1816 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
\r
1819 float CalcRegen(float current, float stable, float regenfactor, float regenframetime)
\r
1821 if(current > stable)
\r
1823 else if(current > stable - 0.25) // when close enough, "snap"
\r
1826 return min(stable, current + (stable - current) * regenfactor * regenframetime);
\r
1829 float CalcRot(float current, float stable, float rotfactor, float rotframetime)
\r
1831 if(current < stable)
\r
1833 else if(current < stable + 0.25) // when close enough, "snap"
\r
1836 return max(stable, current + (stable - current) * rotfactor * rotframetime);
\r
1839 float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit)
\r
1841 if(current > rotstable)
\r
1843 if(rotframetime > 0)
\r
1845 current = CalcRot(current, rotstable, rotfactor, rotframetime);
\r
1846 current = max(rotstable, current - rotlinear * rotframetime);
\r
1849 else if(current < regenstable)
\r
1851 if(regenframetime > 0)
\r
1853 current = CalcRegen(current, regenstable, regenfactor, regenframetime);
\r
1854 current = min(regenstable, current + regenlinear * regenframetime);
\r
1858 if(current > limit)
\r
1864 void player_regen (void)
\r
1866 float minh, mina, minf, maxh, maxa, maxf, limith, limita, limitf, max_mod, regen_mod, rot_mod, limit_mod;
\r
1867 maxh = cvar("g_balance_health_rotstable");
\r
1868 maxa = cvar("g_balance_armor_rotstable");
\r
1869 maxf = cvar("g_balance_fuel_rotstable");
\r
1870 minh = cvar("g_balance_health_regenstable");
\r
1871 mina = cvar("g_balance_armor_regenstable");
\r
1872 minf = cvar("g_balance_fuel_regenstable");
\r
1873 limith = cvar("g_balance_health_limit");
\r
1874 limita = cvar("g_balance_armor_limit");
\r
1875 limitf = cvar("g_balance_fuel_limit");
\r
1877 max_mod = regen_mod = rot_mod = limit_mod = 1;
\r
1879 maxh = maxh * max_mod;
\r
1880 //maxa = maxa * max_mod;
\r
1881 //maxf = maxf * max_mod;
\r
1882 minh = minh * max_mod;
\r
1883 //mina = mina * max_mod;
\r
1884 //minf = minf * max_mod;
\r
1885 limith = limith * limit_mod;
\r
1886 limita = limita * limit_mod;
\r
1887 //limitf = limitf * limit_mod;
\r
1892 if (!g_ca && (!g_lms || cvar("g_lms_regenerate")))
\r
1894 self.armorvalue = CalcRotRegen(self.armorvalue, mina, cvar("g_balance_armor_regen"), cvar("g_balance_armor_regenlinear"), regen_mod * frametime * (time > self.pauseregen_finished), maxa, cvar("g_balance_armor_rot"), cvar("g_balance_armor_rotlinear"), rot_mod * frametime * (time > self.pauserotarmor_finished), limita);
\r
1895 self.health = CalcRotRegen(self.health, minh, cvar("g_balance_health_regen"), cvar("g_balance_health_regenlinear"), regen_mod * frametime * (time > self.pauseregen_finished), maxh, cvar("g_balance_health_rot"), cvar("g_balance_health_rotlinear"), rot_mod * frametime * (time > self.pauserothealth_finished), limith);
\r
1897 // if player rotted to death... die!
\r
1898 if(self.health < 1)
\r
1899 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
\r
1902 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
\r
1903 self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, cvar("g_balance_fuel_regen"), cvar("g_balance_fuel_regenlinear"), regen_mod * frametime * (time > self.pauseregen_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
1906 float zoomstate_set;
\r
1907 void SetZoomState(float z)
\r
1909 if(z != self.zoomstate)
\r
1911 self.zoomstate = z;
\r
1912 ClientData_Touch(self);
\r
1914 zoomstate_set = 1;
\r
1917 void GetPressedKeys(void) {
\r
1918 if (self.movement_x > 0) // get if movement keys are pressed
\r
1919 { // forward key pressed
\r
1920 self.pressedkeys |= KEY_FORWARD;
\r
1921 self.pressedkeys &~= KEY_BACKWARD;
\r
1923 else if (self.movement_x < 0)
\r
1924 { // backward key pressed
\r
1925 self.pressedkeys |= KEY_BACKWARD;
\r
1926 self.pressedkeys &~= KEY_FORWARD;
\r
1930 self.pressedkeys &~= KEY_FORWARD;
\r
1931 self.pressedkeys &~= KEY_BACKWARD;
\r
1934 if (self.movement_y > 0)
\r
1935 { // right key pressed
\r
1936 self.pressedkeys |= KEY_RIGHT;
\r
1937 self.pressedkeys &~= KEY_LEFT;
\r
1939 else if (self.movement_y < 0)
\r
1940 { // left key pressed
\r
1941 self.pressedkeys |= KEY_LEFT;
\r
1942 self.pressedkeys &~= KEY_RIGHT;
\r
1946 self.pressedkeys &~= KEY_RIGHT;
\r
1947 self.pressedkeys &~= KEY_LEFT;
\r
1950 if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed
\r
1951 self.pressedkeys |= KEY_JUMP;
\r
1953 self.pressedkeys &~= KEY_JUMP;
\r
1954 if (self.BUTTON_CROUCH)
\r
1955 self.pressedkeys |= KEY_CROUCH;
\r
1957 self.pressedkeys &~= KEY_CROUCH;
\r
1960 void update_stats (float number, float hit, float fired) {
\r
1961 // self.stat_hit = number + ((number==0) ? 1 : 64) * hit * sv_accuracy_data_share;
\r
1962 // self.stat_fired = number + ((number==0) ? 1 : 64) * fired * sv_accuracy_data_share;
\r
1965 self.stat_hit = number + 64 * hit * sv_accuracy_data_share;
\r
1966 self.stat_fired = number + 64 * fired * sv_accuracy_data_share;
\r
1968 self.stat_hit = hit * sv_accuracy_data_share;
\r
1969 self.stat_fired = fired * sv_accuracy_data_share;
\r
1974 ======================
\r
1975 spectate mode routines
\r
1976 ======================
\r
1979 .float weapon_count;
\r
1980 void SpectateCopy(entity spectatee) {
\r
1981 if(spectatee.weapon_count < WEP_LAST) {
\r
1982 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
1983 spectatee.weapon_count ++;
\r
1985 update_stats (0, spectatee.cvar_cl_accuracy_data_share * spectatee.stat_hit, spectatee.cvar_cl_accuracy_data_share * spectatee.stat_fired);
\r
1987 self.kh_state = spectatee.kh_state;
\r
1988 self.armortype = spectatee.armortype;
\r
1989 self.armorvalue = spectatee.armorvalue;
\r
1990 self.ammo_fuel = spectatee.ammo_fuel;
\r
1991 self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
\r
1992 self.health = spectatee.health;
\r
1994 self.items = spectatee.items;
\r
1995 self.strength_finished = spectatee.strength_finished;
\r
1996 self.invincible_finished = spectatee.invincible_finished;
\r
1997 self.pressedkeys = spectatee.pressedkeys;
\r
1998 self.weapons = spectatee.weapons;
\r
1999 self.switchweapon = spectatee.switchweapon;
\r
2000 self.weapon = spectatee.weapon;
\r
2001 self.punchangle = spectatee.punchangle;
\r
2002 self.view_ofs = spectatee.view_ofs;
\r
2003 self.v_angle = spectatee.v_angle;
\r
2004 self.velocity = spectatee.velocity;
\r
2005 self.dmg_take = spectatee.dmg_take;
\r
2006 self.dmg_save = spectatee.dmg_save;
\r
2007 self.dmg_inflictor = spectatee.dmg_inflictor;
\r
2008 self.angles = spectatee.v_angle;
\r
2009 self.fixangle = TRUE;
\r
2010 self.stomach_load = spectatee.stomach_load;
\r
2011 self.stat_eaten = spectatee.stat_eaten;
\r
2012 self.stat_stomachload = spectatee.stat_stomachload;
\r
2013 self.stat_digesting = spectatee.stat_digesting;
\r
2014 setorigin(self, spectatee.origin);
\r
2015 setsize(self, spectatee.mins, spectatee.maxs);
\r
2016 SetZoomState(spectatee.zoomstate);
\r
2018 anticheat_spectatecopy(spectatee);
\r
2021 float SpectateUpdate() {
\r
2025 if (self == self.enemy)
\r
2028 if(self.enemy.classname != "player")
\r
2031 SpectateCopy(self.enemy);
\r
2036 float SpectateNext() {
\r
2037 other = find(self.enemy, classname, "player");
\r
2040 other = find(other, classname, "player");
\r
2043 self.enemy = other;
\r
2045 if(self.enemy.classname == "player") {
\r
2046 msg_entity = self;
\r
2047 WriteByte(MSG_ONE, SVC_SETVIEW);
\r
2048 WriteEntity(MSG_ONE, self.enemy);
\r
2049 //stuffcmd(self, "set viewsize $tmpviewsize \n");
\r
2050 self.movetype = MOVETYPE_NONE;
\r
2052 self.enemy.weapon_count = 0;
\r
2054 if(!SpectateUpdate())
\r
2055 PutObserverInServer();
\r
2065 ShowRespawnCountdown()
\r
2067 Update a respawn countdown display.
\r
2070 void ShowRespawnCountdown()
\r
2073 if(self.deadflag == DEAD_NO) // just respawned?
\r
2077 number = ceil(self.death_time - time);
\r
2080 if(number <= self.respawn_countdown)
\r
2082 self.respawn_countdown = number - 1;
\r
2083 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
2084 AnnounceTo(self, strcat(ftos(number), ""));
\r
2089 void LeaveSpectatorMode()
\r
2091 if(isJoinAllowed()) {
\r
2092 if(!teams_matter || cvar("g_campaign") || cvar("g_balance_teams") || (self.wasplayer && cvar("g_changeteam_banned"))) {
\r
2093 self.classname = "player";
\r
2095 if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force"))
\r
2096 JoinBestTeam(self, FALSE, TRUE);
\r
2098 if(cvar("g_campaign"))
\r
2099 campaign_bots_may_start = 1;
\r
2101 self.stat_count = WEP_LAST;
\r
2103 PutClientInServer();
\r
2105 if(self.classname == "player")
\r
2106 bprint ("^4", self.netname, "^4 is playing now\n");
\r
2108 if(!cvar("g_campaign"))
\r
2109 centerprint(self,""); // clear MOTD
\r
2113 if (g_ca && self.caplayer) {
\r
2116 stuffcmd(self,"menu_showteamselect\n");
\r
2121 //player may not join because of g_maxplayers is set
\r
2122 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
\r
2127 * Determines whether the player is allowed to join. This depends on cvar
\r
2128 * g_maxplayers, if it isn't used this function always return TRUE, otherwise
\r
2129 * it checks whether the number of currently playing players exceeds g_maxplayers.
\r
2130 * @return bool TRUE if the player is allowed to join, false otherwise
\r
2132 float isJoinAllowed() {
\r
2133 if (!cvar("g_maxplayers"))
\r
2137 local float currentlyPlaying;
\r
2138 FOR_EACH_REALPLAYER(e) {
\r
2139 if(e.classname == "player")
\r
2140 currentlyPlaying += 1;
\r
2142 if(currentlyPlaying < cvar("g_maxplayers"))
\r
2149 * Checks whether the client is an observer or spectator, if so, he will get kicked after
\r
2150 * g_maxplayers_spectator_blocktime seconds
\r
2152 void checkSpectatorBlock() {
\r
2153 if(self.classname == "spectator" || self.classname == "observer") {
\r
2154 if( time > (self.spectatortime + cvar("g_maxplayers_spectator_blocktime")) ) {
\r
2155 sprint(self, "^7You were kicked from the server because you are spectator and spectators aren't allowed at the moment.\n");
\r
2161 float vercmp_recursive(string v1, string v2)
\r
2167 dot1 = strstrofs(v1, ".", 0);
\r
2168 dot2 = strstrofs(v2, ".", 0);
\r
2172 s1 = substring(v1, 0, dot1);
\r
2176 s2 = substring(v2, 0, dot2);
\r
2178 r = stof(s1) - stof(s2);
\r
2182 r = strcasecmp(s1, s2);
\r
2195 return vercmp_recursive(substring(v1, dot1 + 1, 999), substring(v2, dot2 + 1, 999));
\r
2198 float vercmp(string v1, string v2)
\r
2200 if(strcasecmp(v1, v2) == 0) // early out check
\r
2202 return vercmp_recursive(v1, v2);
\r
2205 void ObserverThink()
\r
2207 if (self.flags & FL_JUMPRELEASED) {
\r
2208 if (self.BUTTON_JUMP && !self.version_mismatch) {
\r
2209 self.welcomemessage_time = 0;
\r
2210 self.flags &~= FL_JUMPRELEASED;
\r
2211 self.flags |= FL_SPAWNING;
\r
2212 } else if(self.BUTTON_ATCK && !self.version_mismatch) {
\r
2213 self.welcomemessage_time = 0;
\r
2214 self.flags &~= FL_JUMPRELEASED;
\r
2215 if(SpectateNext() == 1) {
\r
2216 self.classname = "spectator";
\r
2220 if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) {
\r
2221 self.flags |= FL_JUMPRELEASED;
\r
2222 if(self.flags & FL_SPAWNING)
\r
2224 self.flags &~= FL_SPAWNING;
\r
2225 LeaveSpectatorMode();
\r
2230 PrintWelcomeMessage(self);
\r
2233 void SpectatorThink()
\r
2235 if (self.flags & FL_JUMPRELEASED) {
\r
2236 if (self.BUTTON_JUMP && !self.version_mismatch) {
\r
2237 self.welcomemessage_time = 0;
\r
2238 self.flags &~= FL_JUMPRELEASED;
\r
2239 self.flags |= FL_SPAWNING;
\r
2240 } else if(self.BUTTON_ATCK) {
\r
2241 self.welcomemessage_time = 0;
\r
2242 self.flags &~= FL_JUMPRELEASED;
\r
2243 if(SpectateNext() == 1) {
\r
2244 self.classname = "spectator";
\r
2246 self.classname = "observer";
\r
2247 self.stat_count = WEP_LAST;
\r
2248 PutClientInServer();
\r
2250 } else if (self.BUTTON_ATCK2) {
\r
2251 self.welcomemessage_time = 0;
\r
2252 self.flags &~= FL_JUMPRELEASED;
\r
2253 self.classname = "observer";
\r
2254 self.stat_count = WEP_LAST;
\r
2255 PutClientInServer();
\r
2257 if(!SpectateUpdate())
\r
2258 PutObserverInServer();
\r
2261 if (!(self.BUTTON_ATCK || self.BUTTON_ATCK2)) {
\r
2262 self.flags |= FL_JUMPRELEASED;
\r
2263 if(self.flags & FL_SPAWNING)
\r
2265 self.flags &~= FL_SPAWNING;
\r
2266 LeaveSpectatorMode();
\r
2272 PrintWelcomeMessage(self);
\r
2273 self.flags |= FL_CLIENT | FL_NOTARGET;
\r
2276 .float touchexplode_time;
\r
2282 Called every frame for each client before the physics are run
\r
2285 void() ctf_setstatus;
\r
2286 .float items_added;
\r
2287 void PlayerPreThink (void)
\r
2289 self.stat_game_starttime = game_starttime;
\r
2290 self.stat_allow_oldnexbeam = cvar("g_allow_oldnexbeam");
\r
2291 self.stat_leadlimit = cvar("leadlimit");
\r
2295 // physics frames: update anticheat stuff
\r
2296 anticheat_prethink();
\r
2299 if(blockSpectators && frametime)
\r
2300 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
\r
2301 checkSpectatorBlock();
\r
2303 zoomstate_set = 0;
\r
2305 if(self.netname_previous != self.netname)
\r
2307 if(cvar("sv_eventlog"))
\r
2308 GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname));
\r
2309 if(self.netname_previous)
\r
2310 strunzone(self.netname_previous);
\r
2311 self.netname_previous = strzone(self.netname);
\r
2314 // core code for the vore system
\r
2317 if(self.spectatee_status)
\r
2318 Vore_Disconnect();
\r
2320 // version nagging
\r
2321 if(self.version_nagtime)
\r
2322 if(self.cvar_g_voretournamentversion)
\r
2323 if(time > self.version_nagtime)
\r
2325 if(strstr(self.cvar_g_voretournamentversion, "svn", 0) < 0)
\r
2327 if(strstr(cvar_string("g_voretournamentversion"), "svn", 0) >= 0)
\r
2329 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
2330 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
2335 r = vercmp(self.cvar_g_voretournamentversion, cvar_string("g_voretournamentversion"));
\r
2338 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
2339 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
2343 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
2344 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
2348 self.version_nagtime = 0;
\r
2352 if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue)
\r
2354 sprint(self, strcat("godmode saved you ", ftos(self.max_armorvalue), " units of damage, cheater!\n"));
\r
2355 self.max_armorvalue = 0;
\r
2359 if (TetrisPreFrame())
\r
2363 if(self.classname == "player") {
\r
2364 // if(self.netname == "Wazat")
\r
2365 // bprint(self.classname, "\n");
\r
2367 CheckRules_Player();
\r
2369 PrintWelcomeMessage(self);
\r
2371 if (intermission_running)
\r
2373 IntermissionThink (); // otherwise a button could be missed between
\r
2374 return; // the think tics
\r
2377 if(self.teleport_time)
\r
2378 if(time > self.teleport_time)
\r
2380 self.teleport_time = 0;
\r
2381 self.effects = self.effects - (self.effects & EF_NODRAW);
\r
2384 if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
\r
2385 UpdateSelectedPlayer();
\r
2387 //don't allow the player to turn around while game is paused!
\r
2388 if(timeoutStatus == 2) {
\r
2389 self.v_angle = self.lastV_angle;
\r
2390 self.angles = self.lastV_angle;
\r
2391 self.fixangle = TRUE;
\r
2396 player_powerups();
\r
2399 if (self.deadflag != DEAD_NO)
\r
2401 float button_pressed, force_respawn;
\r
2402 if(self.personal && g_race_qualifying)
\r
2404 if(time > self.death_time)
\r
2406 self.death_time = time + 1; // only retry once a second
\r
2408 self.impulse = 141;
\r
2415 button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_GRABBER || self.BUTTON_USE);
\r
2416 force_respawn = (g_lms || (g_ca) || cvar("g_forced_respawn"));
\r
2417 if (self.deadflag == DEAD_DYING)
\r
2420 self.deadflag = DEAD_RESPAWNING;
\r
2421 else if(!button_pressed)
\r
2422 self.deadflag = DEAD_DEAD;
\r
2424 else if (self.deadflag == DEAD_DEAD)
\r
2426 if(button_pressed)
\r
2427 self.deadflag = DEAD_RESPAWNABLE;
\r
2429 else if (self.deadflag == DEAD_RESPAWNABLE)
\r
2431 if(!button_pressed)
\r
2432 self.deadflag = DEAD_RESPAWNING;
\r
2434 else if (self.deadflag == DEAD_RESPAWNING)
\r
2436 if(time > self.death_time)
\r
2438 self.death_time = time + 1; // only retry once a second
\r
2442 ShowRespawnCountdown();
\r
2447 if(g_touchexplode)
\r
2448 if(time > self.touchexplode_time)
\r
2449 if(self.classname == "player")
\r
2450 if(self.deadflag == DEAD_NO)
\r
2451 if not(IS_INDEPENDENT_PLAYER(self))
\r
2452 FOR_EACH_PLAYER(other) if(self != other)
\r
2454 if(time > other.touchexplode_time)
\r
2455 if(other.classname == "player")
\r
2456 if(other.deadflag == DEAD_NO)
\r
2457 if not(IS_INDEPENDENT_PLAYER(other))
\r
2458 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
\r
2460 PlayerTouchExplode(self, other);
\r
2461 self.touchexplode_time = other.touchexplode_time = time + 0.2;
\r
2465 if(g_lms && !self.deadflag && cvar("g_lms_campcheck_interval"))
\r
2469 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
\r
2470 dist = self.prevorigin - self.origin;
\r
2472 self.lms_traveled_distance += fabs(vlen(dist));
\r
2474 if((cvar("g_campaign") && !campaign_bots_may_start) || (time < game_starttime))
\r
2476 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval")*2;
\r
2477 self.lms_traveled_distance = 0;
\r
2480 if(time > self.lms_nextcheck)
\r
2482 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
\r
2483 if(self.lms_traveled_distance < cvar("g_lms_campcheck_distance"))
\r
2485 centerprint(self, cvar_string("g_lms_campcheck_message"));
\r
2486 // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
\r
2487 // 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
2488 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
2490 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
\r
2491 self.lms_traveled_distance = 0;
\r
2495 self.prevorigin = self.origin;
\r
2497 if ((self.BUTTON_CROUCH && !self.grabber.state) || self.health <= g_bloodloss)
\r
2501 self.crouch = TRUE;
\r
2502 self.view_ofs = PL_CROUCH_VIEW_OFS;
\r
2503 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
\r
2504 setanim(self, self.anim_duck, FALSE, TRUE, TRUE);
\r
2511 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
\r
2512 if (!trace_startsolid)
\r
2514 self.crouch = FALSE;
\r
2515 self.view_ofs = PL_VIEW_OFS;
\r
2516 setsize (self, PL_MIN, PL_MAX);
\r
2521 if(self.health <= g_bloodloss && self.deadflag == DEAD_NO)
\r
2523 if(self.bloodloss_timer < time)
\r
2525 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
\r
2526 self.bloodloss_timer = time + 0.5 + random() * 0.5;
\r
2534 // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
\r
2537 self.items &~= self.items_added;
\r
2541 self.items_added = 0;
\r
2542 if(self.items & IT_JETPACK)
\r
2543 if(self.items & IT_FUEL_REGEN || self.ammo_fuel >= 0.01)
\r
2544 self.items_added |= IT_FUEL;
\r
2546 self.items |= self.items_added;
\r
2555 self.dmg_team = max(0, self.dmg_team - cvar("g_teamdamage_resetspeed") * frametime);
\r
2557 //self.angles_y=self.v_angle_y + 90; // temp
\r
2558 } else if(gameover) {
\r
2559 if (intermission_running)
\r
2560 IntermissionThink (); // otherwise a button could be missed between
\r
2562 } else if(self.classname == "observer") {
\r
2564 } else if(self.classname == "spectator") {
\r
2568 if(!zoomstate_set)
\r
2569 SetZoomState(self.BUTTON_ZOOM);
\r
2571 float oldspectatee_status;
\r
2572 oldspectatee_status = self.spectatee_status;
\r
2573 if(self.classname == "spectator")
\r
2574 self.spectatee_status = num_for_edict(self.enemy);
\r
2575 else if(self.classname == "observer")
\r
2576 self.spectatee_status = num_for_edict(self);
\r
2578 self.spectatee_status = 0;
\r
2579 if(self.spectatee_status != oldspectatee_status)
\r
2581 ClientData_Touch(self);
\r
2582 if(g_race || g_cts)
\r
2583 race_InitSpectator();
\r
2586 if(self.teamkill_soundtime)
\r
2587 if(time > self.teamkill_soundtime)
\r
2589 self.teamkill_soundtime = 0;
\r
2591 entity oldpusher, oldself;
\r
2593 oldself = self; self = self.teamkill_soundsource;
\r
2594 oldpusher = self.pusher; self.pusher = oldself;
\r
2596 PlayerSound(self, playersound_teamshoot, CHAN_VOICE, VOICETYPE_LASTATTACKER_ONLY);
\r
2598 self.pusher = oldpusher;
\r
2602 if(self.taunt_soundtime)
\r
2603 if(time > self.taunt_soundtime)
\r
2605 self.taunt_soundtime = 0;
\r
2606 PlayerSound(self, playersound_taunt, CHAN_VOICE, VOICETYPE_AUTOTAUNT);
\r
2609 target_voicescript_next(self);
\r
2612 float isInvisibleString(string s)
\r
2615 s = strdecolorize(s);
\r
2616 for((i = 0), (n = strlen(s)); i < n; ++i)
\r
2618 c = str2chr(s, i);
\r
2636 Called every frame for each client after the physics are run
\r
2639 .float idlekick_lasttimeleft;
\r
2640 void PlayerPostThink (void)
\r
2642 // Savage: Check for nameless players
\r
2643 if (isInvisibleString(self.netname)) {
\r
2644 self.netname = "Player";
\r
2645 stuffcmd(self, strcat("name ", self.netname, substring(ftos(random()), 2, -1), "\n"));
\r
2648 // send the clients accuracy stats to the client
\r
2649 if(self.stat_count > 0)
\r
2652 self.stat_hit = self.stat_count + 64 * floor(self.(stats_hit[self.stat_count - 1]));
\r
2653 self.stat_fired = self.stat_count + 64 * floor(self.(stats_fired[self.stat_count - 1]));
\r
2654 self.stat_count -= 1;
\r
2658 if(self.uid_kicktime)
\r
2659 if(time > self.uid_kicktime)
\r
2661 bprint("^3", self.netname, "^3 was kicked for missing UID.\n");
\r
2667 if(sv_maxidle && frametime)
\r
2669 // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
\r
2671 timeleft = ceil(sv_maxidle - (time - self.parm_idlesince));
\r
2674 bprint("^3", self.netname, "^3 was kicked for idling.\n");
\r
2675 AnnounceTo(self, "terminated");
\r
2679 else if(timeleft <= 10)
\r
2681 if(timeleft != self.idlekick_lasttimeleft)
\r
2683 centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
\r
2684 AnnounceTo(self, strcat(ftos(timeleft), ""));
\r
2689 centerprint_expire(self, CENTERPRIO_IDLEKICK);
\r
2691 self.idlekick_lasttimeleft = timeleft;
\r
2695 if(self.impulse == 100)
\r
2696 ImpulseCommands();
\r
2697 if (TetrisPostFrame())
\r
2703 if(self.classname == "player") {
\r
2704 CheckRules_Player();
\r
2705 UpdateChatBubble();
\r
2706 UpdateTeamBubble();
\r
2708 ImpulseCommands();
\r
2709 if (intermission_running)
\r
2710 return; // intermission or finale
\r
2713 } else if (self.classname == "observer") {
\r
2715 } else if (self.classname == "spectator") {
\r
2721 for(i = 0; i < 1000; ++i)
\r
2724 end = self.origin + '0 0 1024' + 512 * randomvec();
\r
2725 tracebox(self.origin, self.mins, self.maxs, end, MOVE_NORMAL, self);
\r
2726 if(trace_fraction < 1)
\r
2727 if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
\r
2729 print("I HIT SOLID: ", vtos(self.origin), " -> ", vtos(end), "\n");
\r
2737 //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
\r
2739 if(self.waypointsprite_attachedforcarrier)
\r
2740 WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, cvar("g_balance_armor_blockpercent")));
\r
2742 playerdemo_write();
\r
2746 dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));
\r