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

  1. // FILENAME:    Starsiege_Football.cs                  
  2. //
  3. // AUTHORS:      Brother Youth in Asia of the clan NHMK
  4. //
  5. // READER'S NOTE: Someone was in an awful good mood when this script was made...
  6. //                -- Boss Hogg
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. $missionName = "Starsiege_Football";
  11.  
  12. exec("multiplayerStdLib.cs");
  13.  
  14. $BlueScore = 0;
  15. $RedScore = 0;
  16. $PointInterval = 7;
  17. $WinScore = $PointInterval * 6;
  18. $BallCarrierKillValue = 7;
  19. $FumbleTakeUpsValue = 5;
  20. $FumblesValue = 4;
  21. $TouchDownValue = 7;
  22. $MaxFouls = 3;
  23. $PenaltyTime = 60;
  24. $GameOver = "false";
  25. $GoalMade = "false";
  26.  
  27. //--------------------------------------------------------------------------------
  28.  
  29.     
  30. function setRules(){
  31.     echo("function setRules()");
  32.  
  33.    // compose a big "rich text" string of the rules to be displayed in the 
  34.    // game info panel
  35.    
  36.    %rules = "<tIDMULT_FOOTBALL_GAMETYPE>"       @        
  37.             "<tIDMULT_FOOTBALL_MAPNAME>"        @ 
  38.             $missionName                        @  
  39.             "<tIDMULT_FOOTBALL_OBJECTIVES>"     @
  40.             "<tIDMULT_FOOTBALL_SCORING_1>"      @
  41.             "<tIDMULT_FOOTBALL_SCORING_2>"      @
  42.             $TouchDownValue                     @
  43.             "<tIDMULT_FOOTBALL_SCORING_3>"      @
  44.             "<tIDMULT_FOOTBALL_SCORING_4>"      @
  45.             $WinScore                           @
  46.             "<tIDMULT_FOOTBALL_SCORING_5>"      @
  47.             "<tIDMULT_STD_ITEMS>"               @
  48.             "<tIDMULT_FOOTBALL_ENDZONE>"        @
  49.             "<tIDMULT_FOOTBALL_GLOW>"           @
  50.             "<tIDMULT_FOOTBALL_PENALTY_1>"      @
  51.             $MaxFouls                           @
  52.             "<tIDMULT_FOOTBALL_PENALTY_2>"      @
  53.             timeDifference($PenaltyTime, 0)     @
  54.             "<tIDMULT_FOOTBALL_PENALTY_3>"      @
  55.             "<tIDMULT_FOOTBALL_MARKERS>";
  56.   
  57.    // display this string in the panel
  58.    setGameInfo(%rules);
  59. }
  60.  
  61. // anything that redefines the rules needs to do this
  62. // get the rules panel up and running
  63. // this has to be called after the definition of setRules
  64. setRules();
  65.  
  66. //----------------------------------------------
  67.  
  68. function setDefaultMissionOptions()
  69. {
  70.     echo("function setDefaultMissionOptions()");
  71.  
  72.    $server::AllowTeamRed      = true;
  73.    $server::AllowTeamBlue     = true;
  74.    $server::AllowTeamYellow   = false;
  75.    $server::AllowTeamPurple   = false;
  76.  
  77.    $server::TeamPlay          = true;
  78.    $server::AllowDeathmatch   = false;
  79.    $server::AllowTeamPlay     = true;    
  80.  
  81.    $server::disableTeamRed    = false;
  82.    $server::disableTeamBlue   = false;
  83.    $server::disableTeamYellow = true;
  84.    $server::disableTeamPurple = true;
  85. }
  86.  
  87. function onMissionStart(%playerNum)
  88. {
  89.     echo("function onMissionStart(%playerNum)");
  90.     cls();
  91.  
  92.     //reinitialize scores of players who were in previous game
  93.     %count = playerManager::getPlayerCount();
  94.     for(%i = 0; %i < %count; %i = %i + 1)    {
  95.         %curPlayerNum = playerManager::getPlayerNum(%i);
  96.         initStats(%curPlayerNum);
  97.     }
  98.  
  99. }        
  100.  
  101. function onMissionLoad()
  102. {
  103.     echo("function onMissionLoad()");
  104.  
  105.    cdAudioCycle("Yougot", "Terror", "Cloudburst", "Mechsoul"); 
  106. }
  107.  
  108. function initStats(%playerNum){
  109.     echo("function initStats(%playerNum)");
  110.     
  111.     dataStore(%playerNum, "ballCarrierKills", 0);
  112.     dataStore(%playerNum, "fumbleTakeUps", 0);
  113.     dataStore(%playerNum, "fumbles", 0);
  114.     dataStore(%playerNum, "touchDowns", 0);
  115.     dataStore(%playerNum, "fouls", 0);
  116. }
  117.  
  118. //-------------------------------------------------------------
  119. function player::onAdd(%playerNum){
  120.     echo("function player::onAdd(%playerNum)");
  121.  
  122.     dataStore(%playerNum, "onField", 0);
  123.  
  124.    initStats(%playerNum);
  125.  
  126.    say(%playerNum, 0, *IDMULT_FOOTBALL_WELCOME);
  127. }
  128.  
  129. //-------------------------------------------------------------
  130. function vehicle::onAdd(%vehicleId){
  131.     echo("function vehicle::onAdd(%vehicleId)");
  132.  
  133.     %playerNum = playerManager::vehicleIdToPlayerNum(%vehicleId);
  134.  
  135.     // Check to make sure this person isn't cheating to get out of the foul box
  136.     %playersTeam = getTeam(%playerNum);
  137.     if(%playersTeam == *IDSTR_TEAM_YELLOW || %playersTeam == *IDSTR_TEAM_PURPLE){
  138.         sendToPenaltyBox(%vehicleId);
  139.         return;
  140.     }
  141.  
  142.     // Drop them at a point on their ten yard line
  143.     dropAtTenYardLine(%vehicleId);
  144.  
  145.     // Remember that this player is currently on the field
  146.     dataStore(%playerNum, "onField", 1);
  147.  
  148.     %ballCarrier = getItNum();
  149.     
  150.     // If the other team made a touchdown &&
  151.     // no one has the ball &&
  152.     // this person isn't going to the foul box &&
  153.     // this person teams is to get the ball, give them the ball
  154.     if(($GoalMade == *IDSTR_TEAM_BLUE || $GoalMade == *IDSTR_TEAM_RED) &&  getTeam(%playerNum) != $GoalMade){
  155.         schedule("$GoalMade = \"false\";", 7);            
  156.         giveBall(%playerNum, "true");
  157.     }
  158.     // Else this herc is the first in the game, give them the ball...
  159.     else if($GoalMade == "false" && %ballCarrier == "false"){
  160.         schedule("$GoalMade = \"false\";", 7);            
  161.         giveBall(%playerNum, "true");
  162.     }
  163.     // Else no one has the ball and someone should at least get it!!!
  164. }
  165.  
  166. // AREN"T SURE IF WE WANT THIS SINCE THE FLAG IS GIVEN TO HERCS, NOT PLAYERS????
  167. // --------------------------------------------------------------------------
  168. function player::onRemove(%playerNum){
  169.     echo("function player::onRemove(%playerNum)");
  170.     // Are they carrying the ball?  Give it to someone on the opposing team
  171.     // and if no one else is on their team, give it to the other team...
  172.     if(getItNum() == %playerNum){
  173.         giveBallToOtherTeam("true", "true");
  174.     }
  175. }
  176.  
  177. // A vehicle is destroyed
  178. // Is it a team kill?
  179. // Is it a flag carrier?
  180. // --------------------------------------------------------------------------
  181. function vehicle::onDestroyed(%destroyed, %destroyer){
  182.     echo("function vehicle::onDestroyed(%destroyed, %destroyer)");
  183.  
  184.     // Who is this player?
  185.     %playerNum = playerManager::vehicleIdToPlayerNum(%destroyed);
  186.  
  187.     // Who destroyed them?
  188.     %playerDestroyerNum = playerManager::vehicleIdToPlayerNum(%destroyer);      
  189.  
  190.     // K.  They're off the field!
  191.     dataStore(%playerNum, "onField", 0);
  192.  
  193.     // If the destroyer is in the penalty box then give ball to the other team...
  194.     if((getTeam(%playerDestroyerNum) == *IDSTR_TEAM_YELLOW) || (getTeam(%playerDestroyerNum) == *IDSTR_TEAM_PURPLE)){
  195.         giveBallToOtherTeam("true", "true");
  196.         return;
  197.     }
  198.  
  199.     // A touchdown was made.  But does this person have the ball?  Tell them to drop it
  200.     if($GoalMade != "false"){
  201.         if(%playerNum == getItNum())
  202.             dropBall(%playerNum);
  203.     }
  204.  
  205.     // If this player didn't kill themselves...
  206.     if(%destroyed != %destroyer){
  207.  
  208.         // Throw this team killer in the penalty box
  209.         if(getTeam(%playerNum) == getTeam(%playerDestroyerNum)){
  210. //            destroyThisPlayer(%playerDestroyerNum);
  211.             dataStore(%playerDestroyerNum, "fouls", 2);
  212.             Say(0, 0, getName(%playerDestroyerNum) @ *IDMULT_FOOTY_ENTER_PENALTY_BOX);
  213.             addFoul(%playerDestroyerNum);
  214.         }
  215.  
  216.         // Return if the player killed wasn't it!!!!!!!!!!!!!!!!!!!!!!!!
  217.         if(%playerNum != getItNum())
  218.             return;
  219.         
  220.         // The player killed WAS IT; now check the following conditions!!!!!!!!!!!!!!!1
  221.  
  222.         // Give the destroyer points for stopping the ball carrier IF they are on opposing teams
  223.         if(getTeam(%playerNum) != getTeam(%playerDestroyerNum)){
  224.             dataStore(%playerDestroyerNum, "ballCarrierKills", getBallCarrierKills(%playerNum) + 1);
  225.         }
  226.                 
  227.         // Return if the game's over
  228.         if($GameOver == "true")
  229.             return;
  230.  
  231.         // Give ball to the destroyer if this person had the ball and destroyer on opposite team & destroyer isOnField
  232.         else if(getTeam(%playerDestroyerNum) != getTeam(%playerNum) && isOnField(%playerDestroyerNum) != 0){
  233.             // Give the ball to the person who killed the ball carrier
  234.             giveBall(%playerDestroyerNum, "true");
  235.         }
  236.         // Destroyer isn't on the field!  Give ball to other team!!!  Doesn't count if the destroyer is a team killer
  237.         else if(getTeam(%playerDestroyerNum) != getTeam(%playerNum)){
  238.             giveBallToOtherTeam("true", "true");
  239.         }
  240.         else{
  241.             giveBallToOtherTeam("false", "true");
  242.         }
  243.     }
  244.     // What if this person did kill themselves by running into the sideline (o