//Settings const int MET_WARP_EFFECT_DURATION = 60; //Duration of warp special visuals. int MetroidWarps[214747]; const int MET_SAVE_STATION_REG = 9; //Screen->D[reg] const int MET_SAVE_STATION_DRAW_ID_FONT = 0; const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_CLOUR = 0x0F; //Black const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR = 0x01; //White const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_scale = -1; //DrawString(0 scale factor const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET = 8; //Offset from f->X const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET = 9; //Offset from f->X const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET = 8; //Offset from f->Y const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET = 9; //Offset from f->Y const int MET_SAVE_STATION_ = 0; //Default constant template for this beast. //!Indices 0-5 are not used to store coordinates const int MET_SAVE_NUMBER_OF_SAVEPOINTS = 10; const int MET_SAVE_BASE = 6; //Five indices per set. const int MET_SAVE_ID = 0; //Holds the ID of the point in game. const int MET_SAVE_DMAP = 1; //The DMAP for a given warp. const int MET_SAVE_SCREEN = 2; //The screen of a given warp. const int MET_SAVE_X = 3; //The X position to warp to. const int MET_SAVE_Y = 4; //The Y position to warp to. const int MET_SAVE_STATION_ACTIVE = 5; //The Y position to warp to. const itn MET_SAVE_LAST_SAVESTATION = 0; //ID of last save station used. arr[0] const int SFX_SAVE_ERROR = 88; // const int SFX_SAVE_SUCCESS = 93; // const int SFX_TELEPORT_TRANSITION = 100; //Sound effect of teleportation EFFECT. const int SFX_WARP_ERROR = 80; const int SFX_TELEPORT = 67; //Sound effect for teleportation matrix item. //const int WARP_WAVE = 30; const int TELEPORT_CIRCLE_COLOUR = 181; //Colour for teleport circle. const int TELEPORT_WAVE = 60; //Duration of Teleport Wave Effect //! We'll remove this in a future edit. const int SFX_SET_TELEPORT = 98; //Menu Sound for Setting Teleport Destination //const int FLASH_LAYER = 6; //const int TELEPORT_OVERLAY = 5; //const int TELEPORT_SAFETY = 10; //const int WARP_DURATION = 80; //Drawing Colours - ! Set to colours in your palette, or adjust as you see fit. const int WARP_GREEN = 45; const int WARP_BLUE = 11; const int WARP_YELLOW = 126; const int WARP_TEAL = 88; const int WARP_LTBLUE = 93; //or 88 const int WARP_LTGREEN = 44; const int WARP_BRIGHTGREEN = 47; const int WARP_PERIDOT = 97; const int WARP_SMOKE = 73; bool warpAllowed = true; //Shift this into game vars arrays and update functions. bool isWarping = false; //Shift this into game vars arrays and update functions. bool flashingGreen = false; bool teleporting = false; bool arriving = false; const int WARPALLOWED = 1; const int ISWARPING = 2; const int FLASHINGGREEN = 3; const int TELEPORTING = 4; const int ARRIVING = 5; //Returns if samus can teleport, or activate a save point station. bool SamusCanTeleport(){ return ( !jumping && !onLadder && ( SamusAction == SAMUS_ACTION_NONE || SamusAction == SAMUS_ACTION_CROUCH ) && !isShineSpark && OnGround() && !isSpeedBoosting && !SamusHasDied ); } //We do this when we activate the station. void SetWarpPoint(int warp_id, ffc f){ MetroidWarps[MET_SAVE_ID + ( warp_id * MET_SAVE_BASE ) ] = warp_id; MetroidWarps[MET_SAVE_DMAP + ( warp_id * MET_SAVE_BASE ) ] = Game->GetCurDMap(); MetroidWarps[MET_SAVE_SCREEN + ( warp_id * MET_SAVE_BASE ) ] = Game->GetCurScreen(); MetroidWarps[MET_SAVE_X + ( warp_id * MET_SAVE_BASE ) ] = f->X; MetroidWarps[MET_SAVE_Y + ( warp_id * MET_SAVE_BASE ) ] = f->Y; } //A way to set the point based on Samus coordinates, instead of ffc coordinates, if needed. void SetWarpPoint(int warp_id){ MetroidWarps[MET_SAVE_ID + ( warp_id * MET_SAVE_BASE ) ] = warp_id; MetroidWarps[MET_SAVE_DMAP + ( warp_id * MET_SAVE_BASE ) ] = Game->GetCurDMap(); MetroidWarps[MET_SAVE_SCREEN + ( warp_id * MET_SAVE_BASE ) ] = Game->GetCurScreen(); MetroidWarps[MET_SAVE_X + ( warp_id * MET_SAVE_BASE ) ] = Link->X; MetroidWarps[MET_SAVE_Y + ( warp_id * MET_SAVE_BASE ) ] = Link->Y; } //Checks if a given station is active. int WarpPointActive(int station_id) { return MetroidWarps[MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_BASE ) } //Sets a given warp point active/inactive. void WarpPointActive(int station_id, bool setting) { if ( setting ) MetroidWarps[MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_BASE ) = 1; else MetroidWarps[MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_BASE ) = 0; } //Saving the game automation. void SaveGame(int station_id){ SetGameRestoreStation(station_id); /// Game->Save(); } //Save and quit automation. void SaveGameAndQuit(int station_id){ SetGameRestoreStation(station_id); Game->Save(); Game->End(); } //Sets the station that we'll load when the player reloads the game. void SetGameRestoreStation(int station_id){ MetroidWarps[MET_SAVE_LAST_SAVESTATION] = station_id; } //Gets the station to use as a restore point, on player death, or onContinue. int GetGameRestoreStation(){ return MetroidWarps[MET_SAVE_LAST_SAVESTATION]; } //Call during onContinue script, or on death. void RestoreGame(){ //if the game has been saved, then we have a restore station set if ( GetGameRestoreStation() ) { WarpSamus( GetGameRestoreStation(), MET_WARP_EFFECT_DURATION ); } } //ffc script WarpSamus{ // void run(int station_id){ // bool running; //This may not work via an ffc. Didn't we go down this road before? // } //} const int I_ZSUIT = 255; //If of Z Suit item, if desired. //Special suit upgrade to warp anytime. int MetroidZSuit(int button1, int button2){ if ( button1 == button2 ) { int err[]="Report: MetroidXSuit buttons are both boubd to the same input!"; TraceNL(); TraceS(err); TraceNL(); return 0; } int pressed[3]; //button 1, button2, button 3 if ( button1 == BUTTON_A && ( Link->PressA || Link->InputA ) ) pressed[0] = 1; if ( button1 == BUTTON_B && ( Link->PressB || Link->InputB ) ) pressed[0] = 1; if ( button1 == BUTTON_L && ( Link->PressL || Link->InputL ) ) pressed[0] = 1; if ( button1 == BUTTON_R && ( Link->PressR || Link->InputR ) ) pressed[0] = 1; if ( button1 == BUTTON_EX1 && ( Link->PressEx1 || Link->InputEx1 ) ) pressed[0] = 1; if ( button1 == BUTTON_EX2 && ( Link->PressEx2 || Link->InputEx2 ) ) pressed[0] = 1; if ( button1 == BUTTON_EX3 && ( Link->PressEx3 || Link->InputEx3 ) ) pressed[0] = 1; if ( button1 == BUTTON_EX4 && ( Link->PressEx4 || Link->InputEx4 ) ) pressed[0] = 1; if ( button2 == BUTTON_A && ( Link->PressA || Link->InputA ) ) pressed[1] = 1; if ( button2 == BUTTON_B && ( Link->PressB || Link->InputB ) ) pressed[1] = 1; if ( button2 == BUTTON_L && ( Link->PressL || Link->InputL ) ) pressed[1] = 1; if ( button2 == BUTTON_R && ( Link->PressR || Link->InputR ) ) pressed[1] = 1; if ( button2 == BUTTON_EX1 && ( Link->PressEx1 || Link->InputEx1 ) ) pressed[1] = 1; if ( button2 == BUTTON_EX2 && ( Link->PressEx2 || Link->InputEx2 ) ) pressed[1] = 1; if ( button2 == BUTTON_EX3 && ( Link->PressEx3 || Link->InputEx3 ) ) pressed[1] = 1; if ( button2 == BUTTON_EX4 && ( Link->PressEx4 || Link->InputEx4 ) ) pressed[1] = 1; if ( pressed[0] && pressed[1] && SamusCanTeleport() ) { pressed[2] = 1; WarpMenu(); return 1; } } //! The physical save station. //! D0 : Each station needs a unique ID, ranging from 1 to 10. //! The script is set up to allow up to a total of ten save stations using the menus. ffc script MetroidSaveStation{ void run(int station_number){ bool pressed; int choice; while ( true ) { //If this station is active... //Draw station ID. if ( WarpPointActive(station_id) ) { //Draw the station ID, firstthe background Screen->DrawInteger( MET_SAVE_STATION_DRAW_ID_FONT_LAYER this->X + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET, this_>Y + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET, MET_SAVE_STATION_DRAW_ID_FONT, MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR, 0, MET_SAVE_STATION_DRAW_ID_FONT_WIDTH, MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT, station_number, 0, OP_OPAQUE); //Then, the foreground... Screen->DrawInteger( MET_SAVE_STATION_DRAW_ID_FONT_LAYER this->X + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET, this_>Y + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET, MET_SAVE_STATION_DRAW_ID_FONT, MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR, 0, MET_SAVE_STATION_DRAW_ID_FONT_WIDTH, MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT, station_number, 0, OP_OPAQUE); } while ( ( !pressed && !TangoMenuIsActive() ) || ( !TangoMenuIsActive() && !SamusCanTeleport() ) ) { if ( MET_SAVE_USE_BUTTON_R && Link->PressR ) { pressed = true; Link->PressR = false; Link->InputR = false; } if ( MET_SAVE_USE_BUTTON_L && Link->PressL ) { pressed = true; Link->PressL = false; Link->InputL = false; } if ( MET_SAVE_USE_BUTTON_A && Link->PressA ) { pressed = true; Link->PressA = false; Link->InputA = false; } if ( MET_SAVE_USE_BUTTON_B && Link->PressB ) { pressed = true; Link->PressB = false; Link->InputB = false; } if ( MET_SAVE_USE_BUTTON_EX1 && Link->PressEx1 ) { pressed = true; Link->PressEx1 = false; Link->InputEx1 = false; } if ( MET_SAVE_USE_BUTTON_EX2 && Link->PressEx2 ) { pressed = true; Link->PressEx2 = false; Link->InputEx2 = false; } if ( MET_SAVE_USE_BUTTON_EX2 && Link->PressEx3 ) { pressed = true; Link->PressEx3 = false; Link->InputEx3 = false; } if ( MET_SAVE_USE_BUTTON_EX2 && Link->PressEx4 ) { pressed = true; Link->PressEx4 = false; Link->InputEx4 = false; } //If this station is active... //Draw station ID. if ( WarpPointActive(station_id) ) { //Draw the station ID, firstthe background Screen->DrawInteger( MET_SAVE_STATION_DRAW_ID_FONT_LAYER this->X + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET, this_>Y + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET, MET_SAVE_STATION_DRAW_ID_FONT, MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR, 0, MET_SAVE_STATION_DRAW_ID_FONT_WIDTH, MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT, station_number, 0, OP_OPAQUE); //Then, the foreground... Screen->DrawInteger( MET_SAVE_STATION_DRAW_ID_FONT_LAYER this->X + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET, this_>Y + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET, MET_SAVE_STATION_DRAW_ID_FONT, MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR, 0, MET_SAVE_STATION_DRAW_ID_FONT_WIDTH, MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT, station_number, 0, OP_OPAQUE); } Waitframe(); if ( pressed ) { pressed = false; //Set coordinates for this station: SetWarpPoint(station_number,this); //Activate this station if it is inactive if ( !WarpPointActive(station_id) ) { WarpPointActive(station_id,true); //MetroidSaveStationMenu(int station_number); //Do menu choice = MetroidSaveStationMenu(station_number); //Do save, activate, or warp when menu returns //!No, handled by the manu. } Waitframe(); //Main while loop. } } } //Menu called by the save station ffc. int MetroidSaveStationMenu(int station_id) { int lineBreak[]="@26"; int lineBreak[]="@26"; int line1[]="@choice(1)Save@26"; int line2[]="@choice(2)Warp@26"; int line3[]="@choice(3)Save and Quit@26"; int line4[]="@choice(4)Cancel@domenu(1)@suspend()"; SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_3, 32, 32, SIZE_LARGE); Tango_LoadString(WINDOW_SLOT_1, line1); Tango_AppendString(WINDOW_SLOT_1, line2); Tango_AppendString(WINDOW_SLOT_1, line3); Tango_AppendString(WINDOW_SLOT_1, line4); Tango_ActivateSlot(WINDOW_SLOT_1); while(!Tango_MenuIsActive()){ Waitframe(); } // Save the state again... int slotState[278]; int menuState[960]; int cursorPos; Tango_SaveSlotState(WINDOW_SLOT_1, slotState); Tango_SaveMenuState(menuState); int done = 0; int choice; while(true){ while( Tango_MenuIsActive() ) { cursorPos=Tango_GetMenuCursorPosition(); Waitframe(); } choice = Tango_GetLastMenuChoice(); if ( choice == 1 ) { // Save the game SaveGame(station_id); Game->PlaySound(SFX_SAVE_SUCCESS); int text[]="Game Saved"; Tango_ClearSlot(2); ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_2, 48, 48); } else if ( choice == 2 ) { //Warp //! Run the warp menu. WarpMenu(); done = choice; menuArg = choice; } else if ( choice == 3 ) { //Save and quit Game->PlaySound(SFX_SAVE_SUCCESS); SaveGameAndQuit(station_id); done = choice; } else if ( choice == 4 ) //cancel done = -1; } if ( done ) { break; // return choice; } else { Tango_RestoreSlotState(WINDOW_SLOT_1, slotState); Tango_RestoreMenuState(menuState); Tango_SetMenuCursorPosition(cursorPos); } } Tango_ClearSlot(WINDOW_SLOT_1); return done; } //Warp menu, called by MetroidSaveStationMenu(), or by other functions/scripts. int WarpMenu(){ int lineBreak[]="@26"; //Three springs per destination pair. We'll check if they are active, and only display those that are actie. int line1_both[]="@choice(1)Go 1@tab(56)@choice(2)Go 2@26"; int line1_first[]="@choice(1)Go 1@26"; int line1_second[]=" @tab(56)@choice(2)Go 2@26"; int line2_both[]="@choice(3)Go 3@tab(56)@choice(4)Go 4@26"; int line2_first[]="@choice(3)Go 3@26"; int line2_second[]=" @tab(56)@choice(4)Go 4@26"; int line3_both[]="@choice(5)Go 5@tab(56)@choice(6)Go 6@26"; int line3_first[]="@choice(5)Go 5@26"; int line3_second[]=" @tab(56)@choice(6)Go 6@26"; int line4_both[]="@choice(7)Go 7@tab(56)@choice(8)Go 8@26"; int line4_first[]="@choice(7)Go 7@26"; int line4_second[]=" @tab(56)@choice(8)Go 8@26"; int line5_both[]="@choice(9)Go 9@tab(56)@choice(10)Go 10@26"; int line5_first[]="@choice(9)Go 9@26"; int line5_second[]=" @tab(56)@choice(10)Go 10@26"; //We can change '10' to cancel if needed. SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_3, 32, 32, SIZE_LARGE); if ( WarpPointActive(1) && WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_1, line1_both); if ( WarpPointActive(1) && !WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_1, line1_first); if ( !WarpPointActive(1) && WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_1, line1_second); if ( WarpPointActive(3) && WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_1, line2_both); if ( WarpPointActive(3) && !WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_1, line2_first); if ( WarpPointActive(3) && WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_1, line2_second); if ( WarpPointActive(5) && WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_1, line3_both); if ( WarpPointActive(5) && !WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_1, line3_first); if ( WarpPointActive(5) && WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_1, line3_second); if ( WarpPointActive(7) && WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_1, line4_both); if ( WarpPointActive(7) && !WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_1, line4_first); if ( WarpPointActive(7) && WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_1, line4_second); if ( WarpPointActive(9) && WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_1, line5_both); if ( WarpPointActive(9) && !WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_1, line5_first); if ( WarpPointActive(9) && WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_1, line5_second); Tango_ActivateSlot(WINDOW_SLOT_1); while(!Tango_MenuIsActive()){ Waitframe(); } // Save the state again... int slotState[278]; int menuState[960]; int cursorPos; Tango_SaveSlotState(WINDOW_SLOT_1, slotState); Tango_SaveMenuState(menuState); int done = 0; int choice; while(true){ while( Tango_MenuIsActive() ) { cursorPos=Tango_GetMenuCursorPosition(); Waitframe(); } choice = Tango_GetLastMenuChoice(); if ( choice ) WarpSamus( choice, MET_WARP_EFFECT_DURATION ); if ( done ) { break; // return choice; } else { Tango_RestoreSlotState(WINDOW_SLOT_1, slotState); Tango_RestoreMenuState(menuState); Tango_SetMenuCursorPosition(cursorPos); } } Tango_ClearSlot(WINDOW_SLOT_1); return done; } //Does the warp animation, and the phsyical warp. void WarpSamus(int base, int warpDuration) { int startHP = Link->HP; int goDMAP = MetroidWarps[MET_SAVE_DMAP + ( warp_id * MET_SAVE_BASE ); int goSCREEN = MetroidWarps[MET_SAVE_SCREEN + ( warp_id * MET_SAVE_BASE ); int goX = MetroidWarps[MET_SAVE_X + ( warp_id * MET_SAVE_BASE ); int goY = MetroidWarps[MET_SAVE_Y + ( warp_id * MET_SAVE_BASE ); if ( Link->Action == LA_NONE && warpAllowed ) { Game->PlaySound(SFX_TELEPORT_TRANSITION); freezeAction(); teleporting = true; arriving = true; for(int i = warpDuration; i > 0; i--){ //Duration of song/effect. NoAction(); //Freeze Link //Game->PlaySound(SFX_TELEPORT_TRANSITION); //Create animation. Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 ); flashingGreen = false; //if ( !flashingGreen ) { // Screen->Rectangle(5, 0, 0, 256, 172, WARP_GREEN, 1, 0, 0, 0, true, 20); // flashingGreen = true; // Waitframe(); //} do { for ( int j = 1; j > 0; j--){ DrawScreenToLayer(teleportMatrix[TEL_MAP + base], teleportMatrix[TEL_SCREEN + base], 4, 75); Screen->Rectangle(5, 0, 0, 256, 172, WARP_GREEN, 1, 0, 0, 0, true, 25); Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, 1, 1, 0, 0, 0, false, 100 ); flashingGreen = true; Waitframe(); } } while(teleporting && !flashingGreen); do { for ( int j = 1; j > 0; j--){ DrawScreenToLayer(teleportMatrix[TEL_MAP + base], teleportMatrix[TEL_SCREEN + base], 4, 80); Screen->Rectangle(5, 0, 0, 256, 172, WARP_LTGREEN, 1, 0, 0, 0, true, 10); Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 ); flashingGreen = false; Waitframe(); } } while(teleporting && flashingGreen); if ( Link->HP < startHP ) { return; //If Link is hurt, quit } Waitframe(); } Screen->Wavy =60; Link->PitWarp( goDMAP, goSCREEN ); Link->X = goX; Link->Y = goY; teleporting = false; unfreezeAction(); Waitframe(); teleporting = false; flashingGreen = false; } else { Game->PlaySound(SFX_WARP_ERROR); isWarping = false; NotEnoughMP(); //return; } } //! Not ready for use. item script TeleportationMatrix{ void run(int cost, int counter){ //int args[]={ //STATION ID }; int ff[]= "TeleportMenu"; int ffid = Game->GetFFCScript(ff); if ( Game->Counter[counter] >= cost || !cost ) { if ( cost ) Game->Counter[counter] -= cost; RunFFCScript(ffid, args); } else Game->PlaySound(SFX_ERROR); } } //! Do not use as-is. This is the base teleport menu from LoE ffc script TeleportMenu{ void run(station_id){ //Three springs per destination pair. We'll check if they are active, and onyl display those tat are. int line1_both[]="@choice(1)Set 1@tab(56)@choice(7)Go 1@26"; int line1_first[]="@choice(1)Set 1@tab(56)@choice(7)Go 1@26"; int line1_second[]="@choice(1)Set 1@tab(56)@choice(7)Go 1@26"; int line2[]="@choice(2)Set 2@tab(56)@choice(8)Go 2@26"; int line3[]="@choice(3)Set 3@tab(56)@choice(9)Go 3@26"; int line4[]="@choice(4)Set 4@tab(56)@choice(10)Go 4@26"; int line5[]="@choice(5)Set 5@tab(56)@choice(11)Go 5@26"; int line6[]="@choice(6)Set 6@tab(56)@choice(12)Go 6@26"; int line8[]="@domenu(1)@suspend()"; SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 16, 16, SIZE_LARGE); Tango_LoadString(WINDOW_SLOT_1, line2); //Tango_AppendString(WINDOW_SLOT_1, line1); //Tango_AppendString(WINDOW_SLOT_1, line2); Tango_AppendString(WINDOW_SLOT_1, line3); Tango_AppendString(WINDOW_SLOT_1, line4); Tango_AppendString(WINDOW_SLOT_1, line5); Tango_AppendString(WINDOW_SLOT_1, line6); Tango_AppendString(WINDOW_SLOT_1, line7); Tango_AppendString(WINDOW_SLOT_1, line8); Tango_ActivateSlot(WINDOW_SLOT_1); while(!Tango_MenuIsActive()){ Waitframe(); } // Save the state of the text slot and menu. The bitmap won't change, // so it doesn't need saved. int slotState[274]; int menuState[60]; int cursorPos; Tango_SaveSlotState(WINDOW_SLOT_1, slotState); Tango_SaveMenuState(menuState); bool done=false; int choice; while(true) { if ( Link->PressEx1 ){ Quit(); } //if ( done == false && menuOpen == false ) { // menuOpen = true; //} //if ( done == true && menuOpen == true ){ // menuOpen = false; //} while(Tango_MenuIsActive()) { cursorPos=Tango_GetMenuCursorPosition(); Waitframe(); } choice=Tango_GetLastMenuChoice(); if(choice==1) // Set Teleport One { Trace(teleportSetOneCost); if ( Link->MP >= teleportSetOneCost ) { Link->MP -= teleportSetOneCost; setTeleport(TEL_1); Game->PlaySound(SFX_SET_TELEPORT); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==2) // Set Teleport Two { if ( Link->MP >= teleportSetOneCost ) { Link->MP -= teleportSetOneCost; setTeleport(TEL_2); Game->PlaySound(SFX_SET_TELEPORT); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==3) // Set Teleport Three { if ( Link->MP >= teleportSetTwoCost ) { Link->MP -= teleportSetTwoCost; setTeleport(TEL_3); Game->PlaySound(SFX_SET_TELEPORT); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==4){ // Set Teleport Four if ( Link->MP >= teleportSetTwoCost ) { Link->MP -= teleportSetTwoCost; setTeleport(TEL_4); Game->PlaySound(SFX_SET_TELEPORT); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==5) // Set Teleport Five { if ( Link->MP >= teleportSetThreeCost ) { Link->MP -= teleportSetThreeCost; setTeleport(TEL_5); Game->PlaySound(SFX_SET_TELEPORT); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==6) // Set Teleport Six { if ( Link->MP >= teleportSetThreeCost ) { Link->MP -= teleportSetThreeCost; setTeleport(TEL_6); Game->PlaySound(SFX_SET_TELEPORT); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==7) // GO Teleport One { Trace(teleportOneCost); if ( Link->MP >= teleportOneCost ) { Link->MP -= teleportOneCost; ActivateTeleport(TEL_1,TELEPORT_WAVE); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==8) // GO Teleport Two { if ( Link->MP >= teleportOneCost ) { Link->MP -= teleportOneCost; ActivateTeleport(TEL_2,TELEPORT_WAVE); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==9) // GO Teleport Three { if ( Link->MP >= teleportTwoCost ) { Link->MP -= teleportTwoCost; ActivateTeleport(TEL_3,TELEPORT_WAVE); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==10) // GO Teleport Four { if ( Link->MP >= teleportTwoCost ) { Link->MP -= teleportTwoCost; ActivateTeleport(TEL_4,TELEPORT_WAVE); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==11) // GO Teleport Five { if ( Link->MP >= teleportThreeCost ) { Link->MP -= teleportThreeCost; ActivateTeleport(TEL_5,TELEPORT_WAVE); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if(choice==12) // GO Teleport Six { if ( Link->MP >= teleportThreeCost ) { Link->MP -= teleportThreeCost; ActivateTeleport(TEL_6,TELEPORT_WAVE); done=true; } else { Game->PlaySound(SFX_WARP_ERROR); NotEnoughMP(); } } else if (Link->PressEx1){ Quit(); } else{ done=true; } // If we need to return to the top-level menu, // restore the state and loop again. if(done){ break; } else { Tango_RestoreSlotState(WINDOW_SLOT_1, slotState); Tango_RestoreMenuState(menuState); Tango_SetMenuCursorPosition(cursorPos); } } Tango_ClearSlot(WINDOW_SLOT_1); } } //Used if teleporting requires magic. Modify and use if desired. bool NotEnoughMP(){ int lineBreak[]="@26"; int menuEnd[]="@domenu(1)@suspend()"; int line2[]="You do not have enough MP to do that.@26"; int line1[]="@choice(1)Done@26@26"; SetUpWindow(WINDOW_SLOT_2, WINDOW_STYLE_2, 32, 32, SIZE_LARGE); Tango_LoadString(WINDOW_SLOT_2, line1); Tango_AppendString(WINDOW_SLOT_2, line2); Tango_AppendString(WINDOW_SLOT_2, menuEnd); Tango_ActivateSlot(WINDOW_SLOT_2); while(!Tango_MenuIsActive()){ Waitframe(); } // Save the state again... int slotState[274]; int menuState[60]; int cursorPos; Tango_SaveSlotState(WINDOW_SLOT_2, slotState); Tango_SaveMenuState(menuState); int done=0; int choice; while(true) { while(Tango_MenuIsActive()) { cursorPos=Tango_GetMenuCursorPosition(); Waitframe(); } choice=Tango_GetLastMenuChoice(); if(choice==0) // Canceled done=2; else if(choice == 1) { done=2; } else if (Link->PressEx1){ done = 2; } else done=2; if(done>0){ break; } else { Tango_RestoreSlotState(WINDOW_SLOT_2, slotState); Tango_RestoreMenuState(menuState); Tango_SetMenuCursorPosition(cursorPos); } } Tango_ClearSlot(WINDOW_SLOT_2); if(done==1) return true; // Tell parent menu to close else return false; // Tell parent not to close }