Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////
- /// Custom Game Over Screen ///
- /// v1.2 for ZC 2.50.x ///
- /// 24th October, 2018 ///
- /// By: ZoriaRPG ///
- //////////////////////////////////////
- /// Requested by: Korben on PureZC ///
- //////////////////////////////////////
- import "std.zh"
- // Sounds and MIDIs
- const int SFX_WINKOUT = 38; //Sound to play during wink-out animation.
- const int SFX_LINKDEATH = 28; //Sound to play when Link dies.
- const int SFX_GAMEOVERSCREEN_CURSOR = 6; //Sound to play when the player moves the game over cursor.
- const int SFX_GAMEOVERSCREEN_SELECTION = 44; //Sound to play when the user selects a game over menu option.
- const int MIDI_GAMEOVER = -4; //MIDI to play on Game Over screen.
- //Defaults: -3 is the internal Game Over, -2 is Level 9, -1 is Overworld
- // Sprites (Weapons/Misc)
- const int SPR_DEATH = 88; //Sprite of Link Spinning
- const int SPR_DEATH_WINKOUT = 89; //Sprite of wink-out
- // Sprite Timing
- const int END_DEATH_SPIN = 40; //Frames to display death spin animation.
- const int END_WINKOUT = 10; //Frames to display wink-out animation.
- // Other Graphics and Colours
- const int TILE_SAVECURSOR = 20;
- const int TILE_SAVECURSOR_CSET = 1; //CSet for minitile cursor.
- const int _COL_BLACK = 0x0F; //Black in the current palette
- const int _COL_RED = 0x93; //Red in the current palette
- const int _COL_WHITE = 0x01; //White in the current palette
- // Menu Object Positions and Settings
- const int DONT_SAVE_X = 102; //X position of the RETRY string.
- const int SAVE_X = 102; //X position of the SAVE string.
- const int DONT_SAVE_Y = 68; //Y position of the RETRY string.
- const int SAVE_Y = 54; //X position of the SAVE string.
- const int CURSOR_OFFSET = 26; //X offset of the cursor from the text.
- //Global Variables and Arrays
- int gameover[8] = {1,SAVE_Y,DONT_SAVE_Y, 0,0};
- //Indices for gameover[]
- const int MENU_SEL_STATE = 0; //The current selected menu option.
- const int MENU_SEL_POS_X = 1; //Stores where to draw menu selector.
- const int MENU_SEL_POS_Y = 2; //Stores where to draw menu selector.
- const int DEATH_LX = 3; //Cache of Link's last X position before death.
- const int DEATH_LY = 4; //Cache of Link's last Y position before death.
- const int DEATHFRAME = 5; //Timer for death animations.
- const int QUIT = 6; //The game 'QUIT' type, SAVE or RETRY
- //Quit Types
- const int quitSAVE = 1;
- const int quitRETRY = 2;
- global script noF6
- {
- void run()
- {
- while(true)
- {
- //Normal pre-waitdraw functions go here.
- //UpdateGhostZH1();
- //Put any health refull code above this!
- //Run the check to see if Link is dying...
- if ( do_link_death_check() ) break; //LAST before Waitdraw()
- Waitdraw();
- //Normal post-waitdraw functions go here.
- //UpdateGhostZH2();
- Waitframe();
- }
- while(!gameover[QUIT])
- {
- //gameover[DEATH_LX] = Link->X;
- //gameover[DEATH_LY] = Link->Y;
- //Set game music to a silent MIDI.
- Link->HP = Link->MaxHP;
- Link->Invisible = true;
- Link->CollDetection = false;
- //Clean up screen objects
- clean_up_all_screen_objects();
- //Do Link Death animation
- do_death_animation();
- bool menu = true;
- Game->PlayMIDI(MIDI_GAMEOVER);//Play game over midi.
- while(menu) //menu loop
- {
- Link->PressStart = false; //No active subscreen for 2.50
- Link->InputStart = false;
- // GAME OVER SCREEN
- draw_game_over_menu();
- menu = do_game_over_menu_choice();
- Waitdraw();
- Waitframe();
- }
- Waitdraw(); Waitframe();
- }
- if ( gameover[QUIT] == quitSAVE )
- {
- ++Game->NumDeaths;
- Game->Save();
- Game->End();
- }
- else Game->End(); //Retry
- }
- bool do_link_death_check()
- {
- if ( Link->HP < 1 )
- {
- Link->HP = 1;
- Link->Invisible = true;
- Link->CollDetection = false;
- gameover[DEATH_LX] = Link->X;
- gameover[DEATH_LY] = Link->Y;
- return true;
- }
- return false;
- }
- void clean_up_all_screen_objects()
- {
- int q;
- if ( Screen->NumNPCs() )
- {
- for ( q = Screen->NumNPCs(); q > 0; --q )
- {
- npc n = Screen->LoadNPC(q); Remove(n);
- }
- }
- if ( Screen->NumLWeapons() )
- {
- for ( q = Screen->NumLWeapons(); q > 0; --q )
- { lweapon n = Screen->LoadLWeapon(q); Remove(n); }
- }
- if ( Screen->NumEWeapons() )
- {
- for ( q = Screen->NumEWeapons(); q > 0; --q )
- { eweapon n = Screen->LoadEWeapon(q); Remove(n); }
- }
- if ( Screen->NumItems() )
- {
- for ( q = Screen->NumItems(); q > 0; --q )
- { item n = Screen->LoadItem(q); Remove(n); }
- }
- //clear all ffcs
- for ( q = 1; q < 33; ++q )
- {
- ffc f = Screen->LoadFFC(q);
- f->Data = 0; f->Script = 0;
- }
- }
- void draw_game_over_menu()
- {
- int sv[]="SAVE";
- int dsv[]="RETRY";
- //Draw black background with Rectangle()
- Screen->Rectangle(5,0,0,256,256,_COL_BLACK,100, 0,0,0,true,128);
- if ( gameover[MENU_SEL_STATE] )
- {
- //int ss1[]="Drawing cursor and text.";
- //TraceS(ss1);
- Screen->FastTile(6,SAVE_X-CURSOR_OFFSET, SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
- //draw strings, red for selected
- Screen->DrawString(6,SAVE_X,SAVE_Y,0,_COL_RED, -1,0,sv,128);
- Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,_COL_WHITE, -1,0,dsv,128);
- }
- else
- {
- //Draw cursor
- Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, DONT_SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
- //draw strings, red for selected
- Screen->DrawString(6,SAVE_X,SAVE_Y,0,_COL_WHITE, -1,0,sv,128);
- Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,_COL_RED, -1,0,dsv,128);
- }
- }
- bool do_game_over_menu_choice()
- {
- if ( Link->PressDown || Link->PressUp )
- {
- gameover[MENU_SEL_STATE] = Cond(gameover[MENU_SEL_STATE],0,1);
- Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
- return true;
- }
- //Screw it. This is why I added a way to disable the active subscreen to 2.55
- //Global scripts DO NOT LIKE to block the active subscreen!
- //if ( Link->PressStart )
- if ( Link->PressA || Link->PressB )
- {
- //Link->PressStart = false;
- //Link->InputStart = false;
- Game->PlaySound(SFX_GAMEOVERSCREEN_SELECTION);
- if ( gameover[MENU_SEL_STATE] ) gameover[QUIT] = quitSAVE;
- else gameover[QUIT] = quitRETRY; //no save
- return false;
- }
- return true;
- }
- void do_death_animation()
- {
- if ( gameover[DEATHFRAME] == 0 ) Game->PlaySound(SFX_LINKDEATH);
- lweapon death = Screen->CreateLWeapon(LW_SPARKLE);
- death->UseSprite(SPR_DEATH);
- death->X = gameover[DEATH_LX];
- death->Y = gameover[DEATH_LY];
- while ( gameover[DEATHFRAME] < END_DEATH_SPIN )
- {
- ++gameover[DEATHFRAME];
- //spin Link around by drawing his tiles, then make the wink out.
- NoAction(); Waitdraw(); Waitframe();
- }
- Remove(death);
- Game->PlaySound(SFX_WINKOUT);
- lweapon death2 = Screen->CreateLWeapon(LW_SPARKLE);
- death2->UseSprite(SPR_DEATH_WINKOUT);
- death2->X = gameover[DEATH_LX];
- death2->Y = gameover[DEATH_LY];
- while ( gameover[DEATHFRAME] < END_DEATH_SPIN+END_WINKOUT )
- {
- ++gameover[DEATHFRAME];
- //wink-out
- NoAction(); Waitdraw(); Waitframe();
- }
- Remove(death2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement