Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "zcommon.acs"
- //#include "jumpmaze_ranker_solo.acs"
- #DEFINE shortDelay 35
- #DEFINE longDelay 70
- #DEFINE foreverDelay 9999*9999
- int playerAmount = 0;
- int crossedLine = 0;
- int laptotal;
- int lapsArray [8];
- bool playerArray [8];
- bool raceStarted = false;
- bool raceFinished = false;
- ////////////////////////////////////////////////////////////////////////////////////////////////////// 1st Countdown
- Script 01 (void)
- {
- int countdown;
- //Countdown to bike.
- Delay(longDelay);
- for (int i = 0; i < 10; i++)
- {
- countdown = 10 - i;
- SetFont("BigFont");
- HudmessageBold(s: "You have ", d:countdown, s:" seconds to enter a wavebike!"; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 0.2);
- Delay(35);
- }
- SetFont("BigFont");
- HudmessageBold(s: "Access to wavebikes removed."; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 2.5);
- raceStarted = true;
- Delay(longDelay);
- ACS_Execute(11,0);
- }
- Script 02 (void) //Count down canceller.
- {
- for (int i = 0; i < 7; i++)
- {
- Suspend;
- }
- ACS_Terminate(1,0);
- SetFont("BigFont");
- HudmessageBold (s: "Wavebikes are all taken!!"; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 1.5);
- Delay(longDelay);
- ACS_Execute(11,0);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////// Telepoter Scripts
- Script 03 (void) //Teleport 1
- {
- if (raceStarted)
- terminate;
- Teleport(21, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(9,0,6);
- playerArray[0] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 04 (void) //Teleport 2
- {
- if (raceStarted)
- terminate;
- Teleport(22, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(10,0,6);
- playerArray[1] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 05 (void) //Teleport 3
- {
- if (raceStarted)
- terminate;
- Teleport(23, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(11,0,6);
- playerArray[2] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 06 (void) //Teleport 4
- {
- if (raceStarted)
- terminate;
- Teleport(24, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(12,0,6);
- playerArray[3] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 07 (void) //Teleport 5
- {
- if (raceStarted)
- terminate;
- Teleport(25, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(13,0,6);
- playerArray[4] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 08 (void) //Teleport 6
- {
- if (raceStarted)
- terminate;
- Teleport(26, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(14,0,6);
- playerArray[5] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 09 (void) //Teleport 7
- {
- if (raceStarted)
- terminate;
- Teleport(27, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(15,0,6);
- playerArray[6] = true;
- Delay(foreverDelay); //Forever.
- }
- Script 10 (void) //Teleport 8
- {
- if (raceStarted)
- terminate;
- Teleport(28, 0, 0);
- ACS_Execute(2,0);
- GiveInventory("BoatActivate",1);
- ACS_Execute(12,0);
- Floor_LowerInstant(16,0,6);
- playerArray[7] = true;
- Delay(foreverDelay); //Forever.
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////// Race scripts
- Script 11 (void) //Countdown to RACE
- {
- int countdown;
- //Countdown to bike.
- TakeInventory("lapCheck", 10);
- Delay(longDelay);
- for (int i = 0; i < 10; i++)
- {
- countdown = 10 - i;
- SetFont("BigFont");
- HudmessageBold(s: "\cgYou have ", d:countdown, s:" seconds until the race starts!"; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 0.2);
- AmbientSound("hurp/derp", 127);
- Delay(shortDelay);
- }
- SetFont("BigFont");
- if (playerAmount > 0)
- {
- HudmessageBold(s: "\cgThe race has started!"; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 2.0);
- ACS_Execute(471, 0);
- HudmessageBOLD(s: "Lap: /0 ";HUDMSG_PLAIN, 2, 0, 0.95, 1, 0); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- }
- else
- {
- HudmessageBold(s: "\cgNo racers, switching to the next map."; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 2.0);
- Delay(35*3);
- Exit_Normal(0);
- }
- Setmusic("CUTMUS");
- SetLineTexture(17,SIDE_FRONT,TEXTURE_MIDDLE,"-");
- SetLineTexture(17,SIDE_BACK,TEXTURE_MIDDLE,"-");
- SetLineBlocking(17,OFF);
- ACS_Execute(15,0);
- }
- Script 12 (void) //Adds a value to the 'playerAmount' variable
- {
- if (playerAmount > 8)
- {
- playerAmount = 8;
- SetFont("BigFont");
- HudmessageBold(s: "\chToo many racers!"; HUDMSG_FADEOUT, 0, 13, 0.5, 0.25, 2.0);
- terminate;
- }
- playerAmount++;
- }
- Script 13 (void) //Derp
- {
- }
- Script 14 (void) //Checks if someone passed the finish line
- {
- int laps;
- for (int i = 0; i < 8; i++)
- {
- if (playerArray[i] == true)
- lapsArray[i]++;
- if (lapsArray[i] > (GetCVAR("winlimit")))
- {
- RecordFinishedPlayer();
- raceFinished = true;
- }
- else
- {
- SetFont("SmallFont");
- Hudmessage(s: " ", d:lapsArray[i], s:" /";HUDMSG_PLAIN, 1, 0, 0.95, 1, 0);
- }
- }
- ACS_Execute(13,0);
- }
- Script 15 (void) //Checks players for laps
- {
- while (!raceFinished)
- {
- SetFont("SmallFont");
- HudmessageBOLD(s: "Lap: ", d:GetCVAR("winlimit"), s:"";HUDMSG_PLAIN, 2, 0, 0.95, 1, 0);
- Delay(shortDelay);
- }
- }
- Script 30 OPEN //Static scripts.
- {
- Sector_SetFriction(40, 45);
- }
- /*
- Script 31 OPEN
- {
- int i = 0;
- while(i < 1)
- {
- if (playerAmount > PlayerCount())
- playerAmount = PlayerCount();
- }
- }
- */
- Script 32 OPEN //Static scripts.
- {
- if (GetCVAR("SV_DisallowSuidice") == 0)
- ConsoleCommand("SV_DisallowSuicide 1");
- if (GetCVAR("winlimit") == 0)
- ConsoleCommand("winlimit 3");
- if (GetCVAR("winlimit") > 9)
- ConsoleCommand("winlimit 9");
- }
- //DoomThroughDoom- This script it taken from Jumpmaze.
- //Instead of writing my own script to try and get the same result,
- //I've just taken it and modified it.
- // Description:
- // Simple JumpMaze rank script, allowing the adjustement
- // of the number of players to rank and display.
- //
- // New in version 1.2:
- // -- Made the individual time as default for single
- // player.
- //
- // New in version 1.1:
- // -- Added individual time when all rank places
- // have been exhausted.
- //
- // Required files ( must be #included before usage ):
- // -- zcommon.acs
- //
- // USAGE:
- // To use the solo JumpMaze ranker, simply #include the
- // jumpmaze_ranker_solo.acs file and call the public
- // RecordFinishedPlayer() function when a player has
- // crossed the finish line. One can create a dummy script
- // that will be executed when the player crosses the
- // line, which in turn calls the above function.
- //
- // Author: DuNR1DA2 ( Positron )
- // Last modified: March 8, 2010
- //
- // Feel free to modify and distribute this script in any
- // way you like, but please keep this block of text.
- // Script numbers used:
- // If these numbers are used elsewhere, just changed these
- // numbers to something that doesn't exist and the
- // rest will be adjusted.
- #define SECONDS_IN_MINUTE 60
- #define MAX_PLAYERS 32
- #define RANKER_SOLO_PLAYER_ENTER 481
- #define RANKER_SOLO_MAIN_LOOP 482
- #define RANKER_SOLO_PLAYER_COMPLETED 483
- #define RANKER_SOLO_PLAYER_GONE 484
- // Time to wait before displaying the results in tics
- // when a player crosses the finish line.
- #define RANK_DISPLAY_DELAY_TIME 16
- // Update time, in seconds, that will be used
- // to check whether the rank limit was altered.
- #define RANK_LIMIT_CHECK_TIME 1
- // The refresh time, on the other hand, is the
- // time in seconds it takes to re-display the table.
- // This is needed if people who are ranked change
- // their name, to reflect the changes.
- // We set it to ten seconds for performance reasons.
- #define RANK_TABLE_REFRESH_TIME 10
- #define DISCONNECTED_LABEL "Disconnected"
- #define DISCONNECTED_LABEL_COLOR "g" // Red
- #define RANK_LIMIT_CVAR "rank_limit"
- #define RANK_LIMIT_MIN 3
- #define RANK_LIMIT_MAX 8
- #define RANK_TABLE_X 250
- // The offset is used to prevent ID conflicts
- // in HudMessages from other scripts.
- #define RANK_ID_OFFSET 233
- // This variable will store the amount of players to dispaly.
- int rank_limit = RANK_LIMIT_MAX;
- int rank_colors[ 8 ] = {
- "f", // Gold
- "j", // Silver
- "e", // Brown
- "d", // Green
- "n", // Light Blue
- "t", // Purple
- "u", // Gray
- "m", // Black
- };
- #define RANK_TABLE_Y 45100
- #define RANK_PLACE_HEIGHT 2900
- #define PLAYER_DISCONNECTED -1
- #define PLAYER_NOT_FINISHED -1
- // Ranked player properties:
- #define IDX_NUM 0
- #define IDX_MINUTES 1
- #define IDX_SECONDS 2
- int players[ RANK_LIMIT_MAX ][ 8 ];
- int players_ranked = 0;
- int players_displayed[ MAX_PLAYERS ];
- bool rank_is_single_player = false;
- bool is_single_player_finished = false;
- // Public functions ( To be used by the user ):
- // ==========================================================
- function void RecordFinishedPlayer( void ) {
- int player = playerNumber();
- if ( player >= 0 ) {
- if ( rank_is_single_player ) {
- if ( ! is_single_player_finished ) {
- is_single_player_finished = true;
- DisplayIndividualTime();
- }
- }
- // Multiplayer:
- else {
- // To solve the issue with duplicate scripts executing for
- // a single player when the player crosses a vertex that
- // connects to action linedefs, I decided to check whether
- // the player has finished earlier.
- if ( ! IsPlayerFinished( player ) ) {
- RememberFinishedPlayer( player );
- acs_ExecuteAlways( RANKER_SOLO_PLAYER_COMPLETED, 0, player );
- }
- }
- }
- }
- // ==========================================================
- script RANKER_SOLO_PLAYER_ENTER ENTER {
- if ( ! rank_is_single_player ) {
- DrawScoreTable();
- }
- ClearIndividualTime();
- }
- script RANKER_SOLO_MAIN_LOOP OPEN {
- // We don't need this loop in single player.
- if ( gameType() == GAME_SINGLE_PLAYER ) {
- rank_is_single_player = true;
- terminate;
- }
- int time = 0;
- int check_time = shortDelay * RANK_LIMIT_CHECK_TIME;
- while ( true ) {
- int limit = getCvar( RANK_LIMIT_CVAR );
- if ( limit != rank_limit ) {
- if ( limit >= RANK_LIMIT_MIN && limit <= rank_LIMIT_MAX ) {
- ClearTable();
- rank_limit = limit;
- DrawScoreTable();
- }
- }
- if ( time % RANK_TABLE_REFRESH_TIME == 0 ) {
- DrawScoreTable();
- }
- time += 1;
- delay( check_time );
- }
- }
- script RANKER_SOLO_PLAYER_COMPLETED ( int player ) {
- // We first see if we can rank the player in the
- // score table.
- if ( FreeSpotAvailable() ) {
- RankFinishedPlayerInTable( player );
- // We only re-display the table if we haven't gone
- // over the limit. Otherwise, it has no effect.
- if ( players_ranked <= rank_limit ) {
- // To try and replicate the old script's delayed effect,
- // I've added a delay here. This will take some time
- // before finally displaying the results. Notice that
- // this won't affect the player's finish time, because
- // that is recorded in the above function.
- delay( RANK_DISPLAY_DELAY_TIME );
- DrawScoreTable();
- }
- // We display the individual time for the player if
- // we went over the rank display limit, even if we have
- // places still available in the rank table.
- else {
- DisplayIndividualTime();
- }
- }
- // If no more places remain in the score table, then
- // we just display the completion time to the player so
- // they can see the their individual time for the run.
- else {
- DisplayIndividualTime();
- }
- }
- function void ClearIndividualTime( void ) {
- ClearMessage( RANK_ID_OFFSET + RANK_LIMIT_MAX );
- }
- function void RememberFinishedPlayer( int player ) {
- players_displayed[ player ] = true;
- }
- function void ForgetFinishedPlayer( int player ) {
- players_displayed[ player ] = false;
- }
- function bool IsPlayerFinished( int player ) {
- return players_displayed[ player ];
- }
- function bool FreeSpotAvailable( void ) {
- if ( players_ranked < RANK_LIMIT_MAX ) {
- return true;
- }
- return false;
- }
- function int GetPosition( int playerNum ) {
- for ( int place = 0; place < players_ranked; place++ ) {
- if ( players[ place ][ IDX_NUM ] == playerNum ) {
- return place;
- }
- }
- return PLAYER_NOT_FINISHED;
- }
- function void RankFinishedPlayerInTable( int playerNum ) {
- players[ players_ranked ][ IDX_NUM ] = playerNum;
- int time = timer() / shortDelay;
- players[ players_ranked ][ IDX_MINUTES ] =
- time / SECONDS_IN_MINUTE;
- players[ players_ranked ][ IDX_SECONDS ] =
- time % SECONDS_IN_MINUTE;
- players_ranked += 1;
- }
- script RANKER_SOLO_PLAYER_GONE ( int player ) DISCONNECT {
- if ( IsPlayerFinished( player ) ) {
- // Free up the player number for potential players.
- ForgetFinishedPlayer( player );
- // We need to remove the player from the rank table if
- // the player was ever in it:
- if ( IsPlayerInRankTable( player ) ) {
- RemovePlayerFromRankTable( player );
- delay( RANK_DISPLAY_DELAY_TIME );
- DrawScoreTable();
- }
- }
- }
- function bool IsPlayerInRankTable( int player ) {
- if ( GetPosition( player ) != PLAYER_NOT_FINISHED ) {
- return true;
- }
- return false;
- }
- function void RemovePlayerFromRankTable( int player ) {
- int position = GetPosition( player );
- // We indicate that a player has disconnected by
- // removing the player's number with a predefined value.
- players[ position ][ IDX_NUM ] = PLAYER_DISCONNECTED;
- }
- // Drawing functions.
- // ==========================================================
- function void DrawScoreTable( void ) {
- // We need to set the font to small. Otherwise,
- // the font will vary at different times.
- setFont( "SMALLFONT" );
- // Determine the starting height of the table based
- // on the current rank limit.
- int rank_height = RANK_TABLE_Y +
- ( ( RANK_LIMIT_MAX - rank_limit ) * RANK_PLACE_HEIGHT );
- // Determine the amount of iterations to loop.
- int places_to_display = players_ranked;
- if ( places_to_display > rank_limit ) {
- places_to_display = rank_limit;
- }
- for ( int place = 0; place < places_to_display; place++ ) {
- int player = players[ place ][ IDX_NUM ];
- str ordinal_suffix = OrdinalSuffix( place + 1 );
- int minutes = players[ place ][ IDX_MINUTES ];
- str minutes_prefix = DigitPrefix( minutes );
- int seconds = players[ place ][ IDX_SECONDS ];
- str seconds_prefix = DigitPrefix( seconds );
- if ( player != PLAYER_DISCONNECTED ) {
- hudMessageBold(
- s : "\c", s : rank_colors[ place ],
- i : place + 1, s : ordinal_suffix, s : ":\c- ",
- n : player + 1,
- s : "\n\ciTime: ",
- s : minutes_prefix, i : minutes,
- s : ":",
- s : seconds_prefix, i : seconds,
- s : "\c-" ;
- HUDMSG_PLAIN, RANK_ID_OFFSET + place, 0,
- RANK_TABLE_X, rank_height, 0
- );
- }
- else {
- hudMessageBold(
- s : "\c", s : rank_colors[ place ],
- i : place + 1, s : ordinal_suffix, s : ": \c",
- s : DISCONNECTED_LABEL_COLOR,
- s : DISCONNECTED_LABEL,
- s : "\n\ciTime: ",
- s : minutes_prefix, i : minutes,
- s : ":",
- s : seconds_prefix, i : seconds,
- s : "\c-" ;
- HUDMSG_PLAIN, RANK_ID_OFFSET + place, 0,
- RANK_TABLE_X, rank_height, 0
- );
- }
- rank_height += RANK_PLACE_HEIGHT;
- }
- }
- function void ClearTable( void ) {
- for ( int place = 0; place < rank_limit; place++ ) {
- // We clear the previous rendition by using the same
- // message ID, but this time, using a blank string.
- ClearMessageBold( RANK_ID_OFFSET + place );
- }
- }
- function void DisplayIndividualTime( void ) {
- setFont( "SMALLFONT" );
- // Calculate the individual time to display:
- int time = timer() / shortDelay;
- int minutes = time / SECONDS_IN_MINUTE;
- int seconds = time % SECONDS_IN_MINUTE;
- hudMessage(
- s : "\cuTime: \cc",
- s : DigitPrefix( minutes ), i : minutes,
- s : ":",
- s : DigitPrefix( seconds ), i : seconds,
- s : "\c-" ;
- HUDMSG_PLAIN, RANK_ID_OFFSET + RANK_LIMIT_MAX, 0, RANK_TABLE_X,
- RANK_TABLE_Y + ( RANK_PLACE_HEIGHT * RANK_LIMIT_MAX ), 0
- );
- }
- // Utility functions ( Can be used in other scripts. )
- // ==========================================================
- function str DigitPrefix( int digit ) {
- if ( digit >= 0 && digit <= 9 ) {
- return "0";
- }
- return "";
- }
- function str OrdinalSuffix( int value ) {
- if ( value == 11 || value == 12 || value == 13 ) {
- return "th";
- }
- switch ( value % 10 ) {
- case 1: return "st";
- case 2: return "nd";
- case 3: return "rd";
- case 4: return "th";
- }
- return "th";
- }
- // Handy functions to clear messages from the screen.
- function void ClearMessage( int messageId ) {
- hudMessage(
- s : "" ;
- HUDMSG_PLAIN, messageId, 0, 0, 0, 0
- );
- }
- function void ClearMessageBold( int messageId ) {
- hudMessageBold(
- s : "" ;
- HUDMSG_PLAIN, messageId, 0, 0, 0, 0
- );
- }
- // Timer and Par time:
- #define TIME_COLOR_TIMER CR_YELLOW
- script 471 (void)
- {
- int raceTime;
- while ( TRUE )
- {
- raceTime = timer() / shortDelay;
- SetFont( "SMALLFONT" );
- HudMessage(
- d : raceTime / SECONDS_IN_MINUTE,
- s : " : ",
- d : ( raceTime % SECONDS_IN_MINUTE ) / 10,
- s : " ", d : raceTime % 10 ;
- HUDMSG_PLAIN, 434, TIME_COLOR_TIMER, 0.95, 0.95, 2.0
- );
- delay( shortDelay );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement