home *** CD-ROM | disk | FTP | other *** search
- /*
- **
- ** _exitrls.qc (ExitRules Code, 1.0)
- **
- ** Copyright (C) 1996 Johannes Plass
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- **
- ** Author: Johannes Plass (plass@dipmza.physik.uni-mainz.de)
- **
- */
-
- float EXITRULES_FRAGLIMIT = 40; // Players can exit only if at least one
- // player has at least this many frags.
- // Must be >= 0
- float EXITRULES_TIMELIMIT = 1; // Players can exit only if at least this many
- // minutes passed on the current level.
- // Must be >= 0.1
-
- void(entity player) ExitRulesInfo =
- {
- if (!USE_MODULE_EXITRULES) return;
-
- // 123456789#123456789#123456789#12345678
- sprint(player,"# ExitRules: restricts exiting.\n");
- sprint(player," Type 'help-exitrules' for help.\n");
- };
-
- void(entity player) ExitRulesInit =
- {
- if (!USE_MODULE_EXITRULES) return;
-
- stuffcmd(player,"alias help-exitrules \"impulse 210\";\n");
- };
-
- void() ExitRulesSetValues;
-
- void(entity player) ExitRulesHelp =
- {
- if (!USE_MODULE_EXITRULES) return;
-
- // 123456789#123456789#123456789#12345678
- sprint(player,"# ExitRules: imposes restrictions on\n");
- sprint(player," exiting a level. Current rules are:\n");
- sprint(player," ");
- ExitRulesLevelInfo(player);
- if (USE_MODULE_VOTE && USE_SUBMODULE_VOTE_EXITRULES) { //#jp#(Vote)
- // 123456789#123456789#123456789#12345678
- sprint(player," ExitRules may be disabled by voting\n");
- sprint(player," via the command 'vote-exitrules'.\n");
- }
- };
-
- void(entity player) ExitRulesLevelInfo =
- {
- if (!USE_MODULE_EXITRULES) return;
- if (!exitrules_inited) { ExitRulesSetValues(); }
- if (exitrules_status == EXITRULES_STATUS_TIGHT) {
- local string tmpstr;
- // 123456789#123456789#123456789#12345678
- sprint(player,"ExitRules: before you can exit one\n");
- sprint(player,"player must have ");
- tmpstr = ftos(exitrules_fraglimit);
- sprint(player,tmpstr);
- sprint(player," frags.\n");
- } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
- sprint(player,"ExitRules: you can exit.\n");
- }
- };
-
- void() ExitRulesSetValues =
- {
- if (!USE_MODULE_EXITRULES) return;
-
- if (!exitrules_inited) {
- // exitrules are not sensible if 'noexit' is active
- if (cvar("noexit")) {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- // disable exitrules for start level and levels with no exit
- } else if (world.model == "maps/start.bsp") {
- exitrules_status = EXITRULES_STATUS_SOFT;
- } else if (world.model == "maps/end.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else if (world.model == "maps/dm1.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else if (world.model == "maps/dm2.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else if (world.model == "maps/dm3.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else if (world.model == "maps/dm4.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else if (world.model == "maps/dm5.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else if (world.model == "maps/dm6.bsp") {
- exitrules_status = EXITRULES_STATUS_DISABLED;
- } else {
- exitrules_status = EXITRULES_STATUS_TIGHT;
- exitrules_fraglimit = EXITRULES_FRAGLIMIT;
- exitrules_timelimit = EXITRULES_TIMELIMIT;
- }
- exitrules_inited = 1;
- }
- };
-
- float(entity player) ExitRulesExitingIsNotAllowed =
- {
- if (!USE_MODULE_EXITRULES) return(0);
-
- if (!exitrules_inited) { ExitRulesSetValues(); }
- player.exitrules_death = 2;
- if (exitrules_status == EXITRULES_STATUS_DISABLED) {
- player.exitrules_death = 0;
- } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
- player.exitrules_death = 0;
- } else {
- local entity e;
- local float cont;
- e = find(world, classname, "player");
- while (e) {
- if (e.frags >= exitrules_fraglimit) {
- if (e.deadflag != DEAD_DEAD) {
- player.exitrules_death = 0;
- }
- }
- e = find(e, classname, "player");
- }
- }
- if (!player.exitrules_death) {
- if (time < exitrules_timelimit*60) {
- player.exitrules_death = 1;
- }
- }
- return(player.exitrules_death);
- };
-
- void(entity player) ExitRulesClientObituary =
- {
- if (player.exitrules_death == 1) {
- bprint (player.netname);
- bprint(" tried to exit before ");
- bprint(ftos(exitrules_timelimit));
- bprint(" minutes had passed on this level.\n");
- } else {
- bprint (player.netname);
- bprint(" tried to exit before a player had reached ");
- bprint(ftos(exitrules_fraglimit));
- bprint(" frags.\n");
- }
- player.exitrules_death = 0;
- };
-
-
-
-