1 void info_player_start (void)
3 self.classname = "info_player_deathmatch";
6 void info_player_deathmatch (void)
10 float spawn_goodspots, spawn_badspots;
11 entity Spawn_ClassifyPoints(entity firstspot, entity playerlist, float mindist, float goodspotnum, float badspotnum)
13 local entity spot, player;
15 local string spotname;
26 if (vlen(player.origin - spot.origin) < 100)
28 player = player.chain;
32 if (spawn_goodspots >= badspotnum)
34 spawn_badspots = spawn_badspots + 1;
38 if (spawn_goodspots >= goodspotnum)
40 spawn_goodspots = spawn_goodspots + 1;
44 if(self.team == 5)//4)
45 spotname = "info_player_team1";
46 if(self.team == 14)//13)
47 spotname = "info_player_team2";
48 if(self.team == 10)//9)
49 spotname = "info_player_team3";
50 if(self.team == 13)//12)
51 spotname = "info_player_team4";
52 spot = find(spot, classname, spotname);
55 spot = find(spot, classname, "info_player_deathmatch");
60 entity Spawn_FurthestPoint(entity firstspot, entity playerlist)
62 local entity best, spot, player;
63 local float bestrating, rating;
65 bestrating = -1000000;
74 rating = min(rating, vlen(player.origin - spot.origin));
75 player = player.chain;
77 rating = rating + random() * 16;
78 if (bestrating < rating)
83 spot = find(spot, classname, "info_player_deathmatch");
92 Finds a point to respawn
95 entity SelectSpawnPoint (float anypoint)
97 local entity spot, firstspot, playerlist;
100 spot = find (world, classname, "testplayerstart");
104 spotname = "info_player_deathmatch";
106 if(!anypoint && cvar("g_ctf") )
108 if(self.team == 5)//4)
109 spotname = "info_player_team1";
110 if(self.team == 14)//13)
111 spotname = "info_player_team2";
112 if(self.team == 10)//9)
113 spotname = "info_player_team3";
114 if(self.team == 13)//12)
115 spotname = "info_player_team4";
118 playerlist = findchain(classname, "player");
119 firstspot = find(world, classname, spotname);
120 Spawn_ClassifyPoints(firstspot, playerlist, 100, 1000000, 1000000);
121 // first check if there are ANY good spots
122 if (spawn_goodspots > 0)
124 // good spots exist, there is 50/50 chance of choosing a random good
125 // spot or the furthest spot
126 // (this means that roughly every other spawn will be furthest, so you
127 // usually won't get fragged at spawn twice in a row)
129 spot = Spawn_ClassifyPoints(firstspot, playerlist, 100, min(floor(random() * spawn_goodspots), spawn_goodspots - 1), 1000000);
131 spot = Spawn_FurthestPoint(firstspot, playerlist);
135 // no good spots exist, pick a random bad spot
136 spot = Spawn_ClassifyPoints(firstspot, playerlist, 100, 1000000, min(floor(random() * spawn_badspots), spawn_badspots - 1));
141 error ("PutClientInServer: no start points on level");
142 else // try again with deathmatch spots
143 spot = SelectSpawnPoint(TRUE);
153 Checks if the argument string can be a valid playermodel.
154 Returns a valid one in doubt.
157 string CheckPlayerModel(string plyermodel) {
158 if( substring(plyermodel,0,14) != "models/player/") plyermodel = "models/player/marine.zym";
160 /* Possible Fixme: Check if server can open the model?
161 This would kill custom models, however. */
170 putting a client as observer in the server
173 void PutObserverInServer (void)
176 spot = SelectSpawnPoint (FALSE);
177 RemoveGrapplingHook(self); // Wazat's Grappling Hook
179 if(self.frags == 0 && cvar("g_lms") && self.killcount != -666)
180 bprint (strcat("^4", self.netname, "^4 has no more lives left\n"));
181 else if(self.killcount != -666)
182 bprint (strcat("^4", self.netname, "^4 is spectating now\n"));
184 self.classname = "observer";
186 self.takedamage = DAMAGE_NO;
187 self.solid = SOLID_NOT;
188 self.movetype = MOVETYPE_NOCLIP;
189 self.flags = FL_CLIENT | FL_NOTARGET;
190 self.armorvalue = 666;
192 self.armorvalue = cvar("g_balance_armor_start");
193 self.pauserotarmor_finished = 0;
194 self.pauserothealth_finished = 0;
195 self.pauseregen_finished = 0;
196 self.damageforcescale = 0;
205 self.pain_finished = 0;
206 self.strength_finished = 0;
207 self.invincible_finished = 0;
209 self.think = SUB_Null;
213 self.deadflag = DEAD_NO;
214 self.angles = spot.angles;
216 self.fixangle = TRUE;
218 self.view_ofs = PL_VIEW_OFS;
219 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 14));
220 self.oldorigin = self.origin;
225 self.weaponmodel = "";
226 self.weaponframe = 0;
227 self.weaponentity = world;
228 self.killcount = -666;
231 //stuffcmd(self, "set viewsize 120 \n");
232 // bprint (strcat("^4", self.netname, "^4 is spectating now\n"));
240 Called when a client spawns in the server
243 void PutClientInServer (void)
245 if(clienttype(self) == CLIENTTYPE_BOT)
247 self.classname = "player";
250 // player is dead and becomes observer
251 if(cvar("g_lms") && self.frags < 1)
252 self.classname = "observer";
254 if(self.classname == "player") {
257 spot = SelectSpawnPoint (FALSE);
259 RemoveGrapplingHook(self); // Wazat's Grappling Hook
261 self.classname = "player";
262 self.iscreature = TRUE;
263 self.movetype = MOVETYPE_WALK;
264 self.solid = SOLID_SLIDEBOX;
265 self.flags = FL_CLIENT;
266 self.takedamage = DAMAGE_AIM;
268 self.health = cvar("g_balance_health_start");
269 self.armorvalue = cvar("g_balance_armor_start");
270 self.spawnshieldtime = time + cvar("g_spawnshieldtime");
271 self.pauserotarmor_finished = time + 10;
272 self.pauserothealth_finished = time + 10;
273 self.pauseregen_finished = 0;
274 self.damageforcescale = 2;
283 self.pain_finished = 0;
284 self.strength_finished = 0;
285 self.invincible_finished = 0;
287 //self.speed_finished = 0;
288 //self.slowmo_finished = 0;
289 // players have no think function
290 self.think = SUB_Null;
297 self.deadflag = DEAD_NO;
299 self.angles = spot.angles;
301 self.angles_z = 0; // never spawn tilted even if the spot says to
302 self.fixangle = TRUE; // turn this way immediately
303 self.velocity = '0 0 0';
304 self.avelocity = '0 0 0';
305 self.punchangle = '0 0 0';
306 self.punchvector = '0 0 0';
307 self.oldvelocity = self.velocity;
311 if(cvar("sv_defaultcharacter") == 1) {
312 local string defaultmodel;
313 defaultmodel = CheckPlayerModel(cvar_string("sv_defaultplayermodel"));
315 precache_model (defaultmodel);
316 setmodel (self, defaultmodel);
317 self.skin = stof(cvar_string("sv_defaultplayerskin"));
319 self.playermodel = CheckPlayerModel(self.playermodel);
321 precache_model (self.playermodel);
322 setmodel (self, self.playermodel);
323 self.skin = stof(self.playerskin);
328 self.view_ofs = PL_VIEW_OFS;
329 setsize (self, PL_MIN, PL_MAX);
330 setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
331 // don't reset back to last position, even if new position is stuck in solid
332 self.oldorigin = self.origin;
336 self.ammo_shells = cvar("g_lms_start_ammo_shells");
337 self.ammo_nails = cvar("g_lms_start_ammo_nails");
338 self.ammo_rockets = cvar("g_lms_start_ammo_rockets");
339 self.ammo_cells = cvar("g_lms_start_ammo_cells");
340 self.health = cvar("g_lms_start_health");
341 self.armorvalue = cvar("g_lms_start_armor");
343 else if (cvar("g_use_ammunition")) {
344 self.ammo_shells = cvar("g_start_ammo_shells");
345 self.ammo_nails = cvar("g_start_ammo_nails");
346 self.ammo_rockets = cvar("g_start_ammo_rockets");
347 self.ammo_cells = cvar("g_start_ammo_cells");
349 self.ammo_shells = 999;
350 self.ammo_nails = 999;
351 self.ammo_rockets = 999;
352 self.ammo_cells = 999;
356 if (cvar("g_start_weapon_laser") || cvar("g_lms"))
358 self.items = self.items | IT_LASER;
359 self.switchweapon = WEP_LASER;
361 if (cvar("g_start_weapon_shotgun") || cvar("g_lms"))
363 self.items = self.items | IT_SHOTGUN;
364 self.switchweapon = WEP_SHOTGUN;
366 if (cvar("g_start_weapon_uzi") || cvar("g_lms"))
368 self.items = self.items | IT_UZI;
369 self.switchweapon = WEP_UZI;
371 if (cvar("g_start_weapon_grenadelauncher") || cvar("g_lms"))
373 self.items = self.items | IT_GRENADE_LAUNCHER;
374 self.switchweapon = WEP_GRENADE_LAUNCHER;
376 if (cvar("g_start_weapon_electro") || cvar("g_lms"))
378 self.items = self.items | IT_ELECTRO;
379 self.switchweapon = WEP_ELECTRO;
381 if (cvar("g_start_weapon_crylink") || cvar("g_lms"))
383 self.items = self.items | IT_CRYLINK;
384 self.switchweapon = WEP_CRYLINK;
386 if (cvar("g_start_weapon_nex") || cvar("g_lms"))
388 self.items = self.items | IT_NEX;
389 self.switchweapon = WEP_NEX;
391 if (cvar("g_start_weapon_hagar") || cvar("g_lms"))
393 self.items = self.items | IT_HAGAR;
394 self.switchweapon = WEP_HAGAR;
396 if (cvar("g_start_weapon_rocketlauncher") || cvar("g_lms"))
398 self.items = self.items | IT_ROCKET_LAUNCHER;
399 self.switchweapon = WEP_ROCKET_LAUNCHER;
402 if(cvar("g_instagib"))
405 self.switchweapon = WEP_NEX;
406 self.ammo_cells = 999;
409 if(cvar("g_rocketarena"))
411 self.items = IT_ROCKET_LAUNCHER;
412 self.switchweapon = WEP_ROCKET_LAUNCHER;
413 self.ammo_rockets = 999;
416 if(cvar("g_minstagib"))
421 self.switchweapon = WEP_NEX;
422 self.ammo_cells = cvar("g_minstagib_ammo_start");
424 self.jump_interval = time;
427 self.event_damage = PlayerDamage;
429 self.statdraintime = time + 5;
430 self.button0 = self.button1 = self.button2 = self.button3 = 0;
432 if(self.killcount == -666) {
437 self.cnt = WEP_LASER;
443 CL_SpawnWeaponentity();
445 self.exteriorweaponentity.alpha = 1;
447 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
448 self.lms_traveled_distance = 0;
450 //stuffcmd(self, "chase_active 0");
451 //stuffcmd(self, "set viewsize $tmpviewsize \n");
452 } else if(self.classname == "observer") {
453 PutObserverInServer ();
462 void SetNewParms (void)
472 void SetChangeParms (void)
481 Called when a client types 'kill' in the console
484 void ClientKill (void)
486 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
493 Called when a client connects to the server
496 string ColoredTeamName(float t);
497 //void dom_player_join_team(entity pl);
498 void ClientConnect (void)
500 self.classname = "player_joining";
502 if(player_count<0) player_count = 0;
504 //if(cvar("g_domination"))
505 // dom_player_join_team(self);
507 //JoinBestTeam(self, FALSE);
508 if(cvar("teamplay") && self.version == cvar("g_nexuizversion_major")) stuffcmd(self,"menu_showteamselect\n");
511 if(cvar("sv_spectate") == 1 && !cvar("g_lms")) {
512 self.classname = "observer";
514 self.classname = "player";
517 //stuffcmd(self, "set tmpviewsize $viewsize \n");
519 bprint ("^4",self.netname);
520 bprint ("^4 connected");
522 if(cvar("g_domination") || cvar("g_ctf"))
524 bprint(" and joined the ");
525 bprint(ColoredTeamName(self.team));
530 self.welcomemessage_time = time + cvar("welcome_message_time");
531 self.welcomemessage_time2 = 0;
533 stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n"));
534 // send prediction settings to the client
535 stuffcmd(self, strcat("cl_movement_maxspeed ", ftos(cvar("sv_maxspeed")), "\n"));
536 stuffcmd(self, strcat("cl_movement_maxairspeed ", ftos(cvar("sv_maxairspeed")), "\n"));
537 stuffcmd(self, strcat("cl_movement_accelerate ", ftos(cvar("sv_accelerate")), "\n"));
538 stuffcmd(self, strcat("cl_movement_friction ", ftos(cvar("sv_friction")), "\n"));
539 stuffcmd(self, strcat("cl_movement_stopspeed ", ftos(cvar("sv_stopspeed")), "\n"));
540 stuffcmd(self, strcat("cl_movement_jumpvelocity ", ftos(cvar("g_balance_jumpheight")), "\n"));
541 stuffcmd(self, strcat("cl_movement_stepheight ", ftos(cvar("sv_stepheight")), "\n"));
542 stuffcmd(self, strcat("cl_movement_edgefriction 0\n"));
543 // Wazat's grappling hook
544 SetGrappleHookBindings();
546 // get autoswitch state from player
547 stuffcmd(self, "alias autoswitch \"set cl_autoswitch $1; cmd autoswitch $1\"\n");
548 stuffcmd(self, "cmd autoswitch $cl_autoswitch\n");
550 // get version info from player
551 stuffcmd(self, "cmd clientversion $g_nexuizversion_major\n");
553 // set cvar for team scoreboard
554 stuffcmd(self, strcat("set teamplay ", ftos(teams_matter), "\n"));
558 self.frags = cvar("fraglimit");
559 // no fraglimit was set, so player gets 999 lives
563 // disallow player to join after the worst player has lost g_lms_last_join lives
564 // if "g_lms_join_anytime" new players spawn with same amount of lives as the worst active player
565 if(((cvar("fraglimit") - cvar("g_lms_last_join")) > lms_lowest_lives && !cvar("g_lms_join_anytime")) || lms_lowest_lives < 1)
570 else if(cvar("fraglimit") > lms_lowest_lives)
572 self.frags = lms_lowest_lives;
577 self.jointime = time;
584 Called when a client disconnects from the server
587 .entity chatbubbleentity;
588 .entity teambubbleentity;
589 void ClientDisconnect (void)
591 bprint ("^4",self.netname);
592 bprint ("^4 disconnected\n");
594 if (self.chatbubbleentity)
596 remove (self.chatbubbleentity);
597 self.chatbubbleentity = world;
600 if (self.teambubbleentity)
602 remove (self.teambubbleentity);
603 self.teambubbleentity = world;
607 // decrease player count for lms
609 // player was dead, decrease dead count
610 if(cvar("g_lms") && self.frags < 1)
612 //stuffcmd(self, "set viewsize $tmpviewsize \n");
616 void() ChatBubbleThink =
618 self.nextthink = time;
619 if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
624 setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1');
625 if (self.owner.buttonchat && !self.owner.deadflag)
626 self.model = self.mdl;
631 void() UpdateChatBubble =
633 if (!self.modelindex)
635 // spawn a chatbubble entity if needed
636 if (!self.chatbubbleentity)
638 self.chatbubbleentity = spawn();
639 self.chatbubbleentity.owner = self;
640 self.chatbubbleentity.exteriormodeltoclient = self;
641 self.chatbubbleentity.think = ChatBubbleThink;
642 self.chatbubbleentity.nextthink = time;
643 setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr");
644 setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
645 self.chatbubbleentity.mdl = self.chatbubbleentity.model;
646 self.chatbubbleentity.model = "";
651 void() TeamBubbleThink =
653 self.nextthink = time;
654 if (!self.owner.modelindex || self.owner.teambubbleentity != self)
659 // setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1'); // bandwidth hog. setattachment does this now
660 if (self.owner.buttonchat || self.owner.deadflag)
663 self.model = self.mdl;
667 .float() customizeentityforclient;
668 float() ChatBubble_customizeentityforclient = {return (self.owner.team == other.team && other.killcount > -666);};
670 void() UpdateTeamBubble =
672 if (!self.modelindex || !cvar("teamplay"))
674 // spawn a teambubble entity if needed
675 if (!self.teambubbleentity && cvar("teamplay"))
677 self.teambubbleentity = spawn();
678 self.teambubbleentity.owner = self;
679 self.teambubbleentity.exteriormodeltoclient = self;
680 self.teambubbleentity.think = TeamBubbleThink;
681 self.teambubbleentity.nextthink = time;
682 setmodel(self.teambubbleentity, "models/misc/teambubble.spr");
683 // setorigin(self.teambubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
684 setorigin(self.teambubbleentity, self.teambubbleentity.origin + '0 0 15' + self.maxs_z * '0 0 1');
685 setattachment(self.teambubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
686 self.teambubbleentity.mdl = self.teambubbleentity.model;
687 self.teambubbleentity.model = self.teambubbleentity.mdl;
688 self.teambubbleentity.customizeentityforclient = ChatBubble_customizeentityforclient;
692 // LordHavoc: this hack will be removed when proper _pants/_shirt layers are
693 // added to the model skins
694 /*void() UpdateColorModHack =
697 c = self.clientcolors & 15;
698 // LordHavoc: only bothering to support white, green, red, yellow, blue
699 if (teamplay == 0) self.colormod = '0 0 0';
700 else if (c == 0) self.colormod = '1.00 1.00 1.00';
701 else if (c == 3) self.colormod = '0.10 1.73 0.10';
702 else if (c == 4) self.colormod = '1.73 0.10 0.10';
703 else if (c == 12) self.colormod = '1.22 1.22 0.10';
704 else if (c == 13) self.colormod = '0.10 0.10 1.73';
705 else self.colormod = '1 1 1';
708 void UpdatePlayerColors () {
709 if(self.weaponentity) {
710 self.weaponentity.colormap = self.colormap;
711 self.exteriorweaponentity.colormap = self.colormap;
718 When you press the jump key
721 void PlayerJump (void)
725 mjumpheight = cvar("g_balance_jumpheight");
726 if (self.waterlevel >= 2)
728 if (self.watertype == CONTENT_WATER)
729 self.velocity_z = 200;
730 else if (self.watertype == CONTENT_SLIME)
731 self.velocity_z = 80;
733 self.velocity_z = 50;
739 if (!(self.flags & FL_ONGROUND))
742 if (!(self.flags & FL_JUMPRELEASED))
745 if(cvar("g_runematch"))
747 if(self.runes & RUNE_SPEED)
749 if(self.runes & CURSE_SLOW)
750 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_combo_jumpheight");
752 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_jumpheight");
754 else if(self.runes & CURSE_SLOW)
756 mjumpheight = mjumpheight * cvar("g_balance_curse_slow_jumpheight");
760 if(cvar("g_minstagib") && (self.items & IT_INVINCIBLE))
762 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_jumpheight");
765 self.velocity_z = self.velocity_z + mjumpheight;
766 self.oldvelocity_z = self.velocity_z;
768 self.flags = self.flags - FL_ONGROUND;
769 self.flags = self.flags - FL_JUMPRELEASED;
772 void() CheckWaterJump =
774 local vector start, end;
776 // check for a jump-out-of-water
777 makevectors (self.angles);
779 start_z = start_z + 8;
781 normalize(v_forward);
782 end = start + v_forward*24;
783 traceline (start, end, TRUE, self);
784 if (trace_fraction < 1)
786 start_z = start_z + self.maxs_z - 8;
787 end = start + v_forward*24;
788 self.movedir = trace_plane_normal * -50;
789 traceline (start, end, TRUE, self);
790 if (trace_fraction == 1)
791 { // open at eye level
792 self.flags = self.flags | FL_WATERJUMP;
793 self.velocity_z = 225;
794 self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
795 self.teleport_time = time + 2; // safety net
808 void player_powerups (void)
810 if (cvar("g_minstagib"))
812 self.effects = EF_FULLBRIGHT;
813 if (self.items & IT_STRENGTH)
815 if (time > self.strength_finished)
818 self.exteriorweaponentity.alpha = 1;
819 self.items = self.items - (self.items & IT_STRENGTH);
820 sprint(self, "^3Invisibility has worn off\n");
825 if (time < self.strength_finished)
827 self.alpha = cvar("g_minstagib_invis_alpha");
828 self.exteriorweaponentity.alpha = cvar("g_minstagib_invis_alpha");
829 self.items = self.items | IT_STRENGTH;
830 sprint(self, "^3You are invisible\n");
834 if (self.items & IT_INVINCIBLE)
836 if (time > self.invincible_finished)
838 self.items = self.items - (self.items & IT_INVINCIBLE);
839 sprint(self, "^3Speed has worn off\n");
844 if (time < self.invincible_finished)
846 self.items = self.items | IT_INVINCIBLE;
847 sprint(self, "^3You are on speed\n");
853 self.effects = self.effects - (self.effects & (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT));
854 if (self.items & IT_STRENGTH)
856 self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
857 if (time > self.strength_finished)
859 self.items = self.items - (self.items & IT_STRENGTH);
860 sprint(self, "^3Strength has worn off\n");
865 if (time < self.strength_finished)
867 self.items = self.items | IT_STRENGTH;
868 sprint(self, "^3Strength infuses your weapons with devestating power\n");
871 if (self.items & IT_INVINCIBLE)
873 self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
874 if (time > self.invincible_finished)
876 self.items = self.items - (self.items & IT_INVINCIBLE);
877 sprint(self, "^3Shield has worn off\n");
882 if (time < self.invincible_finished)
884 self.items = self.items | IT_INVINCIBLE;
885 sprint(self, "^3Shield surrounds you\n");
889 if (cvar("g_fullbrightplayers"))
890 self.effects = self.effects | EF_FULLBRIGHT;
892 // midair gamemode: damage only while in the air
893 // if in midair mode, being on ground grants temporary invulnerability
894 // (this is so that multishot weapon don't clear the ground flag on the
895 // first damage in the frame, leaving the player vulnerable to the
896 // remaining hits in the same frame)
897 if (self.flags & FL_ONGROUND)
898 if (cvar("g_midair"))
899 self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
901 if (time < self.spawnshieldtime)
902 self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
905 void player_regen (void)
907 float maxh, maxa, max_mod, regen_mod, rot_mod;
908 maxh = cvar("g_balance_health_stable");
909 maxa = cvar("g_balance_armor_stable");
911 if (cvar("g_minstagib") || (cvar("g_lms") && !cvar("g_lms_regenerate")))
914 if(cvar("g_runematch"))
916 max_mod = regen_mod = rot_mod = 1;
917 if (self.runes & RUNE_REGEN)
919 if (self.runes & CURSE_VENOM) // do we have both rune/curse?
921 regen_mod = cvar("g_balance_rune_regen_combo_regenrate");
922 max_mod = cvar("g_balance_rune_regen_combo_hpmod");
926 regen_mod = cvar("g_balance_rune_regen_regenrate");
927 max_mod = cvar("g_balance_rune_regen_hpmod");
930 else if (self.runes & CURSE_VENOM)
932 max_mod = cvar("g_balance_curse_venom_hpmod");
933 if (self.runes & RUNE_REGEN) // do we have both rune/curse?
934 rot_mod = cvar("g_balance_rune_regen_combo_rotrate");
936 rot_mod = cvar("g_balance_curse_venom_rotrate");
937 //if (!self.runes & RUNE_REGEN)
938 // rot_mod = cvar("g_balance_curse_venom_rotrate");
940 maxh = maxh * max_mod;
941 //maxa = maxa * max_mod;
943 if (time > self.pauserotarmor_finished)
945 if (self.armorvalue > maxa)
946 self.armorvalue = bound(0, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_rot") * frametime, 1000);
948 if (time > self.pauserothealth_finished)
950 if (self.health > maxh)
951 self.health = bound(0, self.health + (maxh - self.health) * rot_mod*cvar("g_balance_health_rot") * frametime, 1000);
953 if (time > self.pauseregen_finished)
955 if (self.health < maxh)
956 self.health = bound(0, self.health + (maxh- self.health) * regen_mod*cvar("g_balance_health_regen") * frametime, 1000);
957 if (self.armorvalue < maxa)
958 self.armorvalue = bound(0, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_regen") * frametime, 1000);
963 if (time > self.pauserothealth_finished)
964 if (self.health > maxh)
965 self.health = bound(0, self.health + (maxh - self.health) * cvar("g_balance_health_rot") * frametime, 1000);
966 if (time > self.pauserotarmor_finished)
967 if (self.armorvalue > maxa)
968 self.armorvalue = bound(0, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_rot") * frametime, 1000);
969 if (time > self.pauseregen_finished)
971 if (self.health < maxh)
972 self.health = bound(0, self.health + (maxh- self.health) * cvar("g_balance_health_regen") * frametime, 1000);
973 if (self.armorvalue < maxa)
974 self.armorvalue = bound(0, self.armorvalue + (maxa - self.armorvalue) * cvar("g_balance_armor_regen") * frametime, 1000);
980 ======================
981 spectate mode routines
982 ======================
984 void SpectateCopy(entity spectatee) {
985 self.armortype = spectatee.armortype;
986 self.armorvalue = spectatee.armorvalue;
987 self.currentammo = spectatee.currentammo;
988 self.effects = spectatee.effects;
989 self.health = spectatee.health;
991 self.items = spectatee.items;
992 self.punchangle = spectatee.punchangle;
993 self.view_ofs = spectatee.view_ofs;
994 self.v_angle = spectatee.v_angle;
995 self.viewzoom = spectatee.viewzoom;
996 setorigin(self, spectatee.origin);
997 setsize(self, spectatee.mins, spectatee.maxs);
1000 void SpectateUpdate() {
1001 if (self != self.enemy) {
1002 SpectateCopy(self.enemy);
1004 WriteByte(MSG_ONE, SVC_SETANGLE);
1005 WriteAngle(MSG_ONE, self.enemy.v_angle_x);
1006 WriteAngle(MSG_ONE, self.enemy.v_angle_y);
1007 WriteAngle(MSG_ONE, self.enemy.v_angle_z);
1011 float SpectateNext() {
1012 other = find(self.enemy, classname, "player");
1014 other = find(other, classname, "player");
1019 if(self.enemy.classname == "player") {
1021 WriteByte(MSG_ONE, SVC_SETVIEW);
1022 WriteEntity(MSG_ONE, self.enemy);
1023 //stuffcmd(self, "set viewsize $tmpviewsize \n");
1035 Called every frame for each client before the physics are run
1038 void PlayerPreThink (void)
1040 if(self.classname == "player") {
1041 local vector m1, m2;
1045 // if(self.netname == "Wazat")
1046 // bprint(strcat(self.classname, "\n"));
1048 CheckRules_Player();
1050 if (intermission_running)
1052 IntermissionThink (); // otherwise a button could be missed between
1053 return; // the think tics
1056 if (self.deadflag != DEAD_NO)
1060 if (self.deadflag == DEAD_DYING)
1062 if (time > self.dead_time)
1063 self.deadflag = DEAD_DEAD;
1065 else if (self.deadflag == DEAD_DEAD)
1067 if (!self.button0 && !self.button2 && !self.button3)
1068 self.deadflag = DEAD_RESPAWNABLE;
1070 else if (self.deadflag == DEAD_RESPAWNABLE)
1077 cvar("g_forced_respawn"))
1083 if(cvar("g_lms") && !self.deadflag && cvar("g_lms_campcheck_interval"))
1087 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
1088 dist = self.oldorigin - self.origin;
1090 self.lms_traveled_distance += fabs(vlen(dist));
1092 if(time > self.lms_nextcheck)
1094 //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
1095 if(self.lms_traveled_distance < cvar("g_lms_campcheck_distance"))
1097 centerprint(self, cvar_string("g_lms_campcheck_message"));
1098 Damage(self, self, self, cvar("g_lms_campcheck_damage"), DEATH_CAMP, self.origin, '0 0 0');
1100 self.lms_nextcheck = time + cvar("g_lms_campcheck_interval");
1101 self.lms_traveled_distance = 0;
1110 self.view_ofs = PL_CROUCH_VIEW_OFS;
1111 setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
1118 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
1119 if (!trace_startsolid)
1121 self.crouch = FALSE;
1122 self.view_ofs = PL_VIEW_OFS;
1123 setsize (self, PL_MIN, PL_MAX);
1128 if(cvar("sv_defaultcharacter") == 1) {
1129 local string defaultmodel;
1130 defaultmodel = CheckPlayerModel(cvar_string("sv_defaultplayermodel"));
1132 if (defaultmodel != self.model)
1136 precache_model (defaultmodel);
1137 setmodel (self, defaultmodel);
1138 setsize (self, m1, m2);
1141 if (self.skin != stof(cvar_string("sv_defaultplayerskin")))
1142 self.skin = stof(cvar_string("sv_defaultplayerskin"));
1144 if (self.playermodel != self.model)
1146 self.playermodel = CheckPlayerModel(self.playermodel);
1149 precache_model (self.playermodel);
1150 setmodel (self, self.playermodel);
1151 setsize (self, m1, m2);
1154 if (self.skin != stof(self.playerskin))
1155 self.skin = stof(self.playerskin);
1157 // Savage: Check for nameless players
1158 if (strlen(self.netname) < 1) {
1159 self.netname = "Player";
1160 stuffcmd(self, "name Player\n");
1163 GrapplingHookFrame();
1167 if (self.button4 || (self.weapon == WEP_NEX && self.button3))
1169 if (cvar("g_minstagib") && self.button3)
1171 if (self.jump_interval <= (time + 0.1))
1173 self.jump_interval = time + 1;
1174 weapon_doattack(laser_check, laser_check, W_Laser_Attack);
1177 else if (self.viewzoom > 0.4)
1178 self.viewzoom = max (0.4, self.viewzoom - frametime * 2);
1180 else if (self.viewzoom < 1.0)
1181 self.viewzoom = min (1.0, self.viewzoom + frametime);
1187 self.flags = self.flags | FL_JUMPRELEASED;
1193 //self.angles_y=self.v_angle_y + 90; // temp
1195 if (self.waterlevel == 2)
1198 //if (TetrisPreFrame()) return;
1199 } else if(gameover) {
1200 if (intermission_running)
1201 IntermissionThink (); // otherwise a button could be missed between
1203 } else if(self.classname == "observer") {
1205 if (self.flags & FL_JUMPRELEASED) {
1206 if (self.button2 && self.version == cvar("g_nexuizversion_major")) {
1207 if(!cvar("teamplay")) {
1208 self.flags = self.flags & !FL_JUMPRELEASED;
1209 self.classname = "player";
1211 bprint (strcat("^4", self.netname, "^4 is playing now\n"));
1212 PutClientInServer();
1213 centerprint(self,"");
1216 self.flags = self.flags & !FL_JUMPRELEASED;
1217 stuffcmd(self,"menu_showteamselect\n");
1220 } else if(self.button0 && self.version == cvar("g_nexuizversion_major")) {
1221 self.flags = self.flags & !FL_JUMPRELEASED;
1222 if(SpectateNext() == 1) {
1223 self.classname = "spectator";
1227 if (!(self.button0 || self.button2)) {
1228 self.flags = self.flags | FL_JUMPRELEASED;
1231 if(cvar("g_lms") && self.frags == 0)
1232 centerprint(self, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n^1You have no more lives left\nwait for next round\n\n\n^7press attack to spectate other players");
1233 else if(cvar("g_lms") && self.frags == -1)
1234 centerprint(self, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n^1Match has already begun\nwait for next round\n\n\n^7press attack to spectate other players");
1236 PrintWelcomeMessage(self);
1237 //centerprint(self, "\n\n\npress jump to play\npress attack to spectate other players");
1238 } else if(self.classname == "spectator") {
1240 if (self.flags & FL_JUMPRELEASED) {
1241 if (self.button2 && self.version == cvar("g_nexuizversion_major")) {
1242 if(!cvar("teamplay")) {
1243 self.flags = self.flags & !FL_JUMPRELEASED;
1244 self.classname = "player";
1246 bprint (strcat("^4", self.netname, "^4 is playing now\n"));
1249 WriteByte(MSG_ONE, SVC_SETVIEW);
1250 WriteEntity(MSG_ONE, self);
1251 PutClientInServer();
1252 centerprint(self,"");
1255 self.flags = self.flags & !FL_JUMPRELEASED;
1256 stuffcmd(self,"menu_showteamselect\n");
1259 } else if(self.button0) {
1260 self.flags = self.flags & !FL_JUMPRELEASED;
1261 if(SpectateNext() == 1) {
1262 self.classname = "spectator";
1264 self.classname = "observer";
1266 WriteByte(MSG_ONE, SVC_SETVIEW);
1267 WriteEntity(MSG_ONE, self);
1268 PutClientInServer();
1270 } else if (self.button3) {
1271 self.flags = self.flags & !FL_JUMPRELEASED;
1272 self.classname = "observer";
1274 WriteByte(MSG_ONE, SVC_SETVIEW);
1275 WriteEntity(MSG_ONE, self);
1276 PutClientInServer();
1281 if (!(self.button0 || self.button3)) {
1282 self.flags = self.flags | FL_JUMPRELEASED;
1285 if (cvar("g_lms") && self.frags < 1)
1286 centerprint(self, strcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nspectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode"));
1288 centerprint(self, strcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nspectating ", self.enemy.netname, "\n\n\n^7press jump to play\n^7press attack for next player\npress attack2 for free fly mode"));
1297 Called every frame for each client after the physics are run
1300 void PlayerPostThink (void)
1302 if(self.classname == "player") {
1303 CheckRules_Player();
1306 UpdatePlayerColors();
1307 if (self.deadflag == DEAD_NO)
1310 if (intermission_running)
1311 return; // intermission or finale
1313 //PrintWelcomeMessage(self);
1314 //if (TetrisPostFrame()) return;
1315 } else if (self.classname == "observer") {
1317 } else if (self.classname == "spectator") {