home *** CD-ROM | disk | FTP | other *** search
/ Superpower (Alt) / SUPERPOWER.iso / q / patch / mbq090 / _exitrls.qc < prev    next >
Encoding:
Text File  |  1996-08-29  |  5.4 KB  |  166 lines

  1. /*
  2. **
  3. ** _exitrls.qc (ExitRules Code, 1.0)
  4. **
  5. ** Copyright (C) 1996 Johannes Plass
  6. ** 
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. ** 
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ** 
  21. ** Author:   Johannes Plass (plass@dipmza.physik.uni-mainz.de)
  22. **
  23. */
  24.  
  25. float EXITRULES_FRAGLIMIT = 40; // Players can exit only if at least one 
  26.                                 // player has at least this many frags.
  27.                                 // Must be >= 0
  28. float EXITRULES_TIMELIMIT = 1;  // Players can exit only if at least this many
  29.                                 // minutes passed on the current level.
  30.                                 // Must be >= 0.1
  31.  
  32. void(entity player) ExitRulesInfo =
  33. {
  34.    if (!USE_MODULE_EXITRULES) return;
  35.  
  36.    //             123456789#123456789#123456789#12345678
  37.    sprint(player,"# ExitRules: restricts exiting.\n");
  38.    sprint(player,"  Type 'help-exitrules' for help.\n");
  39. };
  40.  
  41. void(entity player) ExitRulesInit =
  42. {
  43.    if (!USE_MODULE_EXITRULES) return;
  44.  
  45.    stuffcmd(player,"alias help-exitrules \"impulse 210\";\n");
  46. };
  47.  
  48. void() ExitRulesSetValues;
  49.  
  50. void(entity player) ExitRulesHelp =
  51. {
  52.    if (!USE_MODULE_EXITRULES) return;
  53.  
  54.       //          123456789#123456789#123456789#12345678
  55.    sprint(player,"# ExitRules: imposes restrictions on\n");
  56.    sprint(player,"  exiting a level. Current rules are:\n");
  57.    sprint(player,"  ");
  58.    ExitRulesLevelInfo(player);
  59.    if (USE_MODULE_VOTE && USE_SUBMODULE_VOTE_EXITRULES) { //#jp#(Vote)
  60.       //             123456789#123456789#123456789#12345678
  61.       sprint(player,"  ExitRules may be disabled by voting\n");
  62.       sprint(player,"  via the command 'vote-exitrules'.\n");
  63.    }
  64. };
  65.  
  66. void(entity player) ExitRulesLevelInfo =
  67. {
  68.    if (!USE_MODULE_EXITRULES) return;
  69.    if (!exitrules_inited) { ExitRulesSetValues(); }
  70.    if (exitrules_status == EXITRULES_STATUS_TIGHT) {
  71.       local string tmpstr;
  72.       //             123456789#123456789#123456789#12345678
  73.       sprint(player,"ExitRules: before you can exit one\n");
  74.       sprint(player,"player must have ");
  75.       tmpstr = ftos(exitrules_fraglimit);
  76.       sprint(player,tmpstr);
  77.       sprint(player," frags.\n");
  78.    } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
  79.       sprint(player,"ExitRules: you can exit.\n");
  80.    }
  81. };
  82.  
  83. void() ExitRulesSetValues =
  84. {
  85.    if (!USE_MODULE_EXITRULES) return;
  86.  
  87.    if (!exitrules_inited) {
  88.       // exitrules are not sensible if 'noexit' is active
  89.       if (cvar("noexit")) {
  90.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  91.       // disable exitrules for start level and levels with no exit 
  92.       } else if   (world.model == "maps/start.bsp") {
  93.          exitrules_status    = EXITRULES_STATUS_SOFT;
  94.       } else if (world.model == "maps/end.bsp") {
  95.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  96.       } else if (world.model == "maps/dm1.bsp") {
  97.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  98.       } else if (world.model == "maps/dm2.bsp") {
  99.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  100.       } else if (world.model == "maps/dm3.bsp") {
  101.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  102.       } else if (world.model == "maps/dm4.bsp") {
  103.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  104.       } else if (world.model == "maps/dm5.bsp") {
  105.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  106.       } else if (world.model == "maps/dm6.bsp") {
  107.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  108.       } else {
  109.          exitrules_status    = EXITRULES_STATUS_TIGHT;
  110.          exitrules_fraglimit = EXITRULES_FRAGLIMIT;
  111.          exitrules_timelimit = EXITRULES_TIMELIMIT;
  112.       }
  113.       exitrules_inited = 1;
  114.    }
  115. };
  116.  
  117. float(entity player) ExitRulesExitingIsNotAllowed =
  118. {
  119.    if (!USE_MODULE_EXITRULES) return(0);
  120.  
  121.    if (!exitrules_inited) { ExitRulesSetValues(); }
  122.    player.exitrules_death = 2;
  123.    if (exitrules_status == EXITRULES_STATUS_DISABLED) {
  124.       player.exitrules_death = 0;
  125.    } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
  126.       player.exitrules_death = 0;
  127.    } else {
  128.       local entity e;
  129.       local float cont;
  130.       e = find(world, classname, "player");
  131.       while (e) {
  132.          if (e.frags >= exitrules_fraglimit) {
  133.             if (e.deadflag != DEAD_DEAD) {
  134.                player.exitrules_death = 0;
  135.             }
  136.          }
  137.          e = find(e, classname, "player");
  138.       }
  139.    } 
  140.    if (!player.exitrules_death) {
  141.       if (time < exitrules_timelimit*60) {
  142.          player.exitrules_death = 1;
  143.       }
  144.    }
  145.    return(player.exitrules_death);
  146. };
  147.  
  148. void(entity player) ExitRulesClientObituary =
  149. {
  150.    if (player.exitrules_death == 1) {
  151.       bprint (player.netname);
  152.       bprint(" tried to exit before ");
  153.       bprint(ftos(exitrules_timelimit));
  154.       bprint(" minutes had passed on this level.\n");
  155.    } else {
  156.       bprint (player.netname);
  157.       bprint(" tried to exit before a player had reached ");
  158.       bprint(ftos(exitrules_fraglimit));
  159.       bprint(" frags.\n");
  160.    }
  161.    player.exitrules_death = 0;
  162. };
  163.  
  164.  
  165.  
  166.