home *** CD-ROM | disk | FTP | other *** search
/ Classic Fond 54 / ClassicFond54.iso / games / stars.rar / multiplayer / DMstdLib.cs < prev    next >
Text File  |  1999-02-19  |  6KB  |  193 lines

  1. //------------------------------------------------------------------------------
  2. //
  3. // DeathMatch standard library
  4. //
  5.  
  6. //--------------------------------------
  7. // Rules
  8.  
  9. // internal globals
  10. // $killPoints: how many points scored for a kill
  11. // $deathPoints: how many points LOST for dying
  12.  
  13. $killPoints = 3;
  14. $deathPoints = 2;
  15.  
  16. function setRules()
  17. {
  18.    if($server::TeamPlay == true)
  19.     {
  20.       %rules = "<tIDMULT_TDM_GAMETYPE>"   @        
  21.                "<tIDMULT_TDM_MAPNAME>"    @ 
  22.                $missionName               @
  23.                "<tIDMULT_TDM_OBJECTIVES>" @
  24.                "<tIDMULT_TDM_SCORING_1>"  @
  25.                "<tIDMULT_TDM_SCORING_2>"  @
  26.                $killPoints                @
  27.                "<tIDMULT_TDM_SCORING_3>"  @
  28.                "<tIDMULT_TDM_SCORING_4>"  @
  29.                $deathPoints               @
  30.                "<tIDMULT_TDM_SCORING_5>"  @
  31.                "<tIDMULT_TDM_SCORING_6>"  @
  32.                "<tIDMULT_STD_ITEMS>"      @
  33.                "<tIDMULT_STD_HEAL>"       @
  34.                "<tIDMULT_STD_RELOAD_1>"   @
  35.                $PadWaitTime               @
  36.                "<tIDMULT_STD_RELOAD_2>"   @
  37.                "<tIDMULT_STD_ZEN_1>"      @
  38.                $ZenWaitTime               @
  39.                "<tIDMULT_STD_ZEN_2>";
  40.    }
  41.     else
  42.     {
  43.       %rules = "<tIDMULT_DM_GAMETYPE>"    @        
  44.                "<tIDMULT_DM_MAPNAME>"     @ 
  45.                $missionName               @
  46.                "<tIDMULT_DM_OBJECTIVES>"  @
  47.                "<tIDMULT_DM_SCORING_1>"   @
  48.                "<tIDMULT_DM_SCORING_2>"   @
  49.                $killPoints                @
  50.                "<tIDMULT_DM_SCORING_3>"   @
  51.                "<tIDMULT_DM_SCORING_4>"   @
  52.                $deathPoints               @
  53.                "<tIDMULT_DM_SCORING_5>"   @
  54.                "<tIDMULT_STD_ITEMS>"      @
  55.                "<tIDMULT_STD_HEAL>"       @
  56.                "<tIDMULT_STD_RELOAD_1>"   @
  57.                $PadWaitTime               @
  58.                "<tIDMULT_STD_RELOAD_2>"   @
  59.                "<tIDMULT_STD_ZEN_1>"      @
  60.                $ZenWaitTime               @
  61.                "<tIDMULT_STD_ZEN_2>";
  62.                   
  63.    }
  64.    setGameInfo(%rules);      
  65. }
  66.  
  67. // setup the rules
  68. // this has to be called after the definition of setRules
  69. setRules();
  70.                 
  71. function player::onAdd(%this)
  72. {
  73.    player::onAddLog(%this);
  74.     
  75.     if($server::TeamPlay == true)
  76.     {
  77.       say(%this,0, *IDMULT_TDM_WELCOME);          
  78.    }
  79.     else
  80.     {
  81.       say(%this,0, *IDMULT_DM_WELCOME);
  82.    }
  83. }   
  84.  
  85. function vehicle::onAdd(%this)
  86. {
  87.    if($server::TeamPlay != true)
  88.    {
  89.        // see if it is a player
  90.       %player = playerManager::vehicleIdToPlayerNum(%this);
  91.       if(%player == 0)  // that's the server
  92.          return;
  93.          
  94.       // so it's a player
  95.       
  96.       // shouldn't have to do this, but oh well
  97.       setTeam(%this, *IDSTR_TEAM_RED);
  98.    }
  99. }
  100.  
  101. //--------------------------------------
  102. // Death Messages
  103.  
  104. function vehicle::onDestroyed(%destroyed, %destroyer)
  105. {
  106.    // left over from missionStdLib.cs
  107.    vehicle::onDestroyedLog(%destroyed, %destroyer);
  108.    
  109.    // this is weird but %destroyer isn't necessarily a vehicle
  110.    %message = getFancyDeathMessage(getHUDName(%destroyed), getHUDName(%destroyer));
  111.    if(%message != "")
  112.    {
  113.       say( 0, 0, %message);
  114.    }
  115.    
  116.    // enforce the rules
  117.    if($server::TeamPlay == true)
  118.    {
  119.       if(
  120.          (getTeam(%destroyed) == getTeam(%destroyer)) &&
  121.          (%destroyed != %destroyer)
  122.       )
  123.       {
  124.          antiTeamKill(%destroyer);
  125.       }
  126.    }   
  127. }
  128.  
  129. //------------------------------------------------------------------------------
  130. // scoreboard 
  131.  
  132. function getPlayerScore(%a)
  133. {
  134.    return((getKills(%a) * $killPoints) - (getDeaths(%a) * $deathPoints));
  135. }
  136.  
  137. function getTeamScore(%a)
  138. {
  139.    return((getTeamKills(%a) * $killPoints) - (getTeamDeaths(%a) * $deathPoints));
  140. }
  141.  
  142. function initScoreBoard()
  143. {
  144.    deleteVariables("$ScoreBoard::PlayerColumn*");
  145.    deleteVariables("$ScoreBoard::TeamColumn*");
  146.  
  147.    if($server::TeamPlay == "True")    
  148.    {
  149.        // Player ScoreBoard column headings
  150.        $ScoreBoard::PlayerColumnHeader1 = *IDMULT_SCORE_TEAM;
  151.        $ScoreBoard::PlayerColumnHeader2 = *IDMULT_SCORE_SQUAD;
  152.        $ScoreBoard::PlayerColumnHeader3 = *IDMULT_SCORE_SCORE;
  153.        $ScoreBoard::PlayerColumnHeader4 = *IDMULT_SCORE_KILLS;
  154.        $ScoreBoard::PlayerColumnHeader5 = *IDMULT_SCORE_DEATHS;
  155.  
  156.        // Player ScoreBoard column functions
  157.        $ScoreBoard::PlayerColumnFunction1 = "getTeam";
  158.        $ScoreBoard::PlayerColumnFunction2 = "getSquad";
  159.        $ScoreBoard::PlayerColumnFunction3 = "getPlayerScore";
  160.        $ScoreBoard::PlayerColumnFunction4 = "getKills";
  161.        $ScoreBoard::PlayerColumnFunction5 = "getDeaths";
  162.    }
  163.    else
  164.    {
  165.        // Player ScoreBoard column headings
  166.        $ScoreBoard::PlayerColumnHeader1 = *IDMULT_SCORE_SQUAD;
  167.        $ScoreBoard::PlayerColumnHeader2 = *IDMULT_SCORE_SCORE;
  168.        $ScoreBoard::PlayerColumnHeader3 = *IDMULT_SCORE_KILLS;
  169.        $ScoreBoard::PlayerColumnHeader4 = *IDMULT_SCORE_DEATHS;
  170.  
  171.        // Player ScoreBoard column functions
  172.        $ScoreBoard::PlayerColumnFunction1 = "getSquad";
  173.        $ScoreBoard::PlayerColumnFunction2 = "getPlayerScore";
  174.        $ScoreBoard::PlayerColumnFunction3 = "getKills";
  175.        $ScoreBoard::PlayerColumnFunction4 = "getDeaths";
  176.    }
  177.  
  178.    // Team ScoreBoard column headings
  179.    $ScoreBoard::TeamColumnHeader1 = *IDMULT_SCORE_SCORE;
  180.    $ScoreBoard::TeamColumnHeader2 = *IDMULT_SCORE_PLAYERS;
  181.    $ScoreBoard::TeamColumnHeader3 = *IDMULT_SCORE_KILLS;
  182.    $ScoreBoard::TeamColumnHeader4 = *IDMULT_SCORE_DEATHS;
  183.  
  184.    // Team ScoreBoard column functions
  185.    $ScoreBoard::TeamColumnFunction1 = "getTeamScore";
  186.    $ScoreBoard::TeamColumnFunction2 = "getNumberOfPlayersOnTeam";
  187.    $ScoreBoard::TeamColumnFunction3 = "getTeamKills";
  188.    $ScoreBoard::TeamColumnFunction4 = "getTeamDeaths";
  189.  
  190.    // tell server to process all the scoreboard definitions defined above
  191.    serverInitScoreBoard();
  192. }
  193.